#include <fstream>
#include <time.h>
using namespace std;

class params{
private:
  double r_min_ini, r_min_trg;
  double r_max_ini, r_max_trg;
  double i_min_ini, i_min_trg;
  double i_max_ini, i_max_trg;

public:
  int width, height;
  double r_min, r_max, i_min, i_max;
  int max;

  params(){
    r_min_ini = -2.86, r_min_trg = -0.1777;
    r_max_ini = 1.86, r_max_trg = -0.1194;
    i_min_ini = -1.33, i_min_trg = 1.0138;
    i_max_ini = 1.33, i_max_trg = 1.0472;

    width = 1920, height = 1080;
    r_min = r_min_ini, r_max = r_max_ini, i_min = i_min_ini, i_max = i_max_ini;
    max = 50;
  }

  void set_frame_number(int, int);
};

void params::set_frame_number(int n, int max){
  if (n < max){
    double t = 1 - pow(0.001, (double)n/(double)max);
    r_min = r_min_ini +  t*(r_min_trg - r_min_ini);
    r_max = r_max_ini +  t*(r_max_trg - r_max_ini);
    i_min = i_min_ini +  t*(i_min_trg - i_min_ini);
    i_max = i_max_ini +  t*(i_max_trg - i_max_ini);
  }
  else{
    r_min = r_min_trg, r_max = r_max_trg, i_min = i_min_trg, i_max = i_max_trg;
  }
}

void bmp_write(char * img_data, int width, int height, char * filename){
  int size = height*width*3 + 54;
  ofstream bmp(filename, ios::binary);

  char bmp_header[54] = {'B', 'M',
  (char)size, (char)(size >> 8), (char)(size >> 16), (char)(size >> 24),
  0, 0, 0, 0, 54, 0, 0, 0, 40, 0, 0, 0, (char)width, (char)(width >> 8),
  0, 0, (char)height,(char)(height >> 8), 0, 0, 1, 0, 24, 0, 0, 0, 0, 0,
  (char)(size - 54), (char)((size - 54) >> 8),(char)((size - 54) >> 16),
  (char)((size - 54) >> 24),0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  0};

  bmp.write(bmp_header, sizeof bmp_header);
  bmp.write(img_data, size - 54);
  bmp.close();
}

__host__ __device__ double iter(double r_c, double i_c, int max){
  double r_t = 0.0, i_t = 0.0;
  double r_t_2, i_t_2, mag;
  for (int i = 0; i < max; i++){
    r_t_2 = r_t * r_t - i_t * i_t;
    i_t_2 = 2 * r_t * i_t;
    r_t = r_t_2 + r_c;
    i_t = i_t_2 + i_c;
    mag = r_t*r_t + i_t*i_t;
    if (mag > 4){
      return (double)(i + 1 - log(log(mag))/log(2.0))/(double)max;
    }
  }
  return 0;
}

__global__ void populate(char * d_img_data, double r_min, double r_max,
  double i_min, double i_max, int width, int height, int max){
    int x = blockIdx.x*blockDim.x + threadIdx.x;
    int y = blockIdx.y*blockDim.y + threadIdx.y;
    if (x < width && y < height){
      double r = ((double)x/(double)width)*(r_max-r_min)+r_min;
      double i = ((double)y/(double)height)*(i_max-i_min)+i_min;
      double t = iter(r, i, max);
      d_img_data[y*3*width + x*3 + 0] = (char)(255*sqrt(t));
      d_img_data[y*3*width + x*3 + 1] = (char)(255*t);
      d_img_data[y*3*width + x*3 + 2] = (char)(255*t*t);
    }
  }

void plot_frame_gpu(params plot, char * filename){
  /*getting image data*/
  char * h_img_data = new char[plot.width*plot.height*3*sizeof(char)];
  char * d_img_data;
  cudaMalloc((void **) &d_img_data, plot.width*plot.height*3*sizeof(char));
  dim3 threads(32, 32, 1);
  dim3 grid(ceil((double)plot.width/32.0),
    ceil((double)plot.height/32.0), 1);
  populate<<<grid, threads>>>(d_img_data, plot.r_min, plot.r_max, plot.i_min,
    plot.i_max, plot.width, plot.height, plot.max);
  cudaMemcpy(h_img_data, d_img_data, plot.width*plot.height*3*sizeof(char),
    cudaMemcpyDeviceToHost);
  cudaFree(d_img_data);

  /*write to file*/
  bmp_write(h_img_data, plot.width, plot.height, filename);
  delete[] h_img_data;
}

void plot_frame_cpu(params plot, char * filename){
  char * img_data = new char[plot.width*plot.height*3*sizeof(char)];
  for (int y = 0; y < plot.height; y++){
    for (int x = 0; x < plot.width; x++){
      double r = ((double)x/(double)plot.width)*(plot.r_max-plot.r_min)+plot.r_min;
      double i = ((double)y/(double)plot.height)*(plot.i_max-plot.i_min)+plot.i_min;
      double t = iter(r, i, plot.max);
      img_data[y*3*plot.width + x*3 + 0] = (char)(255*sqrt(t));
      img_data[y*3*plot.width + x*3 + 1] = (char)(255*t);
      img_data[y*3*plot.width + x*3 + 2] = (char)(255*t*t);
    }
  }
  bmp_write(img_data, plot.width, plot.height, filename);
  delete[] img_data;
}

int main(int argc, char ** argv){
  int num_frames = 1000;
  clock_t t1, t2;
  char * filename = (char *)malloc(200*sizeof(char));
  params plot;

  /*TEST GPU*/
  ofstream log_gpu("/home/keshav/Dropbox (MIT)/anim_gpu/log_gpu.txt");
  for (int i = 0; i < num_frames; i++){
    sprintf(filename, "/home/keshav/Dropbox (MIT)/anim_gpu/i%03d.bmp", i);
    plot.set_frame_number(i, num_frames);
    t1 = clock();
    plot_frame_gpu(plot, filename);
    t2 = clock();
    log_gpu << 1000*(double)(t2-t1)/(CLOCKS_PER_SEC) << "\n";
    if (!(i%(num_frames/100)) && (argc-1)) printf("Done %2.2f%% on GPU.\n",
      100*(double)i/(double)num_frames);
  }
  log_gpu.close();

  /*TEST CPU*/
  ofstream log_cpu("/home/keshav/Dropbox (MIT)/anim_cpu/log_cpu.txt");
  for (int i = 0; i < num_frames; i++){
    sprintf(filename, "/home/keshav/Dropbox (MIT)/anim_cpu/i%03d.bmp", i);
    plot.set_frame_number(i, num_frames);
    t1 = clock();
    plot_frame_cpu(plot, filename);
    t2 = clock();
    log_cpu << 1000*(double)(t2-t1)/(CLOCKS_PER_SEC) << "\n";
    if (!(i%(num_frames/100)) && (argc-1)) printf("Done %2.2f%% on CPU.\n",
      100*(double)i/(double)num_frames);
  }
  log_cpu.close();

  delete[] filename;
  return 0;
}

	.file	"tmpxft_002c0888_00000000-6_main.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB3777:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE3777:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.align 2
	.globl	_ZN6params16set_frame_numberEii
	.type	_ZN6params16set_frame_numberEii, @function
_ZN6params16set_frame_numberEii:
.LFB3769:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	movq	%rdi, %rbx
	cmpl	%edx, %esi
	jge	.L3
	cvtsi2sdl	%edx, %xmm0
	cvtsi2sdl	%esi, %xmm1
	divsd	%xmm0, %xmm1
	movsd	.LC0(%rip), %xmm0
	call	pow@PLT
	movsd	.LC1(%rip), %xmm1
	movsd	(%rbx), %xmm2
	subsd	%xmm0, %xmm1
	movsd	8(%rbx), %xmm0
	subsd	%xmm2, %xmm0
	mulsd	%xmm1, %xmm0
	addsd	%xmm2, %xmm0
	movsd	16(%rbx), %xmm2
	movsd	%xmm0, 72(%rbx)
	movsd	24(%rbx), %xmm0
	subsd	%xmm2, %xmm0
	mulsd	%xmm1, %xmm0
	addsd	%xmm2, %xmm0
	movsd	32(%rbx), %xmm2
	movsd	%xmm0, 80(%rbx)
	movsd	40(%rbx), %xmm0
	subsd	%xmm2, %xmm0
	mulsd	%xmm1, %xmm0
	addsd	%xmm2, %xmm0
	movsd	48(%rbx), %xmm2
	movsd	%xmm0, 88(%rbx)
	movsd	56(%rbx), %xmm0
	subsd	%xmm2, %xmm0
	mulsd	%xmm1, %xmm0
	addsd	%xmm2, %xmm0
	jmp	.L4
.L3:
	movsd	8(%rdi), %xmm0
	movsd	%xmm0, 72(%rdi)
	movsd	24(%rdi), %xmm0
	movsd	%xmm0, 80(%rdi)
	movsd	40(%rdi), %xmm0
	movsd	%xmm0, 88(%rdi)
	movsd	56(%rdi), %xmm0
.L4:
	movsd	%xmm0, 96(%rbx)
	popq	%rbx
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3769:
	.size	_ZN6params16set_frame_numberEii, .-_ZN6params16set_frame_numberEii
	.globl	_Z4iterddi
	.type	_Z4iterddi, @function
_Z4iterddi:
.LFB3771:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	xorps	%xmm3, %xmm3
	movaps	%xmm0, %xmm4
	xorl	%ebp, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	movaps	%xmm3, %xmm2
	movl	%edi, %ebx
	pushq	%rdx
	.cfi_def_cfa_offset 32
	movsd	.LC3(%rip), %xmm5
.L8:
	cmpl	%ebx, %ebp
	jge	.L14
	movaps	%xmm2, %xmm0
	movaps	%xmm3, %xmm6
	incl	%ebp
	mulsd	%xmm3, %xmm6
	mulsd	%xmm2, %xmm0
	addsd	%xmm2, %xmm2
	mulsd	%xmm2, %xmm3
	subsd	%xmm6, %xmm0
	movaps	%xmm0, %xmm2
	addsd	%xmm1, %xmm3
	addsd	%xmm4, %xmm2
	movaps	%xmm3, %xmm6
	mulsd	%xmm3, %xmm6
	movaps	%xmm2, %xmm0
	mulsd	%xmm2, %xmm0
	addsd	%xmm6, %xmm0
	comisd	%xmm5, %xmm0
	jbe	.L8
	call	log@PLT
	call	log@PLT
	movaps	%xmm0, %xmm1
	cvtsi2sdl	%ebp, %xmm0
	divsd	.LC4(%rip), %xmm1
	subsd	%xmm1, %xmm0
	cvtsi2sdl	%ebx, %xmm1
	divsd	%xmm1, %xmm0
	jmp	.L7
.L14:
	xorps	%xmm0, %xmm0
.L7:
	popq	%rax
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3771:
	.size	_Z4iterddi, .-_Z4iterddi
	.globl	_Z34__device_stub__Z8populatePcddddiiiPcddddiii
	.type	_Z34__device_stub__Z8populatePcddddiiiPcddddiii, @function
_Z34__device_stub__Z8populatePcddddiiiPcddddiii:
.LFB3799:
	.cfi_startproc
	endbr64
	subq	$216, %rsp
	.cfi_def_cfa_offset 224
	movq	%rdi, 56(%rsp)
	leaq	88(%rsp), %rdi
	movl	%esi, 20(%rsp)
	leaq	100(%rsp), %rsi
	movl	%edx, 16(%rsp)
	leaq	72(%rsp), %rdx
	movl	%ecx, 12(%rsp)
	leaq	80(%rsp), %rcx
	movsd	%xmm0, 48(%rsp)
	movsd	%xmm1, 40(%rsp)
	movsd	%xmm2, 32(%rsp)
	movsd	%xmm3, 24(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 200(%rsp)
	xorl	%eax, %eax
	leaq	56(%rsp), %rax
	movl	$1, 96(%rsp)
	movq	%rax, 136(%rsp)
	leaq	48(%rsp), %rax
	movq	%rax, 144(%rsp)
	leaq	40(%rsp), %rax
	movq	%rax, 152(%rsp)
	leaq	32(%rsp), %rax
	movq	%rax, 160(%rsp)
	leaq	24(%rsp), %rax
	movq	%rax, 168(%rsp)
	leaq	20(%rsp), %rax
	movq	%rax, 176(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 184(%rsp)
	leaq	12(%rsp), %rax
	movq	%rax, 192(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 88(%rsp)
	movq	%rax, 100(%rsp)
	movl	$1, 108(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L15
	pushq	80(%rsp)
	.cfi_def_cfa_offset 232
	leaq	_Z8populatePcddddiii(%rip), %rdi
	pushq	80(%rsp)
	.cfi_def_cfa_offset 240
	movq	116(%rsp), %rcx
	movl	124(%rsp), %r8d
	movq	104(%rsp), %rsi
	movl	112(%rsp), %edx
	leaq	152(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 232
	popq	%rdx
	.cfi_def_cfa_offset 224
.L15:
	movq	200(%rsp), %rax
	subq	%fs:40, %rax
	je	.L17
	call	__stack_chk_fail@PLT
.L17:
	addq	$216, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3799:
	.size	_Z34__device_stub__Z8populatePcddddiiiPcddddiii, .-_Z34__device_stub__Z8populatePcddddiiiPcddddiii
	.globl	_Z8populatePcddddiii
	.type	_Z8populatePcddddiii, @function
_Z8populatePcddddiii:
.LFB3800:
	.cfi_startproc
	endbr64
	jmp	_Z34__device_stub__Z8populatePcddddiiiPcddddiii
	.cfi_endproc
.LFE3800:
	.size	_Z8populatePcddddiii, .-_Z8populatePcddddiii
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC5:
	.string	"_Z8populatePcddddiii"
	.section	.text.startup,"ax",@progbits
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB3802:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 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	.LC5(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z8populatePcddddiii(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 48
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	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	%rdx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE3802:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.text
	.globl	_Z9bmp_writePciiS_
	.type	_Z9bmp_writePciiS_, @function
_Z9bmp_writePciiS_:
.LFB3770:
	.cfi_startproc
	.cfi_personality 0x9b,DW.ref.__gxx_personality_v0
	.cfi_lsda 0x1b,.LLSDA3770
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movq	%rdi, %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movl	%esi, %r13d
	movq	%rcx, %rsi
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movl	%edx, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movl	%edx, %ebx
	movl	$4, %edx
	imull	%r13d, %ebx
	subq	$584, %rsp
	.cfi_def_cfa_offset 640
	movq	%fs:40, %rax
	movq	%rax, 568(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rbp
	leal	(%rbx,%rbx,2), %ebx
	movq	%rbp, %rdi
	leal	54(%rbx), %r15d
.LEHB0:
	call	_ZNSt14basic_ofstreamIcSt11char_traitsIcEEC1EPKcSt13_Ios_Openmode@PLT
.LEHE0:
	xorl	%eax, %eax
	leaq	520(%rsp), %rdi
	movl	$12, %ecx
	rep stosl
	movl	%r15d, 516(%rsp)
	movl	$54, %edx
	movq	%rbp, %rdi
	movabsq	$171798691894, %rax
	subl	$54, %r15d
	leaq	514(%rsp), %rsi
	movw	$19778, 514(%rsp)
	movq	%rax, 524(%rsp)
	movl	%r13d, %eax
	movb	%ah, 533(%rsp)
	movl	%r12d, %eax
	movb	%ah, 537(%rsp)
	movl	%ebx, %eax
	sarl	$16, %eax
	movb	%r13b, 532(%rsp)
	movb	%al, 550(%rsp)
	movl	%ebx, %eax
	sarl	$24, %eax
	movb	%r12b, 536(%rsp)
	movl	$1572865, 540(%rsp)
	movb	%r15b, 548(%rsp)
	movb	%bh, 549(%rsp)
	movb	%al, 551(%rsp)
.LEHB1:
	call	_ZNSo5writeEPKcl@PLT
	movslq	%ebx, %rdx
	movq	%r14, %rsi
	movq	%rbp, %rdi
	call	_ZNSo5writeEPKcl@PLT
	movq	%rbp, %rdi
	call	_ZNSt14basic_ofstreamIcSt11char_traitsIcEE5closeEv@PLT
.LEHE1:
	movq	%rbp, %rdi
	call	_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev@PLT
	movq	568(%rsp), %rax
	subq	%fs:40, %rax
	je	.L25
	jmp	.L27
.L26:
	endbr64
	movq	%rax, %rbx
.L23:
	movq	%rbp, %rdi
	call	_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev@PLT
	movq	568(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L27
	movq	%rbx, %rdi
.LEHB2:
	call	_Unwind_Resume@PLT
.LEHE2:
.L27:
	call	__stack_chk_fail@PLT
.L25:
	addq	$584, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3770:
	.globl	__gxx_personality_v0
	.section	.gcc_except_table,"a",@progbits
.LLSDA3770:
	.byte	0xff
	.byte	0xff
	.byte	0x1
	.uleb128 .LLSDACSE3770-.LLSDACSB3770
.LLSDACSB3770:
	.uleb128 .LEHB0-.LFB3770
	.uleb128 .LEHE0-.LEHB0
	.uleb128 0
	.uleb128 0
	.uleb128 .LEHB1-.LFB3770
	.uleb128 .LEHE1-.LEHB1
	.uleb128 .L26-.LFB3770
	.uleb128 0
	.uleb128 .LEHB2-.LFB3770
	.uleb128 .LEHE2-.LEHB2
	.uleb128 0
	.uleb128 0
.LLSDACSE3770:
	.text
	.size	_Z9bmp_writePciiS_, .-_Z9bmp_writePciiS_
	.globl	_Z14plot_frame_gpu6paramsPc
	.type	_Z14plot_frame_gpu6paramsPc, @function
_Z14plot_frame_gpu6paramsPc:
.LFB3772:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	movq	%rdi, %r14
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	subq	$64, %rsp
	.cfi_def_cfa_offset 112
	movl	180(%rsp), %r13d
	movl	176(%rsp), %r12d
	movq	%fs:40, %rax
	movq	%rax, 56(%rsp)
	xorl	%eax, %eax
	movl	%r13d, %ebx
	imull	%r12d, %ebx
	leal	(%rbx,%rbx,2), %ebx
	movslq	%ebx, %rbx
	movq	%rbx, %rdi
	call	_Znam@PLT
	leaq	24(%rsp), %rdi
	movq	%rbx, %rsi
	movq	%rax, %rbp
	call	cudaMalloc@PLT
	cvtsi2sdl	%r13d, %xmm0
	mulsd	.LC6(%rip), %xmm0
	call	ceil@PLT
	movsd	%xmm0, 8(%rsp)
	cvtsi2sdl	%r12d, %xmm0
	mulsd	.LC6(%rip), %xmm0
	call	ceil@PLT
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	$1, %ecx
	cvttsd2siq	%xmm0, %rax
	movsd	8(%rsp), %xmm1
	movl	$1, %esi
	movabsq	$137438953504, %rdx
	movl	%eax, 44(%rsp)
	cvttsd2siq	%xmm1, %rax
	movl	%eax, 48(%rsp)
	movq	44(%rsp), %rdi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L30
	movl	216(%rsp), %ecx
	movl	%r13d, %edx
	movl	%r12d, %esi
	movsd	208(%rsp), %xmm3
	movsd	200(%rsp), %xmm2
	movq	24(%rsp), %rdi
	movsd	192(%rsp), %xmm1
	movsd	184(%rsp), %xmm0
	call	_Z34__device_stub__Z8populatePcddddiiiPcddddiii
.L30:
	movq	24(%rsp), %rsi
	movl	$2, %ecx
	movq	%rbx, %rdx
	movq	%rbp, %rdi
	call	cudaMemcpy@PLT
	movq	24(%rsp), %rdi
	call	cudaFree@PLT
	movq	%rbp, %rdi
	movq	%r14, %rcx
	movl	%r13d, %edx
	movl	%r12d, %esi
	call	_Z9bmp_writePciiS_
	movq	%rbp, %rdi
	call	_ZdaPv@PLT
	movq	56(%rsp), %rax
	subq	%fs:40, %rax
	je	.L31
	call	__stack_chk_fail@PLT
.L31:
	addq	$64, %rsp
	.cfi_def_cfa_offset 48
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3772:
	.size	_Z14plot_frame_gpu6paramsPc, .-_Z14plot_frame_gpu6paramsPc
	.globl	_Z14plot_frame_cpu6paramsPc
	.type	_Z14plot_frame_cpu6paramsPc, @function
_Z14plot_frame_cpu6paramsPc:
.LFB3773:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	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
	xorl	%r12d, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	movl	176(%rsp), %r13d
	movq	%rdi, 24(%rsp)
	movl	180(%rsp), %r14d
	movsd	184(%rsp), %xmm3
	movsd	200(%rsp), %xmm4
	movl	%r13d, %edi
	imull	%r14d, %edi
	movsd	%xmm3, 8(%rsp)
	movsd	%xmm4, 16(%rsp)
	leal	(%rdi,%rdi,2), %edi
	movslq	%edi, %rdi
	call	_Znam@PLT
	movq	%rax, %rbp
	xorl	%eax, %eax
.L34:
	cmpl	%r14d, %eax
	jge	.L36
	leal	(%r12,%r12,2), %ebx
	xorl	%r15d, %r15d
	movslq	%ebx, %rbx
	addq	%rbp, %rbx
.L37:
	cmpl	%r13d, %r15d
	jge	.L39
	cvtsi2sdl	%eax, %xmm1
	movl	%eax, 44(%rsp)
	addq	$3, %rbx
	movl	216(%rsp), %edi
	cvtsi2sdl	%r14d, %xmm0
	cvtsi2sdl	%r13d, %xmm2
	divsd	%xmm0, %xmm1
	movsd	208(%rsp), %xmm0
	subsd	16(%rsp), %xmm0
	mulsd	%xmm0, %xmm1
	cvtsi2sdl	%r15d, %xmm0
	incl	%r15d
	addsd	16(%rsp), %xmm1
	divsd	%xmm2, %xmm0
	movsd	192(%rsp), %xmm2
	subsd	8(%rsp), %xmm2
	mulsd	%xmm2, %xmm0
	addsd	8(%rsp), %xmm0
	call	_Z4iterddi
	movsd	%xmm0, 32(%rsp)
	call	sqrt@PLT
	movsd	32(%rsp), %xmm1
	movl	44(%rsp), %eax
	mulsd	.LC7(%rip), %xmm0
	cvttsd2sil	%xmm0, %ecx
	movsd	.LC7(%rip), %xmm0
	mulsd	%xmm1, %xmm0
	movb	%cl, -3(%rbx)
	cvttsd2sil	%xmm0, %ecx
	mulsd	%xmm1, %xmm0
	movb	%cl, -2(%rbx)
	cvttsd2sil	%xmm0, %ecx
	movb	%cl, -1(%rbx)
	jmp	.L37
.L39:
	incl	%eax
	addl	%r13d, %r12d
	jmp	.L34
.L36:
	movq	24(%rsp), %rcx
	movq	%rbp, %rdi
	movl	%r14d, %edx
	movl	%r13d, %esi
	call	_Z9bmp_writePciiS_
	addq	$56, %rsp
	.cfi_def_cfa_offset 56
	movq	%rbp, %rdi
	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
	jmp	_ZdaPv@PLT
	.cfi_endproc
.LFE3773:
	.size	_Z14plot_frame_cpu6paramsPc, .-_Z14plot_frame_cpu6paramsPc
	.section	.rodata.str1.1
.LC16:
	.string	"/home/keshav/Dropbox (MIT)/anim_gpu/log_gpu.txt"
.LC17:
	.string	"/home/keshav/Dropbox (MIT)/anim_gpu/i%03d.bmp"
.LC20:
	.string	"\n"
.LC22:
	.string	"Done %2.2f%% on GPU.\n"
.LC23:
	.string	"/home/keshav/Dropbox (MIT)/anim_cpu/log_cpu.txt"
.LC24:
	.string	"/home/keshav/Dropbox (MIT)/anim_cpu/i%03d.bmp"
.LC25:
	.string	"Done %2.2f%% on CPU.\n"
	.section	.text.startup
	.globl	main
	.type	main, @function
main:
.LFB3774:
	.cfi_startproc
	.cfi_personality 0x9b,DW.ref.__gxx_personality_v0
	.cfi_lsda 0x1b,.LLSDA3774
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	.cfi_offset 15, -24
	leaq	.LC17(%rip), %r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	movl	%edi, %r12d
	movl	$200, %edi
	pushq	%rbx
	.cfi_offset 3, -56
	xorl	%ebx, %ebx
	subq	$1192, %rsp
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	call	malloc@PLT
	movsd	.LC8(%rip), %xmm2
	movl	$16, %edx
	movsd	.LC10(%rip), %xmm1
	movq	%rax, -1208(%rbp)
	movq	.LC9(%rip), %rax
	leaq	.LC16(%rip), %rsi
	movsd	.LC12(%rip), %xmm0
	movsd	%xmm2, -1192(%rbp)
	movq	%rax, -1184(%rbp)
	movq	.LC11(%rip), %rax
	movl	$50, -1088(%rbp)
	movq	%rax, -1168(%rbp)
	movq	.LC13(%rip), %rax
	movsd	%xmm1, -1176(%rbp)
	movq	%rax, -1152(%rbp)
	movq	.LC14(%rip), %rax
	movsd	%xmm0, -1160(%rbp)
	movq	%rax, -1144(%rbp)
	movq	.LC15(%rip), %rax
	movsd	%xmm2, -1120(%rbp)
	movq	%rax, -1136(%rbp)
	movabsq	$4638564681600, %rax
	movq	%rax, -1128(%rbp)
	leaq	-1080(%rbp), %rax
	movq	%rax, %rdi
	movq	%rax, -1216(%rbp)
	movsd	%xmm1, -1112(%rbp)
	movsd	%xmm0, -1104(%rbp)
.LEHB3:
	call	_ZNSt14basic_ofstreamIcSt11char_traitsIcEEC1EPKcSt13_Ios_Openmode@PLT
.LEHE3:
.L43:
	movq	-1208(%rbp), %rdi
	movq	%r15, %rcx
	movl	%ebx, %r8d
	xorl	%eax, %eax
	movl	$200, %edx
	movl	$2, %esi
	call	__sprintf_chk@PLT
	leaq	-1192(%rbp), %rax
	movl	%ebx, %esi
	movl	$1000, %edx
	movq	%rax, %rdi
	movq	%rax, -1232(%rbp)
	call	_ZN6params16set_frame_numberEii
	call	clock@PLT
	subq	$112, %rsp
	movl	$28, %ecx
	movq	-1232(%rbp), %rsi
	movq	%rsp, %rdi
	movq	%rax, %r13
	rep movsl
	movq	-1208(%rbp), %rdi
.LEHB4:
	.cfi_escape 0x2e,0x70
	call	_Z14plot_frame_gpu6paramsPc
	addq	$112, %rsp
	call	clock@PLT
	movq	-1216(%rbp), %rdi
	subq	%r13, %rax
	cvtsi2sdq	%rax, %xmm0
	mulsd	.LC18(%rip), %xmm0
	divsd	.LC19(%rip), %xmm0
	.cfi_escape 0x2e,0
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	leaq	.LC20(%rip), %r14
	movq	%rax, %rdi
	movl	$1, %edx
	movq	%r14, %rsi
	call	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l@PLT
	cmpl	$1, %r12d
	movl	%ebx, %eax
	movl	$10, %ecx
	setne	%r13b
	cltd
	idivl	%ecx
	testl	%edx, %edx
	jne	.L45
	testb	%r13b, %r13b
	jne	.L41
.L45:
	incl	%ebx
	cmpl	$1000, %ebx
	jne	.L43
	jmp	.L69
.L41:
	cvtsi2sdl	%ebx, %xmm0
	leaq	.LC22(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	mulsd	.LC21(%rip), %xmm0
	divsd	.LC18(%rip), %xmm0
	call	__printf_chk@PLT
	jmp	.L45
.L69:
	movq	-1216(%rbp), %rdi
	call	_ZNSt14basic_ofstreamIcSt11char_traitsIcEE5closeEv@PLT
	leaq	-568(%rbp), %rax
	movl	$16, %edx
	leaq	.LC23(%rip), %rsi
	movq	%rax, %rdi
	movq	%rax, -1224(%rbp)
	call	_ZNSt14basic_ofstreamIcSt11char_traitsIcEEC1EPKcSt13_Ios_Openmode@PLT
.LEHE4:
	xorl	%ebx, %ebx
	leaq	.LC24(%rip), %r15
.L48:
	movq	-1208(%rbp), %rdi
	movq	%r15, %rcx
	movl	%ebx, %r8d
	xorl	%eax, %eax
	movl	$200, %edx
	movl	$2, %esi
	call	__sprintf_chk@PLT
	movq	-1232(%rbp), %rdi
	movl	%ebx, %esi
	movl	$1000, %edx
	call	_ZN6params16set_frame_numberEii
	call	clock@PLT
	subq	$112, %rsp
	movl	$28, %ecx
	movq	-1232(%rbp), %rsi
	movq	%rsp, %rdi
	movq	%rax, %r12
	rep movsl
	movq	-1208(%rbp), %rdi
.LEHB5:
	.cfi_escape 0x2e,0x70
	call	_Z14plot_frame_cpu6paramsPc
	addq	$112, %rsp
	call	clock@PLT
	movq	-1224(%rbp), %rdi
	subq	%r12, %rax
	cvtsi2sdq	%rax, %xmm0
	mulsd	.LC18(%rip), %xmm0
	divsd	.LC19(%rip), %xmm0
	.cfi_escape 0x2e,0
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	movq	%rax, %rdi
	movl	$1, %edx
	movq	%r14, %rsi
	call	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l@PLT
	movl	%ebx, %eax
	movl	$10, %ecx
	cltd
	idivl	%ecx
	testl	%edx, %edx
	jne	.L50
	testb	%r13b, %r13b
	jne	.L46
.L50:
	incl	%ebx
	cmpl	$1000, %ebx
	jne	.L48
	jmp	.L70
.L46:
	cvtsi2sdl	%ebx, %xmm0
	leaq	.LC25(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	mulsd	.LC21(%rip), %xmm0
	divsd	.LC18(%rip), %xmm0
	call	__printf_chk@PLT
	jmp	.L50
.L70:
	movq	-1224(%rbp), %rdi
	call	_ZNSt14basic_ofstreamIcSt11char_traitsIcEE5closeEv@PLT
.LEHE5:
	movq	-1208(%rbp), %rdi
	call	_ZdaPv@PLT
	movq	-1224(%rbp), %rdi
	call	_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev@PLT
	movq	-1216(%rbp), %rdi
	call	_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev@PLT
	movq	-56(%rbp), %rax
	subq	%fs:40, %rax
	je	.L54
	jmp	.L67
.L56:
	endbr64
	movq	%rax, %rbx
.L51:
	movq	-1224(%rbp), %rdi
	call	_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev@PLT
	jmp	.L52
.L55:
	endbr64
	movq	%rax, %rbx
.L52:
	movq	-1216(%rbp), %rdi
	call	_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev@PLT
	movq	-56(%rbp), %rax
	subq	%fs:40, %rax
	jne	.L67
	movq	%rbx, %rdi
.LEHB6:
	call	_Unwind_Resume@PLT
.LEHE6:
.L67:
	call	__stack_chk_fail@PLT
.L54:
	leaq	-40(%rbp), %rsp
	xorl	%eax, %eax
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE3774:
	.section	.gcc_except_table
.LLSDA3774:
	.byte	0xff
	.byte	0xff
	.byte	0x1
	.uleb128 .LLSDACSE3774-.LLSDACSB3774
.LLSDACSB3774:
	.uleb128 .LEHB3-.LFB3774
	.uleb128 .LEHE3-.LEHB3
	.uleb128 0
	.uleb128 0
	.uleb128 .LEHB4-.LFB3774
	.uleb128 .LEHE4-.LEHB4
	.uleb128 .L55-.LFB3774
	.uleb128 0
	.uleb128 .LEHB5-.LFB3774
	.uleb128 .LEHE5-.LEHB5
	.uleb128 .L56-.LFB3774
	.uleb128 0
	.uleb128 .LEHB6-.LFB3774
	.uleb128 .LEHE6-.LEHB6
	.uleb128 0
	.uleb128 0
.LLSDACSE3774:
	.section	.text.startup
	.size	main, .-main
	.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	-755914244
	.long	1062232653
	.align 8
.LC1:
	.long	0
	.long	1072693248
	.align 8
.LC3:
	.long	0
	.long	1074790400
	.align 8
.LC4:
	.long	-17155601
	.long	1072049730
	.align 8
.LC6:
	.long	0
	.long	1067450368
	.align 8
.LC7:
	.long	0
	.long	1081073664
	.align 8
.LC8:
	.long	-1374389535
	.long	-1073290937
	.align 8
.LC9:
	.long	-1539316279
	.long	-1077494049
	.align 8
.LC10:
	.long	1546188227
	.long	1073595023
	.align 8
.LC11:
	.long	-1759218604
	.long	-1078030081
	.align 8
.LC12:
	.long	343597384
	.long	-1074444370
	.align 8
.LC13:
	.long	1498084593
	.long	1072707718
	.align 8
.LC14:
	.long	343597384
	.long	1073039278
	.align 8
.LC15:
	.long	-913969041
	.long	1072742740
	.align 8
.LC18:
	.long	0
	.long	1083129856
	.align 8
.LC19:
	.long	0
	.long	1093567616
	.align 8
.LC21:
	.long	0
	.long	1079574528
	.hidden	DW.ref.__gxx_personality_v0
	.weak	DW.ref.__gxx_personality_v0
	.section	.data.rel.local.DW.ref.__gxx_personality_v0,"awG",@progbits,DW.ref.__gxx_personality_v0,comdat
	.align 8
	.type	DW.ref.__gxx_personality_v0, @object
	.size	DW.ref.__gxx_personality_v0, 8
DW.ref.__gxx_personality_v0:
	.quad	__gxx_personality_v0
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:


#include <hip/hip_runtime.h>
#include <fstream>
#include <time.h>
using namespace std;

class params{
private:
  double r_min_ini, r_min_trg;
  double r_max_ini, r_max_trg;
  double i_min_ini, i_min_trg;
  double i_max_ini, i_max_trg;

public:
  int width, height;
  double r_min, r_max, i_min, i_max;
  int max;

  params(){
    r_min_ini = -2.86, r_min_trg = -0.1777;
    r_max_ini = 1.86, r_max_trg = -0.1194;
    i_min_ini = -1.33, i_min_trg = 1.0138;
    i_max_ini = 1.33, i_max_trg = 1.0472;

    width = 1920, height = 1080;
    r_min = r_min_ini, r_max = r_max_ini, i_min = i_min_ini, i_max = i_max_ini;
    max = 50;
  }

  void set_frame_number(int, int);
};

void params::set_frame_number(int n, int max){
  if (n < max){
    double t = 1 - pow(0.001, (double)n/(double)max);
    r_min = r_min_ini +  t*(r_min_trg - r_min_ini);
    r_max = r_max_ini +  t*(r_max_trg - r_max_ini);
    i_min = i_min_ini +  t*(i_min_trg - i_min_ini);
    i_max = i_max_ini +  t*(i_max_trg - i_max_ini);
  }
  else{
    r_min = r_min_trg, r_max = r_max_trg, i_min = i_min_trg, i_max = i_max_trg;
  }
}

void bmp_write(char * img_data, int width, int height, char * filename){
  int size = height*width*3 + 54;
  ofstream bmp(filename, ios::binary);

  char bmp_header[54] = {'B', 'M',
  (char)size, (char)(size >> 8), (char)(size >> 16), (char)(size >> 24),
  0, 0, 0, 0, 54, 0, 0, 0, 40, 0, 0, 0, (char)width, (char)(width >> 8),
  0, 0, (char)height,(char)(height >> 8), 0, 0, 1, 0, 24, 0, 0, 0, 0, 0,
  (char)(size - 54), (char)((size - 54) >> 8),(char)((size - 54) >> 16),
  (char)((size - 54) >> 24),0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  0};

  bmp.write(bmp_header, sizeof bmp_header);
  bmp.write(img_data, size - 54);
  bmp.close();
}

__host__ __device__ double iter(double r_c, double i_c, int max){
  double r_t = 0.0, i_t = 0.0;
  double r_t_2, i_t_2, mag;
  for (int i = 0; i < max; i++){
    r_t_2 = r_t * r_t - i_t * i_t;
    i_t_2 = 2 * r_t * i_t;
    r_t = r_t_2 + r_c;
    i_t = i_t_2 + i_c;
    mag = r_t*r_t + i_t*i_t;
    if (mag > 4){
      return (double)(i + 1 - log(log(mag))/log(2.0))/(double)max;
    }
  }
  return 0;
}

__global__ void populate(char * d_img_data, double r_min, double r_max,
  double i_min, double i_max, int width, int height, int max){
    int x = blockIdx.x*blockDim.x + threadIdx.x;
    int y = blockIdx.y*blockDim.y + threadIdx.y;
    if (x < width && y < height){
      double r = ((double)x/(double)width)*(r_max-r_min)+r_min;
      double i = ((double)y/(double)height)*(i_max-i_min)+i_min;
      double t = iter(r, i, max);
      d_img_data[y*3*width + x*3 + 0] = (char)(255*sqrt(t));
      d_img_data[y*3*width + x*3 + 1] = (char)(255*t);
      d_img_data[y*3*width + x*3 + 2] = (char)(255*t*t);
    }
  }

void plot_frame_gpu(params plot, char * filename){
  /*getting image data*/
  char * h_img_data = new char[plot.width*plot.height*3*sizeof(char)];
  char * d_img_data;
  hipMalloc((void **) &d_img_data, plot.width*plot.height*3*sizeof(char));
  dim3 threads(32, 32, 1);
  dim3 grid(ceil((double)plot.width/32.0),
    ceil((double)plot.height/32.0), 1);
  populate<<<grid, threads>>>(d_img_data, plot.r_min, plot.r_max, plot.i_min,
    plot.i_max, plot.width, plot.height, plot.max);
  hipMemcpy(h_img_data, d_img_data, plot.width*plot.height*3*sizeof(char),
    hipMemcpyDeviceToHost);
  hipFree(d_img_data);

  /*write to file*/
  bmp_write(h_img_data, plot.width, plot.height, filename);
  delete[] h_img_data;
}

void plot_frame_cpu(params plot, char * filename){
  char * img_data = new char[plot.width*plot.height*3*sizeof(char)];
  for (int y = 0; y < plot.height; y++){
    for (int x = 0; x < plot.width; x++){
      double r = ((double)x/(double)plot.width)*(plot.r_max-plot.r_min)+plot.r_min;
      double i = ((double)y/(double)plot.height)*(plot.i_max-plot.i_min)+plot.i_min;
      double t = iter(r, i, plot.max);
      img_data[y*3*plot.width + x*3 + 0] = (char)(255*sqrt(t));
      img_data[y*3*plot.width + x*3 + 1] = (char)(255*t);
      img_data[y*3*plot.width + x*3 + 2] = (char)(255*t*t);
    }
  }
  bmp_write(img_data, plot.width, plot.height, filename);
  delete[] img_data;
}

int main(int argc, char ** argv){
  int num_frames = 1000;
  clock_t t1, t2;
  char * filename = (char *)malloc(200*sizeof(char));
  params plot;

  /*TEST GPU*/
  ofstream log_gpu("/home/keshav/Dropbox (MIT)/anim_gpu/log_gpu.txt");
  for (int i = 0; i < num_frames; i++){
    sprintf(filename, "/home/keshav/Dropbox (MIT)/anim_gpu/i%03d.bmp", i);
    plot.set_frame_number(i, num_frames);
    t1 = clock();
    plot_frame_gpu(plot, filename);
    t2 = clock();
    log_gpu << 1000*(double)(t2-t1)/(CLOCKS_PER_SEC) << "\n";
    if (!(i%(num_frames/100)) && (argc-1)) printf("Done %2.2f%% on GPU.\n",
      100*(double)i/(double)num_frames);
  }
  log_gpu.close();

  /*TEST CPU*/
  ofstream log_cpu("/home/keshav/Dropbox (MIT)/anim_cpu/log_cpu.txt");
  for (int i = 0; i < num_frames; i++){
    sprintf(filename, "/home/keshav/Dropbox (MIT)/anim_cpu/i%03d.bmp", i);
    plot.set_frame_number(i, num_frames);
    t1 = clock();
    plot_frame_cpu(plot, filename);
    t2 = clock();
    log_cpu << 1000*(double)(t2-t1)/(CLOCKS_PER_SEC) << "\n";
    if (!(i%(num_frames/100)) && (argc-1)) printf("Done %2.2f%% on CPU.\n",
      100*(double)i/(double)num_frames);
  }
  log_cpu.close();

  delete[] filename;
  return 0;
}

	.text
	.file	"main.hip"
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _ZN6params16set_frame_numberEii
.LCPI0_0:
	.quad	0x3f50624dd2f1a9fc              # double 0.001
.LCPI0_1:
	.quad	0x3ff0000000000000              # double 1
	.text
	.globl	_ZN6params16set_frame_numberEii
	.p2align	1, 0x90
	.type	_ZN6params16set_frame_numberEii,@function
_ZN6params16set_frame_numberEii:        # @_ZN6params16set_frame_numberEii
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset %rbx, -16
	movq	%rdi, %rbx
	cmpl	%edx, %esi
	jge	.LBB0_2
# %bb.1:
	cvtsi2sd	%esi, %xmm1
	cvtsi2sd	%edx, %xmm0
	divsd	%xmm0, %xmm1
	movsd	.LCPI0_0(%rip), %xmm0           # xmm0 = mem[0],zero
	callq	pow
	movsd	.LCPI0_1(%rip), %xmm4           # xmm4 = mem[0],zero
	subsd	%xmm0, %xmm4
	movsd	(%rbx), %xmm1                   # xmm1 = mem[0],zero
	movsd	8(%rbx), %xmm0                  # xmm0 = mem[0],zero
	subsd	%xmm1, %xmm0
	mulsd	%xmm4, %xmm0
	addsd	%xmm1, %xmm0
	movsd	16(%rbx), %xmm2                 # xmm2 = mem[0],zero
	movsd	24(%rbx), %xmm1                 # xmm1 = mem[0],zero
	subsd	%xmm2, %xmm1
	mulsd	%xmm4, %xmm1
	addsd	%xmm2, %xmm1
	movsd	32(%rbx), %xmm3                 # xmm3 = mem[0],zero
	movsd	40(%rbx), %xmm2                 # xmm2 = mem[0],zero
	subsd	%xmm3, %xmm2
	mulsd	%xmm4, %xmm2
	addsd	%xmm3, %xmm2
	movsd	48(%rbx), %xmm5                 # xmm5 = mem[0],zero
	movsd	56(%rbx), %xmm3                 # xmm3 = mem[0],zero
	subsd	%xmm5, %xmm3
	mulsd	%xmm4, %xmm3
	addsd	%xmm5, %xmm3
	jmp	.LBB0_3
.LBB0_2:
	movsd	8(%rbx), %xmm0                  # xmm0 = mem[0],zero
	movsd	24(%rbx), %xmm1                 # xmm1 = mem[0],zero
	movsd	40(%rbx), %xmm2                 # xmm2 = mem[0],zero
	movsd	56(%rbx), %xmm3                 # xmm3 = mem[0],zero
.LBB0_3:
	movsd	%xmm0, 72(%rbx)
	movsd	%xmm1, 80(%rbx)
	movsd	%xmm2, 88(%rbx)
	movsd	%xmm3, 96(%rbx)
	popq	%rbx
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end0:
	.size	_ZN6params16set_frame_numberEii, .Lfunc_end0-_ZN6params16set_frame_numberEii
	.cfi_endproc
                                        # -- End function
	.globl	_Z9bmp_writePciiS_              # -- Begin function _Z9bmp_writePciiS_
	.type	_Z9bmp_writePciiS_,@function
_Z9bmp_writePciiS_:                     # @_Z9bmp_writePciiS_
.Lfunc_begin0:
	.cfi_startproc
	.cfi_personality 3, __gxx_personality_v0
	.cfi_lsda 3, .Lexception0
# %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	$568, %rsp                      # imm = 0x238
	.cfi_def_cfa_offset 624
	.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	%edx, %r12d
	movq	%rdi, %r15
	movl	%esi, %eax
	movl	%esi, %r13d
	imull	%edx, %eax
	leal	(%rax,%rax,2), %ebp
	leal	(%rax,%rax,2), %ebx
	addl	$54, %ebx
	leaq	56(%rsp), %r14
	movq	%r14, %rdi
	movq	%rcx, %rsi
	movl	$4, %edx
	callq	_ZNSt14basic_ofstreamIcSt11char_traitsIcEEC1EPKcSt13_Ios_Openmode
	movq	%rsp, %rsi
	movw	$19778, (%rsi)                  # imm = 0x4D42
	movb	%bl, 2(%rsi)
	movb	%bh, 3(%rsp)
	movl	%ebx, %eax
	shrl	$16, %eax
	movb	%al, 4(%rsi)
	shrl	$24, %ebx
	movb	%bl, 5(%rsi)
	movl	%ebp, %ebx
	xorl	%eax, %eax
	movl	%eax, 6(%rsi)
	movabsq	$171798691894, %rcx             # imm = 0x2800000036
	movq	%rcx, 10(%rsi)
	movl	%r13d, %ecx
	movb	%cl, 18(%rsi)
	movb	%ch, 19(%rsp)
	movw	$0, 20(%rsi)
	movl	%r12d, %ecx
	movb	%cl, 22(%rsi)
	movb	%ch, 23(%rsp)
	movl	$65536, 24(%rsi)                # imm = 0x10000
	movb	$24, 28(%rsi)
	movl	%eax, 29(%rsi)
	movb	$0, 33(%rsi)
	movb	%bl, 34(%rsi)
	movb	%bh, 35(%rsp)
	movl	%ebp, %eax
	shrl	$16, %eax
	movb	%al, 36(%rsi)
	movl	%ebp, %eax
	shrl	$24, %eax
	movb	%al, 37(%rsi)
	xorps	%xmm0, %xmm0
	movups	%xmm0, 38(%rsi)
.Ltmp0:
	movl	$54, %edx
	movq	%r14, %rdi
	callq	_ZNSo5writeEPKcl
.Ltmp1:
# %bb.1:
	movslq	%ebx, %rdx
.Ltmp2:
	leaq	56(%rsp), %rdi
	movq	%r15, %rsi
	callq	_ZNSo5writeEPKcl
.Ltmp3:
# %bb.2:
.Ltmp4:
	leaq	56(%rsp), %rdi
	callq	_ZNSt14basic_ofstreamIcSt11char_traitsIcEE5closeEv
.Ltmp5:
# %bb.3:
	movq	_ZTTSt14basic_ofstreamIcSt11char_traitsIcEE(%rip), %rax
	leaq	64(%rsp), %rdi
	movq	%rax, -8(%rdi)
	movq	_ZTTSt14basic_ofstreamIcSt11char_traitsIcEE+24(%rip), %rcx
	movq	-24(%rax), %rax
	movq	%rcx, 56(%rsp,%rax)
	callq	_ZNSt13basic_filebufIcSt11char_traitsIcEED2Ev
	leaq	304(%rsp), %rdi
	callq	_ZNSt8ios_baseD2Ev
	addq	$568, %rsp                      # imm = 0x238
	.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
.LBB1_4:
	.cfi_def_cfa_offset 624
.Ltmp6:
	movq	%rax, %rbx
	leaq	56(%rsp), %rdi
	callq	_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev
	movq	%rbx, %rdi
	callq	_Unwind_Resume@PLT
.Lfunc_end1:
	.size	_Z9bmp_writePciiS_, .Lfunc_end1-_Z9bmp_writePciiS_
	.cfi_endproc
	.section	.gcc_except_table,"a",@progbits
	.p2align	2, 0x0
GCC_except_table1:
.Lexception0:
	.byte	255                             # @LPStart Encoding = omit
	.byte	255                             # @TType Encoding = omit
	.byte	1                               # Call site Encoding = uleb128
	.uleb128 .Lcst_end0-.Lcst_begin0
.Lcst_begin0:
	.uleb128 .Lfunc_begin0-.Lfunc_begin0    # >> Call Site 1 <<
	.uleb128 .Ltmp0-.Lfunc_begin0           #   Call between .Lfunc_begin0 and .Ltmp0
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp0-.Lfunc_begin0           # >> Call Site 2 <<
	.uleb128 .Ltmp5-.Ltmp0                  #   Call between .Ltmp0 and .Ltmp5
	.uleb128 .Ltmp6-.Lfunc_begin0           #     jumps to .Ltmp6
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp5-.Lfunc_begin0           # >> Call Site 3 <<
	.uleb128 .Lfunc_end1-.Ltmp5             #   Call between .Ltmp5 and .Lfunc_end1
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
.Lcst_end0:
	.p2align	2, 0x0
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z4iterddi
.LCPI2_0:
	.quad	0x4010000000000000              # double 4
.LCPI2_1:
	.quad	0xbfe62e42fefa39ef              # double -0.69314718055994529
	.text
	.globl	_Z4iterddi
	.type	_Z4iterddi,@function
_Z4iterddi:                             # @_Z4iterddi
	.cfi_startproc
# %bb.0:
	testl	%edi, %edi
	jle	.LBB2_1
# %bb.3:                                # %.lr.ph.preheader
	pushq	%rbx
	.cfi_def_cfa_offset 16
	subq	$16, %rsp
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -16
	movl	%edi, %ebx
	xorpd	%xmm3, %xmm3
	movl	$-1, %eax
	movsd	.LCPI2_0(%rip), %xmm4           # xmm4 = mem[0],zero
	xorpd	%xmm5, %xmm5
.LBB2_4:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movapd	%xmm3, %xmm2
	mulsd	%xmm3, %xmm2
	movapd	%xmm5, %xmm6
	mulsd	%xmm5, %xmm6
	subsd	%xmm6, %xmm2
	addsd	%xmm3, %xmm3
	mulsd	%xmm3, %xmm5
	movapd	%xmm2, %xmm3
	addsd	%xmm0, %xmm3
	addsd	%xmm1, %xmm5
	movapd	%xmm3, %xmm6
	mulsd	%xmm3, %xmm6
	movapd	%xmm5, %xmm2
	mulsd	%xmm5, %xmm2
	addsd	%xmm6, %xmm2
	ucomisd	%xmm4, %xmm2
	ja	.LBB2_5
# %bb.6:                                #   in Loop: Header=BB2_4 Depth=1
	leal	(%rbx,%rax), %ecx
	decl	%ecx
                                        # kill: def $eax killed $eax killed $rax
	decl	%eax
                                        # kill: def $eax killed $eax def $rax
	cmpl	$-1, %ecx
	jne	.LBB2_4
# %bb.7:
	xorpd	%xmm0, %xmm0
	jmp	.LBB2_8
.LBB2_1:
	.cfi_def_cfa_offset 8
	.cfi_restore %rbx
	xorps	%xmm0, %xmm0
	retq
.LBB2_5:
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -16
	negl	%eax
	xorps	%xmm0, %xmm0
	cvtsi2sd	%eax, %xmm0
	movsd	%xmm0, 8(%rsp)                  # 8-byte Spill
	movapd	%xmm2, %xmm0
	callq	log
	callq	log
	divsd	.LCPI2_1(%rip), %xmm0
	addsd	8(%rsp), %xmm0                  # 8-byte Folded Reload
	xorps	%xmm1, %xmm1
	cvtsi2sd	%ebx, %xmm1
	divsd	%xmm1, %xmm0
.LBB2_8:
	addq	$16, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	.cfi_restore %rbx
	retq
.Lfunc_end2:
	.size	_Z4iterddi, .Lfunc_end2-_Z4iterddi
	.cfi_endproc
                                        # -- End function
	.globl	_Z23__device_stub__populatePcddddiii # -- Begin function _Z23__device_stub__populatePcddddiii
	.type	_Z23__device_stub__populatePcddddiii,@function
_Z23__device_stub__populatePcddddiii:   # @_Z23__device_stub__populatePcddddiii
	.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	$176, %rsp
	.cfi_def_cfa_offset 224
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	72(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	64(%rsp), %rdi
	movsd	%xmm0, (%rdi)
	leaq	56(%rsp), %r8
	movsd	%xmm1, (%r8)
	leaq	48(%rsp), %r9
	movsd	%xmm2, (%r9)
	leaq	40(%rsp), %r10
	movsd	%xmm3, (%r10)
	leaq	20(%rsp), %r11
	movl	%esi, (%r11)
	leaq	16(%rsp), %rsi
	movl	%edx, (%rsi)
	leaq	12(%rsp), %rdx
	movl	%ecx, (%rdx)
	leaq	112(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%r8, 16(%rbx)
	movq	%r9, 24(%rbx)
	movq	%r10, 32(%rbx)
	movq	%r11, 40(%rbx)
	movq	%rsi, 48(%rbx)
	movq	%rdx, 56(%rbx)
	leaq	96(%rsp), %r14
	leaq	80(%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	$_Z8populatePcddddiii, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$192, %rsp
	.cfi_adjust_cfa_offset -192
	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	_Z23__device_stub__populatePcddddiii, .Lfunc_end3-_Z23__device_stub__populatePcddddiii
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z14plot_frame_gpu6paramsPc
.LCPI4_0:
	.quad	0x3fa0000000000000              # double 0.03125
	.text
	.globl	_Z14plot_frame_gpu6paramsPc
	.type	_Z14plot_frame_gpu6paramsPc,@function
_Z14plot_frame_gpu6paramsPc:            # @_Z14plot_frame_gpu6paramsPc
	.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
	pushq	%rax
	.cfi_def_cfa_offset 64
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rdi, %rbx
	movl	128(%rsp), %ebp
	movl	132(%rsp), %r14d
	movl	%ebp, %eax
	imull	%r14d, %eax
	leal	(%rax,%rax,2), %eax
	movslq	%eax, %r12
	movq	%r12, %rdi
	callq	_Znam
	movq	%rax, %r15
	movq	%rsp, %rdi
	movq	%r12, %rsi
	callq	hipMalloc
	cvtsi2sd	%ebp, %xmm0
	mulsd	.LCPI4_0(%rip), %xmm0
	callq	ceil@PLT
	cvttsd2si	%xmm0, %r13
	xorps	%xmm0, %xmm0
	cvtsi2sd	%r14d, %xmm0
	mulsd	.LCPI4_0(%rip), %xmm0
	callq	ceil@PLT
	cvttsd2si	%xmm0, %rdi
	movl	%r13d, %eax
	shlq	$32, %rdi
	orq	%rax, %rdi
	movabsq	$137438953504, %rdx             # imm = 0x2000000020
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB4_2
# %bb.1:
	leaq	64(%rsp), %rax
	movq	(%rsp), %rdi
	movsd	72(%rax), %xmm0                 # xmm0 = mem[0],zero
	movsd	80(%rax), %xmm1                 # xmm1 = mem[0],zero
	movsd	88(%rax), %xmm2                 # xmm2 = mem[0],zero
	movsd	96(%rax), %xmm3                 # xmm3 = mem[0],zero
	movl	104(%rax), %ecx
	movl	%ebp, %esi
	movl	%r14d, %edx
	callq	_Z23__device_stub__populatePcddddiii
.LBB4_2:
	movq	(%rsp), %rsi
	movq	%r15, %rdi
	movq	%r12, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	movq	(%rsp), %rdi
	callq	hipFree
	movq	%r15, %rdi
	movl	%ebp, %esi
	movl	%r14d, %edx
	movq	%rbx, %rcx
	callq	_Z9bmp_writePciiS_
	movq	%r15, %rdi
	callq	_ZdaPv
	addq	$8, %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_end4:
	.size	_Z14plot_frame_gpu6paramsPc, .Lfunc_end4-_Z14plot_frame_gpu6paramsPc
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z14plot_frame_cpu6paramsPc
.LCPI5_0:
	.quad	0x406fe00000000000              # double 255
.LCPI5_1:
	.quad	0x3ff0000000000000              # double 1
.LCPI5_2:
	.quad	0x0000000000000000              # double 0
	.text
	.globl	_Z14plot_frame_cpu6paramsPc
	.type	_Z14plot_frame_cpu6paramsPc,@function
_Z14plot_frame_cpu6paramsPc:            # @_Z14plot_frame_cpu6paramsPc
	.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	$104, %rsp
	.cfi_def_cfa_offset 160
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rdi, 32(%rsp)                  # 8-byte Spill
	movl	224(%rsp), %r14d
	movl	228(%rsp), %ebx
	movl	%r14d, %eax
	imull	%ebx, %eax
	leal	(%rax,%rax,2), %eax
	movslq	%eax, %rdi
	callq	_Znam
	movq	%rax, %r15
	movl	%ebx, 4(%rsp)                   # 4-byte Spill
	testl	%ebx, %ebx
	jle	.LBB5_7
# %bb.1:                                # %.preheader.lr.ph
	leaq	160(%rsp), %rax
	cvtsi2sd	%r14d, %xmm0
	movsd	%xmm0, 88(%rsp)                 # 8-byte Spill
	movsd	72(%rax), %xmm0                 # xmm0 = mem[0],zero
	movsd	80(%rax), %xmm1                 # xmm1 = mem[0],zero
	cvtsi2sdl	4(%rsp), %xmm2          # 4-byte Folded Reload
	movsd	%xmm2, 56(%rsp)                 # 8-byte Spill
	movsd	%xmm0, 80(%rsp)                 # 8-byte Spill
	subsd	%xmm0, %xmm1
	movsd	%xmm1, 72(%rsp)                 # 8-byte Spill
	movsd	96(%rax), %xmm0                 # xmm0 = mem[0],zero
	movsd	88(%rax), %xmm1                 # xmm1 = mem[0],zero
	movsd	%xmm1, 40(%rsp)                 # 8-byte Spill
	subsd	%xmm1, %xmm0
	movsd	%xmm0, 48(%rsp)                 # 8-byte Spill
	movl	104(%rax), %r12d
	leal	(%r14,%r14,2), %eax
	movl	%eax, 28(%rsp)                  # 4-byte Spill
	xorl	%eax, %eax
	movq	%rax, 16(%rsp)                  # 8-byte Spill
	xorpd	%xmm0, %xmm0
	movsd	%xmm0, 8(%rsp)                  # 8-byte Spill
	xorl	%ebp, %ebp
.LBB5_2:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB5_4 Depth 2
	testl	%r14d, %r14d
	jle	.LBB5_6
# %bb.3:                                # %.lr.ph
                                        #   in Loop: Header=BB5_2 Depth=1
	movsd	8(%rsp), %xmm0                  # 8-byte Reload
                                        # xmm0 = mem[0],zero
	divsd	56(%rsp), %xmm0                 # 8-byte Folded Reload
	mulsd	48(%rsp), %xmm0                 # 8-byte Folded Reload
	addsd	40(%rsp), %xmm0                 # 8-byte Folded Reload
	movsd	%xmm0, 96(%rsp)                 # 8-byte Spill
	movq	16(%rsp), %rbx                  # 8-byte Reload
                                        # kill: def $ebx killed $ebx killed $rbx def $rbx
	xorl	%r13d, %r13d
.LBB5_4:                                #   Parent Loop BB5_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	xorps	%xmm0, %xmm0
	cvtsi2sd	%r13d, %xmm0
	divsd	88(%rsp), %xmm0                 # 8-byte Folded Reload
	mulsd	72(%rsp), %xmm0                 # 8-byte Folded Reload
	addsd	80(%rsp), %xmm0                 # 8-byte Folded Reload
	movsd	96(%rsp), %xmm1                 # 8-byte Reload
                                        # xmm1 = mem[0],zero
	movl	%r12d, %edi
	callq	_Z4iterddi
	movapd	%xmm0, %xmm2
	ucomisd	.LCPI5_2(%rip), %xmm0
	jb	.LBB5_8
# %bb.5:                                #   in Loop: Header=BB5_4 Depth=2
	xorps	%xmm0, %xmm0
	sqrtsd	%xmm2, %xmm0
	jmp	.LBB5_9
.LBB5_8:                                # %call.sqrt
                                        #   in Loop: Header=BB5_4 Depth=2
	movapd	%xmm2, %xmm0
	movsd	%xmm2, 64(%rsp)                 # 8-byte Spill
	callq	sqrt
	movsd	64(%rsp), %xmm2                 # 8-byte Reload
                                        # xmm2 = mem[0],zero
.LBB5_9:                                # %.split
                                        #   in Loop: Header=BB5_4 Depth=2
	movsd	.LCPI5_0(%rip), %xmm1           # xmm1 = mem[0],zero
	mulsd	%xmm1, %xmm0
	cvttsd2si	%xmm0, %eax
	movslq	%ebx, %rbx
	movb	%al, (%r15,%rbx)
	movapd	%xmm2, %xmm0
	mulsd	%xmm1, %xmm0
	cvttsd2si	%xmm0, %eax
	movb	%al, 1(%r15,%rbx)
	mulsd	%xmm2, %xmm0
	cvttsd2si	%xmm0, %eax
	movb	%al, 2(%r15,%rbx)
	incq	%r13
	addl	$3, %ebx
	cmpq	%r13, %r14
	jne	.LBB5_4
.LBB5_6:                                # %._crit_edge
                                        #   in Loop: Header=BB5_2 Depth=1
	movsd	8(%rsp), %xmm0                  # 8-byte Reload
                                        # xmm0 = mem[0],zero
	addsd	.LCPI5_1(%rip), %xmm0
	movsd	%xmm0, 8(%rsp)                  # 8-byte Spill
	incl	%ebp
	movq	16(%rsp), %rax                  # 8-byte Reload
	addl	28(%rsp), %eax                  # 4-byte Folded Reload
	movq	%rax, 16(%rsp)                  # 8-byte Spill
	cmpl	4(%rsp), %ebp                   # 4-byte Folded Reload
	jne	.LBB5_2
.LBB5_7:                                # %._crit_edge28
	movq	%r15, %rdi
	movl	%r14d, %esi
	movl	4(%rsp), %edx                   # 4-byte Reload
	movq	32(%rsp), %rcx                  # 8-byte Reload
	callq	_Z9bmp_writePciiS_
	movq	%r15, %rdi
	addq	$104, %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
	jmp	_ZdaPv                          # TAILCALL
.Lfunc_end5:
	.size	_Z14plot_frame_cpu6paramsPc, .Lfunc_end5-_Z14plot_frame_cpu6paramsPc
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function main
.LCPI6_0:
	.quad	0x408f400000000000              # double 1000
.LCPI6_1:
	.quad	0x3f50624dd2f1a9fc              # double 0.001
.LCPI6_2:
	.quad	0x3ff0000000000000              # double 1
.LCPI6_3:
	.quad	0x40057559b3d07c84              # double 2.6822999999999997
.LCPI6_4:
	.quad	0xc006e147ae147ae1              # double -2.8599999999999999
.LCPI6_5:
	.quad	0xbfffab9f559b3d08              # double -1.9794
.LCPI6_6:
	.quad	0x3ffdc28f5c28f5c3              # double 1.8600000000000001
.LCPI6_7:
	.quad	0x4002c01a36e2eb1c              # double 2.3437999999999999
.LCPI6_8:
	.quad	0xbff547ae147ae148              # double -1.3300000000000001
.LCPI6_9:
	.quad	0xbfd219652bd3c364              # double -0.28280000000000016
.LCPI6_10:
	.quad	0x3ff547ae147ae148              # double 1.3300000000000001
.LCPI6_11:
	.quad	0x412e848000000000              # double 1.0E+6
.LCPI6_12:
	.quad	0x4059000000000000              # double 100
	.text
	.globl	main
	.type	main,@function
main:                                   # @main
.Lfunc_begin1:
	.cfi_startproc
	.cfi_personality 3, __gxx_personality_v0
	.cfi_lsda 3, .Lexception1
# %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	$1400, %rsp                     # imm = 0x578
	.cfi_def_cfa_offset 1456
	.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	%edi, %ebp
	movl	$200, %edi
	callq	malloc
	movq	%rax, %rbx
	leaq	376(%rsp), %rdi
	movl	$.L.str, %esi
	movl	$16, %edx
	callq	_ZNSt14basic_ofstreamIcSt11char_traitsIcEEC1EPKcSt13_Ios_Openmode
	movl	$65535, %r14d                   # imm = 0xFFFF
	leaq	264(%rsp), %r15
	xorl	%r12d, %r12d
.LBB6_1:                                # %_ZN6params16set_frame_numberEii.exit
                                        # =>This Inner Loop Header: Depth=1
	movl	$.L.str.1, %esi
	movq	%rbx, %rdi
	movl	%r12d, %edx
	xorl	%eax, %eax
	callq	sprintf
	cvtsi2sd	%r12d, %xmm1
	movsd	%xmm1, 112(%rsp)                # 8-byte Spill
	divsd	.LCPI6_0(%rip), %xmm1
	movsd	.LCPI6_1(%rip), %xmm0           # xmm0 = mem[0],zero
	callq	pow
	movsd	.LCPI6_2(%rip), %xmm1           # xmm1 = mem[0],zero
	subsd	%xmm0, %xmm1
	movapd	%xmm1, %xmm0
	mulsd	.LCPI6_3(%rip), %xmm0
	addsd	.LCPI6_4(%rip), %xmm0
	movsd	%xmm0, 144(%rsp)                # 8-byte Spill
	movapd	%xmm1, %xmm0
	mulsd	.LCPI6_5(%rip), %xmm0
	addsd	.LCPI6_6(%rip), %xmm0
	movsd	%xmm0, 136(%rsp)                # 8-byte Spill
	movapd	%xmm1, %xmm0
	mulsd	.LCPI6_7(%rip), %xmm0
	addsd	.LCPI6_8(%rip), %xmm0
	movsd	%xmm0, 128(%rsp)                # 8-byte Spill
	mulsd	.LCPI6_9(%rip), %xmm1
	addsd	.LCPI6_10(%rip), %xmm1
	movsd	%xmm1, 120(%rsp)                # 8-byte Spill
	callq	clock
	movq	%rax, %r13
	movabsq	$-4609749470587618591, %rax     # imm = 0xC006E147AE147AE1
	movq	%rax, 264(%rsp)
	movabsq	$-4627801699333970487, %rax     # imm = 0xBFC6BEDFA43FE5C9
	movq	%rax, 272(%rsp)
	movabsq	$4611055514479556035, %rax      # imm = 0x3FFDC28F5C28F5C3
	movq	%rax, 280(%rsp)
	movabsq	$-4630103939463482284, %rax     # imm = 0xBFBE90FF97247454
	movq	%rax, 288(%rsp)
	movabsq	$-4614703430177726136, %rax     # imm = 0xBFF547AE147AE148
	movq	%rax, 296(%rsp)
	movabsq	$4607244568474875121, %rax      # imm = 0x3FF03886594AF4F1
	movq	%rax, 304(%rsp)
	movabsq	$4608668606677049672, %rax      # imm = 0x3FF547AE147AE148
	movq	%rax, 312(%rsp)
	movabsq	$4607394988702429295, %rax      # imm = 0x3FF0C154C985F06F
	movq	%rax, 320(%rsp)
	movabsq	$4638564681600, %rax            # imm = 0x43800000780
	movq	%rax, 328(%rsp)
	movsd	144(%rsp), %xmm0                # 8-byte Reload
                                        # xmm0 = mem[0],zero
	movsd	%xmm0, 336(%rsp)
	movsd	136(%rsp), %xmm0                # 8-byte Reload
                                        # xmm0 = mem[0],zero
	movsd	%xmm0, 344(%rsp)
	movsd	128(%rsp), %xmm0                # 8-byte Reload
                                        # xmm0 = mem[0],zero
	movsd	%xmm0, 352(%rsp)
	movsd	120(%rsp), %xmm0                # 8-byte Reload
                                        # xmm0 = mem[0],zero
	movsd	%xmm0, 360(%rsp)
	movl	$50, 368(%rsp)
.Ltmp7:
	movl	$14, %ecx
	movq	%rsp, %rdi
	movq	%r15, %rsi
	rep;movsq (%rsi), %es:(%rdi)
	movq	%rbx, %rdi
	callq	_Z14plot_frame_gpu6paramsPc
.Ltmp8:
# %bb.2:                                #   in Loop: Header=BB6_1 Depth=1
	callq	clock
	subq	%r13, %rax
	xorps	%xmm0, %xmm0
	cvtsi2sd	%rax, %xmm0
	mulsd	.LCPI6_0(%rip), %xmm0
	divsd	.LCPI6_11(%rip), %xmm0
.Ltmp9:
	leaq	376(%rsp), %rdi
	callq	_ZNSo9_M_insertIdEERSoT_
.Ltmp10:
# %bb.3:                                # %_ZNSolsEd.exit
                                        #   in Loop: Header=BB6_1 Depth=1
.Ltmp11:
	movl	$.L.str.2, %esi
	movl	$1, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp12:
# %bb.4:                                # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit
                                        #   in Loop: Header=BB6_1 Depth=1
	cmpl	$1, %ebp
	je	.LBB6_7
# %bb.5:                                # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit
                                        #   in Loop: Header=BB6_1 Depth=1
	movl	%r12d, %eax
	andl	%r14d, %eax
	imull	$52429, %eax, %eax              # imm = 0xCCCD
	shrl	$18, %eax
	andl	$-2, %eax
	leal	(%rax,%rax,4), %eax
	negl	%eax
	andl	%r14d, %eax
	addl	%r12d, %eax
	testw	%ax, %ax
	jne	.LBB6_7
# %bb.6:                                #   in Loop: Header=BB6_1 Depth=1
	movsd	112(%rsp), %xmm0                # 8-byte Reload
                                        # xmm0 = mem[0],zero
	mulsd	.LCPI6_12(%rip), %xmm0
	divsd	.LCPI6_0(%rip), %xmm0
	movl	$.L.str.3, %edi
	movb	$1, %al
	callq	printf
.LBB6_7:                                #   in Loop: Header=BB6_1 Depth=1
	incl	%r12d
	cmpl	$1000, %r12d                    # imm = 0x3E8
	jne	.LBB6_1
# %bb.8:
.Ltmp14:
	leaq	376(%rsp), %rdi
	callq	_ZNSt14basic_ofstreamIcSt11char_traitsIcEE5closeEv
.Ltmp15:
# %bb.9:
.Ltmp17:
	leaq	888(%rsp), %rdi
	movl	$.L.str.4, %esi
	movl	$16, %edx
	callq	_ZNSt14basic_ofstreamIcSt11char_traitsIcEEC1EPKcSt13_Ios_Openmode
.Ltmp18:
# %bb.10:                               # %.preheader
	movl	$65535, %r15d                   # imm = 0xFFFF
	leaq	888(%rsp), %r12
	xorl	%r13d, %r13d
.LBB6_11:                               # %_ZN6params16set_frame_numberEii.exit51
                                        # =>This Inner Loop Header: Depth=1
	movl	$.L.str.5, %esi
	movq	%rbx, %rdi
	movl	%r13d, %edx
	xorl	%eax, %eax
	callq	sprintf
	cvtsi2sd	%r13d, %xmm1
	movsd	%xmm1, 112(%rsp)                # 8-byte Spill
	divsd	.LCPI6_0(%rip), %xmm1
	movsd	.LCPI6_1(%rip), %xmm0           # xmm0 = mem[0],zero
	callq	pow
	movsd	.LCPI6_2(%rip), %xmm1           # xmm1 = mem[0],zero
	subsd	%xmm0, %xmm1
	movapd	%xmm1, %xmm0
	mulsd	.LCPI6_3(%rip), %xmm0
	addsd	.LCPI6_4(%rip), %xmm0
	movsd	%xmm0, 144(%rsp)                # 8-byte Spill
	movapd	%xmm1, %xmm0
	mulsd	.LCPI6_5(%rip), %xmm0
	addsd	.LCPI6_6(%rip), %xmm0
	movsd	%xmm0, 136(%rsp)                # 8-byte Spill
	movapd	%xmm1, %xmm0
	mulsd	.LCPI6_7(%rip), %xmm0
	addsd	.LCPI6_8(%rip), %xmm0
	movsd	%xmm0, 128(%rsp)                # 8-byte Spill
	mulsd	.LCPI6_9(%rip), %xmm1
	addsd	.LCPI6_10(%rip), %xmm1
	movsd	%xmm1, 120(%rsp)                # 8-byte Spill
	callq	clock
	movq	%rax, %r14
	movabsq	$-4609749470587618591, %rax     # imm = 0xC006E147AE147AE1
	movq	%rax, 152(%rsp)
	movabsq	$-4627801699333970487, %rax     # imm = 0xBFC6BEDFA43FE5C9
	movq	%rax, 160(%rsp)
	movabsq	$4611055514479556035, %rax      # imm = 0x3FFDC28F5C28F5C3
	movq	%rax, 168(%rsp)
	movabsq	$-4630103939463482284, %rax     # imm = 0xBFBE90FF97247454
	movq	%rax, 176(%rsp)
	movabsq	$-4614703430177726136, %rax     # imm = 0xBFF547AE147AE148
	movq	%rax, 184(%rsp)
	movabsq	$4607244568474875121, %rax      # imm = 0x3FF03886594AF4F1
	movq	%rax, 192(%rsp)
	movabsq	$4608668606677049672, %rax      # imm = 0x3FF547AE147AE148
	movq	%rax, 200(%rsp)
	movabsq	$4607394988702429295, %rax      # imm = 0x3FF0C154C985F06F
	movq	%rax, 208(%rsp)
	movabsq	$4638564681600, %rax            # imm = 0x43800000780
	movq	%rax, 216(%rsp)
	movsd	144(%rsp), %xmm0                # 8-byte Reload
                                        # xmm0 = mem[0],zero
	movsd	%xmm0, 224(%rsp)
	movsd	136(%rsp), %xmm0                # 8-byte Reload
                                        # xmm0 = mem[0],zero
	movsd	%xmm0, 232(%rsp)
	movsd	128(%rsp), %xmm0                # 8-byte Reload
                                        # xmm0 = mem[0],zero
	movsd	%xmm0, 240(%rsp)
	movsd	120(%rsp), %xmm0                # 8-byte Reload
                                        # xmm0 = mem[0],zero
	movsd	%xmm0, 248(%rsp)
	movl	$50, 256(%rsp)
.Ltmp20:
	movl	$14, %ecx
	movq	%rsp, %rdi
	leaq	152(%rsp), %rsi
	rep;movsq (%rsi), %es:(%rdi)
	movq	%rbx, %rdi
	callq	_Z14plot_frame_cpu6paramsPc
.Ltmp21:
# %bb.12:                               #   in Loop: Header=BB6_11 Depth=1
	callq	clock
	subq	%r14, %rax
	xorps	%xmm0, %xmm0
	cvtsi2sd	%rax, %xmm0
	mulsd	.LCPI6_0(%rip), %xmm0
	divsd	.LCPI6_11(%rip), %xmm0
.Ltmp22:
	movq	%r12, %rdi
	callq	_ZNSo9_M_insertIdEERSoT_
.Ltmp23:
# %bb.13:                               # %_ZNSolsEd.exit52
                                        #   in Loop: Header=BB6_11 Depth=1
.Ltmp24:
	movl	$.L.str.2, %esi
	movl	$1, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp25:
# %bb.14:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit53
                                        #   in Loop: Header=BB6_11 Depth=1
	cmpl	$1, %ebp
	je	.LBB6_17
# %bb.15:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit53
                                        #   in Loop: Header=BB6_11 Depth=1
	movl	%r13d, %eax
	andl	%r15d, %eax
	imull	$52429, %eax, %eax              # imm = 0xCCCD
	shrl	$18, %eax
	andl	$-2, %eax
	leal	(%rax,%rax,4), %eax
	negl	%eax
	andl	%r15d, %eax
	addl	%r13d, %eax
	testw	%ax, %ax
	jne	.LBB6_17
# %bb.16:                               #   in Loop: Header=BB6_11 Depth=1
	movsd	112(%rsp), %xmm0                # 8-byte Reload
                                        # xmm0 = mem[0],zero
	mulsd	.LCPI6_12(%rip), %xmm0
	divsd	.LCPI6_0(%rip), %xmm0
	movl	$.L.str.6, %edi
	movb	$1, %al
	callq	printf
.LBB6_17:                               #   in Loop: Header=BB6_11 Depth=1
	incl	%r13d
	cmpl	$1000, %r13d                    # imm = 0x3E8
	jne	.LBB6_11
# %bb.18:
.Ltmp27:
	leaq	888(%rsp), %r14
	movq	%r14, %rdi
	callq	_ZNSt14basic_ofstreamIcSt11char_traitsIcEE5closeEv
.Ltmp28:
# %bb.19:
	testq	%rbx, %rbx
	je	.LBB6_21
# %bb.20:
	movq	%rbx, %rdi
	callq	_ZdaPv
.LBB6_21:
	movq	_ZTTSt14basic_ofstreamIcSt11char_traitsIcEE(%rip), %rbx
	leaq	896(%rsp), %rdi
	movq	%rbx, -8(%rdi)
	movq	_ZTTSt14basic_ofstreamIcSt11char_traitsIcEE+24(%rip), %r15
	movq	-24(%rbx), %rax
	movq	%r15, 888(%rsp,%rax)
	callq	_ZNSt13basic_filebufIcSt11char_traitsIcEED2Ev
	movl	$248, %r12d
	addq	%r12, %r14
	movq	%r14, %rdi
	callq	_ZNSt8ios_baseD2Ev
	leaq	384(%rsp), %rdi
	movq	%rbx, -8(%rdi)
	movq	-24(%rbx), %rax
	movq	%r15, 376(%rsp,%rax)
	callq	_ZNSt13basic_filebufIcSt11char_traitsIcEED2Ev
	leaq	376(%rsp), %rdi
	addq	%r12, %rdi
	callq	_ZNSt8ios_baseD2Ev
	xorl	%eax, %eax
	addq	$1400, %rsp                     # imm = 0x578
	.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
.LBB6_22:
	.cfi_def_cfa_offset 1456
.Ltmp29:
	jmp	.LBB6_26
.LBB6_23:
.Ltmp19:
	jmp	.LBB6_28
.LBB6_24:
.Ltmp16:
	jmp	.LBB6_28
.LBB6_25:
.Ltmp26:
.LBB6_26:
	movq	%rax, %rbx
	leaq	888(%rsp), %rdi
	callq	_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev
	jmp	.LBB6_29
.LBB6_27:
.Ltmp13:
.LBB6_28:
	movq	%rax, %rbx
.LBB6_29:
	leaq	376(%rsp), %rdi
	callq	_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev
	movq	%rbx, %rdi
	callq	_Unwind_Resume@PLT
.Lfunc_end6:
	.size	main, .Lfunc_end6-main
	.cfi_endproc
	.section	.gcc_except_table,"a",@progbits
	.p2align	2, 0x0
GCC_except_table6:
.Lexception1:
	.byte	255                             # @LPStart Encoding = omit
	.byte	255                             # @TType Encoding = omit
	.byte	1                               # Call site Encoding = uleb128
	.uleb128 .Lcst_end1-.Lcst_begin1
.Lcst_begin1:
	.uleb128 .Lfunc_begin1-.Lfunc_begin1    # >> Call Site 1 <<
	.uleb128 .Ltmp7-.Lfunc_begin1           #   Call between .Lfunc_begin1 and .Ltmp7
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp7-.Lfunc_begin1           # >> Call Site 2 <<
	.uleb128 .Ltmp12-.Ltmp7                 #   Call between .Ltmp7 and .Ltmp12
	.uleb128 .Ltmp13-.Lfunc_begin1          #     jumps to .Ltmp13
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp14-.Lfunc_begin1          # >> Call Site 3 <<
	.uleb128 .Ltmp15-.Ltmp14                #   Call between .Ltmp14 and .Ltmp15
	.uleb128 .Ltmp16-.Lfunc_begin1          #     jumps to .Ltmp16
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp17-.Lfunc_begin1          # >> Call Site 4 <<
	.uleb128 .Ltmp18-.Ltmp17                #   Call between .Ltmp17 and .Ltmp18
	.uleb128 .Ltmp19-.Lfunc_begin1          #     jumps to .Ltmp19
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp20-.Lfunc_begin1          # >> Call Site 5 <<
	.uleb128 .Ltmp25-.Ltmp20                #   Call between .Ltmp20 and .Ltmp25
	.uleb128 .Ltmp26-.Lfunc_begin1          #     jumps to .Ltmp26
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp27-.Lfunc_begin1          # >> Call Site 6 <<
	.uleb128 .Ltmp28-.Ltmp27                #   Call between .Ltmp27 and .Ltmp28
	.uleb128 .Ltmp29-.Lfunc_begin1          #     jumps to .Ltmp29
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp28-.Lfunc_begin1          # >> Call Site 7 <<
	.uleb128 .Lfunc_end6-.Ltmp28            #   Call between .Ltmp28 and .Lfunc_end6
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
.Lcst_end1:
	.p2align	2, 0x0
                                        # -- End function
	.text
	.p2align	4, 0x90                         # -- Begin function __hip_module_ctor
	.type	__hip_module_ctor,@function
__hip_module_ctor:                      # @__hip_module_ctor
	.cfi_startproc
# %bb.0:
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	jne	.LBB7_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB7_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z8populatePcddddiii, %esi
	movl	$.L__unnamed_1, %edx
	movl	$.L__unnamed_1, %ecx
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	movl	$__hip_module_dtor, %edi
	addq	$40, %rsp
	.cfi_def_cfa_offset 8
	jmp	atexit                          # TAILCALL
.Lfunc_end7:
	.size	__hip_module_ctor, .Lfunc_end7-__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	.LBB8_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
.LBB8_2:
	retq
.Lfunc_end8:
	.size	__hip_module_dtor, .Lfunc_end8-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	_Z8populatePcddddiii,@object    # @_Z8populatePcddddiii
	.section	.rodata,"a",@progbits
	.globl	_Z8populatePcddddiii
	.p2align	3, 0x0
_Z8populatePcddddiii:
	.quad	_Z23__device_stub__populatePcddddiii
	.size	_Z8populatePcddddiii, 8

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"/home/keshav/Dropbox (MIT)/anim_gpu/log_gpu.txt"
	.size	.L.str, 48

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"/home/keshav/Dropbox (MIT)/anim_gpu/i%03d.bmp"
	.size	.L.str.1, 46

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

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"Done %2.2f%% on GPU.\n"
	.size	.L.str.3, 22

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"/home/keshav/Dropbox (MIT)/anim_cpu/log_cpu.txt"
	.size	.L.str.4, 48

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"/home/keshav/Dropbox (MIT)/anim_cpu/i%03d.bmp"
	.size	.L.str.5, 46

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"Done %2.2f%% on CPU.\n"
	.size	.L.str.6, 22

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z8populatePcddddiii"
	.size	.L__unnamed_1, 21

	.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 __gxx_personality_v0
	.addrsig_sym _Z23__device_stub__populatePcddddiii
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Unwind_Resume
	.addrsig_sym _Z8populatePcddddiii
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z8populatePcddddiii    ; -- Begin function _Z8populatePcddddiii
	.globl	_Z8populatePcddddiii
	.p2align	8
	.type	_Z8populatePcddddiii,@function
_Z8populatePcddddiii:                   ; @_Z8populatePcddddiii
; %bb.0:
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x44
	s_load_b128 s[16:19], s[0:1], 0x28
	v_and_b32_e32 v2, 0x3ff, v0
	v_bfe_u32 v3, v0, 10, 10
	s_waitcnt lgkmcnt(0)
	s_lshr_b32 s3, s2, 16
	s_and_b32 s2, s2, 0xffff
	s_delay_alu instid0(VALU_DEP_1) | instid1(SALU_CYCLE_1)
	v_mad_u64_u32 v[0:1], null, s14, s2, v[2:3]
	v_mad_u64_u32 v[1:2], null, s15, s3, v[3:4]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_cmp_gt_i32_e32 vcc_lo, s16, v0
	v_cmp_gt_i32_e64 s2, s17, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_and_b32 s2, vcc_lo, s2
	s_and_saveexec_b32 s3, s2
	s_cbranch_execz .LBB0_11
; %bb.1:
	s_clause 0x1
	s_load_b256 s[4:11], s[0:1], 0x0
	s_load_b64 s[2:3], s[0:1], 0x20
	s_cmp_lt_i32 s18, 1
	s_cbranch_scc1 .LBB0_9
; %bb.2:                                ; %.lr.ph.i.preheader
	v_cvt_f64_i32_e32 v[2:3], v0
	v_cvt_f64_i32_e32 v[4:5], s16
	v_cvt_f64_i32_e32 v[6:7], v1
	v_cvt_f64_i32_e32 v[8:9], s17
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_div_scale_f64 v[10:11], null, v[4:5], v[4:5], v[2:3]
	v_div_scale_f64 v[12:13], null, v[8:9], v[8:9], v[6:7]
	v_div_scale_f64 v[22:23], vcc_lo, v[2:3], v[4:5], v[2:3]
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_rcp_f64_e32 v[14:15], v[10:11]
	v_rcp_f64_e32 v[16:17], v[12:13]
	s_waitcnt_depctr 0xfff
	v_fma_f64 v[18:19], -v[10:11], v[14:15], 1.0
	v_fma_f64 v[20:21], -v[12:13], v[16:17], 1.0
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_fma_f64 v[14:15], v[14:15], v[18:19], v[14:15]
	v_fma_f64 v[16:17], v[16:17], v[20:21], v[16:17]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_fma_f64 v[18:19], -v[10:11], v[14:15], 1.0
	v_fma_f64 v[20:21], -v[12:13], v[16:17], 1.0
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_3)
	v_fma_f64 v[14:15], v[14:15], v[18:19], v[14:15]
	v_div_scale_f64 v[18:19], s0, v[6:7], v[8:9], v[6:7]
	v_fma_f64 v[16:17], v[16:17], v[20:21], v[16:17]
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_mul_f64 v[20:21], v[22:23], v[14:15]
	v_mul_f64 v[24:25], v[18:19], v[16:17]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_fma_f64 v[10:11], -v[10:11], v[20:21], v[22:23]
	v_fma_f64 v[12:13], -v[12:13], v[24:25], v[18:19]
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_3) | instid1(VALU_DEP_3)
	v_div_fmas_f64 v[10:11], v[10:11], v[14:15], v[20:21]
	s_mov_b32 vcc_lo, s0
	s_waitcnt lgkmcnt(0)
	v_add_f64 v[14:15], s[8:9], -s[6:7]
	v_div_fmas_f64 v[12:13], v[12:13], v[16:17], v[24:25]
                                        ; implicit-def: $sgpr8
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_div_fixup_f64 v[2:3], v[10:11], v[4:5], v[2:3]
	v_div_fixup_f64 v[6:7], v[12:13], v[8:9], v[6:7]
	v_add_f64 v[8:9], s[2:3], -s[10:11]
	s_mov_b32 s2, 0
                                        ; implicit-def: $sgpr3
	s_delay_alu instid0(VALU_DEP_3) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_fma_f64 v[4:5], v[14:15], v[2:3], s[6:7]
	s_mov_b32 s6, 0
                                        ; implicit-def: $sgpr7
	v_fma_f64 v[6:7], v[8:9], v[6:7], s[10:11]
	v_mov_b32_e32 v8, 0
	v_mov_b32_e32 v9, 0
	s_delay_alu instid0(VALU_DEP_1)
	v_dual_mov_b32 v11, v9 :: v_dual_mov_b32 v10, v8
.LBB0_3:                                ; %.lr.ph.i
                                        ; =>This Inner Loop Header: Depth=1
	s_delay_alu instid0(VALU_DEP_1)
	v_mul_f64 v[2:3], v[10:11], v[10:11]
	v_add_f64 v[12:13], v[8:9], v[8:9]
	s_add_i32 s6, s6, 1
	s_or_b32 s7, s7, exec_lo
	s_or_b32 s8, s8, exec_lo
	s_mov_b32 s9, exec_lo
                                        ; implicit-def: $sgpr0_sgpr1
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_fma_f64 v[2:3], v[8:9], v[8:9], -v[2:3]
	v_fma_f64 v[10:11], v[10:11], v[12:13], v[6:7]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[8:9], v[4:5], v[2:3]
	v_mul_f64 v[2:3], v[8:9], v[8:9]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[2:3], v[10:11], v[10:11], v[2:3]
	v_cmpx_nlt_f64_e32 4.0, v[2:3]
; %bb.4:                                ;   in Loop: Header=BB0_3 Depth=1
	s_cmp_eq_u32 s18, s6
	s_mov_b64 s[0:1], 0
	s_cselect_b32 s10, -1, 0
	s_and_not1_b32 s8, s8, exec_lo
	s_and_b32 s10, s10, exec_lo
	s_and_not1_b32 s7, s7, exec_lo
	s_or_b32 s8, s8, s10
; %bb.5:                                ; %Flow80
                                        ;   in Loop: Header=BB0_3 Depth=1
	s_or_b32 exec_lo, exec_lo, s9
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_b32 s9, exec_lo, s8
	v_dual_mov_b32 v13, s1 :: v_dual_mov_b32 v12, s0
	s_or_b32 s2, s9, s2
	v_mov_b32_e32 v14, s6
	s_and_not1_b32 s0, s3, exec_lo
	s_and_b32 s1, s7, exec_lo
	s_delay_alu instid0(SALU_CYCLE_1)
	s_or_b32 s3, s0, s1
	s_and_not1_b32 exec_lo, exec_lo, s2
	s_cbranch_execnz .LBB0_3
; %bb.6:                                ; %loop.exit.guard
	s_or_b32 exec_lo, exec_lo, s2
	s_and_saveexec_b32 s0, s3
	s_delay_alu instid0(SALU_CYCLE_1)
	s_xor_b32 s17, exec_lo, s0
	s_cbranch_execz .LBB0_8
; %bb.7:
	v_frexp_mant_f64_e32 v[4:5], v[2:3]
	s_mov_b32 s2, 0x55555555
	s_mov_b32 s3, 0x3fe55555
	s_mov_b32 s6, 0x6b47b09a
	s_mov_b32 s8, 0xbf559e2b
	s_mov_b32 s7, 0x3fc38538
	s_mov_b32 s9, 0x3fc3ab76
	s_mov_b32 s10, 0xd7f4df2e
	s_mov_b32 s11, 0x3fc7474d
	s_mov_b32 s12, 0x16291751
	s_mov_b32 s13, 0x3fcc71c0
	s_mov_b32 s14, 0x9b27acf1
	s_mov_b32 s15, 0x3fd24924
	s_mov_b32 s20, 0x998ef7b6
	s_mov_b32 s21, 0x3fd99999
	s_mov_b32 s22, 0x55555780
	s_mov_b32 s23, s3
	s_mov_b32 s0, 0xfefa39ef
	s_mov_b32 s1, 0x3fe62e42
	s_mov_b32 s24, 0x3b39803f
	s_mov_b32 s25, 0x3c7abc9e
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_cmp_gt_f64_e32 vcc_lo, s[2:3], v[4:5]
	v_cndmask_b32_e64 v6, 0, 1, vcc_lo
	v_ldexp_f64 v[4:5], v[4:5], v6
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_add_f64 v[6:7], v[4:5], 1.0
	v_add_f64 v[12:13], v[4:5], -1.0
	v_rcp_f64_e32 v[8:9], v[6:7]
	v_add_f64 v[15:16], v[6:7], -1.0
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_1)
	v_add_f64 v[4:5], v[4:5], -v[15:16]
	s_waitcnt_depctr 0xfff
	v_fma_f64 v[10:11], -v[6:7], v[8:9], 1.0
	v_fma_f64 v[8:9], v[10:11], v[8:9], v[8:9]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[10:11], -v[6:7], v[8:9], 1.0
	v_fma_f64 v[8:9], v[10:11], v[8:9], v[8:9]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_f64 v[10:11], v[12:13], v[8:9]
	v_mul_f64 v[17:18], v[6:7], v[10:11]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[6:7], v[10:11], v[6:7], -v[17:18]
	v_fma_f64 v[4:5], v[10:11], v[4:5], v[6:7]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[6:7], v[17:18], v[4:5]
	v_add_f64 v[15:16], v[12:13], -v[6:7]
	v_add_f64 v[17:18], v[6:7], -v[17:18]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_f64 v[12:13], v[12:13], -v[15:16]
	v_add_f64 v[4:5], v[17:18], -v[4:5]
	v_frexp_exp_i32_f64_e32 v17, v[2:3]
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[6:7], v[12:13], -v[6:7]
	v_add_f64 v[4:5], v[4:5], v[6:7]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[4:5], v[15:16], v[4:5]
	v_mul_f64 v[4:5], v[8:9], v[4:5]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[6:7], v[10:11], v[4:5]
	v_mul_f64 v[8:9], v[6:7], v[6:7]
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_fma_f64 v[12:13], v[8:9], s[8:9], s[6:7]
	v_mul_f64 v[15:16], v[6:7], v[8:9]
	v_fma_f64 v[12:13], v[8:9], v[12:13], s[10:11]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[12:13], v[8:9], v[12:13], s[12:13]
	v_fma_f64 v[12:13], v[8:9], v[12:13], s[14:15]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[12:13], v[8:9], v[12:13], s[20:21]
	v_fma_f64 v[8:9], v[8:9], v[12:13], s[22:23]
	v_ldexp_f64 v[12:13], v[6:7], 1
	v_add_f64 v[6:7], v[6:7], -v[10:11]
	s_delay_alu instid0(VALU_DEP_3) | instskip(SKIP_1) | instid1(VALU_DEP_3)
	v_mul_f64 v[8:9], v[15:16], v[8:9]
	v_subrev_co_ci_u32_e32 v15, vcc_lo, 0, v17, vcc_lo
	v_add_f64 v[4:5], v[4:5], -v[6:7]
	v_cmp_class_f64_e64 vcc_lo, v[2:3], 0x204
	s_delay_alu instid0(VALU_DEP_3) | instskip(SKIP_1) | instid1(VALU_DEP_4)
	v_cvt_f64_i32_e32 v[15:16], v15
	v_add_f64 v[10:11], v[12:13], v[8:9]
	v_ldexp_f64 v[4:5], v[4:5], 1
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_mul_f64 v[17:18], v[15:16], s[0:1]
	v_add_f64 v[6:7], v[10:11], -v[12:13]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_fma_f64 v[12:13], v[15:16], s[0:1], -v[17:18]
	v_add_f64 v[6:7], v[8:9], -v[6:7]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_fma_f64 v[8:9], v[15:16], s[24:25], v[12:13]
	v_add_f64 v[4:5], v[4:5], v[6:7]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_f64 v[6:7], v[17:18], v[8:9]
	v_add_f64 v[12:13], v[10:11], v[4:5]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_f64 v[17:18], v[6:7], -v[17:18]
	v_add_f64 v[15:16], v[6:7], v[12:13]
	v_add_f64 v[10:11], v[12:13], -v[10:11]
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_f64 v[8:9], v[8:9], -v[17:18]
	v_add_f64 v[19:20], v[15:16], -v[6:7]
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_f64 v[4:5], v[4:5], -v[10:11]
	v_add_f64 v[21:22], v[15:16], -v[19:20]
	v_add_f64 v[10:11], v[12:13], -v[19:20]
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_f64 v[12:13], v[8:9], v[4:5]
	v_add_f64 v[6:7], v[6:7], -v[21:22]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_f64 v[6:7], v[10:11], v[6:7]
	v_add_f64 v[10:11], v[12:13], -v[8:9]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_f64 v[6:7], v[12:13], v[6:7]
	v_add_f64 v[12:13], v[12:13], -v[10:11]
	v_add_f64 v[4:5], v[4:5], -v[10:11]
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_f64 v[17:18], v[15:16], v[6:7]
	v_add_f64 v[8:9], v[8:9], -v[12:13]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_f64 v[10:11], v[17:18], -v[15:16]
	v_add_f64 v[4:5], v[4:5], v[8:9]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[6:7], v[6:7], -v[10:11]
	v_add_f64 v[4:5], v[4:5], v[6:7]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[4:5], v[17:18], v[4:5]
	v_dual_cndmask_b32 v4, v4, v2 :: v_dual_cndmask_b32 v5, v5, v3
	v_cmp_neq_f64_e32 vcc_lo, 0, v[2:3]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_cndmask_b32_e32 v3, 0xfff00000, v5, vcc_lo
	v_cndmask_b32_e32 v2, 0, v4, vcc_lo
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_frexp_mant_f64_e32 v[4:5], v[2:3]
	v_cmp_gt_f64_e32 vcc_lo, s[2:3], v[4:5]
	v_cndmask_b32_e64 v6, 0, 1, vcc_lo
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ldexp_f64 v[4:5], v[4:5], v6
	v_add_f64 v[6:7], v[4:5], 1.0
	v_add_f64 v[12:13], v[4:5], -1.0
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_rcp_f64_e32 v[8:9], v[6:7]
	v_add_f64 v[15:16], v[6:7], -1.0
	v_add_f64 v[4:5], v[4:5], -v[15:16]
	s_waitcnt_depctr 0xfff
	v_fma_f64 v[10:11], -v[6:7], v[8:9], 1.0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[8:9], v[10:11], v[8:9], v[8:9]
	v_fma_f64 v[10:11], -v[6:7], v[8:9], 1.0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[8:9], v[10:11], v[8:9], v[8:9]
	v_mul_f64 v[10:11], v[12:13], v[8:9]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_f64 v[17:18], v[6:7], v[10:11]
	v_fma_f64 v[6:7], v[10:11], v[6:7], -v[17:18]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[4:5], v[10:11], v[4:5], v[6:7]
	v_add_f64 v[6:7], v[17:18], v[4:5]
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_add_f64 v[15:16], v[12:13], -v[6:7]
	v_add_f64 v[17:18], v[6:7], -v[17:18]
	v_add_f64 v[12:13], v[12:13], -v[15:16]
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_3)
	v_add_f64 v[4:5], v[17:18], -v[4:5]
	v_frexp_exp_i32_f64_e32 v17, v[2:3]
	v_add_f64 v[6:7], v[12:13], -v[6:7]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[4:5], v[4:5], v[6:7]
	v_add_f64 v[4:5], v[15:16], v[4:5]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_f64 v[4:5], v[8:9], v[4:5]
	v_add_f64 v[6:7], v[10:11], v[4:5]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_f64 v[8:9], v[6:7], v[6:7]
	v_fma_f64 v[12:13], v[8:9], s[8:9], s[6:7]
	v_mul_f64 v[15:16], v[6:7], v[8:9]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[12:13], v[8:9], v[12:13], s[10:11]
	v_fma_f64 v[12:13], v[8:9], v[12:13], s[12:13]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[12:13], v[8:9], v[12:13], s[14:15]
	v_fma_f64 v[12:13], v[8:9], v[12:13], s[20:21]
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_3)
	v_fma_f64 v[8:9], v[8:9], v[12:13], s[22:23]
	v_ldexp_f64 v[12:13], v[6:7], 1
	v_add_f64 v[6:7], v[6:7], -v[10:11]
	v_mul_f64 v[8:9], v[15:16], v[8:9]
	v_subrev_co_ci_u32_e32 v15, vcc_lo, 0, v17, vcc_lo
	s_delay_alu instid0(VALU_DEP_3) | instskip(SKIP_1) | instid1(VALU_DEP_3)
	v_add_f64 v[4:5], v[4:5], -v[6:7]
	v_cmp_class_f64_e64 vcc_lo, v[2:3], 0x204
	v_cvt_f64_i32_e32 v[15:16], v15
	v_add_f64 v[10:11], v[12:13], v[8:9]
	s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_ldexp_f64 v[4:5], v[4:5], 1
	v_mul_f64 v[17:18], v[15:16], s[0:1]
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_f64 v[6:7], v[10:11], -v[12:13]
	v_fma_f64 v[12:13], v[15:16], s[0:1], -v[17:18]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_f64 v[6:7], v[8:9], -v[6:7]
	v_fma_f64 v[8:9], v[15:16], s[24:25], v[12:13]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_f64 v[4:5], v[4:5], v[6:7]
	v_add_f64 v[6:7], v[17:18], v[8:9]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_f64 v[12:13], v[10:11], v[4:5]
	v_add_f64 v[17:18], v[6:7], -v[17:18]
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_3)
	v_add_f64 v[15:16], v[6:7], v[12:13]
	v_add_f64 v[10:11], v[12:13], -v[10:11]
	v_add_f64 v[8:9], v[8:9], -v[17:18]
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_f64 v[19:20], v[15:16], -v[6:7]
	v_add_f64 v[4:5], v[4:5], -v[10:11]
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_3)
	v_add_f64 v[21:22], v[15:16], -v[19:20]
	v_add_f64 v[10:11], v[12:13], -v[19:20]
	v_add_f64 v[12:13], v[8:9], v[4:5]
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[6:7], v[6:7], -v[21:22]
	v_add_f64 v[6:7], v[10:11], v[6:7]
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_f64 v[10:11], v[12:13], -v[8:9]
	v_add_f64 v[6:7], v[12:13], v[6:7]
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_3)
	v_add_f64 v[12:13], v[12:13], -v[10:11]
	v_add_f64 v[4:5], v[4:5], -v[10:11]
	v_add_f64 v[17:18], v[15:16], v[6:7]
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_f64 v[8:9], v[8:9], -v[12:13]
	v_add_f64 v[10:11], v[17:18], -v[15:16]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_f64 v[4:5], v[4:5], v[8:9]
	v_add_f64 v[6:7], v[6:7], -v[10:11]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[4:5], v[4:5], v[6:7]
	v_add_f64 v[4:5], v[17:18], v[4:5]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_dual_cndmask_b32 v5, v5, v3 :: v_dual_cndmask_b32 v4, v4, v2
	v_div_scale_f64 v[6:7], null, s[0:1], s[0:1], v[4:5]
	v_div_scale_f64 v[12:13], vcc_lo, v[4:5], s[0:1], v[4:5]
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_2) | instid1(VALU_DEP_1)
	v_rcp_f64_e32 v[8:9], v[6:7]
	s_waitcnt_depctr 0xfff
	v_fma_f64 v[10:11], -v[6:7], v[8:9], 1.0
	v_fma_f64 v[8:9], v[8:9], v[10:11], v[8:9]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[10:11], -v[6:7], v[8:9], 1.0
	v_fma_f64 v[8:9], v[8:9], v[10:11], v[8:9]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_f64 v[10:11], v[12:13], v[8:9]
	v_fma_f64 v[6:7], -v[6:7], v[10:11], v[12:13]
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_div_fmas_f64 v[6:7], v[6:7], v[8:9], v[10:11]
	v_cmp_ngt_f64_e32 vcc_lo, 0, v[2:3]
	v_div_fixup_f64 v[4:5], v[6:7], s[0:1], v[4:5]
	v_cvt_f64_i32_e32 v[6:7], v14
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_4)
	v_cndmask_b32_e32 v5, 0x7ff80000, v5, vcc_lo
	v_cmp_nge_f64_e32 vcc_lo, 0, v[2:3]
	v_cndmask_b32_e32 v4, 0, v4, vcc_lo
	v_cmp_neq_f64_e32 vcc_lo, 0, v[2:3]
	v_cvt_f64_i32_e32 v[2:3], s18
	v_cndmask_b32_e32 v5, 0xfff00000, v5, vcc_lo
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[4:5], v[6:7], -v[4:5]
	v_div_scale_f64 v[6:7], null, v[2:3], v[2:3], v[4:5]
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_1)
	v_rcp_f64_e32 v[8:9], v[6:7]
	s_waitcnt_depctr 0xfff
	v_fma_f64 v[10:11], -v[6:7], v[8:9], 1.0
	v_fma_f64 v[8:9], v[8:9], v[10:11], v[8:9]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[10:11], -v[6:7], v[8:9], 1.0
	v_fma_f64 v[8:9], v[8:9], v[10:11], v[8:9]
	v_div_scale_f64 v[10:11], vcc_lo, v[4:5], v[2:3], v[4:5]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_f64 v[12:13], v[10:11], v[8:9]
	v_fma_f64 v[6:7], -v[6:7], v[12:13], v[10:11]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_div_fmas_f64 v[6:7], v[6:7], v[8:9], v[12:13]
	v_div_fixup_f64 v[12:13], v[6:7], v[2:3], v[4:5]
.LBB0_8:                                ; %Flow
	s_or_b32 exec_lo, exec_lo, s17
	s_branch .LBB0_10
.LBB0_9:
	v_mov_b32_e32 v12, 0
	v_mov_b32_e32 v13, 0
.LBB0_10:                               ; %_Z4iterddi.exit
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_cmp_gt_f64_e32 vcc_lo, 0x10000000, v[12:13]
	v_cndmask_b32_e64 v2, 0, 1, vcc_lo
	v_lshlrev_b32_e32 v2, 8, v2
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ldexp_f64 v[2:3], v[12:13], v2
	v_rsq_f64_e32 v[4:5], v[2:3]
	s_waitcnt_depctr 0xfff
	v_mul_f64 v[6:7], v[2:3], v[4:5]
	v_mul_f64 v[4:5], v[4:5], 0.5
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[8:9], -v[4:5], v[6:7], 0.5
	v_fma_f64 v[6:7], v[6:7], v[8:9], v[6:7]
	v_fma_f64 v[4:5], v[4:5], v[8:9], v[4:5]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[8:9], -v[6:7], v[6:7], v[2:3]
	v_fma_f64 v[6:7], v[8:9], v[4:5], v[6:7]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[8:9], -v[6:7], v[6:7], v[2:3]
	v_fma_f64 v[4:5], v[8:9], v[4:5], v[6:7]
	v_cndmask_b32_e64 v6, 0, 0xffffff80, vcc_lo
	v_cmp_class_f64_e64 vcc_lo, v[2:3], 0x260
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_ldexp_f64 v[4:5], v[4:5], v6
	v_mul_f64 v[6:7], 0x406fe000, v[12:13]
	v_dual_cndmask_b32 v3, v5, v3 :: v_dual_cndmask_b32 v2, v4, v2
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_3)
	v_mul_f64 v[4:5], v[12:13], v[6:7]
	v_cvt_i32_f64_e32 v6, v[6:7]
	v_mul_f64 v[2:3], 0x406fe000, v[2:3]
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_cvt_i32_f64_e32 v4, v[4:5]
	v_cvt_i32_f64_e32 v8, v[2:3]
	v_mad_u64_u32 v[2:3], null, v1, s16, v[0:1]
	v_lshlrev_b16 v3, 8, v6
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshl_add_u32 v0, v2, 1, v2
	v_ashrrev_i32_e32 v1, 31, v0
	s_waitcnt lgkmcnt(0)
	v_add_co_u32 v0, vcc_lo, s4, v0
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_add_co_ci_u32_e32 v1, vcc_lo, s5, v1, vcc_lo
	v_and_b32_e32 v2, 0xff, v8
	v_or_b32_e32 v2, v2, v3
	s_clause 0x1
	global_store_b8 v[0:1], v4, off offset:2
	global_store_b16 v[0:1], v2, off
.LBB0_11:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z8populatePcddddiii
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 312
		.amdhsa_user_sgpr_count 14
		.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 1
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 1
		.amdhsa_next_free_vgpr 26
		.amdhsa_next_free_sgpr 26
		.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	_Z8populatePcddddiii, .Lfunc_end0-_Z8populatePcddddiii
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 2824
; NumSgprs: 28
; NumVgprs: 26
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 3
; VGPRBlocks: 3
; NumSGPRsForWavesPerEU: 28
; NumVGPRsForWavesPerEU: 26
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 14
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 1
	.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
      - .offset:         8
        .size:           8
        .value_kind:     by_value
      - .offset:         16
        .size:           8
        .value_kind:     by_value
      - .offset:         24
        .size:           8
        .value_kind:     by_value
      - .offset:         32
        .size:           8
        .value_kind:     by_value
      - .offset:         40
        .size:           4
        .value_kind:     by_value
      - .offset:         44
        .size:           4
        .value_kind:     by_value
      - .offset:         48
        .size:           4
        .value_kind:     by_value
      - .offset:         56
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         60
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         64
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         68
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         70
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         72
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         74
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         76
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         78
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         96
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         104
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         112
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         120
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 312
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z8populatePcddddiii
    .private_segment_fixed_size: 0
    .sgpr_count:     28
    .sgpr_spill_count: 0
    .symbol:         _Z8populatePcddddiii.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     26
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
