
#include <stdlib.h>
#include <stdio.h>


int main(int argc,char **argv) {
    printf("Usage ./dump_arrays.out size array_file1 array_file2");

    int N =pow(2,atoi(argv[1]));
    size_t size = N * sizeof(float);
    int loop;

    // Allocate input vectors h_A and h_B in host memory
    float* h_A = (float*)malloc(size);
    float* h_B = (float*)malloc(size);

    FILE *arrayfile_a;
    FILE *arrayfile_b;

    if (argc<3){
        printf("Too few arguments.\nUsage is ./ee16b068_3.out file1.txt file2.txt ");
        return 1;
    }

    // Initialize input vectors
    arrayfile_a = fopen(argv[2], "w");
    arrayfile_b = fopen(argv[3], "w");

    printf("\n Array A (first 10 values) \n ");
    for (loop = 0; loop < N; loop++)
    {
        h_A[loop] = rand() % 100 + 1;
        
        if (loop<10){
            printf("%f ", h_A[loop]);
        }

        fprintf(arrayfile_a, "%f\n", h_A[loop]);
    }

    printf("\n Array B (first 10 values) \n ");
    for (loop = 0; loop < N; loop++)
    {
        h_B[loop] = rand() % 100 + 1;
        
        if (loop<10){
            printf("%f ", h_B[loop]);
        }
        fprintf(arrayfile_b, "%f\n", h_B[loop]);
    }
    
    // Free host memory
    free(arrayfile_a); free(arrayfile_b);
    free(h_A);
    free(h_B);
    return 0;
}
	.file	"tmpxft_0037a582_00000000-6_dump_arrays.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2030:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2030:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"Usage ./dump_arrays.out size array_file1 array_file2"
.LC2:
	.string	"Too few arguments.\nUsage is ./ee16b068_3.out file1.txt file2.txt "
.LC3:
	.string	"w"
.LC4:
	.string	"\n Array A (first 10 values) \n "
.LC5:
	.string	"%f "
.LC6:
	.string	"%f\n"
.LC7:
	.string	"\n Array B (first 10 values) \n "
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2027:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	xorl	%eax, %eax
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movl	%edi, %r13d
	movl	$2, %edi
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movq	%rsi, %rbx
	leaq	.LC0(%rip), %rsi
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	call	__printf_chk@PLT
	movq	8(%rbx), %rdi
	call	atoi@PLT
	movsd	.LC1(%rip), %xmm0
	cvtsi2sdl	%eax, %xmm1
	call	pow@PLT
	cvttsd2sil	%xmm0, %r14d
	movslq	%r14d, %rbp
	salq	$2, %rbp
	movq	%rbp, %rdi
	call	malloc@PLT
	movq	%rbp, %rdi
	movq	%rax, %r12
	call	malloc@PLT
	cmpl	$2, %r13d
	jg	.L3
	leaq	.LC2(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	$1, %eax
	jmp	.L2
.L3:
	movq	16(%rbx), %rdi
	leaq	.LC3(%rip), %r15
	movq	%rax, %rbp
	movq	%r15, %rsi
	call	fopen@PLT
	movq	24(%rbx), %rdi
	movq	%r15, %rsi
	xorl	%ebx, %ebx
	movq	%rax, %r13
	leaq	.LC5(%rip), %r15
	call	fopen@PLT
	leaq	.LC4(%rip), %rsi
	movl	$2, %edi
	movq	%rax, (%rsp)
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L5:
	cmpl	%ebx, %r14d
	jle	.L13
	call	rand@PLT
	movl	$100, %ecx
	cltd
	idivl	%ecx
	incl	%edx
	cmpq	$9, %rbx
	cvtsi2ssl	%edx, %xmm0
	movss	%xmm0, (%r12,%rbx,4)
	cvtss2sd	%xmm0, %xmm0
	ja	.L6
	movq	%r15, %rsi
	movl	$2, %edi
	movb	$1, %al
	movsd	%xmm0, 8(%rsp)
	call	__printf_chk@PLT
	movsd	8(%rsp), %xmm0
.L6:
	leaq	.LC6(%rip), %rdx
	movq	%r13, %rdi
	movb	$1, %al
	incq	%rbx
	movl	$2, %esi
	call	__fprintf_chk@PLT
	jmp	.L5
.L13:
	leaq	.LC7(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	xorl	%ebx, %ebx
	call	__printf_chk@PLT
	leaq	.LC5(%rip), %r15
.L8:
	cmpl	%ebx, %r14d
	jle	.L14
	call	rand@PLT
	movl	$100, %ecx
	cltd
	idivl	%ecx
	incl	%edx
	cmpq	$9, %rbx
	cvtsi2ssl	%edx, %xmm0
	movss	%xmm0, 0(%rbp,%rbx,4)
	cvtss2sd	%xmm0, %xmm0
	ja	.L9
	movq	%r15, %rsi
	movl	$2, %edi
	movb	$1, %al
	movsd	%xmm0, 8(%rsp)
	call	__printf_chk@PLT
	movsd	8(%rsp), %xmm0
.L9:
	movq	(%rsp), %rdi
	leaq	.LC6(%rip), %rdx
	movb	$1, %al
	incq	%rbx
	movl	$2, %esi
	call	__fprintf_chk@PLT
	jmp	.L8
.L14:
	movq	%r13, %rdi
	call	free@PLT
	movq	(%rsp), %rdi
	call	free@PLT
	movq	%r12, %rdi
	call	free@PLT
	movq	%rbp, %rdi
	call	free@PLT
	xorl	%eax, %eax
.L2:
	addq	$24, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2027:
	.size	main, .-main
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2053:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	leaq	_ZL15__fatDeviceText(%rip), %rdi
	call	__cudaRegisterFatBinary@PLT
	movq	%rax, %rdi
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFatBinaryEnd@PLT
	leaq	_ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi
	popq	%rdx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE2053:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.nvFatBinSegment,"aw"
	.align 8
	.type	_ZL15__fatDeviceText, @object
	.size	_ZL15__fatDeviceText, 24
_ZL15__fatDeviceText:
	.long	1180844977
	.long	1
	.quad	fatbinData
	.quad	0
	.local	_ZL20__cudaFatCubinHandle
	.comm	_ZL20__cudaFatCubinHandle,8,8
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC1:
	.long	0
	.long	1073741824
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:



#include <hip/hip_runtime.h>
#include <stdlib.h>
#include <stdio.h>


int main(int argc,char **argv) {
    printf("Usage ./dump_arrays.out size array_file1 array_file2");

    int N =pow(2,atoi(argv[1]));
    size_t size = N * sizeof(float);
    int loop;

    // Allocate input vectors h_A and h_B in host memory
    float* h_A = (float*)malloc(size);
    float* h_B = (float*)malloc(size);

    FILE *arrayfile_a;
    FILE *arrayfile_b;

    if (argc<3){
        printf("Too few arguments.\nUsage is ./ee16b068_3.out file1.txt file2.txt ");
        return 1;
    }

    // Initialize input vectors
    arrayfile_a = fopen(argv[2], "w");
    arrayfile_b = fopen(argv[3], "w");

    printf("\n Array A (first 10 values) \n ");
    for (loop = 0; loop < N; loop++)
    {
        h_A[loop] = rand() % 100 + 1;
        
        if (loop<10){
            printf("%f ", h_A[loop]);
        }

        fprintf(arrayfile_a, "%f\n", h_A[loop]);
    }

    printf("\n Array B (first 10 values) \n ");
    for (loop = 0; loop < N; loop++)
    {
        h_B[loop] = rand() % 100 + 1;
        
        if (loop<10){
            printf("%f ", h_B[loop]);
        }
        fprintf(arrayfile_b, "%f\n", h_B[loop]);
    }
    
    // Free host memory
    free(arrayfile_a); free(arrayfile_b);
    free(h_A);
    free(h_B);
    return 0;
}
	.text
	.file	"dump_arrays.hip"
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function main
.LCPI0_0:
	.quad	0x3ff0000000000000              # double 1
	.text
	.globl	main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	pushq	%rax
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rsi, %r14
	movl	%edi, %ebx
	movl	$.L.str, %edi
	xorl	%eax, %eax
	callq	printf
	movq	8(%r14), %rdi
	callq	atoi
	movsd	.LCPI0_0(%rip), %xmm0           # xmm0 = mem[0],zero
	movl	%eax, %edi
	callq	ldexp@PLT
	cmpl	$2, %ebx
	jg	.LBB0_2
# %bb.1:
	movl	$.L.str.1, %edi
	xorl	%eax, %eax
	callq	printf
	movl	$1, %eax
	jmp	.LBB0_12
.LBB0_2:
	cvttsd2si	%xmm0, %ebp
	movq	16(%r14), %rdi
	movl	$.L.str.2, %esi
	callq	fopen
	movq	%rax, %rbx
	movq	24(%r14), %rdi
	movl	$.L.str.2, %esi
	callq	fopen
	movq	%rax, %r14
	xorl	%r15d, %r15d
	movl	$.L.str.3, %edi
	xorl	%eax, %eax
	callq	printf
	testl	%ebp, %ebp
	jle	.LBB0_3
.LBB0_4:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	callq	rand
	cltq
	imulq	$1374389535, %rax, %rcx         # imm = 0x51EB851F
	movq	%rcx, %rdx
	shrq	$63, %rdx
	sarq	$37, %rcx
	addl	%edx, %ecx
	imull	$100, %ecx, %ecx
	negl	%ecx
	addl	%ecx, %eax
	incl	%eax
	xorps	%xmm0, %xmm0
	cvtsi2ss	%eax, %xmm0
	cvtss2sd	%xmm0, %xmm0
	cmpl	$9, %r15d
	ja	.LBB0_6
# %bb.5:                                #   in Loop: Header=BB0_4 Depth=1
	movl	$.L.str.4, %edi
	movsd	%xmm0, (%rsp)                   # 8-byte Spill
	movsd	(%rsp), %xmm0                   # 8-byte Reload
                                        # xmm0 = mem[0],zero
	movb	$1, %al
	callq	printf
	movsd	(%rsp), %xmm0                   # 8-byte Reload
                                        # xmm0 = mem[0],zero
.LBB0_6:                                # %.lr.ph._crit_edge
                                        #   in Loop: Header=BB0_4 Depth=1
	movl	$.L.str.5, %esi
	movq	%rbx, %rdi
	movb	$1, %al
	callq	fprintf
	incl	%r15d
	cmpl	%r15d, %ebp
	jne	.LBB0_4
# %bb.7:                                # %._crit_edge
	xorl	%r15d, %r15d
	movl	$.L.str.6, %edi
	xorl	%eax, %eax
	callq	printf
	testl	%ebp, %ebp
	jle	.LBB0_11
.LBB0_8:                                # %.lr.ph38
                                        # =>This Inner Loop Header: Depth=1
	callq	rand
	cltq
	imulq	$1374389535, %rax, %rcx         # imm = 0x51EB851F
	movq	%rcx, %rdx
	shrq	$63, %rdx
	sarq	$37, %rcx
	addl	%edx, %ecx
	imull	$100, %ecx, %ecx
	negl	%ecx
	addl	%ecx, %eax
	incl	%eax
	xorps	%xmm0, %xmm0
	cvtsi2ss	%eax, %xmm0
	cvtss2sd	%xmm0, %xmm0
	cmpl	$9, %r15d
	ja	.LBB0_10
# %bb.9:                                #   in Loop: Header=BB0_8 Depth=1
	movl	$.L.str.4, %edi
	movsd	%xmm0, (%rsp)                   # 8-byte Spill
	movsd	(%rsp), %xmm0                   # 8-byte Reload
                                        # xmm0 = mem[0],zero
	movb	$1, %al
	callq	printf
	movsd	(%rsp), %xmm0                   # 8-byte Reload
                                        # xmm0 = mem[0],zero
.LBB0_10:                               # %.lr.ph38._crit_edge
                                        #   in Loop: Header=BB0_8 Depth=1
	movl	$.L.str.5, %esi
	movq	%r14, %rdi
	movb	$1, %al
	callq	fprintf
	incl	%r15d
	cmpl	%r15d, %ebp
	jne	.LBB0_8
	jmp	.LBB0_11
.LBB0_3:                                # %._crit_edge.thread
	movl	$.L.str.6, %edi
	xorl	%eax, %eax
	callq	printf
.LBB0_11:                               # %._crit_edge39
	movq	%rbx, %rdi
	callq	free
	movq	%r14, %rdi
	callq	free
	xorl	%eax, %eax
.LBB0_12:
	addq	$8, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end0:
	.size	main, .Lfunc_end0-main
	.cfi_endproc
                                        # -- End function
	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"Usage ./dump_arrays.out size array_file1 array_file2"
	.size	.L.str, 53

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"Too few arguments.\nUsage is ./ee16b068_3.out file1.txt file2.txt "
	.size	.L.str.1, 66

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"w"
	.size	.L.str.2, 2

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"\n Array A (first 10 values) \n "
	.size	.L.str.3, 31

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"%f "
	.size	.L.str.4, 4

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"%f\n"
	.size	.L.str.5, 4

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"\n Array B (first 10 values) \n "
	.size	.L.str.6, 31

	.type	__hip_cuid_,@object             # @__hip_cuid_
	.bss
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               # 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym __hip_cuid_

	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.section	.bss,"aw",@nobits
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym __hip_cuid_
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.amdgpu_metadata
---
amdhsa.kernels:  []
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
