#include <stdio.h>

extern "C"
int example(int a, int b){
	return a + b;
}

extern "C"
void example2(int input){
	printf("%s%d\n", "hello ", input);
}

extern "C"
void gpuTest(void){
	int n = 10;
	int a[n], b[n], c[n];
	int *dev_a, *dev_b, *dev_c;

	cudaMalloc( (void**)&dev_a, n * sizeof(int) ); 
	cudaMalloc( (void**)&dev_b, n * sizeof(int) ); 
	cudaMalloc( (void**)&dev_c, n * sizeof(int) );

	for (int i=0; i<n; i++) { 
		a[i] = -i;
		b[i] = i * i; 
	}

	cudaMemcpy( dev_a, a, n * sizeof(int), cudaMemcpyHostToDevice );
	cudaMemcpy( dev_b, b, n * sizeof(int), cudaMemcpyHostToDevice );
    //add<<<n,1>>>( dev_a, dev_b, dev_c );
       // copy the array 'c' back from the GPU to the CPU
	cudaMemcpy( c, dev_c, n * sizeof(int), cudaMemcpyDeviceToHost );
       // display the results
	for (int i=0; i<n; i++) {
		printf( "%d + %d = %d\n", a[i], b[i], c[i] );
	}
       // free the memory allocated on the GPU
    cudaFree( dev_a );
    cudaFree( dev_b );
    cudaFree( dev_c );
}
/*
int main(){
	gpuTest();
	printf("hello");
}
*/
	.file	"tmpxft_00231e57_00000000-6_nyTest.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2032:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2032:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	example
	.type	example, @function
example:
.LFB2027:
	.cfi_startproc
	endbr64
	leal	(%rdi,%rsi), %eax
	ret
	.cfi_endproc
.LFE2027:
	.size	example, .-example
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"hello "
.LC1:
	.string	"%s%d\n"
	.text
	.globl	example2
	.type	example2, @function
example2:
.LFB2028:
	.cfi_startproc
	endbr64
	movl	%edi, %ecx
	leaq	.LC0(%rip), %rdx
	movl	$2, %edi
	xorl	%eax, %eax
	leaq	.LC1(%rip), %rsi
	jmp	__printf_chk@PLT
	.cfi_endproc
.LFE2028:
	.size	example2, .-example2
	.section	.rodata.str1.1
.LC2:
	.string	"%d + %d = %d\n"
	.text
	.globl	gpuTest
	.type	gpuTest, @function
gpuTest:
.LFB2029:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	movl	$40, %esi
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	subq	$160, %rsp
	.cfi_def_cfa_offset 208
	movq	%fs:40, %rax
	movq	%rax, 152(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rdi
	leaq	32(%rsp), %rbp
	call	cudaMalloc@PLT
	leaq	16(%rsp), %rdi
	movl	$40, %esi
	leaq	72(%rsp), %r12
	call	cudaMalloc@PLT
	leaq	24(%rsp), %rdi
	movl	$40, %esi
	call	cudaMalloc@PLT
	xorl	%eax, %eax
.L5:
	movl	%eax, %edx
	negl	%edx
	movl	%edx, 0(%rbp,%rax,4)
	movl	%eax, %edx
	imull	%eax, %edx
	movl	%edx, (%r12,%rax,4)
	incq	%rax
	cmpq	$10, %rax
	jne	.L5
	movq	8(%rsp), %rdi
	movl	$1, %ecx
	movq	%rbp, %rsi
	xorl	%ebx, %ebx
	movl	$40, %edx
	leaq	112(%rsp), %r13
	leaq	.LC2(%rip), %r14
	call	cudaMemcpy@PLT
	movq	16(%rsp), %rdi
	movl	$1, %ecx
	movq	%r12, %rsi
	movl	$40, %edx
	call	cudaMemcpy@PLT
	movq	24(%rsp), %rsi
	movl	$2, %ecx
	movq	%r13, %rdi
	movl	$40, %edx
	call	cudaMemcpy@PLT
.L6:
	movl	(%r12,%rbx), %ecx
	movl	0(%rbp,%rbx), %edx
	movq	%r14, %rsi
	movl	$2, %edi
	movl	0(%r13,%rbx), %r8d
	xorl	%eax, %eax
	addq	$4, %rbx
	call	__printf_chk@PLT
	cmpq	$40, %rbx
	jne	.L6
	movq	8(%rsp), %rdi
	call	cudaFree@PLT
	movq	16(%rsp), %rdi
	call	cudaFree@PLT
	movq	24(%rsp), %rdi
	call	cudaFree@PLT
	movq	152(%rsp), %rax
	subq	%fs:40, %rax
	je	.L7
	call	__stack_chk_fail@PLT
.L7:
	addq	$160, %rsp
	.cfi_def_cfa_offset 48
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2029:
	.size	gpuTest, .-gpuTest
	.section	.text.startup,"ax",@progbits
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2055:
	.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
.LFE2055:
	.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
	.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 <stdio.h>

extern "C"
int example(int a, int b){
	return a + b;
}

extern "C"
void example2(int input){
	printf("%s%d\n", "hello ", input);
}

extern "C"
void gpuTest(void){
	int n = 10;
	int a[n], b[n], c[n];
	int *dev_a, *dev_b, *dev_c;

	hipMalloc( (void**)&dev_a, n * sizeof(int) ); 
	hipMalloc( (void**)&dev_b, n * sizeof(int) ); 
	hipMalloc( (void**)&dev_c, n * sizeof(int) );

	for (int i=0; i<n; i++) { 
		a[i] = -i;
		b[i] = i * i; 
	}

	hipMemcpy( dev_a, a, n * sizeof(int), hipMemcpyHostToDevice );
	hipMemcpy( dev_b, b, n * sizeof(int), hipMemcpyHostToDevice );
    //add<<<n,1>>>( dev_a, dev_b, dev_c );
       // copy the array 'c' back from the GPU to the CPU
	hipMemcpy( c, dev_c, n * sizeof(int), hipMemcpyDeviceToHost );
       // display the results
	for (int i=0; i<n; i++) {
		printf( "%d + %d = %d\n", a[i], b[i], c[i] );
	}
       // free the memory allocated on the GPU
    hipFree( dev_a );
    hipFree( dev_b );
    hipFree( dev_c );
}
/*
int main(){
	gpuTest();
	printf("hello");
}
*/
	.text
	.file	"nyTest.hip"
	.globl	example                         # -- Begin function example
	.type	example,@function
example:                                # @example
	.cfi_startproc
# %bb.0:
                                        # kill: def $esi killed $esi def $rsi
                                        # kill: def $edi killed $edi def $rdi
	leal	(%rdi,%rsi), %eax
	retq
.Lfunc_end0:
	.size	example, .Lfunc_end0-example
	.cfi_endproc
                                        # -- End function
	.globl	example2                        # -- Begin function example2
	.type	example2,@function
example2:                               # @example2
	.cfi_startproc
# %bb.0:
	movl	%edi, %edx
	movl	$.L.str, %edi
	movl	$.L.str.1, %esi
	xorl	%eax, %eax
	jmp	printf                          # TAILCALL
.Lfunc_end1:
	.size	example2, .Lfunc_end1-example2
	.cfi_endproc
                                        # -- End function
	.globl	gpuTest                         # -- Begin function gpuTest
	.type	gpuTest,@function
gpuTest:                                # @gpuTest
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	subq	$176, %rsp
	.cfi_def_cfa_offset 192
	.cfi_offset %rbx, -16
	leaq	24(%rsp), %rdi
	movl	$40, %esi
	callq	hipMalloc
	leaq	16(%rsp), %rdi
	movl	$40, %esi
	callq	hipMalloc
	leaq	8(%rsp), %rdi
	movl	$40, %esi
	callq	hipMalloc
	xorl	%eax, %eax
	xorl	%ecx, %ecx
.LBB2_1:                                # =>This Inner Loop Header: Depth=1
	movl	%eax, 80(%rsp,%rcx,4)
	movl	%ecx, %edx
	imull	%ecx, %edx
	movl	%edx, 32(%rsp,%rcx,4)
	incq	%rcx
	decl	%eax
	cmpq	$10, %rcx
	jne	.LBB2_1
# %bb.2:
	movq	24(%rsp), %rdi
	leaq	80(%rsp), %rsi
	movl	$40, %edx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	16(%rsp), %rdi
	leaq	32(%rsp), %rsi
	movl	$40, %edx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	8(%rsp), %rsi
	leaq	128(%rsp), %rdi
	movl	$40, %edx
	movl	$2, %ecx
	callq	hipMemcpy
	xorl	%ebx, %ebx
.LBB2_3:                                # =>This Inner Loop Header: Depth=1
	movl	80(%rsp,%rbx,4), %esi
	movl	32(%rsp,%rbx,4), %edx
	movl	128(%rsp,%rbx,4), %ecx
	movl	$.L.str.2, %edi
	xorl	%eax, %eax
	callq	printf
	incq	%rbx
	cmpq	$10, %rbx
	jne	.LBB2_3
# %bb.4:
	movq	24(%rsp), %rdi
	callq	hipFree
	movq	16(%rsp), %rdi
	callq	hipFree
	movq	8(%rsp), %rdi
	callq	hipFree
	addq	$176, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end2:
	.size	gpuTest, .Lfunc_end2-gpuTest
	.cfi_endproc
                                        # -- End function
	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"%s%d\n"
	.size	.L.str, 6

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"hello "
	.size	.L.str.1, 7

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"%d + %d = %d\n"
	.size	.L.str.2, 14

	.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
