// File: /workspace/github_c_makefile_star2_O2/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 $0x2d8, %rsp            # imm = 0x2D8
movq %rdi, %rbx
movl 0x3d0(%rdi), %ebp
movabsq $0x4168cba800000000, %rax # imm = 0x4168CBA800000000
movq %rax, 0x78(%rsp)
movabsq $0x4166e36000000000, %rax # imm = 0x4166E36000000000
movq %rax, 0x70(%rsp)
movabsq $0x4069000000000000, %rax # imm = 0x4069000000000000
movq %rax, 0x68(%rsp)
movq %rax, 0x60(%rsp)
movabsq $-0x40051eb851eb851f, %rax # imm = 0xBFFAE147AE147AE1
movq %rax, 0x58(%rsp)
movabsq $-0x3ffcd0e560418937, %rax # imm = 0xC0032F1A9FBE76C9
movq %rax, 0x50(%rsp)
movabsq $0x418afd2e00000000, %rax # imm = 0x418AFD2E00000000
movq %rax, 0x48(%rsp)
movabsq $0x41d849f4e0000000, %rax # imm = 0x41D849F4E0000000
movq %rax, 0x40(%rsp)
testl %ebp, %ebp
je 0x46ac
movq 0x3d8(%rbx), %r14
jmp 0x46c5
movl $0x2f8, %edi            # imm = 0x2F8
callq 0x20d0
testq %rax, %rax
je 0x48d8
movq %rax, %r14
pushq $0xa
popq %rbp
leaq 0x88(%rbx), %r12
leaq 0x4e72(%rip), %rsi      # 0x9545
movq %r12, %rdi
callq 0x20e0
testq %rax, %rax
je 0x48ae
movq %rax, %r15
movq %r12, 0x80(%rsp)
leaq 0xd0(%rsp), %r12
movb $0x23, (%r12)
movb $0x23, %al
movq %r12, %r13
cmpb $0x23, %al
sete %cl
testb %al, %al
sete %al
testq %r13, %r13
je 0x4730
orb %al, %cl
je 0x4730
movq %r12, %rdi
movl $0x200, %esi            # imm = 0x200
movq %r15, %rdx
callq 0x2100
movq %rax, %r13
movb 0xd0(%rsp), %al
jmp 0x4701
testq %r13, %r13
je 0x48bd
cmpl $0x2, (%rbx)
jl 0x474c
leaq 0x4063(%rip), %rdi      # 0x87a8
xorl %eax, %eax
callq 0x24d5
leaq 0xd0(%rsp), %r12
movd 0x3d94(%rip), %xmm0     # 0x84f0
punpcklbw %xmm0, %xmm0    # xmm0 = xmm0[0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7]
punpcklwd %xmm0, %xmm0    # xmm0 = xmm0[0,0,1,1,2,2,3,3]
movdqa %xmm0, 0x30(%rsp)
xorl %ecx, %ecx
movq %rbx, 0x8(%rsp)
leal -0x1(%rbp), %eax
cmpq %rax, %rcx
jne 0x479d
addl $0xa, %ebp
movq %r14, %rdi
movq %rcx, %rbx
movslq %ebp, %rax
imulq $0x4c, %rax, %rsi
callq 0x2250
movq %rbx, %rcx
movq %rax, %r14
testq %rax, %rax
je 0x510c
movq %rbp, 0x28(%rsp)
movq %rcx, 0x10(%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 0x4030(%rip), %rsi      # 0x8817
movq %rbp, %rdx
xorl %eax, %eax
pushq %rbx
pushq %r11
pushq %r10
callq 0x20a0
addq $0x20, %rsp
cmpl $0x7, %eax
jne 0x48eb
movq 0x8(%rsp), %rbx
cmpl $0x2, (%rbx)
jl 0x483e
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 0x3ff5(%rip), %rdi      # 0x882c
movb $0x7, %al
callq 0x24d5
movb $0x23, 0xd0(%rsp)
movb $0x23, %al
movq 0x28(%rsp), %rbp
movzbl %al, %ecx
movd %ecx, %xmm0
punpcklbw %xmm0, %xmm0    # xmm0 = xmm0[0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7]
pshuflw $0x0, %xmm0, %xmm0      # xmm0 = xmm0[0,0,0,0,4,5,6,7]
punpcklbw %xmm0, %xmm0    # xmm0 = xmm0[0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7]
punpcklwd %xmm0, %xmm0    # xmm0 = xmm0[0,0,1,1,2,2,3,3]
pcmpeqb 0x30(%rsp), %xmm0
movmskps %xmm0, %edx
testl %edx, %edx
je 0x4893
testq %r13, %r13
je 0x4893
movq %r12, %rdi
movl $0x200, %esi            # imm = 0x200
movq %r15, %rdx
callq 0x2100
movq %rax, %r13
movb 0xd0(%rsp), %al
jmp 0x484d
testq %r13, %r13
je 0x48f9
cmpb $0x65, %al
je 0x48fc
cmpl $0x68, %ecx
je 0x48fc
movq 0x10(%rsp), %rcx
incq %rcx
jmp 0x4771
leaq 0x3e8e(%rip), %rdi      # 0x8743
movq %r12, %rsi
jmp 0x4b2b
leaq 0x3eb0(%rip), %rdi      # 0x8774
movq 0x80(%rsp), %rsi
xorl %eax, %eax
callq 0x255d
jmp 0x5123
leaq 0x3e47(%rip), %rdi      # 0x8726
xorl %eax, %eax
callq 0x255d
jmp 0x512b
movb 0xd0(%rsp), %al
movq 0x8(%rsp), %rbx
jmp 0x48fc
xorl %r13d, %r13d
leaq 0x3f4f(%rip), %r12      # 0x8852
leaq 0xd0(%rsp), %rbp
cmpb $0x68, %al
je 0x4955
movzbl %al, %eax
cmpl $0x65, %eax
jne 0x4a32
leaq 0xd2(%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 0x4a32
movb 0xd0(%rsp), %al
cmpb $0x68, %al
jne 0x498b
leaq 0xd2(%rsp), %rdi
movq %r12, %rsi
leaq 0x40(%rsp), %rdx
leaq 0x50(%rsp), %rcx
leaq 0x70(%rsp), %r8
leaq 0x60(%rsp), %r9
xorl %eax, %eax
callq 0x20a0
cmpl $0x4, %eax
jne 0x4a32
movb 0xd0(%rsp), %al
cmpb $0x65, %al
jne 0x49c1
cmpl $0x2, (%rbx)
jl 0x49f0
movq 0x48(%rsp), %xmm0
movsd 0x58(%rsp), %xmm1
movsd 0x78(%rsp), %xmm2
movsd 0x68(%rsp), %xmm3
leaq 0x3eaf(%rip), %rdi      # 0x8862
movb $0x4, %al
callq 0x24d5
movb 0xd0(%rsp), %al
cmpb $0x68, %al
jne 0x49f0
cmpl $0x2, (%rbx)
jl 0x49f0
movq 0x40(%rsp), %xmm0
movsd 0x50(%rsp), %xmm1
movsd 0x70(%rsp), %xmm2
movsd 0x60(%rsp), %xmm3
leaq 0x3eb2(%rip), %rdi      # 0x889b
movb $0x4, %al
callq 0x24d5
movb $0x23, 0xd0(%rsp)
movb $0x23, %al
cmpb $0x23, %al
setne %cl
testb %al, %al
setne %dl
testb %dl, %cl
jne 0x4a29
testq %r13, %r13
je 0x4a29
movq %rbp, %rdi
movl $0x200, %esi            # imm = 0x200
movq %r15, %rdx
callq 0x2100
movq %rax, %r13
movb 0xd0(%rsp), %al
jmp 0x49fa
testq %r13, %r13
jne 0x490b
movq 0x10(%rsp), %rax
testq %rax, %rax
je 0x4b1c
leal 0x1(%rax), %ebp
cmpl %ebp, 0x28(%rsp)
je 0x4a6a
movl %ebp, %eax
imulq $0x4c, %rax, %rsi
movq %r14, %rdi
callq 0x2250
movq %rax, %r14
movl %ebp, %eax
movq %rax, 0x28(%rsp)
testq %r14, %r14
je 0x5115
cmpl $0x0, (%rbx)
jle 0x4a7f
leaq 0x3e94(%rip), %rdi      # 0x890a
movl %ebp, %esi
xorl %eax, %eax
callq 0x24d5
movq %r15, %rdi
callq 0x2220
cmpl $0x0, (%rbx)
jle 0x4abd
cvtss2sd 0x388(%rbx), %xmm1
leaq 0x3e99(%rip), %rdi      # 0x8934
movq 0x3aad(%rip), %xmm0     # 0x8550
movb $0x2, %al
callq 0x24d5
cmpl $0x2, (%rbx)
jl 0x4abd
leaq 0x3eb7(%rip), %rdi      # 0x896d
xorl %eax, %eax
callq 0x24d5
movsd 0x48(%rsp), %xmm0
movaps %xmm0, 0x10(%rsp)
movsd 0x58(%rsp), %xmm1
movsd 0x3a7a(%rip), %xmm0     # 0x8550
callq 0x2280
movaps %xmm0, 0xa0(%rsp)
movsd 0x78(%rsp), %xmm0
movaps %xmm0, 0x80(%rsp)
movsd 0x68(%rsp), %xmm0
mulsd 0x3a59(%rip), %xmm0     # 0x8558
divsd 0x3a49(%rip), %xmm0     # 0x8550
callq 0x2040
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x4b37
sqrtsd %xmm0, %xmm0
jmp 0x4b3c
leaq 0x3c51(%rip), %rdi      # 0x8774
movq 0x80(%rsp), %rsi
xorl %eax, %eax
callq 0x255d
jmp 0x512b
callq 0x2290
movapd %xmm0, 0x90(%rsp)
movsd 0x48(%rsp), %xmm0
movaps %xmm0, 0xc0(%rsp)
cvtss2sd 0x388(%rbx), %xmm0
movsd 0x58(%rsp), %xmm1
callq 0x2280
movaps %xmm0, 0xb0(%rsp)
movsd 0x68(%rsp), %xmm0
mulsd 0x39dc(%rip), %xmm0     # 0x8558
movsd 0x78(%rsp), %xmm1
movaps %xmm1, 0x30(%rsp)
cvtss2sd 0x388(%rbx), %xmm1
divsd %xmm1, %xmm0
callq 0x2040
ucomisd 0x3528(%rip), %xmm0     # 0x80c8
jb 0x4ba8
sqrtsd %xmm0, %xmm0
jmp 0x4bad
callq 0x2290
movapd 0x10(%rsp), %xmm1
movapd 0x80(%rsp), %xmm2
movapd 0xa0(%rsp), %xmm3
unpcklpd 0x90(%rsp), %xmm0       # xmm0 = xmm0[0],mem[0]
movapd 0xc0(%rsp), %xmm4
unpcklpd %xmm1, %xmm4            # xmm4 = xmm4[0],xmm1[0]
movapd 0xb0(%rsp), %xmm1
unpcklpd %xmm3, %xmm1            # xmm1 = xmm1[0],xmm3[0]
mulpd %xmm4, %xmm1
movapd 0x30(%rsp), %xmm5
unpcklpd %xmm2, %xmm5            # xmm5 = xmm5[0],xmm2[0]
mulpd %xmm0, %xmm5
movapd %xmm5, %xmm6
divpd %xmm1, %xmm6
xorl %r15d, %r15d
movq 0x28(%rsp), %rax
testl %eax, %eax
movl $0x0, %ebx
cmovgl %eax, %ebx
leaq 0xc(%r14), %r13
movss 0x33e8(%rip), %xmm4     # 0x8008
leaq 0x3d60(%rip), %r12      # 0x8987
movapd %xmm5, 0x30(%rsp)
movapd %xmm6, 0x10(%rsp)
cmpq %r15, %rbx
je 0x4ce7
movss -0xc(%r13), %xmm0
ucomiss %xmm0, %xmm4
ja 0x4cdb
cvtss2sd %xmm0, %xmm0
movaps %xmm0, %xmm2
movlhps %xmm0, %xmm2            # xmm2 = xmm2[0],xmm0[0]
divpd %xmm6, %xmm2
movapd %xmm5, %xmm1
mulpd %xmm2, %xmm1
mulpd %xmm2, %xmm2
addpd 0x3893(%rip), %xmm2     # 0x8500
sqrtpd %xmm2, %xmm2
divpd %xmm2, %xmm1
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
divsd %xmm2, %xmm1
cvtps2pd -0x8(%r13), %xmm2
movapd %xmm1, %xmm3
unpcklpd %xmm1, %xmm3            # xmm3 = xmm3[0],xmm1[0]
mulpd %xmm2, %xmm3
cvtpd2ps %xmm3, %xmm2
movlpd %xmm2, -0x8(%r13)
cvtss2sd (%r13), %xmm2
mulsd %xmm1, %xmm2
cvtsd2ss %xmm2, %xmm2
movss %xmm2, (%r13)
movq 0x8(%rsp), %rax
cmpl $0x2, (%rax)
jl 0x4cdb
movq %r12, %rdi
movl %r15d, %esi
movb $0x2, %al
callq 0x24d5
movapd 0x10(%rsp), %xmm6
movapd 0x30(%rsp), %xmm5
movss 0x332d(%rip), %xmm4     # 0x8008
incq %r15
addq $0x4c, %r13
jmp 0x4c33
movsd 0x40(%rsp), %xmm0
movaps %xmm0, 0x10(%rsp)
movsd 0x50(%rsp), %xmm1
movsd 0x3850(%rip), %xmm0     # 0x8550
callq 0x2280
movaps %xmm0, 0xa0(%rsp)
movsd 0x70(%rsp), %xmm0
movaps %xmm0, 0x80(%rsp)
movsd 0x60(%rsp), %xmm0
mulsd 0x382f(%rip), %xmm0     # 0x8558
divsd 0x381f(%rip), %xmm0     # 0x8550
callq 0x2040
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x4d46
sqrtsd %xmm0, %xmm0
jmp 0x4d4b
callq 0x2290
movapd %xmm0, 0x90(%rsp)
movsd 0x40(%rsp), %xmm0
movaps %xmm0, 0xc0(%rsp)
movq 0x8(%rsp), %r15
cvtss2sd 0x388(%r15), %xmm0
movsd 0x50(%rsp), %xmm1
callq 0x2280
movaps %xmm0, 0xb0(%rsp)
movsd 0x60(%rsp), %xmm0
mulsd 0x37c7(%rip), %xmm0     # 0x8558
movsd 0x70(%rsp), %xmm1
movaps %xmm1, 0x30(%rsp)
cvtss2sd 0x388(%r15), %xmm1
divsd %xmm1, %xmm0
callq 0x2040
ucomisd 0x3312(%rip), %xmm0     # 0x80c8
jb 0x4dbe
sqrtsd %xmm0, %xmm0
jmp 0x4dc3
callq 0x2290
movss 0x323d(%rip), %xmm4     # 0x8008
movapd 0x10(%rsp), %xmm1
movapd 0x80(%rsp), %xmm2
movapd 0xa0(%rsp), %xmm3
unpcklpd 0x90(%rsp), %xmm0       # xmm0 = xmm0[0],mem[0]
movapd 0xc0(%rsp), %xmm5
unpcklpd %xmm1, %xmm5            # xmm5 = xmm5[0],xmm1[0]
movapd 0xb0(%rsp), %xmm1
unpcklpd %xmm3, %xmm1            # xmm1 = xmm1[0],xmm3[0]
mulpd %xmm5, %xmm1
movapd 0x30(%rsp), %xmm5
unpcklpd %xmm2, %xmm5            # xmm5 = xmm5[0],xmm2[0]
mulpd %xmm0, %xmm5
movapd %xmm5, %xmm6
divpd %xmm1, %xmm6
leaq 0x18(%r14), %r13
xorl %r15d, %r15d
leaq 0x3b59(%rip), %r12      # 0x8987
movapd %xmm5, 0x30(%rsp)
movapd %xmm6, 0x10(%rsp)
cmpq %r15, %rbx
je 0x4eee
movss -0x18(%r13), %xmm0
ucomiss %xmm0, %xmm4
ja 0x4ee2
cvtss2sd %xmm0, %xmm0
movaps %xmm0, %xmm2
movlhps %xmm0, %xmm2            # xmm2 = xmm2[0],xmm0[0]
divpd %xmm6, %xmm2
movapd %xmm5, %xmm1
mulpd %xmm2, %xmm1
mulpd %xmm2, %xmm2
addpd 0x368c(%rip), %xmm2     # 0x8500
sqrtpd %xmm2, %xmm2
divpd %xmm2, %xmm1
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
divsd %xmm2, %xmm1
cvtps2pd -0x8(%r13), %xmm2
movapd %xmm1, %xmm3
unpcklpd %xmm1, %xmm3            # xmm3 = xmm3[0],xmm1[0]
mulpd %xmm2, %xmm3
cvtpd2ps %xmm3, %xmm2
movlpd %xmm2, -0x8(%r13)
cvtss2sd (%r13), %xmm2
mulsd %xmm1, %xmm2
cvtsd2ss %xmm2, %xmm2
movss %xmm2, (%r13)
movq 0x8(%rsp), %rax
cmpl $0x2, (%rax)
jl 0x4ee2
movq %r12, %rdi
movl %r15d, %esi
movb $0x2, %al
callq 0x24d5
movapd 0x10(%rsp), %xmm6
movapd 0x30(%rsp), %xmm5
movss 0x3126(%rip), %xmm4     # 0x8008
incq %r15
addq $0x4c, %r13
jmp 0x4e3a
imulq $0x4c, %rbx, %rax
xorl %ecx, %ecx
movss 0x35dc(%rip), %xmm0     # 0x84d8
movaps 0x360d(%rip), %xmm1     # 0x8510
movss 0x35d1(%rip), %xmm2     # 0x84dc
movapd 0x360d(%rip), %xmm3     # 0x8520
movapd 0x3615(%rip), %xmm4     # 0x8530
movss 0x35bd(%rip), %xmm5     # 0x84e0
movsd 0x312d(%rip), %xmm6     # 0x8058
movsd 0x362d(%rip), %xmm7     # 0x8560
movq 0x8(%rsp), %rsi
cmpq %rcx, %rax
je 0x5070
movss 0x8(%r14,%rcx), %xmm10
movss 0x14(%r14,%rcx), %xmm8
cvtss2sd 0x4(%r14,%rcx), %xmm9
movaps %xmm10, %xmm11
mulss %xmm0, %xmm11
cvtss2sd %xmm11, %xmm11
xorps %xmm1, %xmm11
cvtss2sd 0xc(%r14,%rcx), %xmm12
movaps %xmm10, %xmm13
mulss %xmm2, %xmm13
cvtss2sd %xmm13, %xmm13
movlhps %xmm13, %xmm11          # xmm11 = xmm11[0],xmm13[0]
movaps %xmm9, %xmm13
movlhps %xmm9, %xmm13           # xmm13 = xmm13[0],xmm9[0]
mulpd %xmm3, %xmm13
addpd %xmm11, %xmm13
movaps %xmm12, %xmm11
movlhps %xmm12, %xmm11          # xmm11 = xmm11[0],xmm12[0]
mulpd %xmm4, %xmm11
addpd %xmm13, %xmm11
cvtpd2ps %xmm11, %xmm11
mulss %xmm5, %xmm10
cvtss2sd %xmm10, %xmm10
mulsd %xmm6, %xmm9
subsd %xmm10, %xmm9
mulsd %xmm7, %xmm12
addsd %xmm9, %xmm12
cvtsd2ss %xmm12, %xmm9
movlpd %xmm11, 0x1c(%r14,%rcx)
movss %xmm9, 0x24(%r14,%rcx)
cvtss2sd 0x10(%r14,%rcx), %xmm9
movaps %xmm8, %xmm10
mulss %xmm0, %xmm10
cvtss2sd %xmm10, %xmm10
xorps %xmm1, %xmm10
cvtss2sd 0x18(%r14,%rcx), %xmm11
movaps %xmm8, %xmm12
mulss %xmm2, %xmm12
cvtss2sd %xmm12, %xmm12
movlhps %xmm12, %xmm10          # xmm10 = xmm10[0],xmm12[0]
movaps %xmm9, %xmm12
movlhps %xmm9, %xmm12           # xmm12 = xmm12[0],xmm9[0]
mulpd %xmm3, %xmm12
addpd %xmm10, %xmm12
movaps %xmm11, %xmm10
movlhps %xmm11, %xmm10          # xmm10 = xmm10[0],xmm11[0]
mulpd %xmm4, %xmm10
addpd %xmm12, %xmm10
cvtpd2ps %xmm10, %xmm10
movlpd %xmm10, 0x30(%r14,%rcx)
mulss %xmm5, %xmm8
cvtss2sd %xmm8, %xmm8
mulsd %xmm6, %xmm9
subsd %xmm8, %xmm9
mulsd %xmm7, %xmm11
addsd %xmm9, %xmm11
cvtsd2ss %xmm11, %xmm8
movss %xmm8, 0x38(%r14,%rcx)
addq $0x4c, %rcx
jmp 0x4f38
andq $0x0, 0x3c(%r14)
andq $0x0, 0x28(%r14)
movslq 0x28(%rsp), %rax
leaq 0x88(%r14), %rcx
xorps %xmm0, %xmm0
pushq $0x1
popq %rdx
movaps 0x34ad(%rip), %xmm1     # 0x8540
xorps %xmm2, %xmm2
cmpq %rax, %rdx
jge 0x50fb
movss -0x3c(%rcx), %xmm3
movaps %xmm3, %xmm4
subss -0x88(%rcx), %xmm4
movsd -0x1c(%rcx), %xmm5
movsd -0x68(%rcx), %xmm6
addps %xmm5, %xmm6
movsd -0x54(%rcx), %xmm5
shufps $0x0, %xmm4, %xmm4      # xmm4 = xmm4[0,0,0,0]
mulps %xmm4, %xmm6
mulps %xmm1, %xmm6
addps %xmm6, %xmm0
shufps $0x0, %xmm3, %xmm3      # xmm3 = xmm3[0,0,0,0]
movaps %xmm0, %xmm6
divps %xmm3, %xmm6
movlps %xmm6, -0x14(%rcx)
movsd -0x8(%rcx), %xmm6
addps %xmm5, %xmm6
mulps %xmm4, %xmm6
mulps %xmm1, %xmm6
addps %xmm6, %xmm2
movaps %xmm2, %xmm4
divps %xmm3, %xmm4
movlps %xmm4, (%rcx)
incq %rdx
addq $0x4c, %rcx
jmp 0x5096
movq %r14, 0x3d8(%rsi)
movl %ebp, 0x3d0(%rsi)
xorl %eax, %eax
jmp 0x512e
leaq 0x36e6(%rip), %rdi      # 0x87f9
jmp 0x511c
leaq 0x37b8(%rip), %rdi      # 0x88d4
xorl %eax, %eax
callq 0x255d
movq %r15, %rdi
callq 0x2220
pushq $-0x1
popq %rax
addq $0x2d8, %rsp            # imm = 0x2D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq