// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movl $0x1, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movss 0x54(%rax), %xmm0
movss %xmm0, -0x20(%rbp)
movq -0x10(%rbp), %rax
movss 0x4(%rax), %xmm0
divss -0x20(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
callq 0x10f0
addq $0x2, %rax
movl %eax, -0x24(%rbp)
movq -0x10(%rbp), %rax
movss 0x8(%rax), %xmm0
divss -0x20(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
callq 0x10f0
addq $0x2, %rax
movl %eax, -0x28(%rbp)
movq -0x10(%rbp), %rax
addq $0x3e0, %rax            # imm = 0x3E0
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rax
movss 0x79f1(%rip), %xmm0     # 0xd128
movss %xmm0, 0x448(%rax)
movq -0x10(%rbp), %rax
movss 0x79d9(%rip), %xmm0     # 0xd124
movss %xmm0, 0x3bc(%rax)
movq -0x10(%rbp), %rax
movss 0x79c5(%rip), %xmm0     # 0xd124
movss %xmm0, 0x3b0(%rax)
movq -0x10(%rbp), %rax
movss 0x58(%rax), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x5814
movl $0x1, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x5812
movl $0x1, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl -0x28(%rbp), %eax
jge 0x5802
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq 0x3e0(%rax,%rcx,8), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x18(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq 0x3e0(%rax,%rcx,8), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x18(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x5796
jmp 0x5804
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x5783
jmp 0x5814
movq -0x10(%rbp), %rdi
addq $0x188, %rdi            # imm = 0x188
leaq 0x7e2e(%rip), %rsi      # 0xd654
callq 0x1180
movq %rax, -0x40(%rbp)
cmpq $0x0, %rax
jne 0x585a
movq -0x10(%rbp), %rsi
addq $0x188, %rsi            # imm = 0x188
leaq 0x8700(%rip), %rdi      # 0xdf47
movb $0x0, %al
callq 0x10e0
movl $0x1, -0x4(%rbp)
jmp 0x67dc
movq -0x10(%rbp), %rsi
addq $0x188, %rsi            # imm = 0x188
leaq 0x870d(%rip), %rdi      # 0xdf79
movb $0x0, %al
callq 0x10e0
movq -0x40(%rbp), %rdi
movq -0x10(%rbp), %rsi
addq $0x1480, %rsi           # imm = 0x1480
callq 0x9df0
movq -0x40(%rbp), %rdi
movq -0x10(%rbp), %rax
movss 0x74(%rax), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x85b3(%rip), %rsi      # 0xde52
movb $0x1, %al
callq 0x1130
movq -0x10(%rbp), %rax
cmpl $0x0, 0x440(%rax)
je 0x58c7
movq -0x40(%rbp), %rdi
leaq 0x85b5(%rip), %rsi      # 0xde73
movb $0x0, %al
callq 0x1130
jmp 0x5911
movq -0x40(%rbp), %rdi
leaq 0x85c0(%rip), %rsi      # 0xde92
movb $0x0, %al
callq 0x1130
movq -0x10(%rbp), %rax
movss 0x444(%rax), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x590f
movq -0x40(%rbp), %rdi
movq -0x10(%rbp), %rax
movss 0x444(%rax), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x85ad(%rip), %rsi      # 0xdeb5
movb $0x1, %al
callq 0x1130
jmp 0x5911
movslq -0x28(%rbp), %rdi
shlq $0x3, %rdi
callq 0x1150
movq %rax, -0x50(%rbp)
cmpq $0x0, %rax
jne 0x594b
leaq 0x8672(%rip), %rdi      # 0xdfa1
movb $0x0, %al
callq 0x10e0
movq -0x40(%rbp), %rdi
callq 0x10b0
movl $0x1, -0x4(%rbp)
jmp 0x67dc
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl -0x28(%rbp), %eax
jge 0x59aa
movslq -0x24(%rbp), %rdi
movl $0xc, %esi
callq 0x1120
movq -0x50(%rbp), %rcx
movslq -0x14(%rbp), %rdx
movq %rax, (%rcx,%rdx,8)
cmpq $0x0, %rax
jne 0x599d
leaq 0x8636(%rip), %rdi      # 0xdfb7
movb $0x0, %al
callq 0x10e0
movq -0x40(%rbp), %rdi
callq 0x10b0
movl $0x1, -0x4(%rbp)
jmp 0x67dc
jmp 0x599f
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x5952
movl $0x1, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl -0x28(%rbp), %eax
jge 0x64f1
movl -0x18(%rbp), %eax
subl $0x1, %eax
cvtsi2ss %eax, %xmm0
mulss -0x20(%rbp), %xmm0
movss %xmm0, -0x2c(%rbp)
movl $0x1, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x64e1
movl -0x14(%rbp), %eax
subl $0x1, %eax
cvtsi2ss %eax, %xmm0
mulss -0x20(%rbp), %xmm0
movss %xmm0, -0x30(%rbp)
cmpl $0x1, -0x18(%rbp)
jne 0x5a21
movq -0x50(%rbp), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x14(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
xorps %xmm0, %xmm0
movss %xmm0, (%rax)
jmp 0x5e1e
movq -0x10(%rbp), %rax
movq 0x430(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x18(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x7, %eax
jne 0x5b40
movq -0x48(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x18(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x48(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl -0x18(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
subsd (%rax,%rcx,8), %xmm0
movq -0x10(%rbp), %rax
movq 0x1458(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x18(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm2
movq -0x48(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl -0x18(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm1
movq -0x48(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x18(%rbp), %rcx
subsd (%rax,%rcx,8), %xmm1
movq -0x10(%rbp), %rax
movq 0x1450(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x18(%rbp), %rcx
mulsd (%rax,%rcx,8), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movss -0x20(%rbp), %xmm1
cvtss2sd %xmm1, %xmm2
movsd 0x754c(%rip), %xmm1     # 0xd060
mulsd %xmm2, %xmm1
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movq -0x50(%rbp), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x14(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movss %xmm0, (%rax)
jmp 0x5e1c
movq -0x10(%rbp), %rax
movq 0x430(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x18(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x2, %eax
jge 0x5c2a
movq -0x10(%rbp), %rax
movq 0x430(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl -0x18(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x7, %eax
jne 0x5c2a
movq -0x48(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl -0x18(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x48(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x18(%rbp), %rcx
subsd (%rax,%rcx,8), %xmm0
movq -0x10(%rbp), %rax
movq 0x1458(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl -0x18(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
mulsd (%rax,%rcx,8), %xmm0
movss -0x20(%rbp), %xmm1
cvtss2sd %xmm1, %xmm2
movsd 0x7452(%rip), %xmm1     # 0xd050
mulsd %xmm2, %xmm1
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movq -0x50(%rbp), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x14(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movss %xmm0, (%rax)
jmp 0x5e1a
movq -0x10(%rbp), %rax
movq 0x430(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x18(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x2, %eax
jge 0x5d14
movq -0x10(%rbp), %rax
movq 0x430(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl -0x18(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x7, %eax
jne 0x5d14
movq -0x48(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x18(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x48(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl -0x18(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
subsd (%rax,%rcx,8), %xmm0
movq -0x10(%rbp), %rax
movq 0x1450(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl -0x18(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
mulsd (%rax,%rcx,8), %xmm0
movss -0x20(%rbp), %xmm1
cvtss2sd %xmm1, %xmm2
movsd 0x7368(%rip), %xmm1     # 0xd050
mulsd %xmm2, %xmm1
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movq -0x50(%rbp), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x14(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movss %xmm0, (%rax)
jmp 0x5e18
movl -0x18(%rbp), %eax
movl -0x28(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jne 0x5d9a
movq -0x48(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl -0x18(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x48(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x18(%rbp), %rcx
subsd (%rax,%rcx,8), %xmm0
movss -0x20(%rbp), %xmm1
cvtss2sd %xmm1, %xmm2
movsd 0x72df(%rip), %xmm1     # 0xd050
mulsd %xmm2, %xmm1
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movq -0x50(%rbp), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x14(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movss %xmm0, (%rax)
jmp 0x5e16
movq -0x48(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl -0x18(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x48(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl -0x18(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
subsd (%rax,%rcx,8), %xmm0
movss -0x20(%rbp), %xmm1
cvtss2sd %xmm1, %xmm2
movsd 0x7271(%rip), %xmm1     # 0xd060
mulsd %xmm2, %xmm1
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movq -0x50(%rbp), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x14(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movss %xmm0, (%rax)
jmp 0x5e18
jmp 0x5e1a
jmp 0x5e1c
jmp 0x5e1e
movq -0x10(%rbp), %rax
movq 0x430(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x18(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x7, %eax
jne 0x5f3e
movq -0x48(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x18(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x48(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movslq -0x18(%rbp), %rcx
subsd (%rax,%rcx,8), %xmm0
movq -0x10(%rbp), %rax
movq 0x1468(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x18(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm2
movq -0x48(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl -0x14(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movslq -0x18(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm1
movq -0x48(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x18(%rbp), %rcx
subsd (%rax,%rcx,8), %xmm1
movq -0x10(%rbp), %rax
movq 0x1460(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x18(%rbp), %rcx
mulsd (%rax,%rcx,8), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movss -0x20(%rbp), %xmm1
cvtss2sd %xmm1, %xmm2
movsd 0x714f(%rip), %xmm1     # 0xd060
mulsd %xmm2, %xmm1
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movq -0x50(%rbp), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x14(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movss %xmm0, 0x8(%rax)
jmp 0x62a3
movq -0x10(%rbp), %rax
movq 0x430(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x18(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x2, %eax
jge 0x6029
movq -0x10(%rbp), %rax
movq 0x430(%rax), %rax
movl -0x14(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movslq -0x18(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x7, %eax
jne 0x6029
movq -0x48(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl -0x14(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movslq -0x18(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x48(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x18(%rbp), %rcx
subsd (%rax,%rcx,8), %xmm0
movq -0x10(%rbp), %rax
movq 0x1468(%rax), %rax
movl -0x14(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movslq -0x18(%rbp), %rcx
mulsd (%rax,%rcx,8), %xmm0
movss -0x20(%rbp), %xmm1
cvtss2sd %xmm1, %xmm2
movsd 0x7054(%rip), %xmm1     # 0xd050
mulsd %xmm2, %xmm1
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movq -0x50(%rbp), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x14(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movss %xmm0, 0x8(%rax)
jmp 0x62a1
movq -0x10(%rbp), %rax
movq 0x430(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x18(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x2, %eax
jge 0x6114
movq -0x10(%rbp), %rax
movq 0x430(%rax), %rax
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movslq -0x18(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x7, %eax
jne 0x6114
movq -0x48(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x18(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x48(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movslq -0x18(%rbp), %rcx
subsd (%rax,%rcx,8), %xmm0
movq -0x10(%rbp), %rax
movq 0x1460(%rax), %rax
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movslq -0x18(%rbp), %rcx
mulsd (%rax,%rcx,8), %xmm0
movss -0x20(%rbp), %xmm1
cvtss2sd %xmm1, %xmm2
movsd 0x6f69(%rip), %xmm1     # 0xd050
mulsd %xmm2, %xmm1
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movq -0x50(%rbp), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x14(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movss %xmm0, 0x8(%rax)
jmp 0x629f
cmpl $0x1, -0x14(%rbp)
jne 0x6197
movq -0x48(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x18(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x48(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movslq -0x18(%rbp), %rcx
subsd (%rax,%rcx,8), %xmm0
movss -0x20(%rbp), %xmm1
cvtss2sd %xmm1, %xmm2
movsd 0x6ee6(%rip), %xmm1     # 0xd050
mulsd %xmm2, %xmm1
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movq -0x50(%rbp), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x14(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movss %xmm0, 0x8(%rax)
jmp 0x629d
movl -0x14(%rbp), %eax
movl -0x24(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jne 0x621e
movq -0x48(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl -0x14(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movslq -0x18(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x48(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x18(%rbp), %rcx
subsd (%rax,%rcx,8), %xmm0
movss -0x20(%rbp), %xmm1
cvtss2sd %xmm1, %xmm2
movsd 0x6e5c(%rip), %xmm1     # 0xd050
mulsd %xmm2, %xmm1
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movq -0x50(%rbp), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x14(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movss %xmm0, 0x8(%rax)
jmp 0x629b
movq -0x48(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl -0x14(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movslq -0x18(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x48(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movslq -0x18(%rbp), %rcx
subsd (%rax,%rcx,8), %xmm0
movss -0x20(%rbp), %xmm1
cvtss2sd %xmm1, %xmm2
movsd 0x6ded(%rip), %xmm1     # 0xd060
mulsd %xmm2, %xmm1
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movq -0x50(%rbp), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x14(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movss %xmm0, 0x8(%rax)
jmp 0x629d
jmp 0x629f
jmp 0x62a1
jmp 0x62a3
movq -0x50(%rbp), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x14(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movss (%rax), %xmm0
movq -0x50(%rbp), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x14(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movss (%rax), %xmm2
movq -0x50(%rbp), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x14(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movss 0x8(%rax), %xmm1
movq -0x50(%rbp), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x14(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
mulss 0x8(%rax), %xmm1
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
callq 0x11b0
cvtsd2ss %xmm0, %xmm0
movq -0x50(%rbp), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x14(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movss %xmm0, 0x4(%rax)
movss %xmm0, -0x34(%rbp)
movss -0x20(%rbp), %xmm0
cvtss2sd %xmm0, %xmm1
movsd 0x6cd0(%rip), %xmm0     # 0xd028
divsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0x54(%rbp)
movss -0x34(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x6cdc(%rip), %xmm1     # 0xd050
ucomisd %xmm1, %xmm0
jbe 0x64d1
movss -0x34(%rbp), %xmm1
movq -0x10(%rbp), %rax
movss 0x448(%rax), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x64d1
movl -0x14(%rbp), %eax
movl -0x54(%rbp), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jle 0x64d1
movl -0x18(%rbp), %eax
movl -0x28(%rbp), %ecx
subl -0x54(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jge 0x64d1
movl -0x14(%rbp), %eax
movl -0x24(%rbp), %ecx
subl -0x54(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jge 0x64d1
movq -0x10(%rbp), %rax
movq 0x430(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x18(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x2, %eax
jne 0x64d1
movq -0x10(%rbp), %rax
movq 0x430(%rax), %rax
movl -0x14(%rbp), %ecx
addl -0x54(%rbp), %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movslq -0x18(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x2, %eax
jne 0x64d1
movq -0x10(%rbp), %rax
movq 0x430(%rax), %rax
movl -0x14(%rbp), %ecx
subl -0x54(%rbp), %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movslq -0x18(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x2, %eax
jne 0x64d1
movq -0x10(%rbp), %rax
movq 0x430(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl -0x18(%rbp), %ecx
addl -0x54(%rbp), %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x2, %eax
jne 0x64d1
movl -0x18(%rbp), %eax
movl -0x54(%rbp), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jl 0x649e
movq -0x10(%rbp), %rax
movq 0x430(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl -0x18(%rbp), %ecx
subl -0x54(%rbp), %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x2, %eax
jne 0x64d1
movss -0x34(%rbp), %xmm0
movq -0x10(%rbp), %rax
movss %xmm0, 0x448(%rax)
movss -0x2c(%rbp), %xmm0
movq -0x10(%rbp), %rax
movss %xmm0, 0x3b0(%rax)
movss -0x30(%rbp), %xmm0
movq -0x10(%rbp), %rax
movss %xmm0, 0x3bc(%rax)
jmp 0x64d3
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x59d8
jmp 0x64e3
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x59b1
movq -0x10(%rbp), %rdi
addq $0x188, %rdi            # imm = 0x188
leaq 0x79da(%rip), %rsi      # 0xdedd
callq 0x11c0
cmpq $0x0, %rax
je 0x6613
movq -0x40(%rbp), %rdi
leaq 0x79c4(%rip), %rsi      # 0xdee1
movb $0x0, %al
callq 0x1130
movl -0x28(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x14(%rbp)
movl -0x24(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x18(%rbp)
movq -0x40(%rbp), %rcx
leaq -0x14(%rbp), %rdi
movl $0x4, %esi
movl $0x1, %edx
callq 0x11a0
movq -0x40(%rbp), %rcx
leaq -0x18(%rbp), %rdi
movl $0x4, %esi
movl $0x1, %edx
callq 0x11a0
movl $0x1, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl -0x28(%rbp), %eax
jge 0x660e
movl $0x1, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x65b0
movq -0x50(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x18(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
xorps %xmm0, %xmm0
movss %xmm0, 0x4(%rax)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x657e
movq -0x50(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
addq $0xc, %rdi
movl -0x24(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rdx
movq -0x40(%rbp), %rcx
movl $0xc, %esi
callq 0x11a0
movl -0x24(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
cmpq %rcx, %rax
je 0x65fe
movq -0x10(%rbp), %rsi
addq $0x188, %rsi            # imm = 0x188
leaq 0x79d6(%rip), %rdi      # 0xdfcd
movb $0x0, %al
callq 0x10e0
jmp 0x6600
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x656b
jmp 0x674d
movq -0x40(%rbp), %rdi
leaq 0x79c7(%rip), %rsi      # 0xdfe5
movb $0x0, %al
callq 0x1130
movl $0x1, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl -0x28(%rbp), %eax
jge 0x674b
movl -0x18(%rbp), %eax
subl $0x1, %eax
cvtsi2ss %eax, %xmm0
mulss -0x20(%rbp), %xmm0
movss %xmm0, -0x2c(%rbp)
movl $0x1, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x672b
movl -0x14(%rbp), %eax
subl $0x1, %eax
cvtsi2ss %eax, %xmm0
mulss -0x20(%rbp), %xmm0
movss %xmm0, -0x30(%rbp)
movq -0x50(%rbp), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x14(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movss 0x4(%rax), %xmm0
movss %xmm0, -0x34(%rbp)
movq -0x40(%rbp), %rdi
movss -0x2c(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movss -0x30(%rbp), %xmm1
cvtss2sd %xmm1, %xmm1
movq -0x48(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x18(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm2
movss -0x34(%rbp), %xmm3
cvtss2sd %xmm3, %xmm3
movq -0x50(%rbp), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x14(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movss (%rax), %xmm4
cvtss2sd %xmm4, %xmm4
movq -0x50(%rbp), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x14(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movss 0x8(%rax), %xmm5
cvtss2sd %xmm5, %xmm5
leaq 0x790e(%rip), %rsi      # 0xe024
movb $0x6, %al
callq 0x1130
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x6653
movq -0x40(%rbp), %rdi
leaq 0x8448(%rip), %rsi      # 0xeb7e
movb $0x0, %al
callq 0x1130
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x662c
jmp 0x674d
movq -0x40(%rbp), %rdi
callq 0x10b0
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl -0x28(%rbp), %eax
jge 0x6781
movq -0x50(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x1030
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x675d
movq -0x50(%rbp), %rdi
callq 0x1030
movq -0x10(%rbp), %rax
cmpl $0x0, 0x80(%rax)
jne 0x67d5
movq -0x10(%rbp), %rax
movss 0x448(%rax), %xmm0
cvtss2sd %xmm0, %xmm0
movq -0x10(%rbp), %rax
movss 0x3b0(%rax), %xmm1
cvtss2sd %xmm1, %xmm1
movq -0x10(%rbp), %rax
movss 0x3bc(%rax), %xmm2
cvtss2sd %xmm2, %xmm2
leaq 0x787b(%rip), %rdi      # 0xe049
movb $0x3, %al
callq 0x10e0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)