// To compile - gcc -o 3dFDTD FDTD3D.c -lm

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <sys/time.h>
#include <cuda_runtime.h>

int main() {
    int imax = 100, jmax = 100, nmax = 1000, nhalf = 20, no = nhalf*3, kmax = 100;
    int i, j, n,k;
    double c = 2.99792458e8, pi = 3.141592654, sigma = 0, mu = 4.0 * pi * 1.0e-7, eps = 8.85418782e-12;
    double delta = 1e-3;
    double dt = delta/(c*1.41421356237);

    double ***Ex, ***Ey, ***Ez, ***Hy, ***Hx, ***Hz;

    cudaEvent_t start_event, stop_event;
    float elapsed_time;

    Ex = (double ***)malloc((imax+1)*sizeof(double **));
    Ey = (double ***)malloc((imax+1)*sizeof(double **));
    Ez = (double ***)malloc((imax+1)*sizeof(double **));
    Hx = (double ***)malloc((imax+1)*sizeof(double **));
    Hy = (double ***)malloc((imax+1)*sizeof(double **));
    Hz = (double ***)malloc((imax+1)*sizeof(double **));

    for(i=0;i<(imax+1);i++) {
        Ex[i] = (double **)malloc((jmax+1)*sizeof(double *));
        Ey[i] = (double **)malloc((jmax+1)*sizeof(double *));
        Ez[i] = (double **)malloc((jmax+1)*sizeof(double *));
        Hx[i] = (double **)malloc((jmax+1)*sizeof(double *));
        Hy[i] = (double **)malloc((jmax+1)*sizeof(double *));
        Hz[i] = (double **)malloc((jmax+1)*sizeof(double *));
        
        for(j=0;j<(jmax+1);j++) {
            Ex[i][j] = (double *)malloc((kmax+1)*sizeof(double));
            Ey[i][j] = (double *)malloc((kmax+1)*sizeof(double));
            Ez[i][j] = (double *)malloc((kmax+1)*sizeof(double));
            Hx[i][j] = (double *)malloc((kmax+1)*sizeof(double));
            Hy[i][j] = (double *)malloc((kmax+1)*sizeof(double));
            Hz[i][j] = (double *)malloc((kmax+1)*sizeof(double));
        }
    }	

    for(k=0;k<(kmax+1);k++){
	for(j=0;j<(jmax+1);j++){
	    for(i=0;i<(imax+1);i++){
                Ex[i][j][k] = 0.0;
                Ey[i][j][k] = 0.0;
                Ez[i][j][k] = 0.0;
                Hx[i][j][k] = 0.0;
                Hy[i][j][k] = 0.0;
                Hz[i][j][k] = 0.0;
	    }
	}
    }	

    double Ca,Cb,Da,Db;

    char buf[18];

    Ca = (1-((sigma*dt)/(2*eps)))/(1+((sigma*dt)/(2*eps)));
    Cb = (dt/(eps*delta))/(1+((sigma*dt)/(2*eps)));
    Da = (1-((sigma*dt)/(2*mu)))/(1+((sigma*dt)/(2*mu)));
    Db = (dt/(mu*delta))/(1+((sigma*dt)/(2*mu)));

    cudaEventCreate(&start_event);
    cudaEventCreate(&stop_event);
    cudaEventRecord(start_event, 0);

    for (n = 0; n < nmax; n++) {
        for (i = 0; i < imax; i++) {
            for (j = 1; j < jmax; j++) {
                for (k = 1; k < kmax; k++) {
                    Ex[i][j][k] = Ca*Ex[i][j][k] + Cb*((Hz[i][j][k] - Hy[i][j-1][k]) + (Hy[i][j][k-1] - Hy[i][j][k]));
                }
            }
        }
        for (i = 1; i < imax; i++) {
            for (j = 0; j < jmax; j++) {
                for (k = 1; k < kmax; k++) {
                    Ey[i][j][k] = Ca*Ey[i][j][k] + Cb*((Hz[i-1][j][k] - Hy[i][j][k]) + (Hy[i][j][k] - Hy[i][j][k-1]));
                }
            }
        }
        for (i = 1; i < imax; i++) {
            for (j = 1; j < jmax; j++) {
                for (k = 0; k < kmax; k++) {
                    Ez[i][j][k] = Ca*Ez[i][j][k] + Cb*((Hz[i][j][k] - Hy[i-1][j][k]) + (Hy[i][j-1][k] - Hy[i][j][k]));
                }
            }
        }
        Ez[imax/2][jmax/2][kmax/2] = exp(-(pow(((n-no)/(double)nhalf),2.0)));
        for (i = 1; i < imax; i++) {
           for (j = 0; j < jmax-1; j++) {
               for (k = 0; k < kmax-1; k++) {
                   Hx[i][j][k] = Da*Hx[i][j][k] + Db*((Ez[i][j][k] - Ez[i][j+1][k]) + (Ez[i][j][k+1]-Ez[i][j][k]));
               }
           }
        }
        for (i = 0; i < imax; i++) {
           for (j = 1; j < jmax-1; j++) {
               for (k = 0; k < kmax-1; k++) {
                   Hy[i][j][k] = Da*Hy[i][j][k] + Db*((Ez[i+1][j][k] - Ez[i][j][k]) + (Ez[i][j][k]-Ez[i][j][k+1]));
               }
           }
        }
        for (i = 0; i < imax; i++) {
           for (j = 0; j < jmax-1; j++) {
               for (k = 1; k < kmax-1; k++) {
                   Hz[i][j][k] = Da*Hz[i][j][k] + Db*((Ez[i][j][k] - Ez[i+1][j][k]) + (Ez[i][j+1][k]-Ez[i][j][k]));
               }
           }
        }
    }

    cudaEventRecord(stop_event, 0);
    cudaEventSynchronize(stop_event);
    cudaEventElapsedTime(&elapsed_time, start_event, stop_event);

    FILE * fPointer;
    fPointer = fopen("parlleloutput.dat","w");
    int x, y, z;
    for (x=0; x<kmax; x++) {
      for (y=1; y<jmax; y++) {
        for (z=1; z<imax; z++) {
          memset(buf, 0, 18);
          sprintf(buf, "%e\n", Ez[(z*imax) + (y*jmax) + x]);
          fputs(buf, fPointer);
        }
      }
    }
    fclose(fPointer);

    // calculate run time

    printf("GPU Time: %.2f\n", elapsed_time);
    return 0;
}

	.file	"tmpxft_0024d115_00000000-6_reviter.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
.LC5:
	.string	"w"
.LC6:
	.string	"parlleloutput.dat"
.LC7:
	.string	"%e\n"
.LC8:
	.string	"GPU Time: %.2f\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
	movl	$808, %edi
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	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
	xorl	%ebx, %ebx
	subq	$136, %rsp
	.cfi_def_cfa_offset 192
	movq	%fs:40, %rax
	movq	%rax, 120(%rsp)
	xorl	%eax, %eax
	call	malloc@PLT
	movl	$808, %edi
	movq	%rax, (%rsp)
	call	malloc@PLT
	movl	$808, %edi
	movq	%rax, 8(%rsp)
	call	malloc@PLT
	movl	$808, %edi
	movq	%rax, %r15
	call	malloc@PLT
	movl	$808, %edi
	movq	%rax, 16(%rsp)
	call	malloc@PLT
	movl	$808, %edi
	movq	%rax, %r12
	call	malloc@PLT
	movq	%rax, %r13
.L4:
	movl	$808, %edi
	xorl	%ebp, %ebp
	call	malloc@PLT
	movl	$808, %edi
	movq	%rax, 24(%rsp)
	movq	(%rsp), %rax
	movq	24(%rsp), %rdx
	movq	%rdx, (%rax,%rbx)
	call	malloc@PLT
	movl	$808, %edi
	movq	%rax, %r14
	movq	8(%rsp), %rax
	movq	%r14, (%rax,%rbx)
	call	malloc@PLT
	movl	$808, %edi
	movq	%rax, (%r15,%rbx)
	movq	%rax, 32(%rsp)
	call	malloc@PLT
	movl	$808, %edi
	movq	%rax, 40(%rsp)
	movq	16(%rsp), %rax
	movq	40(%rsp), %rdx
	movq	%rdx, (%rax,%rbx)
	call	malloc@PLT
	movl	$808, %edi
	movq	%rax, (%r12,%rbx)
	movq	%rax, 48(%rsp)
	call	malloc@PLT
	movq	%rax, 0(%r13,%rbx)
	movq	%rax, %rcx
.L3:
	movl	$808, %edi
	movq	%rcx, 56(%rsp)
	call	malloc@PLT
	movq	24(%rsp), %rdx
	movl	$808, %edi
	movq	%rax, (%rdx,%rbp)
	call	malloc@PLT
	movl	$808, %edi
	movq	%rax, (%r14,%rbp)
	call	malloc@PLT
	movq	32(%rsp), %rdx
	movl	$808, %edi
	movq	%rax, (%rdx,%rbp)
	call	malloc@PLT
	movq	40(%rsp), %rdx
	movl	$808, %edi
	movq	%rax, (%rdx,%rbp)
	call	malloc@PLT
	movq	48(%rsp), %rdx
	movl	$808, %edi
	movq	%rax, (%rdx,%rbp)
	call	malloc@PLT
	movq	56(%rsp), %rcx
	movq	%rax, (%rcx,%rbp)
	addq	$8, %rbp
	cmpq	$808, %rbp
	jne	.L3
	addq	$8, %rbx
	cmpq	$808, %rbx
	jne	.L4
	xorl	%ecx, %ecx
.L5:
	xorl	%eax, %eax
.L9:
	xorl	%esi, %esi
.L6:
	movq	(%rsp), %rdx
	movq	(%rdx,%rsi), %rdi
	movq	8(%rsp), %rdx
	movq	(%rdi,%rax), %rdi
	movq	$0x000000000, (%rdi,%rcx)
	movq	(%rdx,%rsi), %rdi
	movq	16(%rsp), %rdx
	movq	(%rdi,%rax), %rdi
	movq	$0x000000000, (%rdi,%rcx)
	movq	(%r15,%rsi), %rdi
	movq	(%rdi,%rax), %rdi
	movq	$0x000000000, (%rdi,%rcx)
	movq	(%rdx,%rsi), %rdi
	movq	(%rdi,%rax), %rdi
	movq	$0x000000000, (%rdi,%rcx)
	movq	(%r12,%rsi), %rdi
	movq	(%rdi,%rax), %rdi
	movq	$0x000000000, (%rdi,%rcx)
	movq	0(%r13,%rsi), %rdi
	addq	$8, %rsi
	movq	(%rdi,%rax), %rdi
	movq	$0x000000000, (%rdi,%rcx)
	cmpq	$808, %rsi
	jne	.L6
	addq	$8, %rax
	cmpq	$808, %rax
	jne	.L9
	addq	$8, %rcx
	cmpq	$808, %rcx
	jne	.L5
	leaq	80(%rsp), %rdi
	movl	$-60, %r14d
	call	cudaEventCreate@PLT
	leaq	88(%rsp), %rdi
	call	cudaEventCreate@PLT
	movq	80(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
.L10:
	movsd	.LC1(%rip), %xmm1
	xorl	%esi, %esi
.L37:
	movq	(%rsp), %rax
	movq	0(%r13,%rsi), %r10
	movl	$8, %ecx
	movq	(%r12,%rsi), %rdi
	movq	(%rax,%rsi), %r11
.L14:
	movq	(%r11,%rcx), %r9
	movq	(%r10,%rcx), %rbp
	movl	$8, %eax
	movq	-8(%rdi,%rcx), %rbx
	movq	(%rdi,%rcx), %r8
.L11:
	movsd	0(%rbp,%rax), %xmm0
	movsd	-8(%r8,%rax), %xmm2
	subsd	(%rbx,%rax), %xmm0
	subsd	(%r8,%rax), %xmm2
	addsd	%xmm2, %xmm0
	mulsd	%xmm1, %xmm0
	addsd	(%r9,%rax), %xmm0
	movsd	%xmm0, (%r9,%rax)
	addq	$8, %rax
	cmpq	$800, %rax
	jne	.L11
	addq	$8, %rcx
	cmpq	$800, %rcx
	jne	.L14
	addq	$8, %rsi
	cmpq	$800, %rsi
	jne	.L37
	movl	$8, %esi
.L13:
	movq	8(%rsp), %rax
	movq	-8(%r13,%rsi), %r10
	xorl	%ecx, %ecx
	movq	(%r12,%rsi), %r9
	movq	(%rax,%rsi), %r11
.L18:
	movq	(%r11,%rcx), %r8
	movq	(%r10,%rcx), %rbx
	movl	$8, %eax
	movq	(%r9,%rcx), %rdi
.L15:
	movsd	(%rdi,%rax), %xmm2
	movsd	(%rbx,%rax), %xmm0
	subsd	%xmm2, %xmm0
	subsd	-8(%rdi,%rax), %xmm2
	addsd	%xmm2, %xmm0
	mulsd	%xmm1, %xmm0
	addsd	(%r8,%rax), %xmm0
	movsd	%xmm0, (%r8,%rax)
	addq	$8, %rax
	cmpq	$800, %rax
	jne	.L15
	addq	$8, %rcx
	cmpq	$800, %rcx
	jne	.L18
	addq	$8, %rsi
	cmpq	$800, %rsi
	jne	.L13
	movl	$8, %esi
.L17:
	movq	(%r15,%rsi), %r11
	movq	0(%r13,%rsi), %r10
	movl	$8, %ecx
	movq	-8(%r12,%rsi), %r9
	movq	(%r12,%rsi), %rdi
.L22:
	movq	(%r10,%rcx), %rax
	movq	(%r11,%rcx), %r8
	movq	-8(%rdi,%rcx), %rbp
	movq	(%rdi,%rcx), %rbx
	movq	%rax, 24(%rsp)
	movq	(%r9,%rcx), %rax
	movq	%rax, 32(%rsp)
	xorl	%eax, %eax
.L19:
	movq	24(%rsp), %rdx
	movsd	0(%rbp,%rax), %xmm2
	subsd	(%rbx,%rax), %xmm2
	movsd	(%rdx,%rax), %xmm0
	movq	32(%rsp), %rdx
	subsd	(%rdx,%rax), %xmm0
	addsd	%xmm2, %xmm0
	mulsd	%xmm1, %xmm0
	addsd	(%r8,%rax), %xmm0
	movsd	%xmm0, (%r8,%rax)
	addq	$8, %rax
	cmpq	$800, %rax
	jne	.L19
	addq	$8, %rcx
	cmpq	$800, %rcx
	jne	.L22
	addq	$8, %rsi
	cmpq	$800, %rsi
	jne	.L17
	movq	400(%r15), %rax
	cvtsi2sdl	%r14d, %xmm0
	divsd	.LC2(%rip), %xmm0
	mulsd	%xmm0, %xmm0
	xorps	.LC3(%rip), %xmm0
	movq	400(%rax), %rbx
	call	exp@PLT
	movsd	.LC4(%rip), %xmm2
	movl	$8, %esi
	movsd	%xmm0, 400(%rbx)
.L23:
	movq	16(%rsp), %rax
	movq	(%r15,%rsi), %rdi
	xorl	%ecx, %ecx
	movq	(%rax,%rsi), %r10
.L27:
	movq	(%r10,%rcx), %r9
	movq	(%rdi,%rcx), %r8
	xorl	%eax, %eax
	movq	8(%rdi,%rcx), %r11
.L24:
	movsd	(%r8,%rax), %xmm3
	movsd	8(%r8,%rax), %xmm1
	movaps	%xmm3, %xmm0
	subsd	%xmm3, %xmm1
	subsd	(%r11,%rax), %xmm0
	addsd	%xmm1, %xmm0
	mulsd	%xmm2, %xmm0
	addsd	(%r9,%rax), %xmm0
	movsd	%xmm0, (%r9,%rax)
	addq	$8, %rax
	cmpq	$792, %rax
	jne	.L24
	addq	$8, %rcx
	cmpq	$792, %rcx
	jne	.L27
	addq	$8, %rsi
	cmpq	$800, %rsi
	jne	.L23
	xorl	%esi, %esi
.L26:
	movq	(%r12,%rsi), %r11
	movq	8(%r15,%rsi), %r10
	movl	$8, %ecx
	movq	(%r15,%rsi), %r9
.L31:
	movq	(%r11,%rcx), %r8
	movq	(%r10,%rcx), %rbx
	xorl	%eax, %eax
	movq	(%r9,%rcx), %rdi
.L28:
	movsd	(%rdi,%rax), %xmm1
	movsd	(%rbx,%rax), %xmm0
	subsd	%xmm1, %xmm0
	subsd	8(%rdi,%rax), %xmm1
	addsd	%xmm1, %xmm0
	mulsd	%xmm2, %xmm0
	addsd	(%r8,%rax), %xmm0
	movsd	%xmm0, (%r8,%rax)
	addq	$8, %rax
	cmpq	$792, %rax
	jne	.L28
	addq	$8, %rcx
	cmpq	$792, %rcx
	jne	.L31
	addq	$8, %rsi
	cmpq	$800, %rsi
	jne	.L26
	xorl	%esi, %esi
.L30:
	movq	0(%r13,%rsi), %r10
	movq	(%r15,%rsi), %rdi
	xorl	%ecx, %ecx
	movq	8(%r15,%rsi), %r9
.L35:
	movq	(%r10,%rcx), %r8
	movq	(%rdi,%rcx), %rbp
	movl	$8, %eax
	movq	(%r9,%rcx), %rbx
	movq	8(%rdi,%rcx), %r11
.L32:
	movsd	0(%rbp,%rax), %xmm3
	movsd	(%r11,%rax), %xmm1
	movaps	%xmm3, %xmm0
	subsd	%xmm3, %xmm1
	subsd	(%rbx,%rax), %xmm0
	addsd	%xmm1, %xmm0
	mulsd	%xmm2, %xmm0
	addsd	(%r8,%rax), %xmm0
	movsd	%xmm0, (%r8,%rax)
	addq	$8, %rax
	cmpq	$792, %rax
	jne	.L32
	addq	$8, %rcx
	cmpq	$792, %rcx
	jne	.L35
	addq	$8, %rsi
	cmpq	$800, %rsi
	jne	.L30
	incl	%r14d
	cmpl	$940, %r14d
	jne	.L10
	movq	88(%rsp), %rdi
	xorl	%esi, %esi
	leaq	800(%r15), %r12
	xorl	%r14d, %r14d
	call	cudaEventRecord@PLT
	movq	88(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	movq	88(%rsp), %rdx
	movq	80(%rsp), %rsi
	leaq	76(%rsp), %rdi
	call	cudaEventElapsedTime@PLT
	leaq	.LC5(%rip), %rsi
	leaq	.LC6(%rip), %rdi
	call	fopen@PLT
	movq	%rax, 8(%rsp)
.L38:
	movq	%r12, %rbx
	movl	$1, %r13d
.L42:
	movl	$1, %ebp
	xorl	%r15d, %r15d
.L39:
	leaq	102(%rsp), %rax
	movl	$18, %ecx
	movl	$18, %edx
	movl	$2, %esi
	movq	%rax, (%rsp)
	movq	%rax, %rdi
	movl	%r15d, %eax
	rep stosb
	imulq	$800, %rbp, %rax
	movq	(%rsp), %rdi
	incq	%rbp
	leaq	.LC7(%rip), %rcx
	movq	(%rbx,%rax), %r8
	xorl	%eax, %eax
	call	__sprintf_chk@PLT
	movq	8(%rsp), %rsi
	movq	(%rsp), %rdi
	call	fputs@PLT
	cmpq	$100, %rbp
	jne	.L39
	incl	%r13d
	addq	$800, %rbx
	cmpl	$100, %r13d
	jne	.L42
	incq	%r14
	addq	$8, %r12
	cmpq	$100, %r14
	jne	.L38
	movq	8(%rsp), %rdi
	call	fclose@PLT
	leaq	.LC8(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	cvtss2sd	76(%rsp), %xmm0
	call	__printf_chk@PLT
	movq	120(%rsp), %rax
	subq	%fs:40, %rax
	je	.L43
	call	__stack_chk_fail@PLT
.L43:
	addq	$136, %rsp
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	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	-1981208395
	.long	1081124407
	.align 8
.LC2:
	.long	0
	.long	1077149696
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC3:
	.long	0
	.long	-2147483648
	.long	0
	.long	0
	.section	.rodata.cst8
	.align 8
.LC4:
	.long	-1065780835
	.long	1063174279
	.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:

// To compile - gcc -o 3dFDTD FDTD3D.c -lm

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

int main() {
    int imax = 100, jmax = 100, nmax = 1000, nhalf = 20, no = nhalf*3, kmax = 100;
    int i, j, n,k;
    double c = 2.99792458e8, pi = 3.141592654, sigma = 0, mu = 4.0 * pi * 1.0e-7, eps = 8.85418782e-12;
    double delta = 1e-3;
    double dt = delta/(c*1.41421356237);

    double ***Ex, ***Ey, ***Ez, ***Hy, ***Hx, ***Hz;

    hipEvent_t start_event, stop_event;
    float elapsed_time;

    Ex = (double ***)malloc((imax+1)*sizeof(double **));
    Ey = (double ***)malloc((imax+1)*sizeof(double **));
    Ez = (double ***)malloc((imax+1)*sizeof(double **));
    Hx = (double ***)malloc((imax+1)*sizeof(double **));
    Hy = (double ***)malloc((imax+1)*sizeof(double **));
    Hz = (double ***)malloc((imax+1)*sizeof(double **));

    for(i=0;i<(imax+1);i++) {
        Ex[i] = (double **)malloc((jmax+1)*sizeof(double *));
        Ey[i] = (double **)malloc((jmax+1)*sizeof(double *));
        Ez[i] = (double **)malloc((jmax+1)*sizeof(double *));
        Hx[i] = (double **)malloc((jmax+1)*sizeof(double *));
        Hy[i] = (double **)malloc((jmax+1)*sizeof(double *));
        Hz[i] = (double **)malloc((jmax+1)*sizeof(double *));
        
        for(j=0;j<(jmax+1);j++) {
            Ex[i][j] = (double *)malloc((kmax+1)*sizeof(double));
            Ey[i][j] = (double *)malloc((kmax+1)*sizeof(double));
            Ez[i][j] = (double *)malloc((kmax+1)*sizeof(double));
            Hx[i][j] = (double *)malloc((kmax+1)*sizeof(double));
            Hy[i][j] = (double *)malloc((kmax+1)*sizeof(double));
            Hz[i][j] = (double *)malloc((kmax+1)*sizeof(double));
        }
    }	

    for(k=0;k<(kmax+1);k++){
	for(j=0;j<(jmax+1);j++){
	    for(i=0;i<(imax+1);i++){
                Ex[i][j][k] = 0.0;
                Ey[i][j][k] = 0.0;
                Ez[i][j][k] = 0.0;
                Hx[i][j][k] = 0.0;
                Hy[i][j][k] = 0.0;
                Hz[i][j][k] = 0.0;
	    }
	}
    }	

    double Ca,Cb,Da,Db;

    char buf[18];

    Ca = (1-((sigma*dt)/(2*eps)))/(1+((sigma*dt)/(2*eps)));
    Cb = (dt/(eps*delta))/(1+((sigma*dt)/(2*eps)));
    Da = (1-((sigma*dt)/(2*mu)))/(1+((sigma*dt)/(2*mu)));
    Db = (dt/(mu*delta))/(1+((sigma*dt)/(2*mu)));

    hipEventCreate(&start_event);
    hipEventCreate(&stop_event);
    hipEventRecord(start_event, 0);

    for (n = 0; n < nmax; n++) {
        for (i = 0; i < imax; i++) {
            for (j = 1; j < jmax; j++) {
                for (k = 1; k < kmax; k++) {
                    Ex[i][j][k] = Ca*Ex[i][j][k] + Cb*((Hz[i][j][k] - Hy[i][j-1][k]) + (Hy[i][j][k-1] - Hy[i][j][k]));
                }
            }
        }
        for (i = 1; i < imax; i++) {
            for (j = 0; j < jmax; j++) {
                for (k = 1; k < kmax; k++) {
                    Ey[i][j][k] = Ca*Ey[i][j][k] + Cb*((Hz[i-1][j][k] - Hy[i][j][k]) + (Hy[i][j][k] - Hy[i][j][k-1]));
                }
            }
        }
        for (i = 1; i < imax; i++) {
            for (j = 1; j < jmax; j++) {
                for (k = 0; k < kmax; k++) {
                    Ez[i][j][k] = Ca*Ez[i][j][k] + Cb*((Hz[i][j][k] - Hy[i-1][j][k]) + (Hy[i][j-1][k] - Hy[i][j][k]));
                }
            }
        }
        Ez[imax/2][jmax/2][kmax/2] = exp(-(pow(((n-no)/(double)nhalf),2.0)));
        for (i = 1; i < imax; i++) {
           for (j = 0; j < jmax-1; j++) {
               for (k = 0; k < kmax-1; k++) {
                   Hx[i][j][k] = Da*Hx[i][j][k] + Db*((Ez[i][j][k] - Ez[i][j+1][k]) + (Ez[i][j][k+1]-Ez[i][j][k]));
               }
           }
        }
        for (i = 0; i < imax; i++) {
           for (j = 1; j < jmax-1; j++) {
               for (k = 0; k < kmax-1; k++) {
                   Hy[i][j][k] = Da*Hy[i][j][k] + Db*((Ez[i+1][j][k] - Ez[i][j][k]) + (Ez[i][j][k]-Ez[i][j][k+1]));
               }
           }
        }
        for (i = 0; i < imax; i++) {
           for (j = 0; j < jmax-1; j++) {
               for (k = 1; k < kmax-1; k++) {
                   Hz[i][j][k] = Da*Hz[i][j][k] + Db*((Ez[i][j][k] - Ez[i+1][j][k]) + (Ez[i][j+1][k]-Ez[i][j][k]));
               }
           }
        }
    }

    hipEventRecord(stop_event, 0);
    hipEventSynchronize(stop_event);
    hipEventElapsedTime(&elapsed_time, start_event, stop_event);

    FILE * fPointer;
    fPointer = fopen("parlleloutput.dat","w");
    int x, y, z;
    for (x=0; x<kmax; x++) {
      for (y=1; y<jmax; y++) {
        for (z=1; z<imax; z++) {
          memset(buf, 0, 18);
          sprintf(buf, "%e\n", Ez[(z*imax) + (y*jmax) + x]);
          fputs(buf, fPointer);
        }
      }
    }
    fclose(fPointer);

    // calculate run time

    printf("GPU Time: %.2f\n", elapsed_time);
    return 0;
}

	.text
	.file	"reviter.hip"
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function main
.LCPI0_0:
	.quad	0x4070a63789e928b5              # double 266.38855925634135
.LCPI0_1:
	.quad	0x4034000000000000              # double 20
.LCPI0_3:
	.quad	0x3f5ec087c079799d              # double 0.0018769574834532684
	.section	.rodata.cst16,"aM",@progbits,16
	.p2align	4, 0x0
.LCPI0_2:
	.quad	0x8000000000000000              # double -0
	.quad	0x8000000000000000              # double -0
	.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	$136, %rsp
	.cfi_def_cfa_offset 192
	.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	$808, %edi                      # imm = 0x328
	callq	malloc
	movq	%rax, %rbx
	movl	$808, %edi                      # imm = 0x328
	callq	malloc
	movq	%rax, %r14
	movl	$808, %edi                      # imm = 0x328
	callq	malloc
	movq	%rax, %r15
	movl	$808, %edi                      # imm = 0x328
	callq	malloc
	movq	%rax, %r12
	movl	$808, %edi                      # imm = 0x328
	callq	malloc
	movq	%rax, %r13
	movl	$808, %edi                      # imm = 0x328
	callq	malloc
	movq	%rax, %rbp
	xorl	%eax, %eax
	movq	%r14, 48(%rsp)                  # 8-byte Spill
.LBB0_1:                                # =>This Loop Header: Depth=1
                                        #     Child Loop BB0_2 Depth 2
	movq	%rax, 16(%rsp)                  # 8-byte Spill
	movl	$808, %edi                      # imm = 0x328
	callq	malloc
	movq	%rax, 8(%rsp)                   # 8-byte Spill
	movq	16(%rsp), %rcx                  # 8-byte Reload
	movq	%rax, (%rbx,%rcx,8)
	movl	$808, %edi                      # imm = 0x328
	callq	malloc
	movq	%rax, 24(%rsp)                  # 8-byte Spill
	movq	16(%rsp), %rcx                  # 8-byte Reload
	movq	%rax, (%r14,%rcx,8)
	movl	$808, %edi                      # imm = 0x328
	callq	malloc
	movq	%rax, 96(%rsp)                  # 8-byte Spill
	movq	16(%rsp), %r14                  # 8-byte Reload
	movq	%rax, (%r15,%r14,8)
	movl	$808, %edi                      # imm = 0x328
	callq	malloc
	movq	%rax, 88(%rsp)                  # 8-byte Spill
	movq	%rax, (%r12,%r14,8)
	movl	$808, %edi                      # imm = 0x328
	callq	malloc
	movq	%rax, 80(%rsp)                  # 8-byte Spill
	movq	%rax, (%r13,%r14,8)
	movl	$808, %edi                      # imm = 0x328
	callq	malloc
	movq	%rax, 72(%rsp)                  # 8-byte Spill
	movq	%rax, (%rbp,%r14,8)
	xorl	%r14d, %r14d
.LBB0_2:                                #   Parent Loop BB0_1 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movl	$808, %edi                      # imm = 0x328
	callq	malloc
	movq	8(%rsp), %rcx                   # 8-byte Reload
	movq	%rax, (%rcx,%r14)
	movl	$808, %edi                      # imm = 0x328
	callq	malloc
	movq	24(%rsp), %rcx                  # 8-byte Reload
	movq	%rax, (%rcx,%r14)
	movl	$808, %edi                      # imm = 0x328
	callq	malloc
	movq	96(%rsp), %rcx                  # 8-byte Reload
	movq	%rax, (%rcx,%r14)
	movl	$808, %edi                      # imm = 0x328
	callq	malloc
	movq	88(%rsp), %rcx                  # 8-byte Reload
	movq	%rax, (%rcx,%r14)
	movl	$808, %edi                      # imm = 0x328
	callq	malloc
	movq	80(%rsp), %rcx                  # 8-byte Reload
	movq	%rax, (%rcx,%r14)
	movl	$808, %edi                      # imm = 0x328
	callq	malloc
	movq	72(%rsp), %rcx                  # 8-byte Reload
	movq	%rax, (%rcx,%r14)
	addq	$8, %r14
	cmpq	$808, %r14                      # imm = 0x328
	jne	.LBB0_2
# %bb.3:                                #   in Loop: Header=BB0_1 Depth=1
	movq	16(%rsp), %rax                  # 8-byte Reload
	incq	%rax
	cmpq	$101, %rax
	movq	48(%rsp), %r14                  # 8-byte Reload
	jne	.LBB0_1
# %bb.4:                                # %.preheader389.preheader
	xorl	%eax, %eax
	xorl	%ecx, %ecx
.LBB0_5:                                # %.preheader389
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB0_6 Depth 2
                                        #       Child Loop BB0_7 Depth 3
	xorl	%edx, %edx
.LBB0_6:                                # %.preheader388
                                        #   Parent Loop BB0_5 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB0_7 Depth 3
	xorl	%esi, %esi
.LBB0_7:                                #   Parent Loop BB0_5 Depth=1
                                        #     Parent Loop BB0_6 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	movq	(%rbx,%rsi), %rdi
	movq	(%rdi,%rdx,8), %rdi
	movq	%rax, (%rdi,%rcx,8)
	movq	(%r14,%rsi), %rdi
	movq	(%rdi,%rdx,8), %rdi
	movq	%rax, (%rdi,%rcx,8)
	movq	(%r15,%rsi), %rdi
	movq	(%rdi,%rdx,8), %rdi
	movq	%rax, (%rdi,%rcx,8)
	movq	(%r12,%rsi), %rdi
	movq	(%rdi,%rdx,8), %rdi
	movq	%rax, (%rdi,%rcx,8)
	movq	(%r13,%rsi), %rdi
	movq	(%rdi,%rdx,8), %rdi
	movq	%rax, (%rdi,%rcx,8)
	movq	(%rbp,%rsi), %rdi
	movq	(%rdi,%rdx,8), %rdi
	movq	%rax, (%rdi,%rcx,8)
	addq	$8, %rsi
	cmpq	$808, %rsi                      # imm = 0x328
	jne	.LBB0_7
# %bb.8:                                #   in Loop: Header=BB0_6 Depth=2
	incq	%rdx
	cmpq	$101, %rdx
	jne	.LBB0_6
# %bb.9:                                #   in Loop: Header=BB0_5 Depth=1
	incq	%rcx
	cmpq	$101, %rcx
	jne	.LBB0_5
# %bb.10:
	leaq	104(%rsp), %r14
	movq	%r14, %rdi
	callq	hipEventCreate
	leaq	32(%rsp), %rdi
	callq	hipEventCreate
	movq	(%r14), %rdi
	xorl	%eax, %eax
	movq	%rax, 8(%rsp)                   # 8-byte Spill
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	400(%r15), %rax
	movq	%rax, 24(%rsp)                  # 8-byte Spill
	movsd	.LCPI0_0(%rip), %xmm2           # xmm2 = mem[0],zero
	movq	%r15, 64(%rsp)                  # 8-byte Spill
	movq	%rbx, 56(%rsp)                  # 8-byte Spill
.LBB0_11:                               # %.preheader387
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB0_12 Depth 2
                                        #       Child Loop BB0_13 Depth 3
                                        #         Child Loop BB0_14 Depth 4
                                        #     Child Loop BB0_18 Depth 2
                                        #       Child Loop BB0_19 Depth 3
                                        #         Child Loop BB0_20 Depth 4
                                        #     Child Loop BB0_24 Depth 2
                                        #       Child Loop BB0_25 Depth 3
                                        #         Child Loop BB0_26 Depth 4
                                        #     Child Loop BB0_30 Depth 2
                                        #       Child Loop BB0_31 Depth 3
                                        #         Child Loop BB0_32 Depth 4
                                        #     Child Loop BB0_36 Depth 2
                                        #       Child Loop BB0_37 Depth 3
                                        #         Child Loop BB0_38 Depth 4
                                        #     Child Loop BB0_42 Depth 2
                                        #       Child Loop BB0_43 Depth 3
                                        #         Child Loop BB0_44 Depth 4
	xorl	%eax, %eax
.LBB0_12:                               # %.preheader382
                                        #   Parent Loop BB0_11 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB0_13 Depth 3
                                        #         Child Loop BB0_14 Depth 4
	movq	(%rbx,%rax,8), %rcx
	movq	(%rbp,%rax,8), %rdx
	movq	(%r13,%rax,8), %rsi
	movl	$1, %edi
.LBB0_13:                               # %.preheader376
                                        #   Parent Loop BB0_11 Depth=1
                                        #     Parent Loop BB0_12 Depth=2
                                        # =>    This Loop Header: Depth=3
                                        #         Child Loop BB0_14 Depth 4
	movq	(%rcx,%rdi,8), %r8
	movq	(%rdx,%rdi,8), %r9
	movq	-8(%rsi,%rdi,8), %r10
	movq	(%rsi,%rdi,8), %r11
	movl	$1, %r14d
.LBB0_14:                               #   Parent Loop BB0_11 Depth=1
                                        #     Parent Loop BB0_12 Depth=2
                                        #       Parent Loop BB0_13 Depth=3
                                        # =>      This Inner Loop Header: Depth=4
	movsd	(%r9,%r14,8), %xmm0             # xmm0 = mem[0],zero
	subsd	(%r10,%r14,8), %xmm0
	movsd	-8(%r11,%r14,8), %xmm1          # xmm1 = mem[0],zero
	subsd	(%r11,%r14,8), %xmm1
	addsd	%xmm0, %xmm1
	mulsd	%xmm2, %xmm1
	addsd	(%r8,%r14,8), %xmm1
	movsd	%xmm1, (%r8,%r14,8)
	incq	%r14
	cmpq	$100, %r14
	jne	.LBB0_14
# %bb.15:                               #   in Loop: Header=BB0_13 Depth=3
	incq	%rdi
	cmpq	$100, %rdi
	jne	.LBB0_13
# %bb.16:                               #   in Loop: Header=BB0_12 Depth=2
	incq	%rax
	cmpq	$100, %rax
	jne	.LBB0_12
# %bb.17:                               # %.preheader381.preheader
                                        #   in Loop: Header=BB0_11 Depth=1
	movl	$1, %eax
	movq	48(%rsp), %r14                  # 8-byte Reload
.LBB0_18:                               # %.preheader381
                                        #   Parent Loop BB0_11 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB0_19 Depth 3
                                        #         Child Loop BB0_20 Depth 4
	movq	(%r14,%rax,8), %rcx
	movq	-8(%rbp,%rax,8), %rdx
	movq	(%r13,%rax,8), %rsi
	xorl	%edi, %edi
.LBB0_19:                               # %.preheader375
                                        #   Parent Loop BB0_11 Depth=1
                                        #     Parent Loop BB0_18 Depth=2
                                        # =>    This Loop Header: Depth=3
                                        #         Child Loop BB0_20 Depth 4
	movq	(%rcx,%rdi,8), %r8
	movq	(%rdx,%rdi,8), %r9
	movq	(%rsi,%rdi,8), %r10
	movl	$1, %r11d
.LBB0_20:                               #   Parent Loop BB0_11 Depth=1
                                        #     Parent Loop BB0_18 Depth=2
                                        #       Parent Loop BB0_19 Depth=3
                                        # =>      This Inner Loop Header: Depth=4
	movsd	(%r9,%r11,8), %xmm0             # xmm0 = mem[0],zero
	movsd	(%r10,%r11,8), %xmm1            # xmm1 = mem[0],zero
	subsd	%xmm1, %xmm0
	subsd	-8(%r10,%r11,8), %xmm1
	addsd	%xmm0, %xmm1
	mulsd	%xmm2, %xmm1
	addsd	(%r8,%r11,8), %xmm1
	movsd	%xmm1, (%r8,%r11,8)
	incq	%r11
	cmpq	$100, %r11
	jne	.LBB0_20
# %bb.21:                               #   in Loop: Header=BB0_19 Depth=3
	incq	%rdi
	cmpq	$100, %rdi
	jne	.LBB0_19
# %bb.22:                               #   in Loop: Header=BB0_18 Depth=2
	incq	%rax
	cmpq	$100, %rax
	jne	.LBB0_18
# %bb.23:                               # %.preheader380.preheader
                                        #   in Loop: Header=BB0_11 Depth=1
	movl	$1, %eax
.LBB0_24:                               # %.preheader380
                                        #   Parent Loop BB0_11 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB0_25 Depth 3
                                        #         Child Loop BB0_26 Depth 4
	movq	(%r15,%rax,8), %rcx
	movq	(%rbp,%rax,8), %rdx
	movq	-8(%r13,%rax,8), %rsi
	movq	(%r13,%rax,8), %rdi
	movl	$1, %r8d
.LBB0_25:                               # %.preheader374
                                        #   Parent Loop BB0_11 Depth=1
                                        #     Parent Loop BB0_24 Depth=2
                                        # =>    This Loop Header: Depth=3
                                        #         Child Loop BB0_26 Depth 4
	movq	(%rcx,%r8,8), %r9
	movq	(%rdx,%r8,8), %r10
	movq	(%rsi,%r8,8), %r11
	movq	-8(%rdi,%r8,8), %r14
	movq	(%rdi,%r8,8), %r15
	xorl	%ebx, %ebx
.LBB0_26:                               #   Parent Loop BB0_11 Depth=1
                                        #     Parent Loop BB0_24 Depth=2
                                        #       Parent Loop BB0_25 Depth=3
                                        # =>      This Inner Loop Header: Depth=4
	movsd	(%r10,%rbx,8), %xmm0            # xmm0 = mem[0],zero
	subsd	(%r11,%rbx,8), %xmm0
	movsd	(%r14,%rbx,8), %xmm1            # xmm1 = mem[0],zero
	subsd	(%r15,%rbx,8), %xmm1
	addsd	%xmm0, %xmm1
	mulsd	%xmm2, %xmm1
	addsd	(%r9,%rbx,8), %xmm1
	movsd	%xmm1, (%r9,%rbx,8)
	incq	%rbx
	cmpq	$100, %rbx
	jne	.LBB0_26
# %bb.27:                               #   in Loop: Header=BB0_25 Depth=3
	incq	%r8
	cmpq	$100, %r8
	jne	.LBB0_25
# %bb.28:                               #   in Loop: Header=BB0_24 Depth=2
	incq	%rax
	cmpq	$100, %rax
	movq	64(%rsp), %r15                  # 8-byte Reload
	jne	.LBB0_24
# %bb.29:                               #   in Loop: Header=BB0_11 Depth=1
	movq	8(%rsp), %rax                   # 8-byte Reload
	addl	$-60, %eax
	xorps	%xmm1, %xmm1
	cvtsi2sd	%eax, %xmm1
	divsd	.LCPI0_1(%rip), %xmm1
	movapd	%xmm1, %xmm0
	xorpd	.LCPI0_2(%rip), %xmm0
	mulsd	%xmm1, %xmm0
	callq	exp
	movq	24(%rsp), %rax                  # 8-byte Reload
	movq	400(%rax), %rax
	movsd	%xmm0, 400(%rax)
	movl	$1, %eax
	movsd	.LCPI0_3(%rip), %xmm3           # xmm3 = mem[0],zero
.LBB0_30:                               # %.preheader379
                                        #   Parent Loop BB0_11 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB0_31 Depth 3
                                        #         Child Loop BB0_32 Depth 4
	movq	(%r12,%rax,8), %rcx
	movq	(%r15,%rax,8), %rdx
	xorl	%esi, %esi
.LBB0_31:                               # %.preheader373
                                        #   Parent Loop BB0_11 Depth=1
                                        #     Parent Loop BB0_30 Depth=2
                                        # =>    This Loop Header: Depth=3
                                        #         Child Loop BB0_32 Depth 4
	movq	(%rcx,%rsi,8), %rdi
	movq	(%rdx,%rsi,8), %r8
	movq	8(%rdx,%rsi,8), %r9
	xorl	%r10d, %r10d
.LBB0_32:                               #   Parent Loop BB0_11 Depth=1
                                        #     Parent Loop BB0_30 Depth=2
                                        #       Parent Loop BB0_31 Depth=3
                                        # =>      This Inner Loop Header: Depth=4
	movsd	(%r8,%r10,8), %xmm0             # xmm0 = mem[0],zero
	movsd	8(%r8,%r10,8), %xmm1            # xmm1 = mem[0],zero
	subsd	%xmm0, %xmm1
	subsd	(%r9,%r10,8), %xmm0
	addsd	%xmm0, %xmm1
	mulsd	%xmm3, %xmm1
	addsd	(%rdi,%r10,8), %xmm1
	movsd	%xmm1, (%rdi,%r10,8)
	leaq	1(%r10), %r11
	movq	%r11, %r10
	cmpq	$99, %r11
	jne	.LBB0_32
# %bb.33:                               #   in Loop: Header=BB0_31 Depth=3
	incq	%rsi
	cmpq	$99, %rsi
	jne	.LBB0_31
# %bb.34:                               #   in Loop: Header=BB0_30 Depth=2
	incq	%rax
	cmpq	$100, %rax
	jne	.LBB0_30
# %bb.35:                               # %.preheader378.preheader
                                        #   in Loop: Header=BB0_11 Depth=1
	xorl	%eax, %eax
	movsd	.LCPI0_0(%rip), %xmm2           # xmm2 = mem[0],zero
.LBB0_36:                               # %.preheader378
                                        #   Parent Loop BB0_11 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB0_37 Depth 3
                                        #         Child Loop BB0_38 Depth 4
	movq	(%r13,%rax,8), %rcx
	movq	(%r15,%rax,8), %rdx
	movq	8(%r15,%rax,8), %rsi
	movl	$1, %edi
.LBB0_37:                               # %.preheader372
                                        #   Parent Loop BB0_11 Depth=1
                                        #     Parent Loop BB0_36 Depth=2
                                        # =>    This Loop Header: Depth=3
                                        #         Child Loop BB0_38 Depth 4
	movq	(%rcx,%rdi,8), %r8
	movq	(%rsi,%rdi,8), %r9
	movq	(%rdx,%rdi,8), %r10
	xorl	%r11d, %r11d
.LBB0_38:                               #   Parent Loop BB0_11 Depth=1
                                        #     Parent Loop BB0_36 Depth=2
                                        #       Parent Loop BB0_37 Depth=3
                                        # =>      This Inner Loop Header: Depth=4
	movsd	(%r9,%r11,8), %xmm0             # xmm0 = mem[0],zero
	movsd	(%r10,%r11,8), %xmm1            # xmm1 = mem[0],zero
	subsd	%xmm1, %xmm0
	subsd	8(%r10,%r11,8), %xmm1
	addsd	%xmm0, %xmm1
	mulsd	%xmm3, %xmm1
	addsd	(%r8,%r11,8), %xmm1
	movsd	%xmm1, (%r8,%r11,8)
	leaq	1(%r11), %rbx
	movq	%rbx, %r11
	cmpq	$99, %rbx
	jne	.LBB0_38
# %bb.39:                               #   in Loop: Header=BB0_37 Depth=3
	incq	%rdi
	cmpq	$99, %rdi
	jne	.LBB0_37
# %bb.40:                               #   in Loop: Header=BB0_36 Depth=2
	incq	%rax
	cmpq	$100, %rax
	jne	.LBB0_36
# %bb.41:                               # %.preheader377.preheader
                                        #   in Loop: Header=BB0_11 Depth=1
	xorl	%eax, %eax
	movq	56(%rsp), %rbx                  # 8-byte Reload
.LBB0_42:                               # %.preheader377
                                        #   Parent Loop BB0_11 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB0_43 Depth 3
                                        #         Child Loop BB0_44 Depth 4
	movq	(%rbp,%rax,8), %rcx
	movq	(%r15,%rax,8), %rdx
	movq	8(%r15,%rax,8), %rsi
	xorl	%edi, %edi
.LBB0_43:                               # %.preheader371
                                        #   Parent Loop BB0_11 Depth=1
                                        #     Parent Loop BB0_42 Depth=2
                                        # =>    This Loop Header: Depth=3
                                        #         Child Loop BB0_44 Depth 4
	movq	(%rcx,%rdi,8), %r8
	movq	(%rdx,%rdi,8), %r9
	movq	8(%rdx,%rdi,8), %r10
	movq	(%rsi,%rdi,8), %r11
	movl	$1, %r14d
.LBB0_44:                               #   Parent Loop BB0_11 Depth=1
                                        #     Parent Loop BB0_42 Depth=2
                                        #       Parent Loop BB0_43 Depth=3
                                        # =>      This Inner Loop Header: Depth=4
	movsd	(%r9,%r14,8), %xmm0             # xmm0 = mem[0],zero
	movsd	(%r10,%r14,8), %xmm1            # xmm1 = mem[0],zero
	subsd	%xmm0, %xmm1
	subsd	(%r11,%r14,8), %xmm0
	addsd	%xmm0, %xmm1
	mulsd	%xmm3, %xmm1
	addsd	(%r8,%r14,8), %xmm1
	movsd	%xmm1, (%r8,%r14,8)
	incq	%r14
	cmpq	$99, %r14
	jne	.LBB0_44
# %bb.45:                               #   in Loop: Header=BB0_43 Depth=3
	incq	%rdi
	cmpq	$99, %rdi
	jne	.LBB0_43
# %bb.46:                               #   in Loop: Header=BB0_42 Depth=2
	incq	%rax
	cmpq	$100, %rax
	jne	.LBB0_42
# %bb.47:                               #   in Loop: Header=BB0_11 Depth=1
	movq	8(%rsp), %rax                   # 8-byte Reload
	incl	%eax
	movq	%rax, 8(%rsp)                   # 8-byte Spill
	cmpl	$1000, %eax                     # imm = 0x3E8
	jne	.LBB0_11
# %bb.48:
	movq	32(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	32(%rsp), %rdi
	callq	hipEventSynchronize
	movq	104(%rsp), %rsi
	movq	32(%rsp), %rdx
	leaq	44(%rsp), %rdi
	callq	hipEventElapsedTime
	movl	$.L.str, %edi
	movl	$.L.str.1, %esi
	callq	fopen
	movq	%rax, %r14
	xorpd	%xmm0, %xmm0
	movq	%r15, %rbp
	leaq	112(%rsp), %r15
	xorl	%eax, %eax
.LBB0_49:                               # %.preheader370
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB0_50 Depth 2
                                        #       Child Loop BB0_51 Depth 3
	movq	%rax, 8(%rsp)                   # 8-byte Spill
	movl	$1, %r13d
	movq	%rbp, %rbx
.LBB0_50:                               # %.preheader
                                        #   Parent Loop BB0_49 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB0_51 Depth 3
	movl	$1600, %r12d                    # imm = 0x640
.LBB0_51:                               #   Parent Loop BB0_49 Depth=1
                                        #     Parent Loop BB0_50 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	movapd	%xmm0, 112(%rsp)
	movw	$0, 128(%rsp)
	movq	(%rbp,%r12), %rdx
	movl	$.L.str.2, %esi
	movq	%r15, %rdi
	xorl	%eax, %eax
	callq	sprintf
	movq	%r15, %rdi
	movq	%r14, %rsi
	callq	fputs
	xorpd	%xmm0, %xmm0
	addq	$800, %r12                      # imm = 0x320
	cmpq	$80800, %r12                    # imm = 0x13BA0
	jne	.LBB0_51
# %bb.52:                               #   in Loop: Header=BB0_50 Depth=2
	incq	%r13
	addq	$800, %rbp                      # imm = 0x320
	cmpq	$100, %r13
	jne	.LBB0_50
# %bb.53:                               #   in Loop: Header=BB0_49 Depth=1
	movq	8(%rsp), %rax                   # 8-byte Reload
	incq	%rax
	movq	%rbx, %rbp
	addq	$8, %rbp
	cmpq	$100, %rax
	jne	.LBB0_49
# %bb.54:
	movq	%r14, %rdi
	callq	fclose
	xorps	%xmm0, %xmm0
	cvtss2sd	44(%rsp), %xmm0
	movl	$.L.str.3, %edi
	movb	$1, %al
	callq	printf
	xorl	%eax, %eax
	addq	$136, %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
	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"parlleloutput.dat"
	.size	.L.str, 18

	.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\n"
	.size	.L.str.2, 4

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"GPU Time: %.2f\n"
	.size	.L.str.3, 16

	.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
