// File: /workspace/github_c_makefile_star2_O1/radforddc[P]icpc_siggen/fields.c
// Function: setup_velo
static int setup_velo(MJD_Siggen_Setup *setup){
  int vlook_sz = setup->v_lookup_len;
  struct velocity_lookup *v_lookup;

  char  line[MAX_LINE], *c;
  FILE  *fp;
  int   i, v_lookup_len;
  struct velocity_lookup *tmp, v, v0;
  float sumb_e, sumc_e, sumb_h, sumc_h;

  double be=1.3e7, bh=1.2e7, thetae=200.0, thetah=200.0;  // parameters for temperature correction
  double pwre=-1.680, pwrh=-2.398, mue=5.66e7, muh=1.63e9; //     adopted for Ge   DCR Feb 2015
  double mu_0_1, mu_0_2, v_s_1, v_s_2, E_c_1, E_c_2, e, f;

  if (vlook_sz == 0) {
    vlook_sz = 10;
    if ((v_lookup = (struct velocity_lookup *)
	 malloc(vlook_sz*sizeof(*v_lookup))) == NULL) {
      error("malloc failed in setup_velo\n");
      return -1;
    }
  } else {
    v_lookup = setup->v_lookup;
  }

  if ((fp = fopen(setup->drift_name, "r")) == NULL){
    error("failed to open velocity lookup table file: '%s'\n", setup->drift_name);
    return -1;
  }
  line[0] = '#';
  c = line;
  while ((line[0] == '#' || line[0] == '\0') && c != NULL) c = fgets(line, MAX_LINE, fp);
  if (c == NULL) {
    error("Failed to read velocity lookup table from file: %s\n", setup->drift_name);
    fclose(fp);
    return -1;
  }
  TELL_CHATTY("Drift velocity table:\n"
	      "  e          e100    e110    e111    h100    h110    h111\n");   
  for (v_lookup_len = 0; ;v_lookup_len++){
    if (v_lookup_len == vlook_sz - 1){
      vlook_sz += 10;
      if ((tmp = (struct velocity_lookup *)
	   realloc(v_lookup, vlook_sz*sizeof(*v_lookup))) == NULL){
	error("realloc failed in setup_velo\n");
	fclose(fp);
	return -1;
      }
      v_lookup = tmp;
    }
    if (sscanf(line, "%f %f %f %f %f %f %f", 
	       &v_lookup[v_lookup_len].e,
	       &v_lookup[v_lookup_len].e100,
	       &v_lookup[v_lookup_len].e110,
	       &v_lookup[v_lookup_len].e111,
	       &v_lookup[v_lookup_len].h100,
	       &v_lookup[v_lookup_len].h110,
	       &v_lookup[v_lookup_len].h111) != 7){
      break; //assume EOF
    }	   
    //v_lookup[v_lookup_len].e *= 100; /*V/m*/
    tmp = &v_lookup[v_lookup_len];
    TELL_CHATTY("%10.3f%8.3f%8.3f%8.3f%8.3f%8.3f%8.3f\n",
		tmp->e, tmp->e100, tmp->e110, tmp->e111, tmp->h100, tmp->h110,tmp->h111);
    line[0] = '#';
    while ((line[0] == '#' || line[0] == '\0' ||
	    line[0] == '\n' || line[0] == '\r') && c != NULL) c = fgets(line, MAX_LINE, fp);
    if (c == NULL) break;
    if (line[0] == 'e' || line[0] == 'h') break; /* no more velocities data;
						    now reading temp correction data */
  }

  /* check for and decode temperature correction parameters */
  while (line[0] == 'e' || line[0] == 'h') {
    if (line[0] == 'e' &&
	sscanf(line+2, "%lf %lf %lf %lf", 
	       &mue, &pwre, &be, &thetae) != 4) break;//asume EOF
    if (line[0] == 'h' &&
	sscanf(line+2, "%lf %lf %lf %lf", 
	       &muh, &pwrh, &bh, &thetah) != 4) break;//asume EOF
    if (line[0] == 'e')
      TELL_CHATTY("electrons: mu_0 = %.2e x T^%.4f  B = %.2e  Theta = %.0f\n",
		  mue, pwre, be, thetae);
    if (line[0] == 'h')
      TELL_CHATTY("    holes: mu_0 = %.2e x T^%.4f  B = %.2e  Theta = %.0f\n",
		  muh, pwrh, bh, thetah);

    line[0] = '#';
    while ((line[0] == '#' || line[0] == '\0') && c != NULL) c = fgets(line, MAX_LINE, fp);
    if (c == NULL) break;
  }

  if (v_lookup_len == 0){
    error("Failed to read velocity lookup table from file: %s\n", setup->drift_name);
    return -1;
  }  
  v_lookup_len++;
  if (vlook_sz != v_lookup_len){
    if ((tmp = (struct velocity_lookup *) 
	 realloc(v_lookup, v_lookup_len*sizeof(*v_lookup))) == NULL){
      error("realloc failed in setup_velo. This should not happen\n");
      fclose(fp);
      return -1;
    }
    v_lookup = tmp;
    vlook_sz = v_lookup_len;
  }
  TELL_NORMAL("Drift velocity table has %d rows of data\n", v_lookup_len);
  fclose(fp);

  /*
    apply temperature dependence to mobilities;
    see drift_velocities.doc and tempdep.c
    The drift velocity reduces at higher temperature due to the increasing of
    scattering with the lattice vibration. We used a model by M. Ali Omar and
    L. Reggiani (Solid-State Electronics Vol. 30, No. 12 (1987) 1351) to
    calculate the temperature dependence.
  */
  /* electrons */
  TELL_NORMAL("Adjusting mobilities for temperature, from %.1f to %.1f\n", REF_TEMP, setup->xtal_temp);
  TELL_CHATTY("Index  field  vel_factor\n");
  mu_0_1 = mue * pow(REF_TEMP, pwre);
  v_s_1 = be * sqrt(tanh(0.5 * thetae / REF_TEMP));
  E_c_1 = v_s_1 / mu_0_1;
  mu_0_2 = mue * pow(setup->xtal_temp, pwre);
  v_s_2 = be * sqrt(tanh(0.5 * thetae / setup->xtal_temp));
  E_c_2 = v_s_2 / mu_0_2;
  for (i = 0; i < vlook_sz; i++){
    e = v_lookup[i].e;
    if (e < 1) continue;
    f = (v_s_2 * (e/E_c_2) / sqrt(1.0 + (e/E_c_2) * (e/E_c_2))) /
        (v_s_1 * (e/E_c_1) / sqrt(1.0 + (e/E_c_1) * (e/E_c_1)));
    v_lookup[i].e100 *= f;
    v_lookup[i].e110 *= f;
    v_lookup[i].e111 *= f;
    TELL_CHATTY("%2d %5.0f %f\n", i, e, f);
  }

  /* holes */
  mu_0_1 = muh * pow(REF_TEMP, pwrh);
  v_s_1 = bh * sqrt(tanh(0.5 * thetah / REF_TEMP));
  E_c_1 = v_s_1 / mu_0_1;
  mu_0_2 = muh * pow(setup->xtal_temp, pwrh);
  v_s_2 = bh * sqrt(tanh(0.5 * thetah / setup->xtal_temp));
  E_c_2 = v_s_2 / mu_0_2;
  for (i = 0; i < vlook_sz; i++){
    e = v_lookup[i].e;
    if (e < 1) continue;
    f = (v_s_2 * (e/E_c_2) / sqrt(1.0 + (e/E_c_2) * (e/E_c_2))) /
        (v_s_1 * (e/E_c_1) / sqrt(1.0 + (e/E_c_1) * (e/E_c_1)));
    v_lookup[i].h100 *= f;
    v_lookup[i].h110 *= f;
    v_lookup[i].h111 *= f;
    TELL_CHATTY("%2d %5.0f %f\n", i, e, f);
  }
  /* end of temperature correction */

  for (i = 0; i < vlook_sz; i++){
    v = v_lookup[i];
    v_lookup[i].ea =  0.5 * v.e100 -  4 * v.e110 +  4.5 * v.e111;
    v_lookup[i].eb = -2.5 * v.e100 + 16 * v.e110 - 13.5 * v.e111;
    v_lookup[i].ec =  3.0 * v.e100 - 12 * v.e110 +  9.0 * v.e111;
    v_lookup[i].ha =  0.5 * v.h100 -  4 * v.h110 +  4.5 * v.h111;
    v_lookup[i].hb = -2.5 * v.h100 + 16 * v.h110 - 13.5 * v.h111;
    v_lookup[i].hc =  3.0 * v.h100 - 12 * v.h110 +  9.0 * v.h111;
  }
  v_lookup[0].ebp = v_lookup[0].ecp = v_lookup[0].hbp = v_lookup[0].hcp = 0.0;
  sumb_e = sumc_e = sumb_h = sumc_h = 0.0;
  for (i = 1; i < vlook_sz; i++){
    v0 = v_lookup[i-1];
    v = v_lookup[i];
    sumb_e += (v.e - v0.e)*(v0.eb+v.eb)/2;
    sumc_e += (v.e - v0.e)*(v0.ec+v.ec)/2;
    sumb_h += (v.e - v0.e)*(v0.hb+v.hb)/2;
    sumc_h += (v.e - v0.e)*(v0.hc+v.hc)/2;
    v_lookup[i].ebp = sumb_e/v.e;
    v_lookup[i].ecp = sumc_e/v.e;
    v_lookup[i].hbp = sumb_h/v.e;
    v_lookup[i].hcp = sumc_h/v.e;
  }

  setup->v_lookup = v_lookup;
  setup->v_lookup_len = v_lookup_len;

  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x298, %rsp            # imm = 0x298
movq %rdi, %rbx
movl 0x3d0(%rdi), %ebp
movabsq $0x4168cba800000000, %rax # imm = 0x4168CBA800000000
movq %rax, 0x80(%rsp)
movabsq $0x4166e36000000000, %rax # imm = 0x4166E36000000000
movq %rax, 0x78(%rsp)
movabsq $0x4069000000000000, %rax # imm = 0x4069000000000000
movq %rax, 0x70(%rsp)
movq %rax, 0x68(%rsp)
movabsq $-0x40051eb851eb851f, %rax # imm = 0xBFFAE147AE147AE1
movq %rax, 0x60(%rsp)
movabsq $-0x3ffcd0e560418937, %rax # imm = 0xC0032F1A9FBE76C9
movq %rax, 0x58(%rsp)
movabsq $0x418afd2e00000000, %rax # imm = 0x418AFD2E00000000
movq %rax, 0x50(%rsp)
movabsq $0x41d849f4e0000000, %rax # imm = 0x41D849F4E0000000
movq %rax, 0x48(%rsp)
testl %ebp, %ebp
je 0x4a95
movq 0x3d8(%rbx), %r14
jmp 0x4ab0
movl $0x2f8, %edi            # imm = 0x2F8
callq 0x20d0
testq %rax, %rax
je 0x4c9c
movq %rax, %r14
movl $0xa, %ebp
leaq 0x88(%rbx), %r12
leaq 0x4a47(%rip), %rsi      # 0x9505
movq %r12, %rdi
callq 0x20e0
testq %rax, %rax
je 0x4c76
movq %rax, %r15
movq %r12, (%rsp)
leaq 0x90(%rsp), %r12
movb $0x23, (%r12)
movq %r12, %rdi
movl $0x200, %esi            # imm = 0x200
movq %r15, %rdx
callq 0x2100
movq %rax, %r13
movb 0x90(%rsp), %cl
cmpb $0x23, %cl
sete %al
testb %cl, %cl
sete %cl
testq %r13, %r13
je 0x4b11
orb %cl, %al
jne 0x4ae3
testq %r13, %r13
je 0x4c85
cmpl $0x2, (%rbx)
jl 0x4b2d
leaq 0x3c3a(%rip), %rdi      # 0x8760
xorl %eax, %eax
callq 0x25b2
leaq 0x90(%rsp), %r12
xorl %ecx, %ecx
movq %rbx, 0x40(%rsp)
leal -0x1(%rbp), %eax
cmpq %rax, %rcx
jne 0x4b68
addl $0xa, %ebp
movslq %ebp, %rax
imulq $0x4c, %rax, %rsi
movq %r14, %rdi
movq %rcx, %r14
callq 0x2240
movq %r14, %rcx
movq %rax, %r14
testq %rax, %rax
je 0x5679
movq %rbp, 0x38(%rsp)
movq %rcx, 0x8(%rsp)
imulq $0x4c, %rcx, %rax
leaq (%r14,%rax), %rbp
leaq (%r14,%rax), %rcx
addq $0x4, %rcx
leaq 0x8(%r14,%rax), %r8
leaq 0xc(%r14,%rax), %r9
leaq (%r14,%rax), %r10
addq $0x10, %r10
leaq (%r14,%rax), %r11
addq $0x14, %r11
leaq (%r14,%rax), %rbx
addq $0x18, %rbx
subq $0x8, %rsp
movq %r12, %rdi
leaq 0x3c1d(%rip), %rsi      # 0x87cf
movq %rbp, %rdx
xorl %eax, %eax
pushq %rbx
movq 0x50(%rsp), %rbx
pushq %r11
pushq %r10
callq 0x20a0
addq $0x20, %rsp
cmpl $0x7, %eax
jne 0x4cb2
cmpl $0x2, (%rbx)
jl 0x4c09
cvtss2sd (%rbp), %xmm0
cvtss2sd 0x4(%rbp), %xmm1
cvtss2sd 0x8(%rbp), %xmm2
cvtss2sd 0xc(%rbp), %xmm3
cvtss2sd 0x10(%rbp), %xmm4
cvtss2sd 0x14(%rbp), %xmm5
cvtss2sd 0x18(%rbp), %xmm6
leaq 0x3be2(%rip), %rdi      # 0x87e4
movb $0x7, %al
callq 0x25b2
movb $0x23, 0x90(%rsp)
movq %r12, %rdi
movl $0x200, %esi            # imm = 0x200
movq %r15, %rdx
callq 0x2100
movq %rax, %r13
movzbl 0x90(%rsp), %eax
cmpl $0xd, %eax
setne %cl
cmpl $0xa, %eax
setne %dl
testl %eax, %eax
setne %sil
cmpl $0x23, %eax
setne %dil
andb %sil, %dil
andb %dl, %dil
testb %dil, %cl
jne 0x4c55
testq %r13, %r13
jne 0x4c11
testq %r13, %r13
movq 0x38(%rsp), %rbp
je 0x4caf
cmpl $0x65, %eax
je 0x4cb2
cmpl $0x68, %eax
je 0x4cb2
movq 0x8(%rsp), %rcx
incq %rcx
jmp 0x4b3c
leaq 0x3a7e(%rip), %rdi      # 0x86fb
movq %r12, %rsi
jmp 0x4ee4
leaq 0x3aa0(%rip), %rdi      # 0x872c
movq (%rsp), %rsi
xorl %eax, %eax
callq 0x22e0
jmp 0x5690
leaq 0x3a3b(%rip), %rdi      # 0x86de
xorl %eax, %eax
callq 0x22e0
jmp 0x5698
xorl %r13d, %r13d
leaq 0x3b51(%rip), %r12      # 0x880a
leaq 0x90(%rsp), %rbp
movzbl 0x90(%rsp), %eax
cmpl $0x68, %eax
je 0x4d09
cmpl $0x65, %eax
jne 0x4ded
leaq 0x92(%rsp), %rdi
movq %r12, %rsi
leaq 0x50(%rsp), %rdx
leaq 0x60(%rsp), %rcx
leaq 0x80(%rsp), %r8
leaq 0x70(%rsp), %r9
xorl %eax, %eax
callq 0x20a0
cmpl $0x4, %eax
jne 0x4ded
cmpb $0x68, 0x90(%rsp)
jne 0x4d42
leaq 0x92(%rsp), %rdi
movq %r12, %rsi
leaq 0x48(%rsp), %rdx
leaq 0x58(%rsp), %rcx
leaq 0x78(%rsp), %r8
leaq 0x68(%rsp), %r9
xorl %eax, %eax
callq 0x20a0
cmpl $0x4, %eax
jne 0x4ded
cmpb $0x65, 0x90(%rsp)
jne 0x4d7a
cmpl $0x2, (%rbx)
jl 0x4d7a
movsd 0x50(%rsp), %xmm0
movsd 0x60(%rsp), %xmm1
movsd 0x80(%rsp), %xmm2
movsd 0x70(%rsp), %xmm3
leaq 0x3aa7(%rip), %rdi      # 0x881a
movb $0x4, %al
callq 0x25b2
cmpb $0x68, 0x90(%rsp)
jne 0x4daf
cmpl $0x2, (%rbx)
jl 0x4daf
movsd 0x48(%rsp), %xmm0
movsd 0x58(%rsp), %xmm1
movsd 0x78(%rsp), %xmm2
movsd 0x68(%rsp), %xmm3
leaq 0x3aab(%rip), %rdi      # 0x8853
movb $0x4, %al
callq 0x25b2
movb $0x23, 0x90(%rsp)
testq %r13, %r13
je 0x4de4
movq %rbp, %rdi
movl $0x200, %esi            # imm = 0x200
movq %r15, %rdx
callq 0x2100
movq %rax, %r13
movb 0x90(%rsp), %al
cmpb $0x23, %al
setne %cl
testb %al, %al
setne %al
testb %al, %cl
je 0x4db7
testq %r13, %r13
jne 0x4cc1
movq 0x8(%rsp), %rax
testq %rax, %rax
je 0x4ed9
leal 0x1(%rax), %ebp
cmpl %ebp, 0x38(%rsp)
je 0x4e25
movl %ebp, %eax
imulq $0x4c, %rax, %rsi
movq %r14, %rdi
callq 0x2240
movq %rax, %r14
movl %ebp, %eax
movq %rax, 0x38(%rsp)
testq %r14, %r14
je 0x5682
cmpl $0x0, (%rbx)
jle 0x4e3a
leaq 0x3a91(%rip), %rdi      # 0x88c2
movl %ebp, %esi
xorl %eax, %eax
callq 0x25b2
movq %r15, %rdi
callq 0x2210
cmpl $0x0, (%rbx)
jle 0x4e68
xorps %xmm1, %xmm1
cvtss2sd 0x388(%rbx), %xmm1
leaq 0x3a93(%rip), %rdi      # 0x88ec
movsd 0x368f(%rip), %xmm0     # 0x84f0
movb $0x2, %al
callq 0x25b2
cmpl $0x2, (%rbx)
jl 0x4e7b
leaq 0x3ab1(%rip), %rdi      # 0x8925
xorl %eax, %eax
callq 0x25b2
movsd 0x50(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0x60(%rsp), %xmm1
movsd 0x365b(%rip), %xmm0     # 0x84f0
callq 0x2270
movsd %xmm0, (%rsp)
movsd 0x80(%rsp), %xmm0
movsd %xmm0, 0x30(%rsp)
movsd 0x70(%rsp), %xmm0
mulsd 0x363c(%rip), %xmm0     # 0x84f8
divsd 0x362c(%rip), %xmm0     # 0x84f0
callq 0x2040
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x4ef0
sqrtsd %xmm0, %xmm0
jmp 0x4ef5
leaq 0x384c(%rip), %rdi      # 0x872c
movq (%rsp), %rsi
xorl %eax, %eax
callq 0x22e0
jmp 0x5698
callq 0x2280
movsd %xmm0, 0x10(%rsp)
movsd 0x50(%rsp), %xmm0
movsd %xmm0, 0x20(%rsp)
xorps %xmm0, %xmm0
cvtss2sd 0x388(%rbx), %xmm0
movsd 0x60(%rsp), %xmm1
callq 0x2270
movsd %xmm0, 0x18(%rsp)
movsd 0x70(%rsp), %xmm0
mulsd 0x35c7(%rip), %xmm0     # 0x84f8
movsd 0x80(%rsp), %xmm1
movsd %xmm1, 0x28(%rsp)
xorps %xmm1, %xmm1
cvtss2sd 0x388(%rbx), %xmm1
divsd %xmm1, %xmm0
callq 0x2040
ucomisd 0x316c(%rip), %xmm0     # 0x80c8
jb 0x4f64
sqrtsd %xmm0, %xmm0
jmp 0x4f69
callq 0x2280
movq 0x38(%rsp), %rax
movl %eax, %r13d
testl %eax, %eax
jle 0x510d
movsd 0x8(%rsp), %xmm2
mulsd (%rsp), %xmm2
movsd 0x30(%rsp), %xmm1
mulsd 0x10(%rsp), %xmm1
movsd 0x20(%rsp), %xmm3
mulsd 0x18(%rsp), %xmm3
movsd %xmm1, 0x30(%rsp)
divsd %xmm2, %xmm1
movsd %xmm1, 0x20(%rsp)
movsd 0x28(%rsp), %xmm1
mulsd %xmm0, %xmm1
movsd %xmm1, 0x28(%rsp)
divsd %xmm3, %xmm1
movsd %xmm1, 0x10(%rsp)
leaq 0xc(%r14), %rbx
xorl %r15d, %r15d
leaq 0x396b(%rip), %r12      # 0x893f
movss -0xc(%rbx), %xmm0
movss 0x3027(%rip), %xmm1     # 0x8008
ucomiss %xmm0, %xmm1
ja 0x50fd
xorps %xmm2, %xmm2
cvtss2sd %xmm0, %xmm2
movaps %xmm2, %xmm1
divsd 0x10(%rsp), %xmm1
movapd %xmm1, %xmm0
mulsd %xmm1, %xmm0
addsd 0x308e(%rip), %xmm0     # 0x8098
ucomisd 0x30b6(%rip), %xmm0     # 0x80c8
movsd %xmm2, 0x8(%rsp)
movsd %xmm1, (%rsp)
jb 0x5028
xorps %xmm4, %xmm4
sqrtsd %xmm0, %xmm4
jmp 0x5037
callq 0x2280
movsd 0x8(%rsp), %xmm2
movapd %xmm0, %xmm4
movaps %xmm2, %xmm3
divsd 0x20(%rsp), %xmm3
movapd %xmm3, %xmm0
mulsd %xmm3, %xmm0
addsd 0x3048(%rip), %xmm0     # 0x8098
ucomisd 0x3070(%rip), %xmm0     # 0x80c8
jb 0x5060
sqrtsd %xmm0, %xmm0
jmp 0x5089
movsd %xmm3, 0x18(%rsp)
movsd %xmm4, 0x88(%rsp)
callq 0x2280
movsd 0x88(%rsp), %xmm4
movsd 0x18(%rsp), %xmm3
movsd 0x8(%rsp), %xmm2
movsd (%rsp), %xmm1
mulsd 0x28(%rsp), %xmm1
divsd %xmm4, %xmm1
mulsd 0x30(%rsp), %xmm3
divsd %xmm0, %xmm3
xorps %xmm0, %xmm0
cvtss2sd -0x8(%rbx), %xmm0
divsd %xmm3, %xmm1
mulsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x8(%rbx)
xorps %xmm0, %xmm0
cvtss2sd -0x4(%rbx), %xmm0
mulsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x4(%rbx)
xorps %xmm0, %xmm0
cvtss2sd (%rbx), %xmm0
mulsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, (%rbx)
movq 0x40(%rsp), %rax
cmpl $0x2, (%rax)
jl 0x50fd
movq %r12, %rdi
movl %r15d, %esi
movaps %xmm2, %xmm0
movb $0x2, %al
callq 0x25b2
incq %r15
addq $0x4c, %rbx
cmpq %r15, %r13
jne 0x4fd4
movsd 0x48(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0x58(%rsp), %xmm1
movsd 0x33c9(%rip), %xmm0     # 0x84f0
callq 0x2270
movsd %xmm0, (%rsp)
movsd 0x78(%rsp), %xmm0
movsd %xmm0, 0x30(%rsp)
movsd 0x68(%rsp), %xmm0
mulsd 0x33ad(%rip), %xmm0     # 0x84f8
divsd 0x339d(%rip), %xmm0     # 0x84f0
callq 0x2040
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x5168
sqrtsd %xmm0, %xmm0
jmp 0x516d
callq 0x2280
movsd %xmm0, 0x10(%rsp)
movq 0x40(%rsp), %rbx
movsd 0x48(%rsp), %xmm0
movsd %xmm0, 0x20(%rsp)
xorps %xmm0, %xmm0
cvtss2sd 0x388(%rbx), %xmm0
movsd 0x58(%rsp), %xmm1
callq 0x2270
movsd %xmm0, 0x18(%rsp)
movsd 0x68(%rsp), %xmm0
mulsd 0x334a(%rip), %xmm0     # 0x84f8
movsd 0x78(%rsp), %xmm1
movsd %xmm1, 0x28(%rsp)
xorps %xmm1, %xmm1
cvtss2sd 0x388(%rbx), %xmm1
divsd %xmm1, %xmm0
callq 0x2040
ucomisd 0x2ef2(%rip), %xmm0     # 0x80c8
jb 0x51de
sqrtsd %xmm0, %xmm0
jmp 0x51e3
callq 0x2280
cmpl $0x0, 0x38(%rsp)
jle 0x5382
movsd 0x8(%rsp), %xmm2
mulsd (%rsp), %xmm2
movsd 0x30(%rsp), %xmm1
mulsd 0x10(%rsp), %xmm1
movsd 0x20(%rsp), %xmm3
mulsd 0x18(%rsp), %xmm3
movsd %xmm1, 0x30(%rsp)
divsd %xmm2, %xmm1
movsd %xmm1, 0x20(%rsp)
movsd 0x28(%rsp), %xmm1
mulsd %xmm0, %xmm1
movsd %xmm1, 0x28(%rsp)
divsd %xmm3, %xmm1
movsd %xmm1, 0x10(%rsp)
leaq 0x18(%r14), %rbx
xorl %r15d, %r15d
leaq 0x36f6(%rip), %r12      # 0x893f
movss -0x18(%rbx), %xmm0
movss 0x2db2(%rip), %xmm1     # 0x8008
ucomiss %xmm0, %xmm1
ja 0x5372
xorps %xmm2, %xmm2
cvtss2sd %xmm0, %xmm2
movaps %xmm2, %xmm1
divsd 0x10(%rsp), %xmm1
movapd %xmm1, %xmm0
mulsd %xmm1, %xmm0
addsd 0x2e19(%rip), %xmm0     # 0x8098
ucomisd 0x2e41(%rip), %xmm0     # 0x80c8
movsd %xmm2, 0x8(%rsp)
movsd %xmm1, (%rsp)
jb 0x529d
xorps %xmm4, %xmm4
sqrtsd %xmm0, %xmm4
jmp 0x52ac
callq 0x2280
movsd 0x8(%rsp), %xmm2
movapd %xmm0, %xmm4
movaps %xmm2, %xmm3
divsd 0x20(%rsp), %xmm3
movapd %xmm3, %xmm0
mulsd %xmm3, %xmm0
addsd 0x2dd3(%rip), %xmm0     # 0x8098
ucomisd 0x2dfb(%rip), %xmm0     # 0x80c8
jb 0x52d5
sqrtsd %xmm0, %xmm0
jmp 0x52fe
movsd %xmm3, 0x18(%rsp)
movsd %xmm4, 0x88(%rsp)
callq 0x2280
movsd 0x88(%rsp), %xmm4
movsd 0x18(%rsp), %xmm3
movsd 0x8(%rsp), %xmm2
movsd (%rsp), %xmm1
mulsd 0x28(%rsp), %xmm1
divsd %xmm4, %xmm1
mulsd 0x30(%rsp), %xmm3
divsd %xmm0, %xmm3
xorps %xmm0, %xmm0
cvtss2sd -0x8(%rbx), %xmm0
divsd %xmm3, %xmm1
mulsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x8(%rbx)
xorps %xmm0, %xmm0
cvtss2sd -0x4(%rbx), %xmm0
mulsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x4(%rbx)
xorps %xmm0, %xmm0
cvtss2sd (%rbx), %xmm0
mulsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, (%rbx)
movq 0x40(%rsp), %rax
cmpl $0x2, (%rax)
jl 0x5372
movq %r12, %rdi
movl %r15d, %esi
movaps %xmm2, %xmm0
movb $0x2, %al
callq 0x25b2
incq %r15
addq $0x4c, %rbx
cmpq %r15, %r13
jne 0x5249
cmpl $0x0, 0x38(%rsp)
jle 0x555f
imulq $0x4c, %r13, %rax
xorl %ecx, %ecx
movss 0x313d(%rip), %xmm0     # 0x84d8
movsd 0x3155(%rip), %xmm1     # 0x84f8
movsd 0x3155(%rip), %xmm2     # 0x8500
movss 0x3129(%rip), %xmm3     # 0x84dc
movsd 0x314d(%rip), %xmm4     # 0x8508
movsd 0x314d(%rip), %xmm5     # 0x8510
movss 0x3115(%rip), %xmm6     # 0x84e0
movsd 0x2c85(%rip), %xmm7     # 0x8058
movsd 0x313c(%rip), %xmm8     # 0x8518
movss 0x8(%r14,%rcx), %xmm11
movss 0x14(%r14,%rcx), %xmm9
xorps %xmm10, %xmm10
cvtss2sd 0x4(%r14,%rcx), %xmm10
movaps %xmm11, %xmm12
mulss %xmm0, %xmm12
cvtss2sd %xmm12, %xmm12
movaps %xmm10, %xmm13
mulsd %xmm1, %xmm13
subsd %xmm12, %xmm13
xorps %xmm12, %xmm12
cvtss2sd 0xc(%r14,%rcx), %xmm12
movaps %xmm12, %xmm14
mulsd %xmm2, %xmm14
addsd %xmm13, %xmm14
xorps %xmm13, %xmm13
cvtsd2ss %xmm14, %xmm13
movss %xmm13, 0x1c(%r14,%rcx)
movaps %xmm11, %xmm13
mulss %xmm3, %xmm13
cvtss2sd %xmm13, %xmm13
movaps %xmm10, %xmm14
mulsd %xmm4, %xmm14
addsd %xmm13, %xmm14
movaps %xmm12, %xmm13
mulsd %xmm5, %xmm13
addsd %xmm14, %xmm13
cvtsd2ss %xmm13, %xmm13
movss %xmm13, 0x20(%r14,%rcx)
mulss %xmm6, %xmm11
cvtss2sd %xmm11, %xmm11
mulsd %xmm7, %xmm10
subsd %xmm11, %xmm10
mulsd %xmm8, %xmm12
addsd %xmm10, %xmm12
xorps %xmm10, %xmm10
cvtsd2ss %xmm12, %xmm10
movss %xmm10, 0x24(%r14,%rcx)
xorps %xmm10, %xmm10
cvtss2sd 0x10(%r14,%rcx), %xmm10
movaps %xmm9, %xmm11
mulss %xmm0, %xmm11
cvtss2sd %xmm11, %xmm11
movaps %xmm10, %xmm12
mulsd %xmm1, %xmm12
subsd %xmm11, %xmm12
xorps %xmm11, %xmm11
cvtss2sd 0x18(%r14,%rcx), %xmm11
movaps %xmm11, %xmm13
mulsd %xmm2, %xmm13
addsd %xmm12, %xmm13
xorps %xmm12, %xmm12
cvtsd2ss %xmm13, %xmm12
movss %xmm12, 0x30(%r14,%rcx)
movaps %xmm9, %xmm12
mulss %xmm3, %xmm12
cvtss2sd %xmm12, %xmm12
movaps %xmm10, %xmm13
mulsd %xmm4, %xmm13
addsd %xmm12, %xmm13
movaps %xmm11, %xmm12
mulsd %xmm5, %xmm12
addsd %xmm13, %xmm12
cvtsd2ss %xmm12, %xmm12
mulss %xmm6, %xmm9
cvtss2sd %xmm9, %xmm9
mulsd %xmm7, %xmm10
subsd %xmm9, %xmm10
mulsd %xmm8, %xmm11
addsd %xmm10, %xmm11
xorps %xmm9, %xmm9
cvtsd2ss %xmm11, %xmm9
movss %xmm12, 0x34(%r14,%rcx)
movss %xmm9, 0x38(%r14,%rcx)
addq $0x4c, %rcx
cmpq %rcx, %rax
jne 0x53dc
xorl %eax, %eax
movq %rax, 0x3c(%r14)
movq %rax, 0x28(%r14)
cmpl $0x2, 0x38(%rsp)
movq 0x40(%rsp), %rsi
jl 0x566a
imulq $0x4c, %r13, %rcx
addq $-0x4c, %rcx
xorpd %xmm0, %xmm0
xorl %edx, %edx
movss 0x2f55(%rip), %xmm1     # 0x84e4
xorps %xmm2, %xmm2
xorps %xmm3, %xmm3
xorps %xmm4, %xmm4
movss 0x20(%r14,%rdx), %xmm7
movss 0x24(%r14,%rdx), %xmm8
movss 0x34(%r14,%rdx), %xmm9
movss 0x38(%r14,%rdx), %xmm6
movss 0x4c(%r14,%rdx), %xmm5
movaps %xmm5, %xmm10
subss (%r14,%rdx), %xmm10
addss 0x6c(%r14,%rdx), %xmm7
mulss %xmm10, %xmm7
mulss %xmm1, %xmm7
addss 0x70(%r14,%rdx), %xmm8
addss %xmm7, %xmm4
mulss %xmm10, %xmm8
mulss %xmm1, %xmm8
addss %xmm8, %xmm3
addss 0x80(%r14,%rdx), %xmm9
mulss %xmm10, %xmm9
mulss %xmm1, %xmm9
addss %xmm9, %xmm2
addss 0x84(%r14,%rdx), %xmm6
mulss %xmm10, %xmm6
mulss %xmm1, %xmm6
addss %xmm6, %xmm0
movaps %xmm4, %xmm6
divss %xmm5, %xmm6
movss %xmm6, 0x74(%r14,%rdx)
movaps %xmm3, %xmm6
divss %xmm5, %xmm6
movss %xmm6, 0x78(%r14,%rdx)
movaps %xmm2, %xmm6
divss %xmm5, %xmm6
movss %xmm6, 0x88(%r14,%rdx)
movaps %xmm0, %xmm6
divss %xmm5, %xmm6
movss %xmm6, 0x8c(%r14,%rdx)
addq $0x4c, %rdx
cmpq %rdx, %rcx
jne 0x5598
movq %r14, 0x3d8(%rsi)
movl %ebp, 0x3d0(%rsi)
jmp 0x569d
leaq 0x3131(%rip), %rdi      # 0x87b1
jmp 0x5689
leaq 0x3203(%rip), %rdi      # 0x888c
xorl %eax, %eax
callq 0x22e0
movq %r15, %rdi
callq 0x2210
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x298, %rsp            # imm = 0x298
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq