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

double f(double x1, double x2, double x3, double x4, double x5)
{
 return exp(-((x1*x1)+(x2*x2)+(x3*x3)+(x4*x4)+(x5*x5)));
}

/* a function to get a random double between min and max*/
double get_double(double min, double max, unsigned int *seed)
{
 int i;
 double val = min;
 double scope = (max-min);
 double inc = (scope/RAND_MAX);
 for(i = 0; i < 10; ++i)
 {
  val += (rand_r(seed)*inc);
  inc = (inc/RAND_MAX);
 }
 return val;
}

double get_time(struct timespec start, struct timespec stop)
{
 return(
	((double)stop.tv_sec + (double)stop.tv_nsec/1000000000) -
	((double)start.tv_sec + (double)start.tv_nsec/1000000000)
	);
}

void print_data(double *data, int size, FILE *fp)
{
 int i;

 for(i = 0; i < size; ++i)
  fprintf(fp, "%.20lf\t", data[i]);
 fprintf(fp, "\n");

 return;
}


	.file	"tmpxft_00214219_00000000-6_class-func.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2033:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2033:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z1fddddd
	.type	_Z1fddddd, @function
_Z1fddddd:
.LFB2027:
	.cfi_startproc
	endbr64
	mulsd	%xmm0, %xmm0
	mulsd	%xmm1, %xmm1
	mulsd	%xmm2, %xmm2
	mulsd	%xmm3, %xmm3
	mulsd	%xmm4, %xmm4
	addsd	%xmm1, %xmm0
	addsd	%xmm2, %xmm0
	addsd	%xmm3, %xmm0
	addsd	%xmm4, %xmm0
	xorps	.LC0(%rip), %xmm0
	jmp	exp@PLT
	.cfi_endproc
.LFE2027:
	.size	_Z1fddddd, .-_Z1fddddd
	.globl	_Z10get_doubleddPj
	.type	_Z10get_doubleddPj, @function
_Z10get_doubleddPj:
.LFB2028:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rdi, %rbp
	subsd	%xmm0, %xmm1
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	movl	$10, %ebx
	subq	$24, %rsp
	.cfi_def_cfa_offset 48
	divsd	.LC1(%rip), %xmm1
.L4:
	movq	%rbp, %rdi
	movsd	%xmm0, 8(%rsp)
	movsd	%xmm1, (%rsp)
	call	rand_r@PLT
	movsd	(%rsp), %xmm1
	movsd	8(%rsp), %xmm0
	cvtsi2sdl	%eax, %xmm2
	mulsd	%xmm1, %xmm2
	divsd	.LC1(%rip), %xmm1
	addsd	%xmm2, %xmm0
	decl	%ebx
	jne	.L4
	addq	$24, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2028:
	.size	_Z10get_doubleddPj, .-_Z10get_doubleddPj
	.globl	_Z8get_time8timespecS_
	.type	_Z8get_time8timespecS_, @function
_Z8get_time8timespecS_:
.LFB2029:
	.cfi_startproc
	endbr64
	cvtsi2sdq	%rcx, %xmm0
	movsd	.LC2(%rip), %xmm2
	cvtsi2sdq	%rdx, %xmm1
	divsd	%xmm2, %xmm0
	addsd	%xmm1, %xmm0
	cvtsi2sdq	%rsi, %xmm1
	divsd	%xmm2, %xmm1
	cvtsi2sdq	%rdi, %xmm2
	addsd	%xmm2, %xmm1
	subsd	%xmm1, %xmm0
	ret
	.cfi_endproc
.LFE2029:
	.size	_Z8get_time8timespecS_, .-_Z8get_time8timespecS_
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC3:
	.string	"%.20lf\t"
.LC4:
	.string	"\n"
	.text
	.globl	_Z10print_dataPdiP8_IO_FILE
	.type	_Z10print_dataPdiP8_IO_FILE, @function
_Z10print_dataPdiP8_IO_FILE:
.LFB2030:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	leaq	.LC3(%rip), %r14
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	movq	%rdi, %r13
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	movl	%esi, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	xorl	%ebp, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	movq	%rdx, %rbx
.L10:
	cmpl	%ebp, %r12d
	jle	.L13
	movsd	0(%r13,%rbp,8), %xmm0
	movq	%r14, %rdx
	movq	%rbx, %rdi
	movb	$1, %al
	movl	$2, %esi
	incq	%rbp
	call	__fprintf_chk@PLT
	jmp	.L10
.L13:
	movq	%rbx, %rdi
	leaq	.LC4(%rip), %rdx
	popq	%rbx
	.cfi_def_cfa_offset 40
	movl	$2, %esi
	popq	%rbp
	.cfi_def_cfa_offset 32
	xorl	%eax, %eax
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	jmp	__fprintf_chk@PLT
	.cfi_endproc
.LFE2030:
	.size	_Z10print_dataPdiP8_IO_FILE, .-_Z10print_dataPdiP8_IO_FILE
	.section	.text.startup,"ax",@progbits
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2056:
	.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
.LFE2056:
	.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.cst16,"aM",@progbits,16
	.align 16
.LC0:
	.long	0
	.long	-2147483648
	.long	0
	.long	0
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC1:
	.long	-4194304
	.long	1105199103
	.align 8
.LC2:
	.long	0
	.long	1104006501
	.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>
#include<time.h>
#include<math.h>

double f(double x1, double x2, double x3, double x4, double x5)
{
 return exp(-((x1*x1)+(x2*x2)+(x3*x3)+(x4*x4)+(x5*x5)));
}

/* a function to get a random double between min and max*/
double get_double(double min, double max, unsigned int *seed)
{
 int i;
 double val = min;
 double scope = (max-min);
 double inc = (scope/RAND_MAX);
 for(i = 0; i < 10; ++i)
 {
  val += (rand_r(seed)*inc);
  inc = (inc/RAND_MAX);
 }
 return val;
}

double get_time(struct timespec start, struct timespec stop)
{
 return(
	((double)stop.tv_sec + (double)stop.tv_nsec/1000000000) -
	((double)start.tv_sec + (double)start.tv_nsec/1000000000)
	);
}

void print_data(double *data, int size, FILE *fp)
{
 int i;

 for(i = 0; i < size; ++i)
  fprintf(fp, "%.20lf\t", data[i]);
 fprintf(fp, "\n");

 return;
}


	.text
	.file	"class-func.hip"
	.section	.rodata.cst16,"aM",@progbits,16
	.p2align	4, 0x0                          # -- Begin function _Z1fddddd
.LCPI0_0:
	.quad	0x8000000000000000              # double -0
	.quad	0x8000000000000000              # double -0
	.text
	.globl	_Z1fddddd
	.type	_Z1fddddd,@function
_Z1fddddd:                              # @_Z1fddddd
	.cfi_startproc
# %bb.0:
	mulsd	%xmm0, %xmm0
	mulsd	%xmm1, %xmm1
	addsd	%xmm1, %xmm0
	mulsd	%xmm2, %xmm2
	addsd	%xmm2, %xmm0
	mulsd	%xmm3, %xmm3
	addsd	%xmm3, %xmm0
	mulsd	%xmm4, %xmm4
	addsd	%xmm4, %xmm0
	xorpd	.LCPI0_0(%rip), %xmm0
	jmp	exp                             # TAILCALL
.Lfunc_end0:
	.size	_Z1fddddd, .Lfunc_end0-_Z1fddddd
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z10get_doubleddPj
.LCPI1_0:
	.quad	0x41dfffffffc00000              # double 2147483647
	.text
	.globl	_Z10get_doubleddPj
	.type	_Z10get_doubleddPj,@function
_Z10get_doubleddPj:                     # @_Z10get_doubleddPj
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	subq	$24, %rsp
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -24
	.cfi_offset %rbp, -16
	movq	%rdi, %rbx
	movapd	%xmm1, %xmm2
	subsd	%xmm0, %xmm2
	movl	$10, %ebp
.LBB1_1:                                # =>This Inner Loop Header: Depth=1
	movsd	%xmm0, 8(%rsp)                  # 8-byte Spill
	divsd	.LCPI1_0(%rip), %xmm2
	movsd	%xmm2, 16(%rsp)                 # 8-byte Spill
	movq	%rbx, %rdi
	callq	rand_r
	movsd	16(%rsp), %xmm2                 # 8-byte Reload
                                        # xmm2 = mem[0],zero
	xorps	%xmm0, %xmm0
	cvtsi2sd	%eax, %xmm0
	mulsd	%xmm2, %xmm0
	movsd	8(%rsp), %xmm1                  # 8-byte Reload
                                        # xmm1 = mem[0],zero
	addsd	%xmm0, %xmm1
	movsd	%xmm1, 8(%rsp)                  # 8-byte Spill
	movsd	8(%rsp), %xmm0                  # 8-byte Reload
                                        # xmm0 = mem[0],zero
	decl	%ebp
	jne	.LBB1_1
# %bb.2:
	addq	$24, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end1:
	.size	_Z10get_doubleddPj, .Lfunc_end1-_Z10get_doubleddPj
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z8get_time8timespecS_
.LCPI2_0:
	.quad	0x41cdcd6500000000              # double 1.0E+9
	.text
	.globl	_Z8get_time8timespecS_
	.type	_Z8get_time8timespecS_,@function
_Z8get_time8timespecS_:                 # @_Z8get_time8timespecS_
	.cfi_startproc
# %bb.0:
	cvtsi2sd	%rdx, %xmm1
	cvtsi2sd	%rcx, %xmm0
	movsd	.LCPI2_0(%rip), %xmm2           # xmm2 = mem[0],zero
	divsd	%xmm2, %xmm0
	addsd	%xmm1, %xmm0
	xorps	%xmm1, %xmm1
	cvtsi2sd	%rdi, %xmm1
	cvtsi2sd	%rsi, %xmm3
	divsd	%xmm2, %xmm3
	addsd	%xmm1, %xmm3
	subsd	%xmm3, %xmm0
	retq
.Lfunc_end2:
	.size	_Z8get_time8timespecS_, .Lfunc_end2-_Z8get_time8timespecS_
	.cfi_endproc
                                        # -- End function
	.globl	_Z10print_dataPdiP8_IO_FILE     # -- Begin function _Z10print_dataPdiP8_IO_FILE
	.type	_Z10print_dataPdiP8_IO_FILE,@function
_Z10print_dataPdiP8_IO_FILE:            # @_Z10print_dataPdiP8_IO_FILE
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r12
	.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 %r12, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rdx, %rbx
	testl	%esi, %esi
	jle	.LBB3_3
# %bb.1:                                # %.lr.ph.preheader
	movq	%rdi, %r14
	movl	%esi, %r15d
	xorl	%r12d, %r12d
.LBB3_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movsd	(%r14,%r12,8), %xmm0            # xmm0 = mem[0],zero
	movl	$.L.str, %esi
	movq	%rbx, %rdi
	movb	$1, %al
	callq	fprintf
	incq	%r12
	cmpq	%r12, %r15
	jne	.LBB3_2
.LBB3_3:                                # %._crit_edge
	movl	$10, %edi
	movq	%rbx, %rsi
	addq	$8, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	jmp	fputc@PLT                       # TAILCALL
.Lfunc_end3:
	.size	_Z10print_dataPdiP8_IO_FILE, .Lfunc_end3-_Z10print_dataPdiP8_IO_FILE
	.cfi_endproc
                                        # -- End function
	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"%.20lf\t"
	.size	.L.str, 8

	.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
