// File: /workspace/github_c_makefile_star2_O3/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 $0xb8, %rsp
movq %rdi, %rbx
movss 0x4(%rdi), %xmm0
movss 0x54(%rdi), %xmm1
movss %xmm1, 0x60(%rsp)
divss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
callq 0x1100
movq %rax, 0x10(%rsp)
leal 0x2(%rax), %ebp
movss 0x8(%rbx), %xmm0
divss 0x60(%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 0x4cd9
cmpl $0x7ffffffd, 0x10(%rsp) # imm = 0x7FFFFFFD
ja 0x4ccc
movl %ebp, %eax
movl %r14d, %ecx
movl $0x1, %edx
movaps 0x44d5(%rip), %xmm0     # 0x9160
movl $0x1, %esi
cmpl $0x7ffffffd, %r12d      # imm = 0x7FFFFFFD
ja 0x4cc0
movq 0x3e8(%rbx), %rsi
movq (%rsi,%rdx,8), %rsi
movl $0x1, %edi
movsd (%rsi,%rdi,8), %xmm1
xorps %xmm0, %xmm1
movlps %xmm1, (%rsi,%rdi,8)
incq %rdi
cmpq %rdi, %rcx
jne 0x4ca9
movl %r14d, %esi
incq %rdx
cmpq %rax, %rdx
jne 0x4c8b
movl %ebp, %eax
jmp 0x4cd1
movl $0x1, %eax
movl %eax, 0x1c(%rsp)
movl %esi, 0x5c(%rsp)
leaq 0x188(%rbx), %r13
leaq 0x4a2d(%rip), %rsi      # 0x9714
movq %r13, %rdi
callq 0x11a0
testq %rax, %rax
je 0x4d5d
movq %rax, %r15
leaq 0x520d(%rip), %rdi      # 0x9f0b
movq %r13, %rsi
xorl %eax, %eax
callq 0x10f0
leaq 0x1480(%rbx), %rsi
movq %r15, %rdi
callq 0x6d20
xorps %xmm0, %xmm0
cvtss2sd 0x74(%rbx), %xmm0
leaq 0x50be(%rip), %rsi      # 0x9de4
movq %r15, %rdi
movb $0x1, %al
callq 0x1150
cmpl $0x0, 0x440(%rbx)
movl %ebp, 0x4(%rsp)
movq %r12, 0x70(%rsp)
je 0x4d7f
leaq 0x50bc(%rip), %rdi      # 0x9e05
movl $0x1e, %esi
movl $0x1, %edx
movq %r15, %rcx
callq 0x11c0
jmp 0x4dbd
leaq 0x5175(%rip), %rdi      # 0x9ed9
movq %r13, %rsi
xorl %eax, %eax
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x10f0
leaq 0x509e(%rip), %rdi      # 0x9e24
movl $0x22, %esi
movl $0x1, %edx
movq %r15, %rcx
callq 0x11c0
movss 0x444(%rbx), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x4dbd
cvtss2sd %xmm0, %xmm0
leaq 0x5094(%rip), %rsi      # 0x9e47
movq %r15, %rdi
movb $0x1, %al
callq 0x1150
movslq %r14d, %rdi
shlq $0x3, %rdi
callq 0x1170
testq %rax, %rax
je 0x531b
movq %rax, %r12
testl %r14d, %r14d
movq %r15, 0x8(%rsp)
movq %rax, 0x48(%rsp)
movq %r14, 0x20(%rsp)
movq %r13, 0x28(%rsp)
jle 0x532c
movslq 0x4(%rsp), %r13
movl %r14d, %r15d
xorl %r14d, %r14d
movl $0xc, %esi
movq %r13, %rdi
callq 0x1140
movq %rax, (%r12,%r14,8)
testq %rax, %rax
je 0x533d
incq %r14
cmpq %r14, %r15
jne 0x4dfd
movq 0x70(%rsp), %rax
cmpl $0x7ffffffe, %eax       # imm = 0x7FFFFFFE
setb %cl
jae 0x5364
movl %ecx, (%rsp)
incl %eax
movq %rax, 0x50(%rsp)
movss 0x60(%rsp), %xmm6
cvtss2sd %xmm6, %xmm2
movsd 0x423a(%rip), %xmm0     # 0x9088
mulsd %xmm2, %xmm0
movsd 0x41ce(%rip), %xmm1     # 0x9028
mulsd %xmm2, %xmm1
movq 0x10(%rsp), %rcx
incl %ecx
movsd 0x41d3(%rip), %xmm3     # 0x9040
divsd %xmm2, %xmm3
cvttsd2si %xmm3, %edx
leal 0x1(%rdx), %esi
movslq %edx, %r10
notl %edx
movq 0x20(%rsp), %rax
leal (%rax,%rdx), %r8d
movl 0x4(%rsp), %eax
addl %eax, %edx
movslq %esi, %rsi
movslq %edx, %rdi
movslq %r8d, %r8
movl %eax, %r9d
movq %r10, 0x30(%rsp)
leaq (,%r10,8), %rax
negq %rax
movq %rax, 0x90(%rsp)
movl $0x1, %r13d
leaq (%rcx,%rcx,2), %rax
movq %rax, 0x88(%rsp)
movsd 0x415e(%rip), %xmm2     # 0x9028
movq %r15, 0x98(%rsp)
cmpl $0x7ffffffe, 0x10(%rsp) # imm = 0x7FFFFFFE
jae 0x52f8
leaq -0x1(%r13), %rdx
movq %rdx, 0x40(%rsp)
xorps %xmm3, %xmm3
cvtsi2ss %edx, %xmm3
mulss %xmm6, %xmm3
leaq 0x1(%r13), %rax
movq %rax, 0x78(%rsp)
movq 0x430(%rbx), %rdx
movq (%r12,%r13,8), %r14
movq %r13, %r10
movq 0x30(%rsp), %rax
subq %rax, %r10
movq %r10, 0xa0(%rsp)
movq 0x88(%rsp), %r10
leaq (%r14,%r10,4), %r10
addq $0x8, %r10
movq %r10, 0xb0(%rsp)
leaq (%rdx,%rax,8), %rax
movq %rax, 0x38(%rsp)
movq 0x90(%rsp), %rax
addq %rdx, %rax
movq %rax, 0xa8(%rsp)
movl $0x1, %ebp
movl $0x14, %r10d
cmpq $0x1, %r13
jne 0x4f6d
movq 0x8(%r12), %r11
xorps %xmm4, %xmm4
jmp 0x508b
movq (%rdx,%rbp,8), %r11
movb (%r11,%r13), %r15b
cmpb $0x7, %r15b
jne 0x4fd4
movq 0x3e8(%rbx), %r11
movq (%r11,%rbp,8), %r11
movsd -0x8(%r11,%r13,8), %xmm4
movsd (%r11,%r13,8), %xmm5
subsd %xmm5, %xmm4
subsd 0x8(%r11,%r13,8), %xmm5
movq 0x1458(%rbx), %r11
movq 0x1450(%rbx), %r15
movq (%r15,%rbp,8), %r15
mulsd (%r15,%r13,8), %xmm4
movq (%r11,%rbp,8), %r11
mulsd (%r11,%r13,8), %xmm5
addsd %xmm4, %xmm5
divsd %xmm0, %xmm5
xorps %xmm4, %xmm4
cvtsd2ss %xmm5, %xmm4
jmp 0x5088
cmpb $0x1, %r15b
movq 0x50(%rsp), %rax
jg 0x504f
movq 0x40(%rsp), %r15
cmpb $0x7, (%r11,%r15)
jne 0x5017
movq 0x3e8(%rbx), %r11
movq (%r11,%rbp,8), %r11
movsd -0x8(%r11,%r13,8), %xmm4
subsd (%r11,%r13,8), %xmm4
movq 0x1458(%rbx), %r11
movq (%r11,%rbp,8), %r11
mulsd -0x8(%r11,%r13,8), %xmm4
jmp 0x506c
movq 0x78(%rsp), %r15
cmpb $0x7, (%r11,%r15)
jne 0x504f
movq 0x3e8(%rbx), %r11
movq (%r11,%rbp,8), %r11
movsd (%r11,%r13,8), %xmm4
subsd 0x8(%r11,%r13,8), %xmm4
movq 0x1450(%rbx), %r11
movq (%r11,%rbp,8), %r11
mulsd 0x8(%r11,%r13,8), %xmm4
jmp 0x506c
movq 0x3e8(%rbx), %r11
movq (%r11,%rbp,8), %r11
cmpq %rax, %r13
jne 0x5072
movsd -0x8(%r11,%rax,8), %xmm4
subsd (%r11,%rax,8), %xmm4
divsd %xmm1, %xmm4
jmp 0x5084
movsd -0x8(%r11,%r13,8), %xmm4
subsd 0x8(%r11,%r13,8), %xmm4
divsd %xmm0, %xmm4
cvtsd2ss %xmm4, %xmm4
movq %r14, %r11
movss %xmm4, -0x8(%r11,%r10)
movq (%rdx,%rbp,8), %r11
movb (%r11,%r13), %r15b
cmpb $0x7, %r15b
jne 0x50ff
movq 0x3e8(%rbx), %r15
movq -0x8(%r15,%rbp,8), %r12
movq (%r15,%rbp,8), %rax
movsd (%rax,%r13,8), %xmm4
movq 0x8(%r15,%rbp,8), %rax
movsd (%r12,%r13,8), %xmm5
movq 0x48(%rsp), %r12
subsd %xmm4, %xmm5
subsd (%rax,%r13,8), %xmm4
movq 0x1468(%rbx), %rax
movq 0x1460(%rbx), %r15
movq (%r15,%rbp,8), %r15
mulsd (%r15,%r13,8), %xmm5
movq (%rax,%rbp,8), %rax
mulsd (%rax,%r13,8), %xmm4
addsd %xmm5, %xmm4
divsd %xmm0, %xmm4
jmp 0x5181
cmpb $0x1, %r15b
jg 0x526f
movq -0x8(%rdx,%rbp,8), %rax
cmpb $0x7, (%rax,%r13)
jne 0x513f
movq 0x3e8(%rbx), %rax
movq -0x8(%rax,%rbp,8), %r15
movq (%rax,%rbp,8), %rax
movsd (%r15,%r13,8), %xmm4
subsd (%rax,%r13,8), %xmm4
movq 0x1468(%rbx), %rax
movq -0x8(%rax,%rbp,8), %rax
jmp 0x5177
movq 0x8(%rdx,%rbp,8), %rax
cmpb $0x7, (%rax,%r13)
jne 0x526f
movq 0x3e8(%rbx), %rax
movq (%rax,%rbp,8), %r15
movq 0x8(%rax,%rbp,8), %rax
movsd (%r15,%r13,8), %xmm4
subsd (%rax,%r13,8), %xmm4
movq 0x1460(%rbx), %rax
movq 0x8(%rax,%rbp,8), %rax
mulsd (%rax,%r13,8), %xmm4
divsd %xmm1, %xmm4
cvtsd2ss %xmm4, %xmm4
movss %xmm4, (%r14,%r10)
movss -0x8(%r14,%r10), %xmm4
movss (%r14,%r10), %xmm5
mulss %xmm5, %xmm5
mulss %xmm4, %xmm4
addss %xmm5, %xmm4
sqrtss %xmm4, %xmm4
movss %xmm4, -0x4(%r14,%r10)
xorps %xmm5, %xmm5
cvtss2sd %xmm4, %xmm5
ucomisd %xmm2, %xmm5
jbe 0x525a
movss 0x448(%rbx), %xmm5
ucomiss %xmm4, %xmm5
jbe 0x525a
cmpq %rsi, %rbp
jle 0x525a
cmpq %r8, %r13
jge 0x525a
cmpq %rdi, %rbp
jge 0x525a
cmpb $0x2, (%r11,%r13)
jne 0x525a
movq 0x38(%rsp), %rax
movq (%rax,%rbp,8), %rax
cmpb $0x2, (%rax,%r13)
jne 0x525a
movq 0xa8(%rsp), %rax
movq (%rax,%rbp,8), %rax
cmpb $0x2, (%rax,%r13)
jne 0x525a
leaq (%r11,%r13), %rax
movq 0x30(%rsp), %r15
cmpb $0x2, (%r15,%rax)
jne 0x525a
cmpq 0x30(%rsp), %r13
jle 0x5234
movq 0xa0(%rsp), %rax
cmpb $0x2, (%r11,%rax)
jne 0x525a
leal -0x1(%rbp), %eax
xorps %xmm5, %xmm5
cvtsi2ss %eax, %xmm5
mulss %xmm6, %xmm5
movss %xmm4, 0x448(%rbx)
movss %xmm3, 0x3b0(%rbx)
movss %xmm5, 0x3bc(%rbx)
incq %rbp
addq $0xc, %r10
cmpq %rbp, %r9
jne 0x4f5a
jmp 0x5300
cmpq $0x1, %rbp
jne 0x52a3
movq 0x3e8(%rbx), %rax
movq 0x8(%rax), %r15
movq 0x10(%rax), %rax
movsd (%r15,%r13,8), %xmm4
subsd (%rax,%r13,8), %xmm4
divsd %xmm1, %xmm4
cvtsd2ss %xmm4, %xmm4
movss %xmm4, 0x14(%r14)
jmp 0x518b
movq 0x3e8(%rbx), %r15
cmpq %rbp, %rcx
jne 0x52dd
movq -0x8(%r15,%rcx,8), %rax
movq (%r15,%rcx,8), %r15
movsd (%rax,%r13,8), %xmm4
subsd (%r15,%r13,8), %xmm4
divsd %xmm1, %xmm4
cvtsd2ss %xmm4, %xmm4
movq 0xb0(%rsp), %rax
movss %xmm4, (%rax)
jmp 0x518b
movq -0x8(%r15,%rbp,8), %rax
movq 0x8(%r15,%rbp,8), %r15
movsd (%rax,%r13,8), %xmm4
subsd (%r15,%r13,8), %xmm4
jmp 0x50f6
incq %r13
movq %r13, %rax
jmp 0x5310
movq 0x78(%rsp), %rax
movq %rax, %r13
movq 0x98(%rsp), %r15
cmpq %r15, %rax
jne 0x4ed2
jmp 0x536b
leaq 0x4e56(%rip), %rdi      # 0xa178
callq 0x1070
movq %r15, %rdi
jmp 0x534e
movl $0x0, 0x1c(%rsp)
movl $0x0, (%rsp)
jmp 0x5375
leaq 0x4e1f(%rip), %rdi      # 0xa163
callq 0x1070
movq 0x8(%rsp), %rdi
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x10c0
movl $0x0, (%rsp)
movq 0x8(%rsp), %r15
movq 0x28(%rsp), %r13
leaq 0x4af3(%rip), %rsi      # 0x9e6f
movq %r13, %rdi
callq 0x11d0
testq %rax, %rax
je 0x5578
leaq 0x4adf(%rip), %rdi      # 0x9e73
movl $0x1, %r14d
movl $0x1f, %esi
movl $0x1, %edx
movq %r15, %rcx
callq 0x11c0
movq 0x70(%rsp), %rax
incl %eax
leaq 0x1c(%rsp), %rdi
movl %eax, (%rdi)
movq 0x10(%rsp), %rax
leal 0x1(%rax), %ebp
leaq 0x5c(%rsp), %r13
movl %ebp, (%r13)
movl $0x4, %esi
movl $0x1, %edx
movq %r15, %rcx
callq 0x11c0
movl $0x4, %esi
movl $0x1, %edx
movq %r13, %rdi
movq %r15, %rcx
callq 0x11c0
cmpb $0x0, (%rsp)
je 0x56a1
movslq %ebp, %rbp
movl 0x20(%rsp), %r15d
movl 0x4(%rsp), %eax
leaq 0x2(%rax), %r13
andq $-0x4, %r13
addq $-0x2, %rax
movq %rax, %xmm0
pshufd $0x44, %xmm0, %xmm4     # xmm4 = xmm0[0,1,0,1]
movdqa 0x3daa(%rip), %xmm5     # 0x91d0
movdqa 0x3d52(%rip), %xmm6     # 0x9180
movdqa 0x3d1a(%rip), %xmm7     # 0x9150
pxor %xmm7, %xmm4
pcmpeqd %xmm8, %xmm8
movdqa %xmm4, 0x60(%rsp)
movq (%r12,%r14,8), %rdi
cmpl $0x7ffffffd, 0x10(%rsp) # imm = 0x7FFFFFFD
ja 0x5516
leaq 0x34(%rdi), %rax
xorl %ecx, %ecx
movq %rcx, %xmm0
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
movdqa %xmm0, %xmm1
por %xmm6, %xmm1
pxor %xmm7, %xmm1
movdqa %xmm1, %xmm2
pcmpgtd %xmm4, %xmm2
pcmpeqd %xmm4, %xmm1
pshufd $0xf5, %xmm1, %xmm3     # xmm3 = xmm1[1,1,3,3]
pand %xmm2, %xmm3
pshufd $0xf5, %xmm2, %xmm1     # xmm1 = xmm2[1,1,3,3]
por %xmm3, %xmm1
movd %xmm1, %edx
notl %edx
testb $0x1, %dl
je 0x54a3
movl $0x0, -0x24(%rax)
pxor %xmm8, %xmm1
pextrw $0x4, %xmm1, %edx
testb $0x1, %dl
je 0x54b9
movl $0x0, -0x18(%rax)
por %xmm5, %xmm0
pxor %xmm7, %xmm0
movdqa %xmm0, %xmm1
pcmpgtd %xmm4, %xmm1
pcmpeqd %xmm4, %xmm0
pshufd $0xf5, %xmm0, %xmm2     # xmm2 = xmm0[1,1,3,3]
pand %xmm1, %xmm2
pshufd $0xf5, %xmm1, %xmm0     # xmm0 = xmm1[1,1,3,3]
por %xmm2, %xmm0
pxor %xmm8, %xmm0
pextrw $0x0, %xmm0, %edx
testb $0x1, %dl
je 0x54f5
movl $0x0, -0xc(%rax)
pextrw $0x4, %xmm0, %edx
testb $0x1, %dl
je 0x5505
movl $0x0, (%rax)
addq $0x4, %rcx
addq $0x30, %rax
cmpq %rcx, %r13
jne 0x545d
addq $0xc, %rdi
movl $0xc, %esi
movq %rbp, %rdx
movq 0x8(%rsp), %rcx
callq 0x11c0
cmpq %rbp, %rax
je 0x5544
leaq 0x49fb(%rip), %rdi      # 0x9f33
movq 0x28(%rsp), %rsi
xorl %eax, %eax
callq 0x10f0
incq %r14
cmpq %r15, %r14
movdqa 0x60(%rsp), %xmm4
movdqa 0x3c78(%rip), %xmm5     # 0x91d0
movdqa 0x3c20(%rip), %xmm6     # 0x9180
movdqa 0x3be8(%rip), %xmm7     # 0x9150
pcmpeqd %xmm8, %xmm8
jne 0x5445
jmp 0x56a1
leaq 0x49cc(%rip), %rdi      # 0x9f4b
movl $0x3e, %esi
movl $0x1, %edx
movq %r15, %rcx
callq 0x11c0
movl $0x1, %ecx
cmpb $0x0, (%rsp)
je 0x56a1
movl 0x20(%rsp), %eax
movq %rax, 0x40(%rsp)
movl 0x4(%rsp), %eax
decq %rax
movq %rax, 0x38(%rsp)
movq %rbx, 0x80(%rsp)
movq 0x8(%rsp), %r13
cmpl $0x7ffffffd, 0x10(%rsp) # imm = 0x7FFFFFFD
leaq 0x49b9(%rip), %r14      # 0x9f8a
movq 0x38(%rsp), %rbx
movq %rcx, %rbp
ja 0x5676
leal -0x1(%rcx), %eax
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
mulss 0x60(%rsp), %xmm0
movq 0x48(%rsp), %rax
movq (%rax,%rcx,8), %r12
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0x50(%rsp)
addq $0x14, %r12
xorl %r15d, %r15d
xorps %xmm0, %xmm0
cvtsi2ss %r15d, %xmm0
mulss 0x60(%rsp), %xmm0
xorps %xmm1, %xmm1
cvtss2sd %xmm0, %xmm1
movq 0x80(%rsp), %rax
movq 0x3e8(%rax), %rax
movq 0x8(%rax,%r15,8), %rax
movsd (%rax,%rcx,8), %xmm2
xorps %xmm3, %xmm3
cvtss2sd -0x4(%r12), %xmm3
xorps %xmm4, %xmm4
cvtss2sd -0x8(%r12), %xmm4
xorps %xmm5, %xmm5
cvtss2sd (%r12), %xmm5
movq %r13, %rdi
movq %r14, %rsi
movsd 0x50(%rsp), %xmm0
movb $0x6, %al
callq 0x1150
movq %rbp, %rcx
incq %r15
addq $0xc, %r12
cmpq %r15, %rbx
jne 0x5609
movl $0xa, %edi
movq %r13, %rsi
callq 0x1120
movq %rbp, %rcx
incq %rcx
cmpq 0x40(%rsp), %rcx
movq 0x48(%rsp), %r12
movq 0x80(%rsp), %rbx
jne 0x55c2
movq 0x8(%rsp), %rdi
callq 0x10c0
movq 0x20(%rsp), %rax
testl %eax, %eax
jle 0x56cb
movl %eax, %r14d
xorl %r15d, %r15d
movq (%r12,%r15,8), %rdi
callq 0x1030
incq %r15
cmpq %r15, %r14
jne 0x56ba
movq %r12, %rdi
callq 0x1030
cmpl $0x0, 0x80(%rbx)
je 0x56ee
addq $0xb8, %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 0x4899(%rip), %rdi      # 0x9faf
movb $0x3, %al
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x10f0