// File: /workspace/github_cpp_makefile_star2_O1/Luthaf[P]zeopp/grid.cc
// Function: generateBOVGrid(ATOM_NETWORK*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void generateBOVGrid(ATOM_NETWORK *atmnet, string name_f_dist, string name_g_dist, string name_h_dist, string name_f_bov, string name_g_bov, string name_h_bov) {

//-----declare large 3D array as a 3D pointer (i.e., ***) - we have to declare it as pointers otherwise we cannot declare an arbitrarily large grid - but if the grid is too large, you may not have enough RAM to store it, so watch the system monitor!
  double ***grid_distance;

//-----set the extent of the grid. If we know coordinate H (i.e. the coordinate in the abc plane that has all non-0 coordinates) we will know the maximum extent. 
//For my purposes, I defined a cube in terms of corners. A, B, and C correspond to defined unit cell vectors.
//D is the bottom corner between the B and C axes. E is the top corner between the A and C axes.
//F is the top corner between the B and C axes. G is the outermost corner. The innermost corner is simply (0, 0, 0).

  double origin_x = 0; 
  double origin_y = 0; 
  double origin_z = 0; 
  double Ax  = atmnet->v_a.x;
  double Bx = atmnet->v_b.x;
  double By  = atmnet->v_b.y;
  double Cx = atmnet->v_c.x;
  double Cy = atmnet->v_c.y;
  double Cz  = atmnet->v_c.z;

  double Dx = Ax + Bx; double Dy = By; double Dz = 0;
  double Ex = Ax + Cx; double Ey = Cy; double Ez = Cz;
  double Fx = Bx + Cx; double Fy = Cy; double Fz = Cz;
  double Gx = Ax + Bx + Cx; double Gy = By + Cy; double Gz = Cz;

  vector <double> xCoords;
  xCoords.push_back(origin_x); xCoords.push_back(Ax); xCoords.push_back(Bx); xCoords.push_back(Cx); xCoords.push_back(Dx); xCoords.push_back(Ex); xCoords.push_back(Fx); xCoords.push_back(Gx);
  vector <double> yCoords;
  yCoords.push_back(origin_y);yCoords.push_back(By); yCoords.push_back(Cy); yCoords.push_back(Gy);
	vector <double> zCoords;
	zCoords.push_back(origin_y); zCoords.push_back(Cz);

  double xMin = 1000; double xMax = 0;
  for (int a=0; a<xCoords.size(); a++){
    xMin = min(xMin, xCoords.at(a));
    xMax = max(xMax, xCoords.at(a));
  }

  double yMin = 1000; double yMax = 0;
  for (int b=0; b<yCoords.size(); b++){
    yMin = min(yMin, yCoords.at(b));
    yMax = max(yMax, yCoords.at(b));
  }
  double zMin = 1000; double zMax = 0;
  for (int c=0; c<zCoords.size(); c++){
    zMin = min(zMin, zCoords.at(c));
    zMax = max(zMax, zCoords.at(c));
  }

  double XGridDist = xMax - xMin; double YGridDist = yMax - yMin; double ZGridDist = zMax - zMin;


//-----set size that grid will take, i.e. the number of grid points in each dimension
  
  double tempXgrid = XGridDist/GRIDRES; double tempYgrid = YGridDist/GRIDRES; double tempZgrid = ZGridDist/GRIDRES;

  int x_grid_steps = ceil(tempXgrid);
  int y_grid_steps = ceil(tempYgrid); 
  int z_grid_steps = ceil(tempZgrid);

  double shiftInX = x_grid_steps - tempXgrid;
  double shiftInY = y_grid_steps - tempYgrid;
  double shiftInZ = z_grid_steps - tempZgrid;

  double xGridRes = XGridDist/x_grid_steps; double yGridRes = YGridDist/y_grid_steps; double zGridRes = ZGridDist/z_grid_steps;

  x_grid_steps++;
  y_grid_steps++;
  z_grid_steps++;

//-----create large 3D array
  printf("Declaring 3D array.\n\n");
	grid_distance = new double**[x_grid_steps];
	for(int i=0; i<x_grid_steps; i++) {
		grid_distance[i] = new double*[y_grid_steps];
		for(int j=0; j<y_grid_steps; j++) {
			grid_distance[i][j] = new double[z_grid_steps];
		}
	}

//-----fill it with values for the F function
  printf("Filling 3D array F with values.\n\n");
	for(int i=0; i<x_grid_steps; i++) {
		for(int j=0; j<y_grid_steps; j++) {
			for(int k=0; k<z_grid_steps; k++) {
				grid_distance[i][j][k] = calculate_distance_function(atmnet, i,j,k, xMin, yMin, 0, xGridRes, yGridRes, zGridRes, x_grid_steps, y_grid_steps, z_grid_steps, 'f'); 
			}
		}
	}

//-----Print structure_f.distances and structure_f.bov
  printf("Printing F grid.\n\n");
  FILE *file_distances_f, *file_bov_f; 
  char* distance_filename_f = new char [100];
  strcpy(distance_filename_f, name_f_dist.c_str()); 
  file_distances_f = fopen(distance_filename_f,"w");
  write_distances(file_distances_f, grid_distance, x_grid_steps, y_grid_steps, z_grid_steps);
  fclose(file_distances_f); 
  char* bov_filename_f = new char [100];
  strcpy(bov_filename_f, name_f_bov.c_str()); 
  file_bov_f = fopen(bov_filename_f,"w");
  write_bov(file_bov_f, distance_filename_f, x_grid_steps, y_grid_steps, z_grid_steps, xMin, yMin, zMin, XGridDist, YGridDist, ZGridDist);
  fclose(file_bov_f);

//-----fill it with values for the G function
/*
  printf("Filling 3D array G with values.\n\n");
	for(int i=0; i<x_grid_steps; i++) {
		for(int j=0; j<y_grid_steps; j++) {
			for(int k=0; k<z_grid_steps; k++) {
				grid_distance[i][j][k] = calculate_distance_function(atmnet, i,j,k, xMin, yMin, 0, xGridRes, yGridRes, zGridRes, x_grid_steps, y_grid_steps, z_grid_steps, 'g'); 
			}
		}
	}

//-----Print structure_g.distances and structure_g.bov
  printf("Printing G grid.\n\n");
  FILE *file_distances_g, *file_bov_g; 
  char* distance_filename_g = new char [100];
  strcpy(distance_filename_g, name_g_dist.c_str()); 
  file_distances_g = fopen(distance_filename_g,"w");
  write_distances(file_distances_g, grid_distance, x_grid_steps, y_grid_steps, z_grid_steps);
  fclose(file_distances_g); 
  char* bov_filename_g = new char [100];
  strcpy(bov_filename_g, name_g_bov.c_str()); 
  file_bov_g = fopen(bov_filename_g,"w");
  write_bov(file_bov_g, distance_filename_g, x_grid_steps, y_grid_steps, z_grid_steps, xMin, yMin, zMin, XGridDist, YGridDist, ZGridDist);
  fclose(file_bov_g);
*/


//-----fill it with values for the H function
/*
  printf("Filling 3D array H with values.\n\n");
	for(int i=0; i<x_grid_steps; i++) {
		for(int j=0; j<y_grid_steps; j++) {
			for(int k=0; k<z_grid_steps; k++) {
				grid_distance[i][j][k] = calculate_distance_function(atmnet, i,j,k, xMin, yMin, 0, xGridRes, yGridRes, zGridRes, x_grid_steps, y_grid_steps, z_grid_steps, 'h'); 
			}
		}
	}


//-----Print structure_h.distances and structure_h.bov

  printf("Printing H grid.\n\n");
  FILE *file_distances_h, *file_bov_h; 
  char* distance_filename_h = new char [100];
  strcpy(distance_filename_h, name_h_dist.c_str()); 
  file_distances_h = fopen(distance_filename_h,"w");
  write_distances(file_distances_h, grid_distance, x_grid_steps, y_grid_steps, z_grid_steps);
  fclose(file_distances_h); 
  char* bov_filename_h = new char [100];
  strcpy(bov_filename_h, name_h_bov.c_str()); 
  file_bov_h = fopen(bov_filename_h,"w");
  write_bov(file_bov_h, distance_filename_h, x_grid_steps, y_grid_steps, z_grid_steps, xMin, yMin, zMin, XGridDist, YGridDist, ZGridDist);
  fclose(file_bov_h);
*/


//-----free memory!
  printf("Freeing memory.\n\n");
	for(int i=0; i<x_grid_steps; i++) {
		for(int j=0; j<y_grid_steps; j++) {
			delete[] grid_distance[i][j];
		}
    delete[] grid_distance[i];
	}
  delete[] grid_distance; //important to have one "delete[]" per "new"
  delete[] distance_filename_f;
  //delete[] distance_filename_g;
  //delete[] distance_filename_h;
  delete[] bov_filename_f;
  //delete[] bov_filename_g;
  //delete[] bov_filename_h;

//---end successfully
  printf("Program complete.\n\n");


}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x178, %rsp            # imm = 0x178
movq %r8, %rbx
movq %rsi, %r14
movq %rdi, %r15
xorl %eax, %eax
movq %rax, 0x158(%rsp)
movq %rax, 0x88(%rsp)
movsd 0x38(%rdi), %xmm0
movsd %xmm0, 0x128(%rsp)
movsd 0x50(%rdi), %xmm1
movsd %xmm1, 0x120(%rsp)
movsd 0x58(%rdi), %xmm2
movsd %xmm2, 0x118(%rsp)
movsd 0x68(%rdi), %xmm3
movsd %xmm3, 0x110(%rsp)
movsd 0x70(%rdi), %xmm4
movsd %xmm4, 0x108(%rsp)
movsd 0x78(%rdi), %xmm5
movsd %xmm5, 0x100(%rsp)
movapd %xmm0, %xmm5
addsd %xmm1, %xmm5
movsd %xmm5, 0xf8(%rsp)
addsd %xmm3, %xmm0
movsd %xmm0, 0xf0(%rsp)
addsd %xmm3, %xmm1
movsd %xmm1, 0xe8(%rsp)
addsd %xmm3, %xmm5
movsd %xmm5, 0xe0(%rsp)
addsd %xmm4, %xmm2
movsd %xmm2, 0xd8(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, 0x10(%rsp)
movq %rax, 0x20(%rsp)
movq 0x18(%rsp), %rsi
testq %rsi, %rsi
je 0x88ab8
movq $0x0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x18(%rsp)
jmp 0x88aca
leaq 0x10(%rsp), %rdi
leaq 0x158(%rsp), %rdx
callq 0x148c4
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x88aee
movsd 0x128(%rsp), %xmm0
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x18(%rsp)
jmp 0x88b00
leaq 0x10(%rsp), %rdi
leaq 0x128(%rsp), %rdx
callq 0x148c4
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x88b24
movsd 0x120(%rsp), %xmm0
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x18(%rsp)
jmp 0x88b36
leaq 0x10(%rsp), %rdi
leaq 0x120(%rsp), %rdx
callq 0x148c4
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x88b5a
movsd 0x110(%rsp), %xmm0
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x18(%rsp)
jmp 0x88b6c
leaq 0x10(%rsp), %rdi
leaq 0x110(%rsp), %rdx
callq 0x148c4
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x88b90
movsd 0xf8(%rsp), %xmm0
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x18(%rsp)
jmp 0x88ba2
leaq 0x10(%rsp), %rdi
leaq 0xf8(%rsp), %rdx
callq 0x148c4
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x88bc6
movsd 0xf0(%rsp), %xmm0
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x18(%rsp)
jmp 0x88bd8
leaq 0x10(%rsp), %rdi
leaq 0xf0(%rsp), %rdx
callq 0x148c4
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x88bfc
movsd 0xe8(%rsp), %xmm0
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x18(%rsp)
jmp 0x88c0e
leaq 0x10(%rsp), %rdi
leaq 0xe8(%rsp), %rdx
callq 0x148c4
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x88c32
movsd 0xe0(%rsp), %xmm0
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x18(%rsp)
jmp 0x88c44
leaq 0x10(%rsp), %rdi
leaq 0xe0(%rsp), %rdx
callq 0x148c4
xorpd %xmm0, %xmm0
movapd %xmm0, 0x30(%rsp)
movq $0x0, 0x40(%rsp)
movq 0x38(%rsp), %rsi
testq %rsi, %rsi
je 0x88c79
movsd 0x88(%rsp), %xmm0
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x38(%rsp)
jmp 0x88c8b
leaq 0x30(%rsp), %rdi
leaq 0x88(%rsp), %rdx
callq 0x148c4
movq 0x38(%rsp), %rsi
cmpq 0x40(%rsp), %rsi
je 0x88caf
movsd 0x118(%rsp), %xmm0
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x38(%rsp)
jmp 0x88cc1
leaq 0x30(%rsp), %rdi
leaq 0x118(%rsp), %rdx
callq 0x148c4
movq 0x38(%rsp), %rsi
cmpq 0x40(%rsp), %rsi
je 0x88ce5
movsd 0x108(%rsp), %xmm0
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x38(%rsp)
jmp 0x88cf7
leaq 0x30(%rsp), %rdi
leaq 0x108(%rsp), %rdx
callq 0x148c4
movq 0x38(%rsp), %rsi
cmpq 0x40(%rsp), %rsi
je 0x88d1b
movsd 0xd8(%rsp), %xmm0
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x38(%rsp)
jmp 0x88d2d
leaq 0x30(%rsp), %rdi
leaq 0xd8(%rsp), %rdx
callq 0x148c4
xorpd %xmm0, %xmm0
movapd %xmm0, 0x60(%rsp)
movq $0x0, 0x70(%rsp)
movq 0x68(%rsp), %rsi
testq %rsi, %rsi
je 0x88d62
movsd 0x88(%rsp), %xmm0
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x68(%rsp)
jmp 0x88d74
leaq 0x60(%rsp), %rdi
leaq 0x88(%rsp), %rdx
callq 0x148c4
movq 0x68(%rsp), %rsi
cmpq 0x70(%rsp), %rsi
je 0x88d98
movsd 0x100(%rsp), %xmm0
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x68(%rsp)
jmp 0x88daa
leaq 0x60(%rsp), %rdi
leaq 0x100(%rsp), %rdx
callq 0x148c4
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %rcx
xorpd %xmm2, %xmm2
movsd 0xcb940(%rip), %xmm3    # 0x154700
movapd %xmm3, %xmm5
xorpd %xmm4, %xmm4
subq %rax, %rcx
je 0x88e08
sarq $0x3, %rcx
cmpq $0x1, %rcx
adcq $0x0, %rcx
movsd 0xcb91f(%rip), %xmm1    # 0x154700
xorpd %xmm0, %xmm0
xorl %edx, %edx
movsd (%rax,%rdx,8), %xmm4
movapd %xmm4, %xmm5
minsd %xmm1, %xmm5
maxsd %xmm0, %xmm4
incq %rdx
movapd %xmm4, %xmm0
movapd %xmm5, %xmm1
cmpq %rdx, %rcx
jne 0x88de7
movq 0x30(%rsp), %rax
movq 0x38(%rsp), %rcx
movapd %xmm3, %xmm6
subq %rax, %rcx
je 0x88e56
sarq $0x3, %rcx
cmpq $0x1, %rcx
adcq $0x0, %rcx
movsd 0xcb8d1(%rip), %xmm1    # 0x154700
xorpd %xmm0, %xmm0
xorl %edx, %edx
movsd (%rax,%rdx,8), %xmm2
movapd %xmm2, %xmm6
minsd %xmm1, %xmm6
maxsd %xmm0, %xmm2
incq %rdx
movapd %xmm2, %xmm0
movapd %xmm6, %xmm1
cmpq %rdx, %rcx
jne 0x88e35
movq 0x60(%rsp), %rax
movq 0x68(%rsp), %rcx
subq %rax, %rcx
movq %rbx, 0x148(%rsp)
movq %r14, 0x150(%rsp)
je 0x88eb2
sarq $0x3, %rcx
cmpq $0x1, %rcx
adcq $0x0, %rcx
movsd 0xcb877(%rip), %xmm1    # 0x154700
xorpd %xmm0, %xmm0
xorl %edx, %edx
movsd (%rax,%rdx,8), %xmm7
movapd %xmm7, %xmm3
minsd %xmm1, %xmm3
maxsd %xmm0, %xmm7
incq %rdx
movapd %xmm7, %xmm0
movapd %xmm3, %xmm1
cmpq %rdx, %rcx
jne 0x88e8f
jmp 0x88eb6
xorpd %xmm7, %xmm7
movapd %xmm4, %xmm0
movsd %xmm5, 0x98(%rsp)
subsd %xmm5, %xmm0
movsd %xmm6, 0x90(%rsp)
subsd %xmm6, %xmm2
movsd %xmm3, 0x140(%rsp)
subsd %xmm3, %xmm7
movsd 0xce797(%rip), %xmm1    # 0x157680
movsd %xmm0, 0xb8(%rsp)
divsd %xmm1, %xmm0
movsd %xmm2, 0xc0(%rsp)
divsd %xmm1, %xmm2
movsd %xmm2, 0xa0(%rsp)
movsd %xmm7, 0xb0(%rsp)
divsd %xmm1, %xmm7
movsd %xmm7, 0x58(%rsp)
callq 0x40d0
movapd %xmm0, 0x160(%rsp)
cvttsd2si %xmm0, %ebx
movsd 0xa0(%rsp), %xmm0
callq 0x40d0
movaps %xmm0, 0xa0(%rsp)
movsd 0x58(%rsp), %xmm0
callq 0x40d0
movapd %xmm0, 0x130(%rsp)
leaq 0xce952(%rip), %rdi     # 0x1578b4
callq 0x4660
movslq %ebx, %rax
cmpl $-0x1, %ebx
leaq 0x8(,%rax,8), %rax
movq $-0x1, %rdi
cmovgeq %rax, %rdi
callq 0x4030
movq %rax, %r12
cvttsd2si 0xa0(%rsp), %eax
cvttsd2si 0x130(%rsp), %edx
leal 0x1(%rbx), %ecx
movq %rcx, 0x50(%rsp)
movq %rax, 0x80(%rsp)
incl %eax
movq %rax, 0x48(%rsp)
movq %rbx, %rax
movq %rdx, 0xd0(%rsp)
leal 0x1(%rdx), %ebx
movq %rax, 0xc8(%rsp)
testl %eax, %eax
js 0x89040
movslq 0x48(%rsp), %rcx
shlq $0x3, %rcx
cmpl $-0x1, 0x80(%rsp)
movq $-0x1, %rax
cmovlq %rax, %rcx
movq %rcx, 0x58(%rsp)
movslq %ebx, %r13
shlq $0x3, %r13
cmpl $-0x1, 0xd0(%rsp)
cmovlq %rax, %r13
xorl %ebp, %ebp
movq 0x58(%rsp), %rdi
callq 0x4030
movq %rax, (%r12,%rbp,8)
cmpl $0x0, 0x80(%rsp)
js 0x89036
xorl %r14d, %r14d
movq %r13, %rdi
callq 0x4030
movq (%r12,%rbp,8), %rcx
movq %rax, (%rcx,%r14,8)
incq %r14
cmpq %r14, 0x48(%rsp)
jne 0x8901c
incq %rbp
cmpq 0x50(%rsp), %rbp
jne 0x89001
leaq 0xce882(%rip), %rdi     # 0x1578c9
callq 0x4660
cmpl $0x0, 0xc8(%rsp)
movsd 0x98(%rsp), %xmm0
movsd 0x90(%rsp), %xmm1
js 0x89161
cvttpd2dq 0x160(%rsp), %xmm2
cvtdq2pd %xmm2, %xmm3
cvttpd2dq 0xa0(%rsp), %xmm2
cvtdq2pd %xmm2, %xmm4
cvttpd2dq 0x130(%rsp), %xmm2
cvtdq2pd %xmm2, %xmm2
movsd 0xb8(%rsp), %xmm5
divsd %xmm3, %xmm5
movsd %xmm5, 0x58(%rsp)
movsd 0xc0(%rsp), %xmm3
divsd %xmm4, %xmm3
movsd %xmm3, 0xa0(%rsp)
movsd 0xb0(%rsp), %xmm3
divsd %xmm2, %xmm3
movsd %xmm3, 0x130(%rsp)
xorl %r14d, %r14d
cmpl $0x0, 0x80(%rsp)
js 0x89153
xorl %r13d, %r13d
cmpl $0x0, 0xd0(%rsp)
js 0x89149
xorl %ebp, %ebp
movl $0x66, 0x8(%rsp)
xorpd %xmm2, %xmm2
movq %r15, %rdi
movl %r14d, %esi
movl %r13d, %edx
movl %ebp, %ecx
movsd 0x58(%rsp), %xmm3
movsd 0xa0(%rsp), %xmm4
movsd 0x130(%rsp), %xmm5
callq 0x8938a
movq (%r12,%r14,8), %rax
movq (%rax,%r13,8), %rax
movsd %xmm0, (%rax,%rbp,8)
incq %rbp
cmpq %rbp, %rbx
movsd 0x98(%rsp), %xmm0
movsd 0x90(%rsp), %xmm1
jne 0x890ee
incq %r13
cmpq 0x48(%rsp), %r13
jne 0x890e2
incq %r14
cmpq 0x50(%rsp), %r14
jne 0x890d5
leaq 0xce782(%rip), %rdi     # 0x1578ea
callq 0x4660
movl $0x64, %edi
callq 0x4030
movq %rax, %r15
movq 0x150(%rsp), %rax
movq (%rax), %rsi
movq %r15, %rdi
callq 0x43f0
leaq 0xcaa00(%rip), %rsi     # 0x153b94
movq %r15, %rdi
callq 0x4510
movq %rax, %r14
movq %rax, %rdi
movq %r12, %rsi
movq 0x50(%rsp), %rdx
movq 0x48(%rsp), %rcx
movl %ebx, %r8d
callq 0x8958b
movq %r14, %rdi
callq 0x4450
movl $0x64, %edi
callq 0x4030
movq %rax, %r14
movq 0x148(%rsp), %rax
movq (%rax), %rsi
movq %r14, %rdi
callq 0x43f0
leaq 0xca9ae(%rip), %rsi     # 0x153b94
movq %r14, %rdi
callq 0x4510
movq %rax, %r13
leaq 0xce4b8(%rip), %rsi     # 0x1576b0
movq %rax, %rdi
movq %r15, %rdx
movq 0x50(%rsp), %rcx
movq 0x48(%rsp), %r8
movl %ebx, %r9d
movsd 0x98(%rsp), %xmm0
movsd 0x90(%rsp), %xmm1
movsd 0x140(%rsp), %xmm2
movsd 0xb8(%rsp), %xmm3
movsd 0xc0(%rsp), %xmm4
movsd 0xb0(%rsp), %xmm5
movb $0x6, %al
callq 0x45f0
movq %r13, %rdi
callq 0x4450
leaq 0xce6a5(%rip), %rdi     # 0x1578fc
callq 0x4660
cmpl $0x0, 0xc8(%rsp)
js 0x892a9
xorl %ebx, %ebx
cmpl $0x0, 0x80(%rsp)
js 0x89291
xorl %r13d, %r13d
movq (%r12,%rbx,8), %rax
movq (%rax,%r13,8), %rdi
testq %rdi, %rdi
je 0x89287
callq 0x4570
incq %r13
cmpq %r13, 0x48(%rsp)
jne 0x89275
movq (%r12,%rbx,8), %rdi
testq %rdi, %rdi
je 0x8929f
callq 0x4570
incq %rbx
cmpq 0x50(%rsp), %rbx
jne 0x89268
movq %r12, %rdi
callq 0x4570
movq %r15, %rdi
callq 0x4570
movq %r14, %rdi
callq 0x4570
leaq 0xce645(%rip), %rdi     # 0x15790d
callq 0x4660
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x892e4
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x892fb
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x89312
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
addq $0x178, %rsp            # imm = 0x178
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x8933a
jmp 0x8933a
jmp 0x8933a
movq %rax, %rbx
jmp 0x89354
jmp 0x8933a
movq %rax, %rbx
jmp 0x8936b
jmp 0x8933a
jmp 0x8933a
movq %rax, %rbx
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x89354
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x8936b
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x89382
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq %rbx, %rdi
callq 0x4780