// File: /workspace/github_c_makefile_star2_O1/radforddc[P]icpc_siggen/icpc_fieldgen_opt.c
// Function: write_ev
int write_ev(MJD_Siggen_Setup *setup) {
  int    i, j, new=1;
  float  grid = setup->xtal_grid;
  //int    L  = setup->xtal_length/grid + 2.99;
  //int    R  = setup->xtal_radius/grid + 2.99;
  int    L  = lrint(setup->xtal_length/grid)+2;
  int    R  = lrint(setup->xtal_radius/grid)+2;
  float  r, z, E;
  FILE   *file;
  double ***v = setup->v;
  cyl_pt **e;

  setup->Emin = 99999.9;
  setup->rmin = setup->zmin = 999.9;


  if (setup->impurity_z0 > 0) {
    // swap voltages back to negative for n-type material
    for (i=1; i<L; i++) {
      for (j=1; j<R; j++) {
        setup->v[new][i][j] = -setup->v[new][i][j];
      }
    }
  }

  /* write potential and field to output file */
  if (!(file = fopen(setup->field_name, "w"))) {
    printf("ERROR: Cannot open file %s for electric field...\n", setup->field_name);
    return 1;
  } else {
    printf("Writing electric field data to file %s\n", setup->field_name);
  }
  /* copy configuration parameters to output file */
  report_config(file, setup->config_file_name);
  fprintf(file, "#\n# HV bias in fieldgen: %.1f V\n", setup->xtal_HV);
  if (setup->fully_depleted) {
    fprintf(file, "# Detector is fully depleted.\n");
  } else {
    fprintf(file, "# Detector is not fully depleted.\n");
    if (setup->bubble_volts > 0.0f)
      fprintf(file, "# Pinch-off bubble at %.0f V potential\n", setup->bubble_volts);
  }
  
  if ((e = (cyl_pt **) malloc(R*sizeof(*e))) == NULL) {
    printf("ERROR: Malloc failed\n");
    fclose(file);
    return 1;
  }
  for (i = 0; i < R; i++){
    if ((e[i] = (cyl_pt *) calloc(L, sizeof(*e[i]))) == NULL) {
      printf("ERROR: Calloc failed\n");
      fclose(file);
      return 1;
    }
  }

  for (j = 1; j < R; j++) {
    r = (j-1) * grid;
    for (i = 1; i < L; i++) {
      z = (i-1) * grid;
      // calc E in r-direction
      if (j == 1) {  // r = 0; symmetry implies E_r = 0
        e[j][i].r = 0;
      } else if (setup->point_type[i][j] == CONTACT_EDGE) {
        e[j][i].r = ((v[new][i][j] - v[new][i][j+1])*setup->dr[1][i][j] +
               (v[new][i][j-1] - v[new][i][j])*setup->dr[0][i][j]) / (0.2*grid);
      } else if (setup->point_type[i][j] < INSIDE &&
                 setup->point_type[i][j-1] == CONTACT_EDGE) {
        e[j][i].r =  (v[new][i][j-1] - v[new][i][j]) * setup->dr[1][i][j-1] / ( 0.1*grid) ;
      } else if (setup->point_type[i][j] < INSIDE &&
                 setup->point_type[i][j+1] == CONTACT_EDGE) {
        e[j][i].r =  (v[new][i][j] - v[new][i][j+1]) * setup->dr[0][i][j+1] / ( 0.1*grid) ;
      } else if (j == R-1) {
        e[j][i].r = (v[new][i][j-1] - v[new][i][j])/(0.1*grid);
      } else {
        e[j][i].r = (v[new][i][j-1] - v[new][i][j+1])/(0.2*grid);
      }
      // calc E in z-direction
      if (setup->point_type[i][j] == CONTACT_EDGE) {
        e[j][i].z = ((v[new][i][j] - v[new][i+1][j])*setup->dz[1][i][j] +
               (v[new][i-1][j] - v[new][i][j])*setup->dz[0][i][j]) / (0.2*grid);
      } else if (setup->point_type[i][j] < INSIDE &&
                 setup->point_type[i-1][j] == CONTACT_EDGE) {
        e[j][i].z =  (v[new][i-1][j] - v[new][i][j]) * setup->dz[1][i-1][j] / ( 0.1*grid) ;
      } else if (setup->point_type[i][j] < INSIDE &&
                 setup->point_type[i+1][j] == CONTACT_EDGE) {
        e[j][i].z =  (v[new][i][j] - v[new][i+1][j]) * setup->dz[0][i+1][j] / ( 0.1*grid) ;
      } else if (i == 1) {
        e[j][i].z = (v[new][i][j] - v[new][i+1][j])/(0.1*grid);
      } else if (i == L-1) {
        e[j][i].z = (v[new][i-1][j] - v[new][i][j])/(0.1*grid);
      } else {
        e[j][i].z = (v[new][i-1][j] - v[new][i+1][j])/(0.2*grid);
      }

      /* temporarily store E in e[j][i].phi */
      E = e[j][i].phi = sqrt(e[j][i].r*e[j][i].r + e[j][i].z*e[j][i].z);
      /* check for minimum field inside bulk of detector */
      int k = 3.0/grid;
      if (E > 0.1 && E < setup->Emin &&
          i > k+1 && j < R-k-1 && i < L-k-1 &&
          setup->point_type[i][j] == INSIDE &&
          setup->point_type[i + k][j] == INSIDE &&  // point is at least 3 mm from a boundary
          setup->point_type[i - k][j] == INSIDE &&
          setup->point_type[i][j + k] == INSIDE &&
          (j < k+1 || setup->point_type[i][j - k] == INSIDE)) {
        setup->Emin = E;
        setup->rmin = r;
        setup->zmin = z;
      }
    }
  }

  if (strstr(setup->field_name, "unf")) {
    fprintf(file, "#\n## start of unformatted data\n");
    i = R-1; j = L-1;
    fwrite(&i, sizeof(int), 1, file);
    fwrite(&j, sizeof(int), 1, file);
    for (i = 1; i < R; i++) {
      for (j = 1; j < L; j++) e[i][j].phi = 0;
      if (fwrite(&e[i][1], sizeof(cyl_pt), L-1, file) != L-1) {
        printf("ERROR while writing %s\n", setup->field_name);
      }
    }
  } else {
    fprintf(file, "#\n## r (mm), z (mm), V (V),  E (V/cm), E_r (V/cm), E_z (V/cm)\n");
    for (j = 1; j < R; j++) {
      r = (j-1) * grid;
      for (i = 1; i < L; i++) {
        z = (i-1) * grid;
        E = e[j][i].phi;
        fprintf(file, "%7.2f %7.2f %7.1f %7.1f %7.1f %7.1f\n",
                r, z, v[new][i][j], E, e[j][i].r, e[j][i].z);
      }
      fprintf(file, "\n");
    }
  }
  fclose(file);
  for (i = 0; i < R; i++) free(e[i]);
  free(e);

  if (!setup->write_WP)
    printf("\n Minimum bulk field = %.2f V/cm at (r,z) = (%.1f, %.1f) mm\n\n",
           setup->Emin, setup->rmin, setup->zmin);

  if (0) { /* write point_type to output file */
    file = fopen("fields/point_type.dat", "w");
    for (j = 1; j < R; j++) {
      for (i = 1; i < L; i++)
        fprintf(file, "%7.2f %7.2f %2d\n",
                (j-1)*grid, (i-1)*grid, setup->point_type[i][j]);
      fprintf(file, "\n");
    }
    fclose(file);
  }

  return 0;
 }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movq %rdi, %rbx
movss 0x4(%rdi), %xmm0
movss 0x54(%rdi), %xmm1
movss %xmm1, 0xc(%rsp)
divss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
callq 0x1100
movq %rax, 0x38(%rsp)
leal 0x2(%rax), %ebp
movss 0x8(%rbx), %xmm0
divss 0xc(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
callq 0x1100
movq %rax, %r12
leal 0x2(%rax), %r14d
movl $0x47c34ff3, 0x448(%rbx) # imm = 0x47C34FF3
movl $0x4479f99a, %eax       # imm = 0x4479F99A
movl %eax, 0x3bc(%rbx)
movl %eax, 0x3b0(%rbx)
movss 0x58(%rbx), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x4d4b
cmpl $0x7ffffffd, 0x38(%rsp) # imm = 0x7FFFFFFD
ja 0x4d3a
movl %ebp, %edx
movl %r14d, %esi
movl $0x1, %eax
movaps 0x4442(%rip), %xmm0     # 0x9140
movl $0x1, %ecx
cmpl $0x7ffffffd, %r12d      # imm = 0x7FFFFFFD
ja 0x4d30
movq 0x3e8(%rbx), %rcx
movq (%rcx,%rax,8), %rdi
movl $0x1, %ecx
movsd (%rdi,%rcx,8), %xmm1
xorps %xmm0, %xmm1
movlps %xmm1, (%rdi,%rcx,8)
incq %rcx
cmpq %rcx, %rsi
jne 0x4d1c
incq %rax
cmpq %rdx, %rax
jne 0x4cfe
jmp 0x4d43
movl 0x8(%rsp), %ecx
movl $0x1, %eax
movl %eax, 0x4(%rsp)
movl %ecx, 0x8(%rsp)
leaq 0x188(%rbx), %r13
leaq 0x493b(%rip), %rsi      # 0x9694
movq %r13, %rdi
callq 0x11b0
testq %rax, %rax
je 0x4dc6
movq %rax, %r15
leaq 0x511b(%rip), %rdi      # 0x9e8b
movq %r13, %rsi
xorl %eax, %eax
callq 0x10f0
leaq 0x1480(%rbx), %rsi
movq %r15, %rdi
callq 0x6e0c
xorps %xmm0, %xmm0
cvtss2sd 0x74(%rbx), %xmm0
leaq 0x4fcc(%rip), %rsi      # 0x9d64
movq %r15, %rdi
movb $0x1, %al
callq 0x1150
cmpl $0x0, 0x440(%rbx)
je 0x4de8
leaq 0x4fd3(%rip), %rdi      # 0x9d85
movl $0x1e, %esi
movl $0x1, %edx
movq %r15, %rcx
callq 0x11d0
jmp 0x4e26
leaq 0x508c(%rip), %rdi      # 0x9e59
movq %r13, %rsi
xorl %eax, %eax
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x10f0
leaq 0x4fb5(%rip), %rdi      # 0x9da4
movl $0x22, %esi
movl $0x1, %edx
movq %r15, %rcx
callq 0x11d0
movss 0x444(%rbx), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x4e26
cvtss2sd %xmm0, %xmm0
leaq 0x4fab(%rip), %rsi      # 0x9dc7
movq %r15, %rdi
movb $0x1, %al
callq 0x1150
movslq %r14d, %rdi
shlq $0x3, %rdi
callq 0x1180
testq %rax, %rax
je 0x4e8e
movq %rax, %rdi
movq %r13, 0x70(%rsp)
movq %r12, 0x50(%rsp)
testl %r14d, %r14d
movq %rax, 0x10(%rsp)
movq %r14, 0x28(%rsp)
movl %ebp, 0x24(%rsp)
jle 0x4e9a
movslq %ebp, %rbp
movl %r14d, %r14d
xorl %r12d, %r12d
movl $0xc, %esi
movq %rbp, %rdi
callq 0x1140
movq 0x10(%rsp), %rdi
movq %rax, (%rdi,%r12,8)
testq %rax, %rax
je 0x553d
incq %r12
cmpq %r12, %r14
jne 0x4e60
movq %r15, 0x30(%rsp)
jmp 0x4ea2
leaq 0x5263(%rip), %rdi      # 0xa0f8
jmp 0x5549
movq %r15, 0x30(%rsp)
xorl %r12d, %r12d
movl %r12d, 0x4(%rsp)
movl $0x1, %r14d
cmpl $0x7ffffffd, 0x50(%rsp) # imm = 0x7FFFFFFD
ja 0x541a
movq 0x50(%rsp), %rax
incl %eax
movq %rax, 0xa8(%rsp)
movss 0xc(%rsp), %xmm2
xorps %xmm0, %xmm0
cvtss2sd %xmm2, %xmm0
movsd 0x4199(%rip), %xmm1     # 0x9078
mulsd %xmm0, %xmm1
movsd %xmm1, 0x40(%rsp)
movsd 0x4137(%rip), %xmm1     # 0x9028
mulsd %xmm0, %xmm1
movsd %xmm1, 0x18(%rsp)
leaq 0x8(%rdi), %rbp
movq 0x38(%rsp), %rax
incl %eax
movq %rax, 0xa0(%rsp)
movsd 0x412a(%rip), %xmm1     # 0x9040
divsd %xmm0, %xmm1
cvttsd2si %xmm1, %eax
leal 0x1(%rax), %ecx
movslq %eax, %r10
notl %eax
movq 0x28(%rsp), %rsi
leal (%rsi,%rax), %edx
movl 0x24(%rsp), %r8d
addl %r8d, %eax
movslq %ecx, %rcx
movq %rcx, 0xc0(%rsp)
cltq
movq %rax, 0xb0(%rsp)
movslq %edx, %rax
movq %rax, 0xb8(%rsp)
movl %esi, %eax
movl %r8d, %esi
movq %r10, 0x58(%rsp)
leaq (,%r10,8), %rdx
movq %rdx, 0x90(%rsp)
negq %rdx
movq %rdx, 0x88(%rsp)
movl $0x1, %r14d
xorps %xmm3, %xmm3
movsd 0x409c(%rip), %xmm4     # 0x9028
movq %rax, 0x78(%rsp)
movl $0x1, %r12d
cmpl $0x7ffffffd, 0x38(%rsp) # imm = 0x7FFFFFFD
ja 0x540e
leaq -0x1(%r14), %rcx
movq %rcx, 0x98(%rsp)
xorps %xmm0, %xmm0
cvtsi2ss %ecx, %xmm0
mulss %xmm2, %xmm0
movss %xmm0, 0x6c(%rsp)
leaq (%rdi,%r14,8), %rax
movq %rax, 0x48(%rsp)
movq (%rdi,%r14,8), %r15
movq %r14, %rax
subq 0x58(%rsp), %rax
movq %rax, 0x80(%rsp)
movl $0x1, %r12d
xorl %r13d, %r13d
xorps %xmm0, %xmm0
movq %rbp, %rax
cmpq $0x1, %r14
je 0x5131
movq 0x430(%rbx), %rax
movq (%rax,%r12,8), %rax
movb (%rax,%r14), %cl
cmpb $0x7, %cl
jne 0x5067
movq 0x3e8(%rbx), %rax
movq (%rax,%r12,8), %rax
movsd -0x8(%rax,%r14,8), %xmm0
movsd (%rax,%r14,8), %xmm1
subsd %xmm1, %xmm0
subsd 0x8(%rax,%r14,8), %xmm1
movq 0x1458(%rbx), %rax
movq 0x1450(%rbx), %rcx
movq (%rcx,%r12,8), %rcx
mulsd (%rcx,%r14,8), %xmm0
movq (%rax,%r12,8), %rax
mulsd (%rax,%r14,8), %xmm1
addsd %xmm0, %xmm1
divsd 0x40(%rsp), %xmm1
xorps %xmm0, %xmm0
cvtsd2ss %xmm1, %xmm0
jmp 0x512c
cmpb $0x1, %cl
jg 0x50df
movq 0x98(%rsp), %rdx
cmpb $0x7, (%rax,%rdx)
jne 0x50a6
movq 0x3e8(%rbx), %rax
movq (%rax,%r12,8), %rax
movsd -0x8(%rax,%r14,8), %xmm0
subsd (%rax,%r14,8), %xmm0
movq 0x1458(%rbx), %rax
movq (%rax,%r12,8), %rax
mulsd -0x8(%rax,%r14,8), %xmm0
jmp 0x5101
cmpb $0x1, %cl
jg 0x50df
cmpb $0x7, 0x1(%rax,%r14)
jne 0x50df
movq 0x3e8(%rbx), %rax
movq (%rax,%r12,8), %rax
movsd (%rax,%r14,8), %xmm0
subsd 0x8(%rax,%r14,8), %xmm0
movq 0x1450(%rbx), %rax
movq (%rax,%r12,8), %rax
mulsd 0x8(%rax,%r14,8), %xmm0
jmp 0x5101
cmpq 0xa8(%rsp), %r14
jne 0x5109
movq 0x3e8(%rbx), %rax
movq (%rax,%r12,8), %rax
movsd -0x8(%rax,%r14,8), %xmm0
subsd (%rax,%r14,8), %xmm0
divsd 0x18(%rsp), %xmm0
jmp 0x5128
movq 0x3e8(%rbx), %rax
movq (%rax,%r12,8), %rax
movsd -0x8(%rax,%r14,8), %xmm0
subsd 0x8(%rax,%r14,8), %xmm0
divsd 0x40(%rsp), %xmm0
cvtsd2ss %xmm0, %xmm0
movq 0x48(%rsp), %rax
movq (%rax), %rax
movss %xmm0, 0xc(%rax,%r13)
movq 0x430(%rbx), %rax
movq (%rax,%r12,8), %rcx
movb (%rcx,%r14), %cl
cmpb $0x7, %cl
jne 0x51ab
movq 0x3e8(%rbx), %rax
movq -0x8(%rax,%r12,8), %rcx
movq (%rax,%r12,8), %rdx
movsd (%rdx,%r14,8), %xmm0
movq 0x8(%rax,%r12,8), %rax
movsd (%rcx,%r14,8), %xmm1
subsd %xmm0, %xmm1
subsd (%rax,%r14,8), %xmm0
movq 0x1468(%rbx), %rax
movq (%rax,%r12,8), %rax
movq 0x1460(%rbx), %rcx
movq (%rcx,%r12,8), %rcx
mulsd (%rcx,%r14,8), %xmm1
mulsd (%rax,%r14,8), %xmm0
addsd %xmm1, %xmm0
divsd 0x40(%rsp), %xmm0
jmp 0x5290
cmpb $0x1, %cl
jg 0x522a
movq -0x8(%rax,%r12,8), %rdx
cmpb $0x7, (%rdx,%r14)
jne 0x51ef
movq 0x3e8(%rbx), %rax
movq -0x8(%rax,%r12,8), %rcx
movq (%rax,%r12,8), %rax
movsd (%rcx,%r14,8), %xmm0
subsd (%rax,%r14,8), %xmm0
movq 0x1468(%rbx), %rax
movq -0x8(%rax,%r12,8), %rax
mulsd (%rax,%r14,8), %xmm0
jmp 0x528a
cmpb $0x1, %cl
jg 0x522a
movq 0x8(%rax,%r12,8), %rax
cmpb $0x7, (%rax,%r14)
jne 0x522a
movq 0x3e8(%rbx), %rax
movq (%rax,%r12,8), %rcx
movq 0x8(%rax,%r12,8), %rax
movsd (%rcx,%r14,8), %xmm0
subsd (%rax,%r14,8), %xmm0
movq 0x1460(%rbx), %rax
movq 0x8(%rax,%r12,8), %rax
jmp 0x51e4
cmpq $0x1, %r12
jne 0x5260
movq 0x3e8(%rbx), %rax
movq 0x8(%rax), %rcx
movq 0x10(%rax), %rax
movsd (%rcx,%r14,8), %xmm0
subsd (%rax,%r14,8), %xmm0
divsd 0x18(%rsp), %xmm0
cvtsd2ss %xmm0, %xmm0
movq (%rdi,%r14,8), %rax
movss %xmm0, 0x14(%rax)
jmp 0x529f
cmpq %r12, 0xa0(%rsp)
jne 0x53e7
movq 0x3e8(%rbx), %rax
movq -0x8(%rax,%r12,8), %rcx
movq (%rax,%r12,8), %rax
movsd (%rcx,%r14,8), %xmm0
subsd (%rax,%r14,8), %xmm0
divsd 0x18(%rsp), %xmm0
cvtsd2ss %xmm0, %xmm0
movq (%rdi,%r14,8), %rax
movss %xmm0, 0x14(%rax,%r13)
movss 0xc(%r15,%r13), %xmm0
movss 0x14(%r15,%r13), %xmm1
mulss %xmm1, %xmm1
mulss %xmm0, %xmm0
addss %xmm1, %xmm0
ucomiss %xmm3, %xmm0
jb 0x52c4
sqrtss %xmm0, %xmm0
jmp 0x52f5
movq %r12, 0x60(%rsp)
movq %rbx, %r12
movq %rsi, %rbx
callq 0x1170
movsd 0x3d4c(%rip), %xmm4     # 0x9028
xorps %xmm3, %xmm3
movq %rbx, %rsi
movq %r12, %rbx
movq 0x60(%rsp), %r12
movq 0x10(%rsp), %rdi
movss 0xc(%rsp), %xmm2
movss %xmm0, 0x10(%r15,%r13)
xorps %xmm1, %xmm1
cvtss2sd %xmm0, %xmm1
ucomisd %xmm4, %xmm1
jbe 0x53d5
movss 0x448(%rbx), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x53d5
cmpq 0xc0(%rsp), %r12
jle 0x53d5
cmpq 0xb8(%rsp), %r14
jge 0x53d5
cmpq 0xb0(%rsp), %r12
jge 0x53d5
movq 0x430(%rbx), %rcx
movq (%rcx,%r12,8), %rax
cmpb $0x2, (%rax,%r14)
jne 0x53d5
movq 0x90(%rsp), %rdx
addq %rcx, %rdx
movq (%rdx,%r12,8), %rdx
cmpb $0x2, (%rdx,%r14)
jne 0x53d5
addq 0x88(%rsp), %rcx
movq (%rcx,%r12,8), %rcx
cmpb $0x2, (%rcx,%r14)
jne 0x53d5
leaq (%rax,%r14), %rcx
movq 0x58(%rsp), %rdx
cmpb $0x2, (%rdx,%rcx)
jne 0x53d5
cmpq 0x58(%rsp), %r14
jle 0x53a7
movq 0x80(%rsp), %rcx
cmpb $0x2, (%rax,%rcx)
jne 0x53d5
leal -0x1(%r12), %eax
xorps %xmm1, %xmm1
cvtsi2ss %eax, %xmm1
mulss %xmm2, %xmm1
movss %xmm0, 0x448(%rbx)
movss 0x6c(%rsp), %xmm0
movss %xmm0, 0x3b0(%rbx)
movss %xmm1, 0x3bc(%rbx)
incq %r12
addq $0xc, %r13
cmpq %r12, %rsi
jne 0x4fe8
jmp 0x5409
movq 0x3e8(%rbx), %rax
movq -0x8(%rax,%r12,8), %rcx
movq 0x8(%rax,%r12,8), %rax
movsd (%rcx,%r14,8), %xmm0
subsd (%rax,%r14,8), %xmm0
jmp 0x51a0
movq 0x78(%rsp), %rax
incq %r14
cmpq %rax, %r14
jne 0x4f91
movl %r14d, 0x8(%rsp)
movl %r12d, 0x4(%rsp)
leaq 0x49c4(%rip), %rsi      # 0x9def
movq 0x70(%rsp), %rdi
callq 0x11f0
testq %rax, %rax
je 0x5567
leaq 0x49ae(%rip), %rdi      # 0x9df3
movl $0x1, %r14d
movl $0x1f, %esi
movl $0x1, %edx
movq 0x30(%rsp), %r12
movq %r12, %rcx
callq 0x11d0
movq 0x50(%rsp), %r13
leal 0x1(%r13), %eax
leaq 0x4(%rsp), %rdi
movl %eax, (%rdi)
movq 0x38(%rsp), %rax
leal 0x1(%rax), %r15d
leaq 0x8(%rsp), %rbp
movl %r15d, (%rbp)
movl $0x4, %esi
movl $0x1, %edx
movq %r12, %rcx
callq 0x11d0
movl $0x4, %esi
movl $0x1, %edx
movq %rbp, %rdi
movq %r12, %rcx
callq 0x11d0
cmpl $0x7ffffffd, %r13d      # imm = 0x7FFFFFFD
ja 0x567a
movslq %r15d, %r13
movl 0x28(%rsp), %r15d
movl 0x24(%rsp), %ebp
movq 0x10(%rsp), %rcx
movl $0x1, %r12d
cmpl $0x7ffffffd, 0x38(%rsp) # imm = 0x7FFFFFFD
ja 0x54f9
movq (%rcx,%r14,8), %rax
addq $0x10, %rax
movl $0x1, %r12d
movl $0x0, (%rax)
incq %r12
addq $0xc, %rax
cmpq %r12, %rbp
jne 0x54e7
movq (%rcx,%r14,8), %rdi
addq $0xc, %rdi
movl $0xc, %esi
movq %r13, %rdx
movq 0x30(%rsp), %rcx
callq 0x11d0
cmpq %r13, %rax
je 0x552b
leaq 0x4994(%rip), %rdi      # 0x9eb3
movq 0x70(%rsp), %rsi
xorl %eax, %eax
callq 0x10f0
incq %r14
cmpq %r15, %r14
movq 0x10(%rsp), %rcx
jne 0x54c9
jmp 0x5685
movl %r12d, 0x4(%rsp)
leaq 0x4b9a(%rip), %rdi      # 0xa0e3
callq 0x1070
movq %r15, %rdi
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x10c0
leaq 0x495d(%rip), %rdi      # 0x9ecb
movl $0x1, %r14d
movl $0x3e, %esi
movl $0x1, %edx
movq 0x30(%rsp), %r13
movq %r13, %rcx
callq 0x11d0
cmpl $0x7ffffffd, 0x50(%rsp) # imm = 0x7FFFFFFD
ja 0x5696
movl 0x28(%rsp), %r15d
movl 0x24(%rsp), %r12d
decq %r12
movq %r15, 0x40(%rsp)
movl $0x1, %ebp
cmpl $0x7ffffffd, 0x38(%rsp) # imm = 0x7FFFFFFD
ja 0x565a
leal -0x1(%r14), %eax
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
movss 0xc(%rsp), %xmm1
mulss %xmm1, %xmm0
movq 0x10(%rsp), %rax
movq (%rax,%r14,8), %r15
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0x60(%rsp)
addq $0x14, %r15
xorl %ebp, %ebp
xorps %xmm0, %xmm0
cvtsi2ss %ebp, %xmm0
mulss %xmm1, %xmm0
xorps %xmm1, %xmm1
cvtss2sd %xmm0, %xmm1
movq 0x3e8(%rbx), %rax
movq 0x8(%rax,%rbp,8), %rax
movsd (%rax,%r14,8), %xmm2
xorps %xmm3, %xmm3
cvtss2sd -0x4(%r15), %xmm3
xorps %xmm4, %xmm4
cvtss2sd -0x8(%r15), %xmm4
xorps %xmm5, %xmm5
cvtss2sd (%r15), %xmm5
movq %r13, %rdi
leaq 0x48d6(%rip), %rsi      # 0x9f0a
movsd 0x60(%rsp), %xmm0
movb $0x6, %al
callq 0x1150
movss 0xc(%rsp), %xmm1
incq %rbp
addq $0xc, %r15
cmpq %rbp, %r12
jne 0x55ec
incl %ebp
movq 0x40(%rsp), %r15
movl $0xa, %edi
movq %r13, %rsi
callq 0x1120
incq %r14
cmpq %r15, %r14
jne 0x55ab
movq %r13, 0x30(%rsp)
jmp 0x56a0
movl 0x8(%rsp), %r12d
movl $0x1, %r14d
movl %r14d, 0x4(%rsp)
movl %r12d, 0x8(%rsp)
movq 0x28(%rsp), %r15
jmp 0x56ae
movl 0x4(%rsp), %ebp
movl $0x1, %r14d
movq 0x28(%rsp), %r15
movl %r14d, 0x8(%rsp)
movl %ebp, 0x4(%rsp)
movq 0x30(%rsp), %rdi
callq 0x10c0
testl %r15d, %r15d
jle 0x56e0
movl %r15d, %r15d
xorl %r14d, %r14d
movq 0x10(%rsp), %rax
movq (%rax,%r14,8), %rdi
callq 0x1030
movq 0x10(%rsp), %rdi
incq %r14
cmpq %r14, %r15
jne 0x56c3
jmp 0x56e8
xorl %r14d, %r14d
movq 0x10(%rsp), %rdi
movl %r14d, 0x4(%rsp)
callq 0x1030
cmpl $0x0, 0x80(%rbx)
je 0x570d
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorps %xmm0, %xmm0
cvtss2sd 0x448(%rbx), %xmm0
xorps %xmm1, %xmm1
cvtss2sd 0x3b0(%rbx), %xmm1
xorps %xmm2, %xmm2
cvtss2sd 0x3bc(%rbx), %xmm2
leaq 0x47fa(%rip), %rdi      # 0x9f2f
movb $0x3, %al
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x10f0