// File: /workspace/github_c_makefile_star2_O3/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 $0x2c8, %rsp            # imm = 0x2C8
movq %rdi, %rbx
movl 0x3d0(%rdi), %ebp
movabsq $0x4168cba800000000, %rax # imm = 0x4168CBA800000000
movq %rax, 0x68(%rsp)
movabsq $0x4166e36000000000, %rax # imm = 0x4166E36000000000
movq %rax, 0x60(%rsp)
movabsq $0x4069000000000000, %rax # imm = 0x4069000000000000
movq %rax, 0x58(%rsp)
movq %rax, 0x50(%rsp)
movabsq $-0x40051eb851eb851f, %rax # imm = 0xBFFAE147AE147AE1
movq %rax, 0x48(%rsp)
movabsq $-0x3ffcd0e560418937, %rax # imm = 0xC0032F1A9FBE76C9
movq %rax, 0x40(%rsp)
movabsq $0x418afd2e00000000, %rax # imm = 0x418AFD2E00000000
movq %rax, 0x38(%rsp)
movabsq $0x41d849f4e0000000, %rax # imm = 0x41D849F4E0000000
movq %rax, 0x30(%rsp)
testl %ebp, %ebp
je 0x48dc
movq 0x3d8(%rbx), %r14
jmp 0x48f7
movl $0x2f8, %edi            # imm = 0x2F8
callq 0x20d0
testq %rax, %rax
je 0x4aec
movq %rax, %r14
movl $0xa, %ebp
leaq 0x88(%rbx), %r13
leaq 0x4c40(%rip), %rsi      # 0x9545
movq %r13, %rdi
callq 0x20e0
testq %rax, %rax
je 0x4ac7
movq %rax, %r15
leaq 0xc0(%rsp), %r12
movb $0x23, (%r12)
movq %r12, %rdi
movl $0x200, %esi            # imm = 0x200
movq %r15, %rdx
callq 0x2100
movb 0xc0(%rsp), %dl
cmpb $0x23, %dl
sete %cl
testb %dl, %dl
sete %dl
testq %rax, %rax
je 0x4951
orb %dl, %cl
jne 0x4926
testq %rax, %rax
je 0x4ad6
movq %r13, 0x80(%rsp)
movq %rbx, 0x8(%rsp)
cmpl $0x2, (%rbx)
jl 0x497a
leaq 0x3e35(%rip), %rdi      # 0x87a8
xorl %eax, %eax
callq 0x25b2
leaq 0xc0(%rsp), %r13
movd 0x3b66(%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, 0x20(%rsp)
xorl %ebx, %ebx
leal -0x1(%rbp), %eax
cmpq %rax, %rbx
jne 0x49c0
addl $0xa, %ebp
movslq %ebp, %rax
imulq $0x4c, %rax, %rsi
movq %r14, %rdi
callq 0x2250
movq %rax, %r14
testq %rax, %rax
je 0x5384
movq %rbp, 0x10(%rsp)
imulq $0x4c, %rbx, %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), %r12
addq $0x18, %r12
subq $0x8, %rsp
movq %r13, %rdi
leaq 0x3e12(%rip), %rsi      # 0x8817
movq %rbp, %rdx
xorl %eax, %eax
pushq %r12
pushq %r11
pushq %r10
callq 0x20a0
addq $0x20, %rsp
cmpl $0x7, %eax
jne 0x4aff
movq 0x8(%rsp), %rax
cmpl $0x2, (%rax)
jl 0x4a60
xorps %xmm0, %xmm0
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 0x3dd3(%rip), %rdi      # 0x882c
movb $0x7, %al
callq 0x25b2
movb $0x23, 0xc0(%rsp)
movq %r13, %rdi
movl $0x200, %esi            # imm = 0x200
movq %r15, %rdx
callq 0x2100
movzbl 0xc0(%rsp), %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 0x20(%rsp), %xmm0
movmskps %xmm0, %edx
testl %edx, %edx
je 0x4aa7
testq %rax, %rax
jne 0x4a68
testq %rax, %rax
sete %bpl
je 0x4b08
cmpl $0x65, %ecx
je 0x4b08
cmpl $0x68, %ecx
je 0x4b08
incq %rbx
movq 0x10(%rsp), %rbp
jmp 0x499a
leaq 0x3c75(%rip), %rdi      # 0x8743
movq %r13, %rsi
jmp 0x4c71
leaq 0x3c97(%rip), %rdi      # 0x8774
movq %r13, %rsi
xorl %eax, %eax
callq 0x22e0
jmp 0x539b
leaq 0x3c33(%rip), %rdi      # 0x8726
xorl %eax, %eax
callq 0x22e0
jmp 0x53a3
movb 0xc0(%rsp), %cl
xorl %ebp, %ebp
leaq 0x3d43(%rip), %r13      # 0x8852
leaq 0xc0(%rsp), %r12
cmpb $0x68, %cl
je 0x4b62
movzbl %cl, %eax
cmpl $0x65, %eax
jne 0x4c4d
leaq 0xc2(%rsp), %rdi
movq %r13, %rsi
leaq 0x38(%rsp), %rdx
leaq 0x48(%rsp), %rcx
leaq 0x68(%rsp), %r8
leaq 0x58(%rsp), %r9
xorl %eax, %eax
callq 0x20a0
cmpl $0x4, %eax
jne 0x4c4d
movb 0xc0(%rsp), %al
cmpb $0x68, %al
jne 0x4b98
leaq 0xc2(%rsp), %rdi
movq %r13, %rsi
leaq 0x30(%rsp), %rdx
leaq 0x40(%rsp), %rcx
leaq 0x60(%rsp), %r8
leaq 0x50(%rsp), %r9
xorl %eax, %eax
callq 0x20a0
cmpl $0x4, %eax
jne 0x4c4d
movb 0xc0(%rsp), %al
cmpb $0x65, %al
jne 0x4bd3
movq 0x8(%rsp), %rax
cmpl $0x2, (%rax)
jl 0x4c07
movq 0x38(%rsp), %xmm0
movsd 0x48(%rsp), %xmm1
movsd 0x68(%rsp), %xmm2
movsd 0x58(%rsp), %xmm3
leaq 0x3c9d(%rip), %rdi      # 0x8862
movb $0x4, %al
callq 0x25b2
movb 0xc0(%rsp), %al
cmpb $0x68, %al
jne 0x4c07
movq 0x8(%rsp), %rax
cmpl $0x2, (%rax)
jl 0x4c07
movq 0x30(%rsp), %xmm0
movsd 0x40(%rsp), %xmm1
movsd 0x60(%rsp), %xmm2
movsd 0x50(%rsp), %xmm3
leaq 0x3c9b(%rip), %rdi      # 0x889b
movb $0x4, %al
callq 0x25b2
movb $0x23, 0xc0(%rsp)
testb $0x1, %bpl
jne 0x4c4d
movq %r12, %rdi
movl $0x200, %esi            # imm = 0x200
movq %r15, %rdx
callq 0x2100
movb 0xc0(%rsp), %cl
cmpb $0x23, %cl
setne %dl
testb %cl, %cl
setne %sil
testb %sil, %dl
jne 0x4c42
testq %rax, %rax
jne 0x4c15
xorl %ebp, %ebp
testq %rax, %rax
jne 0x4b17
testq %rbx, %rbx
je 0x4c62
leal 0x1(%rbx), %ebp
cmpl %ebp, 0x10(%rsp)
jne 0x4c7d
movq 0x8(%rsp), %r12
jmp 0x4ca3
leaq 0x3b0b(%rip), %rdi      # 0x8774
movq 0x80(%rsp), %rsi
xorl %eax, %eax
callq 0x22e0
jmp 0x53a3
movl %ebp, %eax
imulq $0x4c, %rax, %rsi
movq %r14, %rdi
callq 0x2250
movq %rax, %r14
movl %ebp, %eax
movq %rax, 0x10(%rsp)
testq %r14, %r14
movq 0x8(%rsp), %r12
je 0x538d
cmpl $0x0, (%r12)
jle 0x4cba
leaq 0x3c59(%rip), %rdi      # 0x890a
movl %ebp, %esi
xorl %eax, %eax
callq 0x25b2
movq %r15, %rdi
callq 0x2220
cmpl $0x0, (%r12)
jle 0x4d01
xorps %xmm1, %xmm1
cvtss2sd 0x388(%r12), %xmm1
leaq 0x3c57(%rip), %rdi      # 0x8934
movq 0x386b(%rip), %xmm0     # 0x8550
movb $0x2, %al
callq 0x25b2
cmpl $0x2, (%r12)
jl 0x4d01
leaq 0x3c73(%rip), %rdi      # 0x896d
xorl %eax, %eax
callq 0x25b2
movl 0x10(%rsp), %ebx
movsd 0x38(%rsp), %xmm0
movaps %xmm0, 0x20(%rsp)
movsd 0x48(%rsp), %xmm1
movsd 0x3832(%rip), %xmm0     # 0x8550
callq 0x2280
movaps %xmm0, 0x80(%rsp)
movsd 0x68(%rsp), %xmm0
movaps %xmm0, 0x10(%rsp)
movsd 0x58(%rsp), %xmm0
mulsd 0x3814(%rip), %xmm0     # 0x8558
divsd 0x3804(%rip), %xmm0     # 0x8550
callq 0x2040
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x4d61
sqrtsd %xmm0, %xmm0
jmp 0x4d66
callq 0x2290
movapd %xmm0, 0x70(%rsp)
movsd 0x38(%rsp), %xmm0
movaps %xmm0, 0xb0(%rsp)
xorps %xmm0, %xmm0
cvtss2sd 0x388(%r12), %xmm0
movsd 0x48(%rsp), %xmm1
callq 0x2280
movaps %xmm0, 0xa0(%rsp)
movsd 0x58(%rsp), %xmm0
mulsd 0x37b0(%rip), %xmm0     # 0x8558
movsd 0x68(%rsp), %xmm1
movaps %xmm1, 0x90(%rsp)
xorps %xmm1, %xmm1
cvtss2sd 0x388(%r12), %xmm1
divsd %xmm1, %xmm0
callq 0x2040
ucomisd 0x32f4(%rip), %xmm0     # 0x80c8
jb 0x4ddc
sqrtsd %xmm0, %xmm4
jmp 0x4de5
callq 0x2290
movapd %xmm0, %xmm4
testl %ebx, %ebx
jle 0x4f13
movapd 0xb0(%rsp), %xmm0
unpcklpd 0x20(%rsp), %xmm0       # xmm0 = xmm0[0],mem[0]
movapd 0xa0(%rsp), %xmm1
unpcklpd 0x80(%rsp), %xmm1       # xmm1 = xmm1[0],mem[0]
mulpd %xmm0, %xmm1
movapd 0x90(%rsp), %xmm0
unpcklpd 0x10(%rsp), %xmm0       # xmm0 = xmm0[0],mem[0]
unpcklpd 0x70(%rsp), %xmm4       # xmm4 = xmm4[0],mem[0]
mulpd %xmm0, %xmm4
movapd %xmm4, %xmm5
divpd %xmm1, %xmm5
leaq 0xc(%r14), %r13
xorl %r15d, %r15d
movss 0x31c6(%rip), %xmm6     # 0x8008
movapd 0x36b6(%rip), %xmm7     # 0x8500
leaq 0x3b36(%rip), %r12      # 0x8987
movapd %xmm4, 0x20(%rsp)
movapd %xmm5, 0x10(%rsp)
movss -0xc(%r13), %xmm0
ucomiss %xmm0, %xmm6
ja 0x4f03
cvtss2sd %xmm0, %xmm0
movaps %xmm0, %xmm2
movlhps %xmm0, %xmm2            # xmm2 = xmm2[0],xmm0[0]
divpd %xmm5, %xmm2
movapd %xmm4, %xmm1
mulpd %xmm2, %xmm1
mulpd %xmm2, %xmm2
addpd %xmm7, %xmm2
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)
xorps %xmm2, %xmm2
cvtss2sd (%r13), %xmm2
mulsd %xmm1, %xmm2
cvtsd2ss %xmm2, %xmm2
movss %xmm2, (%r13)
movq 0x8(%rsp), %rax
cmpl $0x2, (%rax)
jl 0x4f03
movq %r12, %rdi
movl %r15d, %esi
movb $0x2, %al
callq 0x25b2
movapd 0x3611(%rip), %xmm7     # 0x8500
movss 0x3111(%rip), %xmm6     # 0x8008
movapd 0x10(%rsp), %xmm5
movapd 0x20(%rsp), %xmm4
incq %r15
addq $0x4c, %r13
cmpq %r15, %rbx
jne 0x4e5d
movsd 0x30(%rsp), %xmm0
movaps %xmm0, 0x20(%rsp)
movsd 0x40(%rsp), %xmm1
movsd 0x3624(%rip), %xmm0     # 0x8550
callq 0x2280
movaps %xmm0, 0x80(%rsp)
movsd 0x60(%rsp), %xmm0
movaps %xmm0, 0x10(%rsp)
movsd 0x50(%rsp), %xmm0
mulsd 0x3606(%rip), %xmm0     # 0x8558
divsd 0x35f6(%rip), %xmm0     # 0x8550
callq 0x2040
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x4f6f
sqrtsd %xmm0, %xmm0
jmp 0x4f74
callq 0x2290
movapd %xmm0, 0x70(%rsp)
movq 0x8(%rsp), %r15
movsd 0x30(%rsp), %xmm0
movaps %xmm0, 0xb0(%rsp)
xorps %xmm0, %xmm0
cvtss2sd 0x388(%r15), %xmm0
movsd 0x40(%rsp), %xmm1
callq 0x2280
movaps %xmm0, 0xa0(%rsp)
movsd 0x50(%rsp), %xmm0
mulsd 0x359e(%rip), %xmm0     # 0x8558
movsd 0x60(%rsp), %xmm1
movaps %xmm1, 0x90(%rsp)
xorps %xmm1, %xmm1
cvtss2sd 0x388(%r15), %xmm1
divsd %xmm1, %xmm0
callq 0x2040
ucomisd 0x30e3(%rip), %xmm0     # 0x80c8
jb 0x4ff0
xorps %xmm4, %xmm4
sqrtsd %xmm0, %xmm4
jmp 0x4ff9
callq 0x2290
movapd %xmm0, %xmm4
testl %ebx, %ebx
jle 0x5368
movapd 0xb0(%rsp), %xmm0
unpcklpd 0x20(%rsp), %xmm0       # xmm0 = xmm0[0],mem[0]
movapd 0xa0(%rsp), %xmm1
unpcklpd 0x80(%rsp), %xmm1       # xmm1 = xmm1[0],mem[0]
mulpd %xmm0, %xmm1
movapd 0x90(%rsp), %xmm0
unpcklpd 0x10(%rsp), %xmm0       # xmm0 = xmm0[0],mem[0]
unpcklpd 0x70(%rsp), %xmm4       # xmm4 = xmm4[0],mem[0]
mulpd %xmm0, %xmm4
movapd %xmm4, %xmm5
divpd %xmm1, %xmm5
leaq 0x18(%r14), %r13
xorl %r15d, %r15d
movss 0x2fb2(%rip), %xmm6     # 0x8008
movapd 0x34a2(%rip), %xmm7     # 0x8500
leaq 0x3922(%rip), %r12      # 0x8987
movapd %xmm4, 0x20(%rsp)
movapd %xmm5, 0x10(%rsp)
movss -0x18(%r13), %xmm0
ucomiss %xmm0, %xmm6
ja 0x5117
cvtss2sd %xmm0, %xmm0
movaps %xmm0, %xmm2
movlhps %xmm0, %xmm2            # xmm2 = xmm2[0],xmm0[0]
divpd %xmm5, %xmm2
movapd %xmm4, %xmm1
mulpd %xmm2, %xmm1
mulpd %xmm2, %xmm2
addpd %xmm7, %xmm2
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)
xorps %xmm2, %xmm2
cvtss2sd (%r13), %xmm2
mulsd %xmm1, %xmm2
cvtsd2ss %xmm2, %xmm2
movss %xmm2, (%r13)
movq 0x8(%rsp), %rax
cmpl $0x2, (%rax)
jl 0x5117
movq %r12, %rdi
movl %r15d, %esi
movb $0x2, %al
callq 0x25b2
movapd 0x33fd(%rip), %xmm7     # 0x8500
movss 0x2efd(%rip), %xmm6     # 0x8008
movapd 0x10(%rsp), %xmm5
movapd 0x20(%rsp), %xmm4
incq %r15
addq $0x4c, %r13
cmpq %r15, %rbx
jne 0x5071
testl %ebx, %ebx
movq 0x8(%rsp), %r15
jle 0x5368
imulq $0x4c, %rbx, %rax
xorl %ecx, %ecx
movss 0x3396(%rip), %xmm0     # 0x84d8
movaps 0x33c7(%rip), %xmm1     # 0x8510
movss 0x338b(%rip), %xmm2     # 0x84dc
movapd 0x33c7(%rip), %xmm3     # 0x8520
movapd 0x33cf(%rip), %xmm4     # 0x8530
movss 0x3377(%rip), %xmm5     # 0x84e0
movsd 0x2ee7(%rip), %xmm6     # 0x8058
movsd 0x33e7(%rip), %xmm7     # 0x8560
movss 0x8(%r14,%rcx), %xmm10
movss 0x14(%r14,%rcx), %xmm8
xorps %xmm9, %xmm9
cvtss2sd 0x4(%r14,%rcx), %xmm9
movaps %xmm10, %xmm11
mulss %xmm0, %xmm11
cvtss2sd %xmm11, %xmm11
xorps %xmm1, %xmm11
xorps %xmm12, %xmm12
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
xorps %xmm9, %xmm9
cvtsd2ss %xmm12, %xmm9
movlpd %xmm11, 0x1c(%r14,%rcx)
movss %xmm9, 0x24(%r14,%rcx)
xorps %xmm9, %xmm9
cvtss2sd 0x10(%r14,%rcx), %xmm9
movaps %xmm8, %xmm10
mulss %xmm0, %xmm10
cvtss2sd %xmm10, %xmm10
xorps %xmm1, %xmm10
xorps %xmm11, %xmm11
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
mulss %xmm5, %xmm8
cvtss2sd %xmm8, %xmm8
mulsd %xmm6, %xmm9
subsd %xmm8, %xmm9
mulsd %xmm7, %xmm11
addsd %xmm9, %xmm11
xorps %xmm8, %xmm8
cvtsd2ss %xmm11, %xmm8
movlpd %xmm10, 0x30(%r14,%rcx)
movss %xmm8, 0x38(%r14,%rcx)
addq $0x4c, %rcx
cmpq %rcx, %rax
jne 0x5179
xorl %ecx, %ecx
movq %rcx, 0x3c(%r14)
movq %rcx, 0x28(%r14)
cmpl $0x1, %ebx
je 0x5372
movss (%r14), %xmm5
movsd 0x20(%r14), %xmm7
movsd 0x34(%r14), %xmm3
xorps %xmm0, %xmm0
movl $0x4c, %ecx
movaps 0x3249(%rip), %xmm1     # 0x8540
xorps %xmm2, %xmm2
movss (%r14,%rcx), %xmm8
movaps %xmm8, %xmm6
subss %xmm5, %xmm6
movsd 0x20(%r14,%rcx), %xmm4
addps %xmm4, %xmm7
shufps $0x0, %xmm6, %xmm6      # xmm6 = xmm6[0,0,0,0]
mulps %xmm6, %xmm7
mulps %xmm1, %xmm7
addps %xmm7, %xmm0
movaps %xmm8, %xmm5
shufps $0x0, %xmm8, %xmm8      # xmm8 = xmm8[0,0,0,0]
movaps %xmm0, %xmm7
divps %xmm8, %xmm7
movlps %xmm7, 0x28(%r14,%rcx)
movsd 0x34(%r14,%rcx), %xmm9
addps %xmm9, %xmm3
mulps %xmm6, %xmm3
mulps %xmm1, %xmm3
addps %xmm3, %xmm2
movaps %xmm2, %xmm3
divps %xmm8, %xmm3
movlps %xmm3, 0x3c(%r14,%rcx)
addq $0x4c, %rcx
movaps %xmm4, %xmm7
movaps %xmm9, %xmm3
cmpq %rcx, %rax
jne 0x52fa
jmp 0x5372
xorl %eax, %eax
movq %rax, 0x3c(%r14)
movq %rax, 0x28(%r14)
movq %r14, 0x3d8(%r15)
movl %ebp, 0x3d0(%r15)
xorl %eax, %eax
jmp 0x53a8
leaq 0x346e(%rip), %rdi      # 0x87f9
jmp 0x5394
leaq 0x3540(%rip), %rdi      # 0x88d4
xorl %eax, %eax
callq 0x22e0
movq %r15, %rdi
callq 0x2220
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x2c8, %rsp            # imm = 0x2C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq