// File: /workspace/github_c_makefile_star2_O2/radforddc[P]icpc_siggen/read_config.c
// Function: read_config
int read_config(char *config_file_name, MJD_Siggen_Setup *setup) {

  /* reads and parses configuration file of name config_file_name
     fills in values of MJD_Siggen_Setup setup, defined in mjd_siggen.h
     returns 0 on success, 1 otherwise
  */

  char key_word[][32] = {
    "xtal_length",
    "xtal_radius",
    "top_bullet_radius",
    "bottom_bullet_radius",
    "pc_length",
    "pc_radius",
    "bulletize_PC",
    "bottom_taper_length",  // note: these two keywords must stay adjacent, in this order
    "taper_length",         // <- for compatibility with old mjd config files, == "bottom taper_length
    "outer_taper_length",
    "outer_taper_width",
    "taper_angle",
    "inner_taper_length",
    "inner_taper_width",
    "hole_length_gap",     // can use gap (i.e. xtal_length - hole_length) instead. This keyword must be before "hole_length".
    "hole_length",
    "hole_radius",
    "hole_bullet_radius",
    "wrap_around_radius",
    "ditch_depth",
    "ditch_thickness",
    "Li_thickness",
    "vacuum_gap",
    "xtal_grid",
    "impurity_z0",
    "impurity_gradient",
    "impurity_quadratic",
    "impurity_surface",
    "impurity_radial_add",
    "impurity_radial_mult",
    "impurity_rpower",
    "xtal_HV",
    "surface_drift_vel_factor",

    "drift_name",
    "field_name",
    "wp_name",
    "xtal_temp",
    "preamp_tau",
    "time_steps_calc",
    "step_time_calc",
    "step_time_out",
    "charge_cloud_size",
    "use_diffusion",
    "energy",
    "verbosity_level",
    "max_iterations",
    "write_field",
    "write_WP",
    ""
  };

  int   ii, i, l, n=0, ok, iint = 0, diameter = 0;
  float fi;
  char  *c, line[256], line2[256], name[256];
  FILE  *file;


  /* initialize everything to zero... */
  memset(setup, 0, sizeof(*setup));
  /* ...except for impurity_radial_mult */
  setup->impurity_radial_mult = 1.0f;      // 1.0 is neutral (no radial gradient)
  setup->surface_drift_vel_factor = 1.0f;  // normal fast drift, same as bulk

  if (!(file = fopen(config_file_name, "r"))) {
    printf("\nERROR: config file %s does not exist?\n", config_file_name);
    return 1;
  }
  /* read config file */
  printf("\nReading values from config file %s\n", config_file_name);
  while (fgets(line, sizeof(line), file)) {
    n++;
    /* ignore comments and blank lines */
    if (strlen(line) < 3 || *line == ' ' || *line == '\t' || *line == '#') continue;
    /* if line contains "_diam" (for diameter) replace with "_radius"
       this allows the user to specify diametwrs instead of radii */
    diameter = 0;
    if ((c = strstr(line, "_diam"))) {
      diameter = 1;
      if (setup->verbosity >= CHATTY) printf("Line: %s", line);
      strcpy(line2, c+5);
      strcpy(c, "_radius");
      strcpy(c+7, line2);
      if (setup->verbosity >= CHATTY) printf("   -->  %s", line);      
    }

    for (i=0; (l=strlen(key_word[i])) > 0; i++) {
      if (!strncmp(line, key_word[i], l)) {
	/* line starts with key_word[i] */
      if (setup->verbosity >= CHATTY) printf("Line: %s", line);
	if (line[l] != ' ' && line[l] != '\t') {
	  ok = 0;
	} else {
	  // for (c = line + l; *c != ' ' && *c != '\t'; c++) ;
	  /* find next non-white-space char */
	  for (c = line + l; *c == ' ' || *c == '\t'; c++) ;
	  name[0] = 0;
	  ii = iint = 0;
	  fi = 0;
	  if (strstr(key_word[i], "_name")) {
	    /* extract character string for file name */
	    for (ok=0; ok<256 && *c != ' ' && *c != '\t' && *c != '\n' &&  *c != '\r'; ok++) {
	      name[ok] = *c;
	      c++;
	    }
	    name[ok] = '\0';	    
	  } else if (!strncmp("time_steps_calc", key_word[i], l) ||
		     !strncmp("use_diffusion", key_word[i], l) ||
		     !strncmp("verbosity_level", key_word[i], l) ||
		     !strncmp("max_iterations", key_word[i], l) ||
		     !strncmp("write_field", key_word[i], l) ||
		     !strncmp("write_WP", key_word[i], l) ||
		     !strncmp("bulletize_PC", key_word[i], l)) {
	    /* extract integer value */
	    ok = sscanf(c, "%d", &ii);
	    iint = 1;
	  } else {
	    /* extract float value */
	    ok = sscanf(c, "%f", &fi);
            if (diameter) fi /= 2.0;
	  }
	}
	if (ok < 1) {
	  printf("ERROR reading %s from config file %s\n"
		 "   ...line number %d is: %s",
		 key_word[i], config_file_name, n, line);
	  return 1;
	}

        if (!strncmp(key_word[i], "taper_length", l)) {
          i--;                      // use previous keyword = "bottom_taper_length" instead
          l=strlen(key_word[i]);    // for backwards compatibiity wth old mjd config files
        }

	if (strstr(key_word[i], "verbosity_level")) {
	  setup->verbosity = ii;
	} else if (strstr(key_word[i], "xtal_length")) {
	  setup->xtal_length = fi;
	} else if (strstr(key_word[i], "xtal_radius")) {
	  setup->xtal_radius = fi;
	} else if (strstr(key_word[i], "top_bullet_radius")) {
	  setup->top_bullet_radius = fi;
	} else if (strstr(key_word[i], "bottom_bullet_radius")) {
	  setup->bottom_bullet_radius = fi;
	} else if (strstr(key_word[i], "pc_length")) {
	  setup->pc_length = fi;
	} else if (strstr(key_word[i], "pc_radius")) {
	  setup->pc_radius = fi;
	} else if (strstr(key_word[i], "bulletize_PC")) {
	  setup->bulletize_PC = ii;
	} else if (strstr(key_word[i], "bottom_taper_length")) {
	  setup->bottom_taper_length = fi;
	} else if (strstr(key_word[i], "outer_taper_length")) {
	  setup->outer_taper_length = fi;
	} else if (strstr(key_word[i], "outer_taper_width")) {
	  setup->outer_taper_width = fi;
	} else if (strstr(key_word[i], "taper_angle")) {
	  setup->taper_angle = fi;
	} else if (strstr(key_word[i], "inner_taper_length")) {
	  setup->inner_taper_length = fi;
	} else if (strstr(key_word[i], "inner_taper_width")) {
	  setup->inner_taper_width = fi;
	} else if (strstr(key_word[i], "hole_length")) {
	  setup->hole_length = fi;
          /* the user can specify "hole_length_gap" = xtal_length - hole_length, instead of "hole_length" */
          if (strstr(line, "hole_length_gap")  && fi < setup->xtal_length) {
            setup->hole_length = setup->xtal_length - fi;
            if (setup->verbosity >= CHATTY) printf("   -->  hole_length: %f\n", setup->hole_length);
          }
	} else if (strstr(key_word[i], "hole_radius")) {
	  setup->hole_radius = fi;
	} else if (strstr(key_word[i], "hole_bullet_radius")) {
	  setup->hole_bullet_radius = fi;
	} else if (strstr(key_word[i], "wrap_around_radius")) {
	  setup->wrap_around_radius = fi;
	} else if (strstr(key_word[i], "ditch_depth")) {
	  setup->ditch_depth = fi;
	} else if (strstr(key_word[i], "ditch_thickness")) {
	  setup->ditch_thickness = fi;
	} else if (strstr(key_word[i], "Li_thickness")) {
	  setup->Li_thickness = fi;
	} else if (strstr(key_word[i], "vacuum_gap")) {
	  setup->vacuum_gap = fi;
	} else if (strstr(key_word[i], "xtal_grid")) {
	  setup->xtal_grid = fi;
	} else if (strstr(key_word[i], "impurity_z0")) {
	  setup->impurity_z0 = fi;
	} else if (strstr(key_word[i], "impurity_gradient")) {
	  setup->impurity_gradient = fi;
	} else if (strstr(key_word[i], "impurity_quadratic")) {
	  setup->impurity_quadratic = fi;
	} else if (strstr(key_word[i], "impurity_surface")) {
	  setup->impurity_surface = fi;
	} else if (strstr(key_word[i], "impurity_radial_add")) {
	  setup->impurity_radial_add = fi;
	} else if (strstr(key_word[i], "impurity_radial_mult")) {
	  setup->impurity_radial_mult = fi;
	} else if (strstr(key_word[i], "impurity_rpower")) {
	  setup->impurity_rpower = fi;
	} else if (strstr(key_word[i], "xtal_HV")) {
	  setup->xtal_HV = fi;
	} else if (strstr(key_word[i], "surface_drift_vel_factor")) {
	  setup->surface_drift_vel_factor = fi;
	} else if (strstr(key_word[i], "drift_name")) {
	  strncpy(setup->drift_name, name, 256);
	} else if (strstr(key_word[i], "field_name")) {
	  strncpy(setup->field_name, name, 256);
	} else if (strstr(key_word[i], "wp_name")) {
	  strncpy(setup->wp_name, name, 256);
	} else if (strstr(key_word[i], "xtal_temp")) {
	  setup->xtal_temp = fi;
	} else if (strstr(key_word[i], "preamp_tau")) {
	  setup->preamp_tau = fi;
	} else if (strstr(key_word[i], "time_steps_calc")) {
	  setup->time_steps_calc = ii;
	} else if (strstr(key_word[i], "step_time_calc")) {
	  setup->step_time_calc = fi;
	} else if (strstr(key_word[i], "step_time_out")) {
	  setup->step_time_out = fi;
	} else if (strstr(key_word[i], "charge_cloud_size")) {
	  setup->charge_cloud_size = fi;
	} else if (strstr(key_word[i], "use_diffusion")) {
	  setup->use_diffusion = ii;
	} else if (strstr(key_word[i], "energy")) {
	  setup->energy = fi;
	} else if (strstr(key_word[i], "max_iterations")) {
	  setup->max_iterations = ii;
	} else if (strstr(key_word[i], "write_field")) {
	  setup->write_field = ii;
	} else if (strstr(key_word[i], "write_WP")) {
	  setup->write_WP = ii;
	} else {
	  printf("ERROR; unrecognized keyword %s\n", key_word[i]);
	  return 1;
	}

	if (setup->verbosity >= CHATTY) {
	  // printf("%s", line);
	  if (iint) {
	    printf("%s: %d\n", key_word[i], ii);
	  } else if (strlen(name) > 0) {
	    printf("%s: %s\n", key_word[i], name);
	  } else {
	    printf("%s: %f\n", key_word[i], fi);
	  }
	}
	break;
      }
    }
  }
  fclose(file);

  /* some consistency checks */
  if (setup->inner_taper_length > setup->hole_length - setup->hole_bullet_radius)
    setup->inner_taper_length = setup->hole_length - setup->hole_bullet_radius;
  if (setup->hole_bullet_radius > setup->hole_radius)
    setup->hole_bullet_radius = setup->hole_radius;
  if (setup->outer_taper_length > setup->xtal_length ||
      setup->inner_taper_length > setup->hole_length ||
      setup->hole_length > setup->xtal_length ||
      setup->hole_length < setup->hole_bullet_radius ||
      setup->inner_taper_length > setup->hole_length - setup->hole_bullet_radius ||
      (setup->hole_radius +
       setup->outer_taper_width +
       setup->inner_taper_width) > setup->xtal_radius) {
    printf("\nERROR: Inconsistent detector dimensions:\n"
           "   crystal length and radius: %5.2f %5.2f\n"
           "      hole length and radius: %5.2f %5.2f\n"
           "outer taper length and width: %5.2f %5.2f\n"
           "inner taper length and width: %5.2f %5.2f\n\n",
           setup->xtal_length, setup->xtal_radius,
           setup->hole_length, setup->hole_radius,
           setup->outer_taper_length, setup->outer_taper_width,
           setup->inner_taper_length, setup->inner_taper_width);
    return 1;
  }

  if (setup->taper_angle > 0) {
    /* convert taper angle to taper widths */
    if (setup->outer_taper_length > 0) {
      setup->outer_taper_width =
        setup->outer_taper_length * tan(setup->taper_angle * 3.14159/180.0);
      if (setup->verbosity >= CHATTY) printf("  ->>  outer taper width: %f\n", setup->outer_taper_width);
    }
    if (setup->inner_taper_length > 0) {
      setup->inner_taper_width =
        setup->inner_taper_length * tan(setup->taper_angle * 3.14159/180.0);
      if (setup->verbosity >= CHATTY) printf("  ->>  inner taper width: %f\n", setup->inner_taper_width);
    }
  } else {
    /* convert taper width to taper angle */
    if (setup->outer_taper_length > 0 &&
        setup->outer_taper_width > 0)
      setup->taper_angle =
        atan(setup->outer_taper_width/setup->outer_taper_length) * 180.0/3.14159;
    else if (setup->inner_taper_length > 0 &&
             setup->inner_taper_width > 0)
      setup->taper_angle =
        atan(setup->inner_taper_width/setup->inner_taper_length) * 180.0/3.14159;
    if (setup->taper_angle > 0)
      if (setup->verbosity >= CHATTY) printf("  ->>  taper angle: %f\n", setup->taper_angle);
  }
  if (setup->wrap_around_radius > 0 &&
      setup->ditch_depth > 0 && setup->ditch_thickness > 0 &&
      (setup->pc_radius == 0 || setup->pc_radius > setup->wrap_around_radius - setup->ditch_thickness))
    setup->pc_radius = setup->wrap_around_radius - setup->ditch_thickness;
  if (setup->wrap_around_radius == 0 ||
      setup->wrap_around_radius > setup->xtal_radius - setup->bottom_taper_length)
    setup->wrap_around_radius = setup->xtal_radius - setup->bottom_taper_length;

  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x978, %rsp            # imm = 0x978
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x19ca(%rip), %rsi      # 0x3770
leaq 0x350(%rsp), %rdi
movl $0x620, %edx            # imm = 0x620
callq 0x10f0
movl $0x15b0, %edx           # imm = 0x15B0
movq %rbx, %rdi
xorl %esi, %esi
callq 0x10d0
movl $0x3f800000, %eax       # imm = 0x3F800000
movl %eax, 0x6c(%rbx)
movl %eax, 0x1590(%rbx)
leaq 0x12c4(%rip), %rsi      # 0x30a0
movq %r14, %rdi
callq 0x1120
testq %rax, %rax
je 0x29ae
movq %rax, %r12
leaq 0x1fc1(%rip), %rdi      # 0x3db8
movq %r14, 0x48(%rsp)
movq %r14, %rsi
xorl %eax, %eax
callq 0x10c0
leaq 0x88(%rbx), %rax
movq %rax, 0x40(%rsp)
leaq 0x188(%rbx), %rax
movq %rax, 0x38(%rsp)
leaq 0x288(%rbx), %rax
movq %rax, 0x30(%rsp)
leaq 0x150(%rsp), %rbp
xorl %r14d, %r14d
movq %rbx, 0x10(%rsp)
movq %r12, 0x18(%rsp)
movq %rbp, %rdi
movl $0x100, %esi            # imm = 0x100
movq %r12, %rdx
callq 0x10e0
testq %rax, %rax
je 0x292c
incl %r14d
movq %rbp, %rdi
callq 0x10a0
cmpq $0x3, %rax
jb 0x1e3f
movb 0x150(%rsp), %al
cmpb $0x23, %al
je 0x1e3f
cmpb $0x20, %al
je 0x1e3f
cmpb $0x9, %al
je 0x1e3f
movq %rbp, %rdi
leaq 0x1f57(%rip), %rsi      # 0x3ddd
callq 0x1140
movq %rax, %r12
testq %rax, %rax
je 0x1eef
cmpl $0x2, (%rbx)
jl 0x1ea9
leaq 0x1f44(%rip), %rdi      # 0x3de3
movq %rbp, %rsi
xorl %eax, %eax
callq 0x10c0
leaq 0x5(%r12), %rsi
leaq 0x250(%rsp), %r15
movq %r15, %rdi
callq 0x1050
movabsq $0x7375696461725f, %rax # imm = 0x7375696461725F
movq %rax, (%r12)
leaq 0x7(%r12), %rdi
movq %r15, %rsi
callq 0x1050
cmpl $0x2, (%rbx)
jl 0x1eef
leaq 0x1f07(%rip), %rdi      # 0x3dec
movq %rbp, %rsi
xorl %eax, %eax
callq 0x10c0
movl %r14d, 0x8(%rsp)
leaq 0x350(%rsp), %r15
xorl %r14d, %r14d
movq %r15, %rdi
callq 0x10a0
movq %rax, %r13
testl %r13d, %r13d
jle 0x1f31
andl $0x7fffffff, %r13d      # imm = 0x7FFFFFFF
movq %rbp, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x1040
testl %eax, %eax
je 0x1f40
incq %r14
addq $0x20, %r15
jmp 0x1eff
movq 0x18(%rsp), %r12
movl 0x8(%rsp), %r14d
jmp 0x1e3f
cmpl $0x2, (%rbx)
jl 0x1f56
leaq 0x1e97(%rip), %rdi      # 0x3de3
movq %rbp, %rsi
xorl %eax, %eax
callq 0x10c0
movzbl 0x150(%rsp,%r13), %eax
cmpl $0x20, %eax
je 0x1f6d
cmpl $0x9, %eax
jne 0x2ab6
leaq (%rsp,%r13), %rbx
addq $0x150, %rbx            # imm = 0x150
cmpb $0x20, %al
je 0x1f84
movzbl %al, %eax
cmpl $0x9, %eax
jne 0x1f8c
movb 0x1(%rbx), %al
incq %rbx
jmp 0x1f78
andl $0x0, 0x24(%rsp)
movb $0x0, 0x50(%rsp)
andl $0x0, 0x4(%rsp)
movq %r15, %rdi
leaq 0x2106(%rip), %rsi      # 0x40ab
callq 0x1140
testq %rax, %rax
je 0x1fe4
xorl %eax, %eax
movabsq $0x100002600, %rdx      # imm = 0x100002600
cmpq $0x100, %rax            # imm = 0x100
je 0x20de
movzbl (%rbx,%rax), %ecx
cmpq $0x20, %rcx
ja 0x1fdb
btq %rcx, %rdx
jb 0x20e3
movb %cl, 0x50(%rsp,%rax)
incq %rax
jmp 0x1fbb
leaq 0x1e0c(%rip), %rdi      # 0x3df7
movq %r15, %rsi
movq %r13, %rdx
callq 0x1040
testl %eax, %eax
je 0x20c3
leaq 0x1e02(%rip), %rdi      # 0x3e07
movq %r15, %rsi
movq %r13, %rdx
callq 0x1040
testl %eax, %eax
je 0x20c3
leaq 0x1df6(%rip), %rdi      # 0x3e15
movq %r15, %rsi
movq %r13, %rdx
callq 0x1040
testl %eax, %eax
je 0x20c3
leaq 0x1dec(%rip), %rdi      # 0x3e25
movq %r15, %rsi
movq %r13, %rdx
callq 0x1040
testl %eax, %eax
je 0x20c3
leaq 0x1de5(%rip), %rdi      # 0x3e34
movq %r15, %rsi
movq %r13, %rdx
callq 0x1040
testl %eax, %eax
je 0x20c3
leaq 0x1ddb(%rip), %rdi      # 0x3e40
movq %r15, %rsi
movq %r13, %rdx
callq 0x1040
testl %eax, %eax
je 0x20c3
leaq 0x1dce(%rip), %rdi      # 0x3e49
movq %r15, %rsi
movq %r13, %rdx
callq 0x1040
testl %eax, %eax
je 0x20c3
movq %rbx, %rdi
leaq 0x1dc5(%rip), %rsi      # 0x3e59
leaq 0x4(%rsp), %rdx
xorl %eax, %eax
callq 0x1110
testq %r12, %r12
je 0x20b9
movss 0x4(%rsp), %xmm0
mulss 0x16b5(%rip), %xmm0     # 0x3768
movss %xmm0, 0x4(%rsp)
movq 0x10(%rsp), %rbx
movb $0x1, %r12b
jmp 0x20f2
xorl %r12d, %r12d
movq %rbx, %rdi
leaq 0x1d86(%rip), %rsi      # 0x3e56
leaq 0x24(%rsp), %rdx
xorl %eax, %eax
callq 0x1110
jmp 0x20ed
movl $0x100, %eax            # imm = 0x100
movl %eax, %ecx
movb $0x0, 0x50(%rsp,%rcx)
movb $0x1, %r12b
movq 0x10(%rsp), %rbx
testl %eax, %eax
jle 0x2ab6
movl %r12d, 0x2c(%rsp)
movq %r15, %rdi
leaq 0x1dee(%rip), %rsi      # 0x3ef7
movq %r13, %rdx
callq 0x1040
cmpl $0x1, %eax
sbbl $0x0, %r14d
movslq %r14d, %rax
shlq $0x5, %rax
leaq (%rsp,%rax), %r15
addq $0x350, %r15            # imm = 0x350
movq %r15, %rdi
leaq 0x1ce1(%rip), %rsi      # 0x3e15
callq 0x1140
testq %rax, %rax
je 0x2153
movl 0x24(%rsp), %eax
movl %eax, (%rbx)
movq 0x18(%rsp), %r12
movl 0x8(%rsp), %r14d
jmp 0x2341
movq %r15, %rdi
leaq 0x1d40(%rip), %rsi      # 0x3e9d
callq 0x1140
testq %rax, %rax
movq 0x18(%rsp), %r12
movl 0x8(%rsp), %r14d
je 0x2181
movss 0x4(%rsp), %xmm0
movss %xmm0, 0x4(%rbx)
jmp 0x233f
movq %r15, %rdi
leaq 0x1d1e(%rip), %rsi      # 0x3ea9
callq 0x1140
testq %rax, %rax
je 0x21a5
movss 0x4(%rsp), %xmm0
movss %xmm0, 0x8(%rbx)
jmp 0x233f
movq %r15, %rdi
leaq 0x1d06(%rip), %rsi      # 0x3eb5
callq 0x1140
testq %rax, %rax
je 0x21c9
movss 0x4(%rsp), %xmm0
movss %xmm0, 0x40(%rbx)
jmp 0x233f
movq %r15, %rdi
leaq 0x1cf4(%rip), %rsi      # 0x3ec7
callq 0x1140
testq %rax, %rax
je 0x21ed
movss 0x4(%rsp), %xmm0
movss %xmm0, 0x44(%rbx)
jmp 0x233f
movq %r15, %rdi
leaq 0x1ce5(%rip), %rsi      # 0x3edc
callq 0x1140
testq %rax, %rax
je 0x2211
movss 0x4(%rsp), %xmm0
movss %xmm0, 0xc(%rbx)
jmp 0x233f
movq %r15, %rdi
leaq 0x1ccb(%rip), %rsi      # 0x3ee6
callq 0x1140
testq %rax, %rax
je 0x2235
movss 0x4(%rsp), %xmm0
movss %xmm0, 0x10(%rbx)
jmp 0x233f
movq %r15, %rdi
leaq 0x1c0a(%rip), %rsi      # 0x3e49
callq 0x1140
testq %rax, %rax
je 0x2258
movl 0x24(%rsp), %eax
movl %eax, 0x84(%rbx)
jmp 0x233f
movq %r15, %rdi
leaq 0x1c8e(%rip), %rsi      # 0x3ef0
callq 0x1140
testq %rax, %rax
je 0x227c
movss 0x4(%rsp), %xmm0
movss %xmm0, 0x20(%rbx)
jmp 0x233f
movq %r15, %rdi
leaq 0x1c7e(%rip), %rsi      # 0x3f04
callq 0x1140
testq %rax, %rax
je 0x22a0
movss 0x4(%rsp), %xmm0
movss %xmm0, 0x2c(%rbx)
jmp 0x233f
movq %r15, %rdi
leaq 0x1c6d(%rip), %rsi      # 0x3f17
callq 0x1140
testq %rax, %rax
je 0x22c1
movss 0x4(%rsp), %xmm0
movss %xmm0, 0x38(%rbx)
jmp 0x233f
movq %r15, %rdi
leaq 0x1c5e(%rip), %rsi      # 0x3f29
callq 0x1140
testq %rax, %rax
je 0x22e7
movss 0x4(%rsp), %xmm0
movq 0x10(%rsp), %rbx
movss %xmm0, 0x30(%rbx)
jmp 0x2335
movq %r15, %rdi
leaq 0x1c44(%rip), %rsi      # 0x3f35
callq 0x1140
testq %rax, %rax
je 0x230d
movss 0x4(%rsp), %xmm0
movq 0x10(%rsp), %rbx
movss %xmm0, 0x34(%rbx)
jmp 0x2335
movq %r15, %rdi
leaq 0x1c31(%rip), %rsi      # 0x3f48
callq 0x1140
testq %rax, %rax
je 0x23a9
movss 0x4(%rsp), %xmm0
movq 0x10(%rsp), %rbx
movss %xmm0, 0x3c(%rbx)
movq 0x18(%rsp), %r12
movl 0x8(%rsp), %r14d
movl (%rbx), %eax
cmpl $0x2, %eax
jl 0x1e3f
cmpb $0x0, 0x2c(%rsp)
je 0x2373
cmpb $0x0, 0x50(%rsp)
je 0x238d
leaq 0x1dcd(%rip), %rdi      # 0x412c
movq %r15, %rsi
leaq 0x50(%rsp), %rdx
xorl %eax, %eax
callq 0x10c0
jmp 0x1e3f
movl 0x24(%rsp), %edx
leaq 0x1da6(%rip), %rdi      # 0x4124
movq %r15, %rsi
xorl %eax, %eax
callq 0x10c0
jmp 0x1e3f
cvtss2sd 0x4(%rsp), %xmm0
leaq 0x1d9a(%rip), %rdi      # 0x4134
movq %r15, %rsi
movb $0x1, %al
callq 0x10c0
jmp 0x1e3f
movq %r15, %rdi
leaq 0x1ba7(%rip), %rsi      # 0x3f5a
callq 0x1140
testq %rax, %rax
je 0x2430
movss 0x4(%rsp), %xmm0
movq 0x10(%rsp), %rbx
movss %xmm0, 0x28(%rsp)
movss %xmm0, 0x24(%rbx)
movq %rbp, %rdi
leaq 0x1b89(%rip), %rsi      # 0x3f66
callq 0x1140
testq %rax, %rax
movq 0x18(%rsp), %r12
movl 0x8(%rsp), %r14d
je 0x233f
movss 0x4(%rbx), %xmm0
ucomiss 0x28(%rsp), %xmm0
jbe 0x233f
subss 0x28(%rsp), %xmm0
movss %xmm0, 0x24(%rbx)
cmpl $0x2, (%rbx)
jl 0x1e3f
cvtss2sd %xmm0, %xmm0
leaq 0x1b52(%rip), %rdi      # 0x3f76
movb $0x1, %al
callq 0x10c0
jmp 0x233f
movq %r15, %rdi
leaq 0x1b55(%rip), %rsi      # 0x3f8f
callq 0x1140
testq %rax, %rax
je 0x2459
movss 0x4(%rsp), %xmm0
movq 0x10(%rsp), %rbx
movss %xmm0, 0x28(%rbx)
jmp 0x2335
movq %r15, %rdi
leaq 0x1b38(%rip), %rsi      # 0x3f9b
callq 0x1140
testq %rax, %rax
je 0x2482
movss 0x4(%rsp), %xmm0
movq 0x10(%rsp), %rbx
movss %xmm0, 0x48(%rbx)
jmp 0x2335
movq %r15, %rdi
leaq 0x1b22(%rip), %rsi      # 0x3fae
callq 0x1140
testq %rax, %rax
je 0x24ab
movss 0x4(%rsp), %xmm0
movq 0x10(%rsp), %rbx
movss %xmm0, 0x14(%rbx)
jmp 0x2335
movq %r15, %rdi
leaq 0x1b0c(%rip), %rsi      # 0x3fc1
callq 0x1140
testq %rax, %rax
je 0x24d4
movss 0x4(%rsp), %xmm0
movq 0x10(%rsp), %rbx
movss %xmm0, 0x18(%rbx)
jmp 0x2335
movq %r15, %rdi
leaq 0x1aef(%rip), %rsi      # 0x3fcd
callq 0x1140
testq %rax, %rax
je 0x24fd
movss 0x4(%rsp), %xmm0
movq 0x10(%rsp), %rbx
movss %xmm0, 0x1c(%rbx)
jmp 0x2335
movq %r15, %rdi
leaq 0x1ad6(%rip), %rsi      # 0x3fdd
callq 0x1140
testq %rax, %rax
je 0x2526
movss 0x4(%rsp), %xmm0
movq 0x10(%rsp), %rbx
movss %xmm0, 0x4c(%rbx)
jmp 0x2335
movq %r15, %rdi
leaq 0x1aba(%rip), %rsi      # 0x3fea
callq 0x1140
testq %rax, %rax
je 0x254f
movss 0x4(%rsp), %xmm0
movq 0x10(%rsp), %rbx
movss %xmm0, 0x50(%rbx)
jmp 0x2335
movq %r15, %rdi
leaq 0x1a9c(%rip), %rsi      # 0x3ff5
callq 0x1140
testq %rax, %rax
je 0x2578
movss 0x4(%rsp), %xmm0
movq 0x10(%rsp), %rbx
movss %xmm0, 0x54(%rbx)
jmp 0x2335
movq %r15, %rdi
leaq 0x1a7d(%rip), %rsi      # 0x3fff
callq 0x1140
testq %rax, %rax
je 0x25a1
movss 0x4(%rsp), %xmm0
movq 0x10(%rsp), %rbx
movss %xmm0, 0x58(%rbx)
jmp 0x2335
movq %r15, %rdi
leaq 0x1a60(%rip), %rsi      # 0x400b
callq 0x1140
testq %rax, %rax
je 0x25ca
movss 0x4(%rsp), %xmm0
movq 0x10(%rsp), %rbx
movss %xmm0, 0x5c(%rbx)
jmp 0x2335
movq %r15, %rdi
leaq 0x1a49(%rip), %rsi      # 0x401d
callq 0x1140
testq %rax, %rax
je 0x25f3
movss 0x4(%rsp), %xmm0
movq 0x10(%rsp), %rbx
movss %xmm0, 0x60(%rbx)
jmp 0x2335
movq %r15, %rdi
leaq 0x1a33(%rip), %rsi      # 0x4030
callq 0x1140
testq %rax, %rax
je 0x261c
movss 0x4(%rsp), %xmm0
movq 0x10(%rsp), %rbx
movss %xmm0, 0x64(%rbx)
jmp 0x2335
movq %r15, %rdi
leaq 0x1a1b(%rip), %rsi      # 0x4041
callq 0x1140
testq %rax, %rax
je 0x2645
movss 0x4(%rsp), %xmm0
movq 0x10(%rsp), %rbx
movss %xmm0, 0x68(%rbx)
jmp 0x2335
movq %r15, %rdi
leaq 0x1a06(%rip), %rsi      # 0x4055
callq 0x1140
testq %rax, %rax
je 0x266e
movss 0x4(%rsp), %xmm0
movq 0x10(%rsp), %rbx
movss %xmm0, 0x6c(%rbx)
jmp 0x2335
movq %r15, %rdi
leaq 0x19f2(%rip), %rsi      # 0x406a
callq 0x1140
testq %rax, %rax
je 0x2697
movss 0x4(%rsp), %xmm0
movq 0x10(%rsp), %rbx
movss %xmm0, 0x70(%rbx)
jmp 0x2335
movq %r15, %rdi
leaq 0x19d9(%rip), %rsi      # 0x407a
callq 0x1140
testq %rax, %rax
je 0x26c0
movss 0x4(%rsp), %xmm0
movq 0x10(%rsp), %rbx
movss %xmm0, 0x74(%rbx)
jmp 0x2335
movq %r15, %rdi
leaq 0x19b8(%rip), %rsi      # 0x4082
callq 0x1140
testq %rax, %rax
je 0x26ec
movss 0x4(%rsp), %xmm0
movq 0x10(%rsp), %rbx
movss %xmm0, 0x1590(%rbx)
jmp 0x2335
movq %r15, %rdi
leaq 0x19a5(%rip), %rsi      # 0x409b
callq 0x1140
testq %rax, %rax
je 0x270c
movl $0x100, %edx            # imm = 0x100
movq 0x40(%rsp), %rdi
jmp 0x274a
movq %r15, %rdi
leaq 0x1990(%rip), %rsi      # 0x40a6
callq 0x1140
testq %rax, %rax
je 0x272c
movl $0x100, %edx            # imm = 0x100
movq 0x38(%rsp), %rdi
jmp 0x274a
movq %r15, %rdi
leaq 0x197b(%rip), %rsi      # 0x40b1
callq 0x1140
testq %rax, %rax
je 0x275e
movl $0x100, %edx            # imm = 0x100
movq 0x30(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x1030
movq 0x10(%rsp), %rbx
jmp 0x2335
movq %r15, %rdi
leaq 0x1951(%rip), %rsi      # 0x40b9
callq 0x1140
testq %rax, %rax
je 0x278a
movss 0x4(%rsp), %xmm0
movq 0x10(%rsp), %rbx
movss %xmm0, 0x388(%rbx)
jmp 0x2335
movq %r15, %rdi
leaq 0x192f(%rip), %rsi      # 0x40c3
callq 0x1140
testq %rax, %rax
je 0x27b6
movss 0x4(%rsp), %xmm0
movq 0x10(%rsp), %rbx
movss %xmm0, 0x38c(%rbx)
jmp 0x2335
movq %r15, %rdi
leaq 0x1637(%rip), %rsi      # 0x3df7
callq 0x1140
testq %rax, %rax
je 0x27de
movl 0x24(%rsp), %eax
movq 0x10(%rsp), %rbx
movl %eax, 0x390(%rbx)
jmp 0x2335
movq %r15, %rdi
leaq 0x18e6(%rip), %rsi      # 0x40ce
callq 0x1140
testq %rax, %rax
je 0x280a
movss 0x4(%rsp), %xmm0
movq 0x10(%rsp), %rbx
movss %xmm0, 0x394(%rbx)
jmp 0x2335
movq %r15, %rdi
leaq 0x18c9(%rip), %rsi      # 0x40dd
callq 0x1140
testq %rax, %rax
je 0x2836
movss 0x4(%rsp), %xmm0
movq 0x10(%rsp), %rbx
movss %xmm0, 0x398(%rbx)
jmp 0x2335
movq %r15, %rdi
leaq 0x18ab(%rip), %rsi      # 0x40eb
callq 0x1140
testq %rax, %rax
je 0x2862
movss 0x4(%rsp), %xmm0
movq 0x10(%rsp), %rbx
movss %xmm0, 0x39c(%rbx)
jmp 0x2335
movq %r15, %rdi
leaq 0x159b(%rip), %rsi      # 0x3e07
callq 0x1140
testq %rax, %rax
je 0x288a
movl 0x24(%rsp), %eax
movq 0x10(%rsp), %rbx
movl %eax, 0x3a0(%rbx)
jmp 0x2335
movq %r15, %rdi
leaq 0x1869(%rip), %rsi      # 0x40fd
callq 0x1140
testq %rax, %rax
je 0x28b6
movss 0x4(%rsp), %xmm0
movq 0x10(%rsp), %rbx
movss %xmm0, 0x3a4(%rbx)
jmp 0x2335
movq %r15, %rdi
leaq 0x1565(%rip), %rsi      # 0x3e25
callq 0x1140
testq %rax, %rax
je 0x28db
movl 0x24(%rsp), %eax
movq 0x10(%rsp), %rbx
movl %eax, 0x78(%rbx)
jmp 0x2335
movq %r15, %rdi
leaq 0x154f(%rip), %rsi      # 0x3e34
callq 0x1140
testq %rax, %rax
je 0x2900
movl 0x24(%rsp), %eax
movq 0x10(%rsp), %rbx
movl %eax, 0x7c(%rbx)
jmp 0x2335
movq %r15, %rdi
leaq 0x1536(%rip), %rsi      # 0x3e40
callq 0x1140
testq %rax, %rax
je 0x2bb6
movl 0x24(%rsp), %eax
movq 0x10(%rsp), %rbx
movl %eax, 0x80(%rbx)
jmp 0x2335
movq %r12, %rdi
callq 0x1090
movss 0x24(%rbx), %xmm2
movss 0x34(%rbx), %xmm6
movss 0x48(%rbx), %xmm0
movaps %xmm2, %xmm1
subss %xmm0, %xmm1
ucomiss %xmm1, %xmm6
jbe 0x2957
movss %xmm1, 0x34(%rbx)
movaps %xmm1, %xmm6
movss 0x28(%rbx), %xmm3
ucomiss %xmm3, %xmm0
jbe 0x2969
movss %xmm3, 0x48(%rbx)
movaps %xmm3, %xmm0
movss 0x4(%rbx), %xmm5
movss 0x2c(%rbx), %xmm4
ucomiss %xmm5, %xmm4
jbe 0x29c4
cvtss2sd %xmm5, %xmm0
cvtss2sd 0x8(%rbx), %xmm1
cvtss2sd %xmm2, %xmm2
cvtss2sd %xmm3, %xmm3
cvtss2sd 0x38(%rbx), %xmm5
cvtss2sd %xmm4, %xmm4
cvtss2sd %xmm6, %xmm6
cvtss2sd 0x3c(%rbx), %xmm7
leaq 0x179a(%rip), %rdi      # 0x413c
movb $0x8, %al
callq 0x10c0
jmp 0x2ad8
leaq 0x13db(%rip), %rdi      # 0x3d90
movq %r14, %rsi
xorl %eax, %eax
callq 0x10c0
jmp 0x2ad8
ucomiss %xmm5, %xmm2
ja 0x2978
ucomiss %xmm2, %xmm6
ja 0x2978
ucomiss %xmm2, %xmm0
ja 0x2978
movaps %xmm2, %xmm1
subss %xmm0, %xmm1
ucomiss %xmm1, %xmm6
ja 0x2978
movss 0x38(%rbx), %xmm7
movss 0x3c(%rbx), %xmm1
movaps %xmm3, %xmm0
addss %xmm7, %xmm0
addss %xmm1, %xmm0
ucomiss 0x8(%rbx), %xmm0
ja 0x2978
movss 0x30(%rbx), %xmm0
xorps %xmm2, %xmm2
ucomiss %xmm2, %xmm0
jbe 0x2aed
ucomiss %xmm2, %xmm4
jbe 0x2a5d
cvtss2sd %xmm4, %xmm1
movsd %xmm1, 0x8(%rsp)
cvtss2sd %xmm0, %xmm0
mulsd 0x5de(%rip), %xmm0      # 0x3008
divsd 0x5de(%rip), %xmm0      # 0x3010
callq 0x1100
mulsd 0x8(%rsp), %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x38(%rbx)
cmpl $0x2, (%rbx)
jl 0x2a5d
cvtss2sd %xmm0, %xmm0
leaq 0x17ba(%rip), %rdi      # 0x4210
movb $0x1, %al
callq 0x10c0
movss 0x34(%rbx), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x2b4f
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0x8(%rsp)
cvtss2sd 0x30(%rbx), %xmm0
mulsd 0x583(%rip), %xmm0      # 0x3008
divsd 0x583(%rip), %xmm0      # 0x3010
callq 0x1100
mulsd 0x8(%rsp), %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x3c(%rbx)
cmpl $0x1, (%rbx)
jle 0x2b4f
leaq 0x177d(%rip), %rdi      # 0x422e
jmp 0x2b44
leaq 0x139f(%rip), %rdi      # 0x3e5c
leaq 0x150(%rsp), %r8
movq %r15, %rsi
movq 0x48(%rsp), %rdx
movl 0x8(%rsp), %ecx
xorl %eax, %eax
callq 0x10c0
pushq $0x1
popq %rax
addq $0x978, %rsp            # imm = 0x978
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
ucomiss %xmm2, %xmm4
jbe 0x2afd
ucomiss %xmm2, %xmm7
jbe 0x2afd
divss %xmm4, %xmm7
jmp 0x2b0e
ucomiss %xmm2, %xmm6
jbe 0x2b30
ucomiss %xmm2, %xmm1
jbe 0x2b30
divss %xmm6, %xmm1
movaps %xmm1, %xmm7
cvtss2sd %xmm7, %xmm0
callq 0x1080
mulsd 0x4f1(%rip), %xmm0      # 0x3010
divsd 0x4e1(%rip), %xmm0      # 0x3008
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x30(%rbx)
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x2b4f
cmpl $0x2, (%rbx)
jl 0x2b4f
leaq 0x1708(%rip), %rdi      # 0x424c
cvtss2sd %xmm0, %xmm0
movb $0x1, %al
callq 0x10c0
movss 0x14(%rbx), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x2b90
movss 0x18(%rbx), %xmm2
ucomiss %xmm1, %xmm2
jbe 0x2b90
movss 0x1c(%rbx), %xmm3
xorps %xmm2, %xmm2
ucomiss %xmm2, %xmm3
jbe 0x2b90
movss 0x10(%rbx), %xmm4
ucomiss %xmm2, %xmm4
movaps %xmm0, %xmm2
subss %xmm3, %xmm2
jne 0x2b86
jnp 0x2b8b
ucomiss %xmm2, %xmm4
jbe 0x2b90
movss %xmm2, 0x10(%rbx)
xorl %eax, %eax
ucomiss %xmm1, %xmm0
movss 0x8(%rbx), %xmm1
subss 0x20(%rbx), %xmm1
jne 0x2ba3
jnp 0x2bac
ucomiss %xmm1, %xmm0
jbe 0x2adb
movss %xmm1, 0x14(%rbx)
jmp 0x2adb
leaq 0x1547(%rip), %rdi      # 0x4104
movq %r15, %rsi
jmp 0x29b8