/* Linear convection equation with periodic BC
 * solved using MUSCL scheme
 * CUDA implementation of hyp.c using only global memory
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define minmod(a,b)   ( (fabs(a) < fabs(b)) ? (a) : (b) )


//function prototypes
void initCond(int, float, float*);
__global__ void fluxFun(float*, float*);
__global__ void update(int, float, float, float*, float*, float*);
__global__ void periodic(float*, int);

int main(){
   float *u;
   float *uold_d, *u_d, *fl_d;
   int np = 101, ns;
   float dx = 1.0/(np-1);
   float dt, cfl;
   int niter, maxiter;
   int nirk, rkmax=3;
   int i;
   FILE *fpt;
   dim3 grid, block;

   ns   = np + 2 + 2;

   u    = (float*)malloc(ns*sizeof(float));

   cudaMalloc((void**)&uold_d, (ns)*sizeof(float));
   cudaMalloc((void**)&u_d,    (ns)*sizeof(float));
   cudaMalloc((void**)&fl_d,   (np+1)*sizeof(float));

   cfl = 0.9;
   dt  = cfl*dx;
   maxiter = 1.0/dt + 1;

   //set initial conditions
   initCond(np, dx, u);

   fpt = fopen("init.dat", "w");
   for(i=0; i<np; i++) fprintf(fpt, "%e %e\n", dx*i, u[i+2]);
   fclose(fpt);

   cudaMemcpy(uold_d, u, (ns)*sizeof(float), 
              cudaMemcpyHostToDevice);
   cudaMemcpy(u_d, u, (ns)*sizeof(float), 
              cudaMemcpyHostToDevice);

   //time-step loop
   for(niter=0; niter<maxiter; niter++){

      //RK stages
      for(nirk=0; nirk<rkmax; nirk++){

         //flux computation
         block.x = 3;
         grid.x  = (np+1)/block.x;
         fluxFun<<<grid,block>>>(u_d, fl_d);

         //update conserved variable
         block.x = 1;
         grid.x  = (np)/block.x;
         update<<<grid,block>>>(nirk, dt, dx, uold_d, fl_d, u_d);

         //set periodicity
         block.x = 1;
         grid.x  = (ns)/block.x;
         periodic<<<grid,block>>>(u_d, np);
      }
      cudaMemcpy(uold_d, u_d, (ns)*sizeof(float), 
                 cudaMemcpyDeviceToDevice);

   }
   cudaMemcpy(u, u_d, (ns)*sizeof(float), 
              cudaMemcpyDeviceToHost);

   fpt = fopen("final.dat", "w");
   for(i=0; i<np; i++) fprintf(fpt, "%e %e\n", dx*i, u[i+2]);
   fclose(fpt);

   free(u);

   cudaFree(uold_d);
   cudaFree(u_d);
   cudaFree(fl_d);

}

//set initial condition
void initCond(int np, float dx, float *u){
   int i;
   float x;

   for(i=0; i<np; i++){
      x = dx*i;
      u[i+2] = sin(2.0*M_PI*x);
   }
   u[0]    = u[np];
   u[1]    = u[np+1];
   u[np+2] = u[2];
   u[np+3] = u[3];

}

//flux function
__global__ void fluxFun(float *u, float *fl){
   float uj, ujp1, ujm1, ujp2;
   float ul, ur;

   int idx = blockIdx.x*blockDim.x + threadIdx.x;

   ujm1 = *(u+idx);
   uj   = *(u+idx+1);
   ujp1 = *(u+idx+2);
   ujp2 = *(u+idx+3);

   ul = uj   + 0.5*minmod( (uj-ujm1), (ujp1-uj) );
   ur = ujp1 - 0.5*minmod( (ujp1-uj), (ujp2-ujp1) );

   fl[idx] = ul;

}

//perform one stage of RK
__global__ void update(int nirk, float dt, float dx, float *uold, float *fl, 
                       float *u){
   int idx = blockIdx.x*blockDim.x + threadIdx.x;
   float res;
   float airk[3] = {0.0, 3.0/4.0, 1.0/3.0};

   res = fl[idx+1] - fl[idx];
   u[idx+2] = airk[nirk]*uold[idx+2] + 
          (1.0-airk[nirk])*(u[idx+2] - (dt/dx)*res);
}

//set periodic BC
__global__ void periodic(float *u, int np){
   int idx = blockIdx.x*blockDim.x + threadIdx.x;

   if(idx==0)
      u[idx] = u[np];
   else if(idx==1)
      u[idx] = u[np+1];
   else if(idx==np+2)
      u[idx] = u[2];
   else if(idx==np+3)
      u[idx] = u[3];
   else
      u[idx] = u[idx];

}

	.file	"tmpxft_00341917_00000000-6_hyp_global.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2031:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2031:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z8initCondifPf
	.type	_Z8initCondifPf, @function
_Z8initCondifPf:
.LFB2028:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	xorl	%r12d, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movslq	%edi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	movq	%rsi, %rbx
	subq	$16, %rsp
	.cfi_def_cfa_offset 48
	movss	%xmm0, 12(%rsp)
.L3:
	cmpl	%r12d, %ebp
	jle	.L7
	cvtsi2ssl	%r12d, %xmm0
	mulss	12(%rsp), %xmm0
	cvtss2sd	%xmm0, %xmm0
	mulsd	.LC0(%rip), %xmm0
	call	sin@PLT
	cvtsd2ss	%xmm0, %xmm0
	movss	%xmm0, 8(%rbx,%r12,4)
	incq	%r12
	jmp	.L3
.L7:
	movss	(%rbx,%rbp,4), %xmm0
	leaq	0(,%rbp,4), %rax
	movss	%xmm0, (%rbx)
	movss	4(%rbx,%rax), %xmm0
	movss	%xmm0, 4(%rbx)
	movss	8(%rbx), %xmm0
	movss	%xmm0, 8(%rbx,%rax)
	movss	12(%rbx), %xmm0
	movss	%xmm0, 12(%rbx,%rax)
	addq	$16, %rsp
	.cfi_def_cfa_offset 32
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2028:
	.size	_Z8initCondifPf, .-_Z8initCondifPf
	.globl	_Z28__device_stub__Z7fluxFunPfS_PfS_
	.type	_Z28__device_stub__Z7fluxFunPfS_PfS_, @function
_Z28__device_stub__Z7fluxFunPfS_PfS_:
.LFB2053:
	.cfi_startproc
	endbr64
	subq	$120, %rsp
	.cfi_def_cfa_offset 128
	movq	%rdi, 8(%rsp)
	leaq	32(%rsp), %rcx
	leaq	24(%rsp), %rdx
	movq	%rsi, (%rsp)
	leaq	40(%rsp), %rdi
	leaq	52(%rsp), %rsi
	movq	%fs:40, %rax
	movq	%rax, 104(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rax
	movl	$1, 48(%rsp)
	movq	%rax, 88(%rsp)
	movq	%rsp, %rax
	movq	%rax, 96(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 40(%rsp)
	movq	%rax, 52(%rsp)
	movl	$1, 60(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L8
	pushq	32(%rsp)
	.cfi_def_cfa_offset 136
	leaq	_Z7fluxFunPfS_(%rip), %rdi
	pushq	32(%rsp)
	.cfi_def_cfa_offset 144
	movq	68(%rsp), %rcx
	movl	76(%rsp), %r8d
	movq	56(%rsp), %rsi
	movl	64(%rsp), %edx
	leaq	104(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 136
	popq	%rdx
	.cfi_def_cfa_offset 128
.L8:
	movq	104(%rsp), %rax
	subq	%fs:40, %rax
	je	.L10
	call	__stack_chk_fail@PLT
.L10:
	addq	$120, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2053:
	.size	_Z28__device_stub__Z7fluxFunPfS_PfS_, .-_Z28__device_stub__Z7fluxFunPfS_PfS_
	.globl	_Z7fluxFunPfS_
	.type	_Z7fluxFunPfS_, @function
_Z7fluxFunPfS_:
.LFB2054:
	.cfi_startproc
	endbr64
	jmp	_Z28__device_stub__Z7fluxFunPfS_PfS_
	.cfi_endproc
.LFE2054:
	.size	_Z7fluxFunPfS_, .-_Z7fluxFunPfS_
	.globl	_Z32__device_stub__Z6updateiffPfS_S_iffPfS_S_
	.type	_Z32__device_stub__Z6updateiffPfS_S_iffPfS_S_, @function
_Z32__device_stub__Z6updateiffPfS_S_iffPfS_S_:
.LFB2055:
	.cfi_startproc
	endbr64
	subq	$184, %rsp
	.cfi_def_cfa_offset 192
	movl	%edi, 44(%rsp)
	leaq	72(%rsp), %rdi
	movq	%rsi, 24(%rsp)
	leaq	84(%rsp), %rsi
	movq	%rdx, 16(%rsp)
	leaq	56(%rsp), %rdx
	movq	%rcx, 8(%rsp)
	leaq	64(%rsp), %rcx
	movss	%xmm0, 40(%rsp)
	movss	%xmm1, 36(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 168(%rsp)
	xorl	%eax, %eax
	leaq	44(%rsp), %rax
	movl	$1, 80(%rsp)
	movq	%rax, 120(%rsp)
	leaq	40(%rsp), %rax
	movq	%rax, 128(%rsp)
	leaq	36(%rsp), %rax
	movq	%rax, 136(%rsp)
	leaq	24(%rsp), %rax
	movq	%rax, 144(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 152(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 160(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 72(%rsp)
	movq	%rax, 84(%rsp)
	movl	$1, 92(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L13
	pushq	64(%rsp)
	.cfi_def_cfa_offset 200
	leaq	_Z6updateiffPfS_S_(%rip), %rdi
	pushq	64(%rsp)
	.cfi_def_cfa_offset 208
	movq	100(%rsp), %rcx
	movl	108(%rsp), %r8d
	movq	88(%rsp), %rsi
	movl	96(%rsp), %edx
	leaq	136(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 200
	popq	%rdx
	.cfi_def_cfa_offset 192
.L13:
	movq	168(%rsp), %rax
	subq	%fs:40, %rax
	je	.L15
	call	__stack_chk_fail@PLT
.L15:
	addq	$184, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2055:
	.size	_Z32__device_stub__Z6updateiffPfS_S_iffPfS_S_, .-_Z32__device_stub__Z6updateiffPfS_S_iffPfS_S_
	.globl	_Z6updateiffPfS_S_
	.type	_Z6updateiffPfS_S_, @function
_Z6updateiffPfS_S_:
.LFB2056:
	.cfi_startproc
	endbr64
	jmp	_Z32__device_stub__Z6updateiffPfS_S_iffPfS_S_
	.cfi_endproc
.LFE2056:
	.size	_Z6updateiffPfS_S_, .-_Z6updateiffPfS_S_
	.globl	_Z28__device_stub__Z8periodicPfiPfi
	.type	_Z28__device_stub__Z8periodicPfiPfi, @function
_Z28__device_stub__Z8periodicPfiPfi:
.LFB2057:
	.cfi_startproc
	endbr64
	subq	$120, %rsp
	.cfi_def_cfa_offset 128
	movq	%rdi, 8(%rsp)
	leaq	32(%rsp), %rcx
	leaq	24(%rsp), %rdx
	movl	%esi, 4(%rsp)
	leaq	40(%rsp), %rdi
	leaq	52(%rsp), %rsi
	movq	%fs:40, %rax
	movq	%rax, 104(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rax
	movl	$1, 48(%rsp)
	movq	%rax, 88(%rsp)
	leaq	4(%rsp), %rax
	movq	%rax, 96(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 40(%rsp)
	movq	%rax, 52(%rsp)
	movl	$1, 60(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L18
	pushq	32(%rsp)
	.cfi_def_cfa_offset 136
	leaq	_Z8periodicPfi(%rip), %rdi
	pushq	32(%rsp)
	.cfi_def_cfa_offset 144
	movq	68(%rsp), %rcx
	movl	76(%rsp), %r8d
	movq	56(%rsp), %rsi
	movl	64(%rsp), %edx
	leaq	104(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 136
	popq	%rdx
	.cfi_def_cfa_offset 128
.L18:
	movq	104(%rsp), %rax
	subq	%fs:40, %rax
	je	.L20
	call	__stack_chk_fail@PLT
.L20:
	addq	$120, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2057:
	.size	_Z28__device_stub__Z8periodicPfiPfi, .-_Z28__device_stub__Z8periodicPfiPfi
	.globl	_Z8periodicPfi
	.type	_Z8periodicPfi, @function
_Z8periodicPfi:
.LFB2058:
	.cfi_startproc
	endbr64
	jmp	_Z28__device_stub__Z8periodicPfiPfi
	.cfi_endproc
.LFE2058:
	.size	_Z8periodicPfi, .-_Z8periodicPfi
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC2:
	.string	"w"
.LC3:
	.string	"init.dat"
.LC4:
	.string	"%e %e\n"
.LC6:
	.string	"final.dat"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2027:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	movl	$420, %edi
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	leaq	.LC2(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	leaq	.LC4(%rip), %r12
	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
	subq	$64, %rsp
	.cfi_def_cfa_offset 112
	movq	%fs:40, %rax
	movq	%rax, 56(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 36(%rsp)
	movq	%rax, 48(%rsp)
	call	malloc@PLT
	leaq	8(%rsp), %rdi
	movl	$420, %esi
	movq	%rax, %rbx
	call	cudaMalloc@PLT
	leaq	16(%rsp), %rdi
	movl	$420, %esi
	call	cudaMalloc@PLT
	leaq	24(%rsp), %rdi
	movl	$408, %esi
	call	cudaMalloc@PLT
	movss	.LC1(%rip), %xmm0
	movq	%rbx, %rsi
	movl	$101, %edi
	call	_Z8initCondifPf
	movq	%r13, %rsi
	leaq	.LC3(%rip), %rdi
	call	fopen@PLT
	movq	%rax, %r14
.L24:
	cvtsi2ssl	%ebp, %xmm0
	cvtss2sd	8(%rbx,%rbp,4), %xmm1
	movq	%r12, %rdx
	movq	%r14, %rdi
	mulss	.LC1(%rip), %xmm0
	movl	$2, %esi
	movb	$2, %al
	incq	%rbp
	cvtss2sd	%xmm0, %xmm0
	call	__fprintf_chk@PLT
	cmpq	$101, %rbp
	jne	.L24
	movq	%r14, %rdi
	movl	$112, %r14d
	call	fclose@PLT
	movq	8(%rsp), %rdi
	movl	$1, %ecx
	movq	%rbx, %rsi
	movl	$420, %edx
	call	cudaMemcpy@PLT
	movq	16(%rsp), %rdi
	movl	$1, %ecx
	movq	%rbx, %rsi
	movl	$420, %edx
	call	cudaMemcpy@PLT
.L25:
	xorl	%ebp, %ebp
.L29:
	movl	52(%rsp), %ecx
	movl	40(%rsp), %esi
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	$34, 32(%rsp)
	movq	32(%rsp), %rdi
	movl	$3, 44(%rsp)
	movq	44(%rsp), %rdx
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L26
	movq	24(%rsp), %rsi
	movq	16(%rsp), %rdi
	call	_Z28__device_stub__Z7fluxFunPfS_PfS_
.L26:
	movl	52(%rsp), %ecx
	movl	40(%rsp), %esi
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	$101, 32(%rsp)
	movq	32(%rsp), %rdi
	movl	$1, 44(%rsp)
	movq	44(%rsp), %rdx
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L27
	movq	16(%rsp), %rcx
	movq	24(%rsp), %rdx
	movl	%ebp, %edi
	movq	8(%rsp), %rsi
	movss	.LC1(%rip), %xmm1
	movss	.LC5(%rip), %xmm0
	call	_Z32__device_stub__Z6updateiffPfS_S_iffPfS_S_
.L27:
	movl	52(%rsp), %ecx
	movq	44(%rsp), %rdx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	$105, 32(%rsp)
	movl	40(%rsp), %esi
	movq	32(%rsp), %rdi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L28
	movq	16(%rsp), %rdi
	movl	$101, %esi
	call	_Z28__device_stub__Z8periodicPfiPfi
.L28:
	incl	%ebp
	cmpl	$3, %ebp
	jne	.L29
	movq	16(%rsp), %rsi
	movq	8(%rsp), %rdi
	movl	$3, %ecx
	movl	$420, %edx
	call	cudaMemcpy@PLT
	decl	%r14d
	jne	.L25
	movq	16(%rsp), %rsi
	movl	$2, %ecx
	movq	%rbx, %rdi
	xorl	%ebp, %ebp
	movl	$420, %edx
	call	cudaMemcpy@PLT
	movq	%r13, %rsi
	leaq	.LC6(%rip), %rdi
	call	fopen@PLT
	movq	%rax, %r13
.L31:
	cvtsi2ssl	%ebp, %xmm0
	cvtss2sd	8(%rbx,%rbp,4), %xmm1
	movq	%r12, %rdx
	movq	%r13, %rdi
	mulss	.LC1(%rip), %xmm0
	movl	$2, %esi
	movb	$2, %al
	incq	%rbp
	cvtss2sd	%xmm0, %xmm0
	call	__fprintf_chk@PLT
	cmpq	$101, %rbp
	jne	.L31
	movq	%r13, %rdi
	call	fclose@PLT
	movq	%rbx, %rdi
	call	free@PLT
	movq	8(%rsp), %rdi
	call	cudaFree@PLT
	movq	16(%rsp), %rdi
	call	cudaFree@PLT
	movq	24(%rsp), %rdi
	call	cudaFree@PLT
	movq	56(%rsp), %rax
	subq	%fs:40, %rax
	je	.L32
	call	__stack_chk_fail@PLT
.L32:
	addq	$64, %rsp
	.cfi_def_cfa_offset 48
	xorl	%eax, %eax
	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
.LFE2027:
	.size	main, .-main
	.section	.rodata.str1.1
.LC7:
	.string	"_Z8periodicPfi"
.LC8:
	.string	"_Z6updateiffPfS_S_"
.LC9:
	.string	"_Z7fluxFunPfS_"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2060:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	leaq	_ZL15__fatDeviceText(%rip), %rdi
	call	__cudaRegisterFatBinary@PLT
	pushq	$0
	.cfi_def_cfa_offset 24
	xorl	%r9d, %r9d
	orl	$-1, %r8d
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC7(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_Z8periodicPfi(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 48
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFunction@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	movq	%rbx, %rdi
	xorl	%r9d, %r9d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC8(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z6updateiffPfS_S_(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 40
	pushq	$0
	.cfi_def_cfa_offset 48
	call	__cudaRegisterFunction@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	movq	%rbx, %rdi
	xorl	%r9d, %r9d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC9(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z7fluxFunPfS_(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 40
	pushq	$0
	.cfi_def_cfa_offset 48
	call	__cudaRegisterFunction@PLT
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	call	__cudaRegisterFatBinaryEnd@PLT
	leaq	_ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE2060:
	.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
.LC0:
	.long	1413754136
	.long	1075388923
	.section	.rodata.cst4,"aM",@progbits,4
	.align 4
.LC1:
	.long	1008981770
	.align 4
.LC5:
	.long	1007908028
	.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:

/* Linear convection equation with periodic BC
 * solved using MUSCL scheme
 * CUDA implementation of hyp.c using only global memory
*/

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

#define minmod(a,b)   ( (fabs(a) < fabs(b)) ? (a) : (b) )


//function prototypes
void initCond(int, float, float*);
__global__ void fluxFun(float*, float*);
__global__ void update(int, float, float, float*, float*, float*);
__global__ void periodic(float*, int);

int main(){
   float *u;
   float *uold_d, *u_d, *fl_d;
   int np = 101, ns;
   float dx = 1.0/(np-1);
   float dt, cfl;
   int niter, maxiter;
   int nirk, rkmax=3;
   int i;
   FILE *fpt;
   dim3 grid, block;

   ns   = np + 2 + 2;

   u    = (float*)malloc(ns*sizeof(float));

   hipMalloc((void**)&uold_d, (ns)*sizeof(float));
   hipMalloc((void**)&u_d,    (ns)*sizeof(float));
   hipMalloc((void**)&fl_d,   (np+1)*sizeof(float));

   cfl = 0.9;
   dt  = cfl*dx;
   maxiter = 1.0/dt + 1;

   //set initial conditions
   initCond(np, dx, u);

   fpt = fopen("init.dat", "w");
   for(i=0; i<np; i++) fprintf(fpt, "%e %e\n", dx*i, u[i+2]);
   fclose(fpt);

   hipMemcpy(uold_d, u, (ns)*sizeof(float), 
              hipMemcpyHostToDevice);
   hipMemcpy(u_d, u, (ns)*sizeof(float), 
              hipMemcpyHostToDevice);

   //time-step loop
   for(niter=0; niter<maxiter; niter++){

      //RK stages
      for(nirk=0; nirk<rkmax; nirk++){

         //flux computation
         block.x = 3;
         grid.x  = (np+1)/block.x;
         fluxFun<<<grid,block>>>(u_d, fl_d);

         //update conserved variable
         block.x = 1;
         grid.x  = (np)/block.x;
         update<<<grid,block>>>(nirk, dt, dx, uold_d, fl_d, u_d);

         //set periodicity
         block.x = 1;
         grid.x  = (ns)/block.x;
         periodic<<<grid,block>>>(u_d, np);
      }
      hipMemcpy(uold_d, u_d, (ns)*sizeof(float), 
                 hipMemcpyDeviceToDevice);

   }
   hipMemcpy(u, u_d, (ns)*sizeof(float), 
              hipMemcpyDeviceToHost);

   fpt = fopen("final.dat", "w");
   for(i=0; i<np; i++) fprintf(fpt, "%e %e\n", dx*i, u[i+2]);
   fclose(fpt);

   free(u);

   hipFree(uold_d);
   hipFree(u_d);
   hipFree(fl_d);

}

//set initial condition
void initCond(int np, float dx, float *u){
   int i;
   float x;

   for(i=0; i<np; i++){
      x = dx*i;
      u[i+2] = sin(2.0*M_PI*x);
   }
   u[0]    = u[np];
   u[1]    = u[np+1];
   u[np+2] = u[2];
   u[np+3] = u[3];

}

//flux function
__global__ void fluxFun(float *u, float *fl){
   float uj, ujp1, ujm1, ujp2;
   float ul, ur;

   int idx = blockIdx.x*blockDim.x + threadIdx.x;

   ujm1 = *(u+idx);
   uj   = *(u+idx+1);
   ujp1 = *(u+idx+2);
   ujp2 = *(u+idx+3);

   ul = uj   + 0.5*minmod( (uj-ujm1), (ujp1-uj) );
   ur = ujp1 - 0.5*minmod( (ujp1-uj), (ujp2-ujp1) );

   fl[idx] = ul;

}

//perform one stage of RK
__global__ void update(int nirk, float dt, float dx, float *uold, float *fl, 
                       float *u){
   int idx = blockIdx.x*blockDim.x + threadIdx.x;
   float res;
   float airk[3] = {0.0, 3.0/4.0, 1.0/3.0};

   res = fl[idx+1] - fl[idx];
   u[idx+2] = airk[nirk]*uold[idx+2] + 
          (1.0-airk[nirk])*(u[idx+2] - (dt/dx)*res);
}

//set periodic BC
__global__ void periodic(float *u, int np){
   int idx = blockIdx.x*blockDim.x + threadIdx.x;

   if(idx==0)
      u[idx] = u[np];
   else if(idx==1)
      u[idx] = u[np+1];
   else if(idx==np+2)
      u[idx] = u[2];
   else if(idx==np+3)
      u[idx] = u[3];
   else
      u[idx] = u[idx];

}

	.text
	.file	"hyp_global.hip"
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function main
.LCPI0_0:
	.long	0x3c23d70a                      # float 0.00999999977
.LCPI0_2:
	.long	0x3c1374bc                      # float 0.00899999961
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0
.LCPI0_1:
	.quad	0x401921fb54442d18              # double 6.2831853071795862
	.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	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$40, %rsp
	.cfi_def_cfa_offset 96
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	$420, %edi                      # imm = 0x1A4
	callq	malloc
	movq	%rax, %r15
	leaq	8(%rsp), %rdi
	movl	$420, %esi                      # imm = 0x1A4
	callq	hipMalloc
	movq	%rsp, %rdi
	movl	$420, %esi                      # imm = 0x1A4
	callq	hipMalloc
	leaq	16(%rsp), %rdi
	movl	$408, %esi                      # imm = 0x198
	callq	hipMalloc
	xorl	%ebx, %ebx
.LBB0_1:                                # %.lr.ph.i
                                        # =>This Inner Loop Header: Depth=1
	xorps	%xmm0, %xmm0
	cvtsi2ss	%ebx, %xmm0
	mulss	.LCPI0_0(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	mulsd	.LCPI0_1(%rip), %xmm0
	callq	sin
	cvtsd2ss	%xmm0, %xmm0
	movss	%xmm0, 8(%r15,%rbx,4)
	incq	%rbx
	cmpq	$101, %rbx
	jne	.LBB0_1
# %bb.2:                                # %_Z8initCondifPf.exit
	movq	8(%r15), %rax
	movq	404(%r15), %rcx
	movq	%rcx, (%r15)
	movq	%rax, 412(%r15)
	movl	$.L.str, %edi
	movl	$.L.str.1, %esi
	callq	fopen
	movq	%rax, %rbx
	xorl	%r14d, %r14d
.LBB0_3:                                # =>This Inner Loop Header: Depth=1
	xorps	%xmm0, %xmm0
	cvtsi2ss	%r14d, %xmm0
	mulss	.LCPI0_0(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	xorps	%xmm1, %xmm1
	cvtss2sd	8(%r15,%r14,4), %xmm1
	movl	$.L.str.2, %esi
	movq	%rbx, %rdi
	movb	$2, %al
	callq	fprintf
	incq	%r14
	cmpq	$101, %r14
	jne	.LBB0_3
# %bb.4:
	movabsq	$4294967297, %r14               # imm = 0x100000001
	movq	%rbx, %rdi
	callq	fclose
	movq	8(%rsp), %rdi
	movl	$420, %edx                      # imm = 0x1A4
	movq	%r15, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	movq	(%rsp), %rdi
	movl	$420, %edx                      # imm = 0x1A4
	movq	%r15, 24(%rsp)                  # 8-byte Spill
	movq	%r15, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	xorl	%eax, %eax
	leaq	2(%r14), %r15
	leaq	33(%r14), %r12
	leaq	100(%r14), %r13
	leaq	104(%r14), %rbp
.LBB0_5:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB0_6 Depth 2
	movq	%rax, 32(%rsp)                  # 8-byte Spill
	xorl	%ebx, %ebx
.LBB0_6:                                #   Parent Loop BB0_5 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movq	%r12, %rdi
	movl	$1, %esi
	movq	%r15, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB0_8
# %bb.7:                                #   in Loop: Header=BB0_6 Depth=2
	movq	(%rsp), %rdi
	movq	16(%rsp), %rsi
	callq	_Z22__device_stub__fluxFunPfS_
.LBB0_8:                                #   in Loop: Header=BB0_6 Depth=2
	movq	%r13, %rdi
	movl	$1, %esi
	movq	%r14, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB0_10
# %bb.9:                                #   in Loop: Header=BB0_6 Depth=2
	movq	8(%rsp), %rsi
	movq	16(%rsp), %rdx
	movq	(%rsp), %rcx
	movl	%ebx, %edi
	movss	.LCPI0_2(%rip), %xmm0           # xmm0 = mem[0],zero,zero,zero
	movss	.LCPI0_0(%rip), %xmm1           # xmm1 = mem[0],zero,zero,zero
	callq	_Z21__device_stub__updateiffPfS_S_
.LBB0_10:                               #   in Loop: Header=BB0_6 Depth=2
	movq	%rbp, %rdi
	movl	$1, %esi
	movq	%r14, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB0_12
# %bb.11:                               #   in Loop: Header=BB0_6 Depth=2
	movq	(%rsp), %rdi
	movl	$101, %esi
	callq	_Z23__device_stub__periodicPfi
.LBB0_12:                               #   in Loop: Header=BB0_6 Depth=2
	incl	%ebx
	cmpl	$3, %ebx
	jne	.LBB0_6
# %bb.13:                               #   in Loop: Header=BB0_5 Depth=1
	movq	8(%rsp), %rdi
	movq	(%rsp), %rsi
	movl	$420, %edx                      # imm = 0x1A4
	movl	$3, %ecx
	callq	hipMemcpy
	movq	32(%rsp), %rax                  # 8-byte Reload
	incl	%eax
	cmpl	$112, %eax
	jne	.LBB0_5
# %bb.14:
	movq	(%rsp), %rsi
	movl	$420, %edx                      # imm = 0x1A4
	movq	24(%rsp), %r15                  # 8-byte Reload
	movq	%r15, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
	movl	$.L.str.3, %edi
	movl	$.L.str.1, %esi
	callq	fopen
	movq	%rax, %rbx
	xorl	%r14d, %r14d
.LBB0_15:                               # =>This Inner Loop Header: Depth=1
	xorps	%xmm0, %xmm0
	cvtsi2ss	%r14d, %xmm0
	mulss	.LCPI0_0(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	xorps	%xmm1, %xmm1
	cvtss2sd	8(%r15,%r14,4), %xmm1
	movl	$.L.str.2, %esi
	movq	%rbx, %rdi
	movb	$2, %al
	callq	fprintf
	incq	%r14
	cmpq	$101, %r14
	jne	.LBB0_15
# %bb.16:
	movq	%rbx, %rdi
	callq	fclose
	movq	%r15, %rdi
	callq	free
	movq	8(%rsp), %rdi
	callq	hipFree
	movq	(%rsp), %rdi
	callq	hipFree
	movq	16(%rsp), %rdi
	callq	hipFree
	xorl	%eax, %eax
	addq	$40, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.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
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z8initCondifPf
.LCPI1_0:
	.quad	0x401921fb54442d18              # double 6.2831853071795862
	.text
	.globl	_Z8initCondifPf
	.type	_Z8initCondifPf,@function
_Z8initCondifPf:                        # @_Z8initCondifPf
	.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, %rbx
	movl	%edi, %ebp
	testl	%edi, %edi
	jle	.LBB1_3
# %bb.1:                                # %.lr.ph.preheader
	movaps	%xmm0, %xmm1
	movl	%ebp, %r14d
	xorl	%r15d, %r15d
	movss	%xmm0, 4(%rsp)                  # 4-byte Spill
.LBB1_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	xorps	%xmm0, %xmm0
	cvtsi2ss	%r15d, %xmm0
	mulss	%xmm1, %xmm0
	cvtss2sd	%xmm0, %xmm0
	mulsd	.LCPI1_0(%rip), %xmm0
	callq	sin
	movss	4(%rsp), %xmm1                  # 4-byte Reload
                                        # xmm1 = mem[0],zero,zero,zero
	cvtsd2ss	%xmm0, %xmm0
	movss	%xmm0, 8(%rbx,%r15,4)
	incq	%r15
	cmpq	%r15, %r14
	jne	.LBB1_2
.LBB1_3:                                # %._crit_edge
	movslq	%ebp, %rax
	movss	(%rbx,%rax,4), %xmm0            # xmm0 = mem[0],zero,zero,zero
	movss	%xmm0, (%rbx)
	movss	4(%rbx,%rax,4), %xmm0           # xmm0 = mem[0],zero,zero,zero
	movss	%xmm0, 4(%rbx)
	movss	8(%rbx), %xmm0                  # xmm0 = mem[0],zero,zero,zero
	movss	%xmm0, 8(%rbx,%rax,4)
	movss	12(%rbx), %xmm0                 # xmm0 = mem[0],zero,zero,zero
	movss	%xmm0, 12(%rbx,%rax,4)
	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_end1:
	.size	_Z8initCondifPf, .Lfunc_end1-_Z8initCondifPf
	.cfi_endproc
                                        # -- End function
	.globl	_Z22__device_stub__fluxFunPfS_  # -- Begin function _Z22__device_stub__fluxFunPfS_
	.type	_Z22__device_stub__fluxFunPfS_,@function
_Z22__device_stub__fluxFunPfS_:         # @_Z22__device_stub__fluxFunPfS_
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$80, %rsp
	.cfi_def_cfa_offset 128
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	24(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	16(%rsp), %rcx
	movq	%rsi, (%rcx)
	leaq	64(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	leaq	48(%rsp), %r14
	leaq	32(%rsp), %r15
	leaq	8(%rsp), %r12
	movq	%rsp, %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z7fluxFunPfS_, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$96, %rsp
	.cfi_adjust_cfa_offset -96
	popq	%rbx
	.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
	retq
.Lfunc_end2:
	.size	_Z22__device_stub__fluxFunPfS_, .Lfunc_end2-_Z22__device_stub__fluxFunPfS_
	.cfi_endproc
                                        # -- End function
	.globl	_Z21__device_stub__updateiffPfS_S_ # -- Begin function _Z21__device_stub__updateiffPfS_S_
	.type	_Z21__device_stub__updateiffPfS_S_,@function
_Z21__device_stub__updateiffPfS_S_:     # @_Z21__device_stub__updateiffPfS_S_
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$144, %rsp
	.cfi_def_cfa_offset 192
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	20(%rsp), %rax
	movl	%edi, (%rax)
	leaq	16(%rsp), %rdi
	movss	%xmm0, (%rdi)
	leaq	12(%rsp), %r8
	movss	%xmm1, (%r8)
	leaq	56(%rsp), %r9
	movq	%rsi, (%r9)
	leaq	48(%rsp), %rsi
	movq	%rdx, (%rsi)
	leaq	40(%rsp), %rdx
	movq	%rcx, (%rdx)
	leaq	96(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%r8, 16(%rbx)
	movq	%r9, 24(%rbx)
	movq	%rsi, 32(%rbx)
	movq	%rdx, 40(%rbx)
	leaq	80(%rsp), %r14
	leaq	64(%rsp), %r15
	leaq	32(%rsp), %r12
	leaq	24(%rsp), %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z6updateiffPfS_S_, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$160, %rsp
	.cfi_adjust_cfa_offset -160
	popq	%rbx
	.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
	retq
.Lfunc_end3:
	.size	_Z21__device_stub__updateiffPfS_S_, .Lfunc_end3-_Z21__device_stub__updateiffPfS_S_
	.cfi_endproc
                                        # -- End function
	.globl	_Z23__device_stub__periodicPfi  # -- Begin function _Z23__device_stub__periodicPfi
	.type	_Z23__device_stub__periodicPfi,@function
_Z23__device_stub__periodicPfi:         # @_Z23__device_stub__periodicPfi
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$80, %rsp
	.cfi_def_cfa_offset 128
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	24(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	4(%rsp), %rcx
	movl	%esi, (%rcx)
	leaq	64(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	leaq	48(%rsp), %r14
	leaq	32(%rsp), %r15
	leaq	16(%rsp), %r12
	leaq	8(%rsp), %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z8periodicPfi, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$96, %rsp
	.cfi_adjust_cfa_offset -96
	popq	%rbx
	.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
	retq
.Lfunc_end4:
	.size	_Z23__device_stub__periodicPfi, .Lfunc_end4-_Z23__device_stub__periodicPfi
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_ctor
	.type	__hip_module_ctor,@function
__hip_module_ctor:                      # @__hip_module_ctor
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	subq	$32, %rsp
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -16
	movq	__hip_gpubin_handle(%rip), %rbx
	testq	%rbx, %rbx
	jne	.LBB5_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rbx
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB5_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z7fluxFunPfS_, %esi
	movl	$.L__unnamed_1, %edx
	movl	$.L__unnamed_1, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z6updateiffPfS_S_, %esi
	movl	$.L__unnamed_2, %edx
	movl	$.L__unnamed_2, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z8periodicPfi, %esi
	movl	$.L__unnamed_3, %edx
	movl	$.L__unnamed_3, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	movl	$__hip_module_dtor, %edi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit                          # TAILCALL
.Lfunc_end5:
	.size	__hip_module_ctor, .Lfunc_end5-__hip_module_ctor
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_dtor
	.type	__hip_module_dtor,@function
__hip_module_dtor:                      # @__hip_module_dtor
	.cfi_startproc
# %bb.0:
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	je	.LBB6_2
# %bb.1:
	pushq	%rax
	.cfi_def_cfa_offset 16
	callq	__hipUnregisterFatBinary
	movq	$0, __hip_gpubin_handle(%rip)
	addq	$8, %rsp
	.cfi_def_cfa_offset 8
.LBB6_2:
	retq
.Lfunc_end6:
	.size	__hip_module_dtor, .Lfunc_end6-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"init.dat"
	.size	.L.str, 9

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

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"%e %e\n"
	.size	.L.str.2, 7

	.type	_Z7fluxFunPfS_,@object          # @_Z7fluxFunPfS_
	.section	.rodata,"a",@progbits
	.globl	_Z7fluxFunPfS_
	.p2align	3, 0x0
_Z7fluxFunPfS_:
	.quad	_Z22__device_stub__fluxFunPfS_
	.size	_Z7fluxFunPfS_, 8

	.type	_Z6updateiffPfS_S_,@object      # @_Z6updateiffPfS_S_
	.globl	_Z6updateiffPfS_S_
	.p2align	3, 0x0
_Z6updateiffPfS_S_:
	.quad	_Z21__device_stub__updateiffPfS_S_
	.size	_Z6updateiffPfS_S_, 8

	.type	_Z8periodicPfi,@object          # @_Z8periodicPfi
	.globl	_Z8periodicPfi
	.p2align	3, 0x0
_Z8periodicPfi:
	.quad	_Z23__device_stub__periodicPfi
	.size	_Z8periodicPfi, 8

	.type	.L.str.3,@object                # @.str.3
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.3:
	.asciz	"final.dat"
	.size	.L.str.3, 10

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z7fluxFunPfS_"
	.size	.L__unnamed_1, 15

	.type	.L__unnamed_2,@object           # @1
.L__unnamed_2:
	.asciz	"_Z6updateiffPfS_S_"
	.size	.L__unnamed_2, 19

	.type	.L__unnamed_3,@object           # @2
.L__unnamed_3:
	.asciz	"_Z8periodicPfi"
	.size	.L__unnamed_3, 15

	.type	__hip_fatbin_wrapper,@object    # @__hip_fatbin_wrapper
	.section	.hipFatBinSegment,"a",@progbits
	.p2align	3, 0x0
__hip_fatbin_wrapper:
	.long	1212764230                      # 0x48495046
	.long	1                               # 0x1
	.quad	__hip_fatbin
	.quad	0
	.size	__hip_fatbin_wrapper, 24

	.type	__hip_gpubin_handle,@object     # @__hip_gpubin_handle
	.local	__hip_gpubin_handle
	.comm	__hip_gpubin_handle,8,8
	.section	.init_array,"aw",@init_array
	.p2align	3, 0x0
	.quad	__hip_module_ctor
	.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 _Z22__device_stub__fluxFunPfS_
	.addrsig_sym _Z21__device_stub__updateiffPfS_S_
	.addrsig_sym _Z23__device_stub__periodicPfi
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z7fluxFunPfS_
	.addrsig_sym _Z6updateiffPfS_S_
	.addrsig_sym _Z8periodicPfi
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z7fluxFunPfS_          ; -- Begin function _Z7fluxFunPfS_
	.globl	_Z7fluxFunPfS_
	.p2align	8
	.type	_Z7fluxFunPfS_,@function
_Z7fluxFunPfS_:                         ; @_Z7fluxFunPfS_
; %bb.0:
	s_clause 0x1
	s_load_b32 s4, s[0:1], 0x1c
	s_load_b128 s[0:3], s[0:1], 0x0
	s_waitcnt lgkmcnt(0)
	s_and_b32 s4, s4, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[1:2], null, s15, s4, v[0:1]
	v_ashrrev_i32_e32 v2, 31, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[3:4], 2, v[1:2]
	v_add_co_u32 v0, vcc_lo, s0, v3
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_4) | instid1(VALU_DEP_1)
	v_add_co_ci_u32_e32 v1, vcc_lo, s1, v4, vcc_lo
	global_load_b96 v[0:2], v[0:1], off
	s_waitcnt vmcnt(0)
	v_sub_f32_e32 v0, v1, v0
	v_sub_f32_e32 v2, v2, v1
	v_cmp_lt_f32_e64 vcc_lo, |v0|, |v2|
	v_cndmask_b32_e32 v0, v2, v0, vcc_lo
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_cvt_f64_f32_e32 v[5:6], v0
	v_cvt_f64_f32_e32 v[0:1], v1
	v_fma_f64 v[0:1], v[5:6], 0.5, v[0:1]
	s_delay_alu instid0(VALU_DEP_1)
	v_cvt_f32_f64_e32 v2, v[0:1]
	v_add_co_u32 v0, vcc_lo, s2, v3
	v_add_co_ci_u32_e32 v1, vcc_lo, s3, v4, vcc_lo
	global_store_b32 v[0:1], v2, off
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z7fluxFunPfS_
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 272
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 0
		.amdhsa_next_free_vgpr 7
		.amdhsa_next_free_sgpr 16
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end0:
	.size	_Z7fluxFunPfS_, .Lfunc_end0-_Z7fluxFunPfS_
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 168
; NumSgprs: 18
; NumVgprs: 7
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 7
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.protected	_Z6updateiffPfS_S_      ; -- Begin function _Z6updateiffPfS_S_
	.globl	_Z6updateiffPfS_S_
	.p2align	8
	.type	_Z6updateiffPfS_S_,@function
_Z6updateiffPfS_S_:                     ; @_Z6updateiffPfS_S_
; %bb.0:
	s_clause 0x2
	s_load_b32 s2, s[0:1], 0x34
	s_load_b256 s[4:11], s[0:1], 0x0
	s_load_b64 s[0:1], s[0:1], 0x20
	s_waitcnt lgkmcnt(0)
	s_and_b32 s2, s2, 0xffff
	v_div_scale_f32 v8, null, s6, s6, s5
	v_mad_u64_u32 v[1:2], null, s15, s2, v[0:1]
	s_cmp_eq_u32 s4, 1
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_rcp_f32_e32 v9, v8
	v_ashrrev_i32_e32 v2, 31, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[0:1], 2, v[1:2]
	v_add_co_u32 v2, vcc_lo, s10, v0
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v3, vcc_lo, s11, v1, vcc_lo
	v_add_co_u32 v4, vcc_lo, s8, v0
	v_add_co_ci_u32_e32 v5, vcc_lo, s9, v1, vcc_lo
	v_add_co_u32 v0, vcc_lo, s0, v0
	global_load_b64 v[2:3], v[2:3], off
	v_add_co_ci_u32_e32 v1, vcc_lo, s1, v1, vcc_lo
	global_load_b32 v6, v[4:5], off offset:8
	global_load_b32 v7, v[0:1], off offset:8
	s_cselect_b32 s0, -1, 0
	s_cmp_lg_u32 s4, 2
	v_cndmask_b32_e64 v4, 0, 0x3f400000, s0
	v_fma_f32 v5, -v8, v9, 1.0
	s_cselect_b32 vcc_lo, -1, 0
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_dual_cndmask_b32 v10, 0x3eaaaaab, v4 :: v_dual_fmac_f32 v9, v5, v9
	v_div_scale_f32 v11, vcc_lo, s5, s6, s5
	v_cvt_f64_f32_e32 v[4:5], v10
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_f32_e32 v12, v11, v9
	v_fma_f32 v13, -v8, v12, v11
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fmac_f32_e32 v12, v13, v9
	v_fma_f32 v8, -v8, v12, v11
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_3) | instid1(VALU_DEP_3)
	v_div_fmas_f32 v8, v8, v9, v12
	v_add_f64 v[4:5], -v[4:5], 1.0
	s_waitcnt vmcnt(2)
	v_sub_f32_e32 v2, v3, v2
	v_div_fixup_f32 v3, v8, s6, s5
	s_waitcnt vmcnt(1)
	v_mul_f32_e32 v6, v10, v6
	s_waitcnt vmcnt(0)
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_fma_f32 v7, -v3, v2, v7
	v_cvt_f64_f32_e32 v[2:3], v6
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_cvt_f64_f32_e32 v[6:7], v7
	v_fma_f64 v[2:3], v[4:5], v[6:7], v[2:3]
	s_delay_alu instid0(VALU_DEP_1)
	v_cvt_f32_f64_e32 v2, v[2:3]
	global_store_b32 v[0:1], v2, off offset:8
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z6updateiffPfS_S_
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 296
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 0
		.amdhsa_next_free_vgpr 14
		.amdhsa_next_free_sgpr 16
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end1:
	.size	_Z6updateiffPfS_S_, .Lfunc_end1-_Z6updateiffPfS_S_
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 348
; NumSgprs: 18
; NumVgprs: 14
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 14
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.protected	_Z8periodicPfi          ; -- Begin function _Z8periodicPfi
	.globl	_Z8periodicPfi
	.p2align	8
	.type	_Z8periodicPfi,@function
_Z8periodicPfi:                         ; @_Z8periodicPfi
; %bb.0:
	s_clause 0x2
	s_load_b32 s4, s[0:1], 0x1c
	s_load_b64 s[2:3], s[0:1], 0x0
	s_load_b32 s0, s[0:1], 0x8
	s_mov_b32 s5, exec_lo
	s_waitcnt lgkmcnt(0)
	s_and_b32 s1, s4, 0xffff
	s_mov_b32 s4, 0
	v_mad_u64_u32 v[1:2], null, s15, s1, v[0:1]
	s_mov_b32 s1, 0
	s_delay_alu instid0(VALU_DEP_1)
	v_cmpx_lt_i32_e32 0, v1
	s_xor_b32 s5, exec_lo, s5
	s_cbranch_execz .LBB2_4
; %bb.1:                                ; %LeafBlock27
	s_mov_b32 s1, -1
	s_mov_b32 s6, exec_lo
	v_cmpx_eq_u32_e32 1, v1
	s_cbranch_execz .LBB2_3
; %bb.2:
	s_ashr_i32 s1, s0, 31
	v_mov_b32_e32 v0, 0
	s_lshl_b64 s[8:9], s[0:1], 2
	s_delay_alu instid0(SALU_CYCLE_1)
	s_add_u32 s8, s2, s8
	s_addc_u32 s9, s3, s9
	s_load_b32 s1, s[8:9], 0x4
	s_waitcnt lgkmcnt(0)
	v_mov_b32_e32 v2, s1
	s_xor_b32 s1, exec_lo, -1
	global_store_b32 v0, v2, s[2:3] offset:4
.LBB2_3:                                ; %Flow32
	s_or_b32 exec_lo, exec_lo, s6
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_b32 s1, s1, exec_lo
.LBB2_4:                                ; %Flow31
	s_and_not1_saveexec_b32 s5, s5
; %bb.5:                                ; %LeafBlock
	v_cmp_ne_u32_e32 vcc_lo, 0, v1
	s_and_not1_b32 s1, s1, exec_lo
	s_mov_b32 s4, exec_lo
	s_and_b32 s6, vcc_lo, exec_lo
	s_delay_alu instid0(SALU_CYCLE_1)
	s_or_b32 s1, s1, s6
; %bb.6:                                ; %Flow33
	s_or_b32 exec_lo, exec_lo, s5
	s_and_saveexec_b32 s5, s1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_xor_b32 s1, exec_lo, s5
	s_cbranch_execz .LBB2_14
; %bb.7:
	s_add_i32 s5, s0, 2
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(SALU_CYCLE_1)
	v_cmp_ne_u32_e32 vcc_lo, s5, v1
	s_and_saveexec_b32 s5, vcc_lo
	s_xor_b32 s5, exec_lo, s5
	s_cbranch_execz .LBB2_11
; %bb.8:
	s_add_i32 s6, s0, 3
	s_delay_alu instid0(SALU_CYCLE_1)
	v_cmp_eq_u32_e32 vcc_lo, s6, v1
	s_and_saveexec_b32 s6, vcc_lo
	s_cbranch_execz .LBB2_10
; %bb.9:
	s_load_b32 s7, s[2:3], 0xc
	v_ashrrev_i32_e32 v2, 31, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[0:1], 2, v[1:2]
	v_add_co_u32 v0, vcc_lo, s2, v0
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v1, vcc_lo, s3, v1, vcc_lo
	s_waitcnt lgkmcnt(0)
	v_mov_b32_e32 v2, s7
	global_store_b32 v[0:1], v2, off
.LBB2_10:                               ; %Flow
	s_or_b32 exec_lo, exec_lo, s6
                                        ; implicit-def: $vgpr1_vgpr2
.LBB2_11:                               ; %Flow29
	s_and_not1_saveexec_b32 s5, s5
	s_cbranch_execz .LBB2_13
; %bb.12:
	s_load_b32 s6, s[2:3], 0x8
	v_ashrrev_i32_e32 v2, 31, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[0:1], 2, v[1:2]
	v_add_co_u32 v0, vcc_lo, s2, v0
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v1, vcc_lo, s3, v1, vcc_lo
	s_waitcnt lgkmcnt(0)
	v_mov_b32_e32 v2, s6
	global_store_b32 v[0:1], v2, off
.LBB2_13:                               ; %Flow30
	s_or_b32 exec_lo, exec_lo, s5
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_not1_b32 s4, s4, exec_lo
.LBB2_14:                               ; %Flow34
	s_or_b32 exec_lo, exec_lo, s1
	s_and_saveexec_b32 s1, s4
	s_cbranch_execz .LBB2_16
; %bb.15:
	s_ashr_i32 s1, s0, 31
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_lshl_b64 s[0:1], s[0:1], 2
	s_add_u32 s0, s2, s0
	s_addc_u32 s1, s3, s1
	s_load_b32 s0, s[0:1], 0x0
	s_waitcnt lgkmcnt(0)
	v_dual_mov_b32 v0, 0 :: v_dual_mov_b32 v1, s0
	global_store_b32 v0, v1, s[2:3]
.LBB2_16:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z8periodicPfi
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 272
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 0
		.amdhsa_next_free_vgpr 3
		.amdhsa_next_free_sgpr 16
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end2:
	.size	_Z8periodicPfi, .Lfunc_end2-_Z8periodicPfi
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 456
; NumSgprs: 18
; NumVgprs: 3
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 3
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.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_
	.amdgpu_metadata
---
amdhsa.kernels:
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         8
        .size:           8
        .value_kind:     global_buffer
      - .offset:         16
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         20
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         24
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         28
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         30
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         32
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         34
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         36
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         38
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         56
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         64
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         80
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 272
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z7fluxFunPfS_
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z7fluxFunPfS_.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     7
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
  - .args:
      - .offset:         0
        .size:           4
        .value_kind:     by_value
      - .offset:         4
        .size:           4
        .value_kind:     by_value
      - .offset:         8
        .size:           4
        .value_kind:     by_value
      - .address_space:  global
        .offset:         16
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         24
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         32
        .size:           8
        .value_kind:     global_buffer
      - .offset:         40
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         44
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         48
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         52
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         54
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         56
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         58
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         60
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         62
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         80
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         88
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         96
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         104
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 296
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z6updateiffPfS_S_
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z6updateiffPfS_S_.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     14
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .offset:         8
        .size:           4
        .value_kind:     by_value
      - .offset:         16
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         20
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         24
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         28
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         30
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         32
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         34
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         36
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         38
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         56
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         64
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         80
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 272
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z8periodicPfi
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z8periodicPfi.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     3
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
