// File: /workspace/github_c_makefile_star2_O3/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 0x18f2(%rip), %rsi      # 0x3770
leaq 0x150(%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 0x11ec(%rip), %rsi      # 0x30a0
movq %r14, %rdi
callq 0x1120
movq %rax, 0x20(%rsp)
testq %rax, %rax
je 0x2aa8
leaq 0x1ee7(%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 0x770(%rsp), %rbp
movl $0x0, 0x2c(%rsp)
leaq 0x150(%rsp), %r14
movq %rbx, 0x10(%rsp)
movq %rbp, %rdi
movl $0x100, %esi            # imm = 0x100
movq 0x20(%rsp), %rdx
callq 0x10e0
testq %rax, %rax
je 0x2a18
incl 0x2c(%rsp)
movq %rbp, %rdi
callq 0x10a0
cmpq $0x3, %rax
jb 0x1f21
movb 0x770(%rsp), %al
cmpb $0x23, %al
je 0x1f21
cmpb $0x20, %al
je 0x1f21
cmpb $0x9, %al
je 0x1f21
movq %rbp, %rdi
leaq 0x1e72(%rip), %rsi      # 0x3ddd
callq 0x1140
movq %rax, %r12
testq %rax, %rax
je 0x1fd4
cmpl $0x2, (%rbx)
jl 0x1f8e
leaq 0x1e5f(%rip), %rdi      # 0x3de3
movq %rbp, %rsi
xorl %eax, %eax
callq 0x10c0
leaq 0x5(%r12), %rsi
leaq 0x870(%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 0x1fd4
leaq 0x1e22(%rip), %rdi      # 0x3dec
movq %rbp, %rsi
xorl %eax, %eax
callq 0x10c0
movq %r14, %rdi
callq 0x10a0
movq %rax, %r15
testl %r15d, %r15d
jle 0x1f21
movq %r14, %r13
xorl %r14d, %r14d
andl $0x7fffffff, %r15d      # imm = 0x7FFFFFFF
movq %rbp, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x1040
testl %eax, %eax
je 0x202b
incq %r14
addq $0x20, %r13
movq %r13, %rdi
callq 0x10a0
movq %rax, %r15
testl %r15d, %r15d
jg 0x1fee
leaq 0x150(%rsp), %r14
jmp 0x1f21
cmpl $0x2, (%rbx)
jl 0x2041
leaq 0x1dac(%rip), %rdi      # 0x3de3
movq %rbp, %rsi
xorl %eax, %eax
callq 0x10c0
movzbl 0x770(%rsp,%r15), %eax
cmpl $0x20, %eax
je 0x2058
cmpl $0x9, %eax
jne 0x2bb6
leaq (%rsp,%r15), %rbx
addq $0x770, %rbx            # imm = 0x770
cmpb $0x20, %al
je 0x206f
movzbl %al, %eax
cmpl $0x9, %eax
jne 0x2077
movb 0x1(%rbx), %al
incq %rbx
jmp 0x2063
movb $0x0, 0x50(%rsp)
xorl %eax, %eax
movl %eax, 0x1c(%rsp)
movl %eax, 0xc(%rsp)
movq %r13, %rdi
leaq 0x201b(%rip), %rsi      # 0x40ab
callq 0x1140
testq %rax, %rax
je 0x20d9
xorl %eax, %eax
movabsq $0x100002600, %rdx      # imm = 0x100002600
movzbl (%rbx,%rax), %ecx
cmpq $0x20, %rcx
ja 0x20b6
btq %rcx, %rdx
jb 0x20ca
movb %cl, 0x50(%rsp,%rax)
incq %rax
cmpq $0x100, %rax            # imm = 0x100
jne 0x20a6
movl $0x100, %eax            # imm = 0x100
movl %eax, %ecx
movb $0x0, 0x50(%rsp,%rcx)
movb $0x1, %r12b
jmp 0x21d1
leaq 0x1d17(%rip), %rdi      # 0x3df7
movq %r13, %rsi
movq %r15, %rdx
callq 0x1040
testl %eax, %eax
je 0x21b8
leaq 0x1d0d(%rip), %rdi      # 0x3e07
movq %r13, %rsi
movq %r15, %rdx
callq 0x1040
testl %eax, %eax
je 0x21b8
leaq 0x1d01(%rip), %rdi      # 0x3e15
movq %r13, %rsi
movq %r15, %rdx
callq 0x1040
testl %eax, %eax
je 0x21b8
leaq 0x1cf7(%rip), %rdi      # 0x3e25
movq %r13, %rsi
movq %r15, %rdx
callq 0x1040
testl %eax, %eax
je 0x21b8
leaq 0x1cf0(%rip), %rdi      # 0x3e34
movq %r13, %rsi
movq %r15, %rdx
callq 0x1040
testl %eax, %eax
je 0x21b8
leaq 0x1ce6(%rip), %rdi      # 0x3e40
movq %r13, %rsi
movq %r15, %rdx
callq 0x1040
testl %eax, %eax
je 0x21b8
leaq 0x1cd9(%rip), %rdi      # 0x3e49
movq %r13, %rsi
movq %r15, %rdx
callq 0x1040
testl %eax, %eax
je 0x21b8
movq %rbx, %rdi
leaq 0x1cd0(%rip), %rsi      # 0x3e59
leaq 0xc(%rsp), %rdx
xorl %eax, %eax
callq 0x1110
testq %r12, %r12
je 0x21ae
movss 0xc(%rsp), %xmm0
mulss 0x15c0(%rip), %xmm0     # 0x3768
movss %xmm0, 0xc(%rsp)
movq 0x10(%rsp), %rbx
movb $0x1, %r12b
jmp 0x21d6
xorl %r12d, %r12d
movq %rbx, %rdi
leaq 0x1c91(%rip), %rsi      # 0x3e56
leaq 0x1c(%rsp), %rdx
xorl %eax, %eax
callq 0x1110
movq 0x10(%rsp), %rbx
testl %eax, %eax
jle 0x2bb6
movq %r13, %rdi
leaq 0x1d0f(%rip), %rsi      # 0x3ef7
movq %r15, %rdx
callq 0x1040
cmpl $0x1, %eax
sbbl $0x0, %r14d
movslq %r14d, %rax
shlq $0x5, %rax
leaq (%rsp,%rax), %r13
addq $0x150, %r13            # imm = 0x150
movq %r13, %rdi
leaq 0x1c02(%rip), %rsi      # 0x3e15
callq 0x1140
testq %rax, %rax
je 0x2230
movl 0x1c(%rsp), %eax
movl %eax, (%rbx)
leaq 0x150(%rsp), %r14
jmp 0x242b
movq %r13, %rdi
leaq 0x1c63(%rip), %rsi      # 0x3e9d
callq 0x1140
testq %rax, %rax
je 0x225c
movss 0xc(%rsp), %xmm0
movss %xmm0, 0x4(%rbx)
leaq 0x150(%rsp), %r14
jmp 0x2429
movq %r13, %rdi
leaq 0x1c43(%rip), %rsi      # 0x3ea9
callq 0x1140
testq %rax, %rax
leaq 0x150(%rsp), %r14
je 0x2288
movss 0xc(%rsp), %xmm0
movss %xmm0, 0x8(%rbx)
jmp 0x2429
movq %r13, %rdi
leaq 0x1c23(%rip), %rsi      # 0x3eb5
callq 0x1140
testq %rax, %rax
je 0x22ac
movss 0xc(%rsp), %xmm0
movss %xmm0, 0x40(%rbx)
jmp 0x2429
movq %r13, %rdi
leaq 0x1c11(%rip), %rsi      # 0x3ec7
callq 0x1140
testq %rax, %rax
je 0x22d0
movss 0xc(%rsp), %xmm0
movss %xmm0, 0x44(%rbx)
jmp 0x2429
movq %r13, %rdi
leaq 0x1c02(%rip), %rsi      # 0x3edc
callq 0x1140
testq %rax, %rax
je 0x22f4
movss 0xc(%rsp), %xmm0
movss %xmm0, 0xc(%rbx)
jmp 0x2429
movq %r13, %rdi
leaq 0x1be8(%rip), %rsi      # 0x3ee6
callq 0x1140
testq %rax, %rax
je 0x2318
movss 0xc(%rsp), %xmm0
movss %xmm0, 0x10(%rbx)
jmp 0x2429
movq %r13, %rdi
leaq 0x1b27(%rip), %rsi      # 0x3e49
callq 0x1140
testq %rax, %rax
je 0x233b
movl 0x1c(%rsp), %eax
movl %eax, 0x84(%rbx)
jmp 0x2429
movq %r13, %rdi
leaq 0x1bab(%rip), %rsi      # 0x3ef0
callq 0x1140
testq %rax, %rax
je 0x235f
movss 0xc(%rsp), %xmm0
movss %xmm0, 0x20(%rbx)
jmp 0x2429
movq %r13, %rdi
leaq 0x1b9b(%rip), %rsi      # 0x3f04
callq 0x1140
testq %rax, %rax
je 0x2383
movss 0xc(%rsp), %xmm0
movss %xmm0, 0x2c(%rbx)
jmp 0x2429
movq %r13, %rdi
leaq 0x1b8a(%rip), %rsi      # 0x3f17
callq 0x1140
testq %rax, %rax
je 0x23a7
movss 0xc(%rsp), %xmm0
movss %xmm0, 0x38(%rbx)
jmp 0x2429
movl %r12d, %r15d
movq %r13, %rdi
leaq 0x1b75(%rip), %rsi      # 0x3f29
callq 0x1140
testq %rax, %rax
je 0x23d0
movss 0xc(%rsp), %xmm0
movq 0x10(%rsp), %rbx
movss %xmm0, 0x30(%rbx)
jmp 0x241e
movq %r13, %rdi
leaq 0x1b5b(%rip), %rsi      # 0x3f35
callq 0x1140
testq %rax, %rax
je 0x23f6
movss 0xc(%rsp), %xmm0
movq 0x10(%rsp), %rbx
movss %xmm0, 0x34(%rbx)
jmp 0x241e
movq %r13, %rdi
leaq 0x1b48(%rip), %rsi      # 0x3f48
callq 0x1140
testq %rax, %rax
je 0x2494
movss 0xc(%rsp), %xmm0
movq 0x10(%rsp), %rbx
movss %xmm0, 0x3c(%rbx)
leaq 0x150(%rsp), %r14
movl %r15d, %r12d
movl (%rbx), %eax
cmpl $0x2, %eax
jl 0x1f21
testb %r12b, %r12b
je 0x245b
cmpb $0x0, 0x50(%rsp)
je 0x2475
leaq 0x1ce5(%rip), %rdi      # 0x412c
movq %r13, %rsi
leaq 0x50(%rsp), %rdx
xorl %eax, %eax
callq 0x10c0
jmp 0x1f21
movl 0x1c(%rsp), %edx
leaq 0x1cbe(%rip), %rdi      # 0x4124
movq %r13, %rsi
xorl %eax, %eax
callq 0x10c0
jmp 0x1f21
xorps %xmm0, %xmm0
cvtss2sd 0xc(%rsp), %xmm0
leaq 0x1caf(%rip), %rdi      # 0x4134
movq %r13, %rsi
movb $0x1, %al
callq 0x10c0
jmp 0x1f21
movq %r13, %rdi
leaq 0x1abc(%rip), %rsi      # 0x3f5a
callq 0x1140
testq %rax, %rax
je 0x251c
movss 0xc(%rsp), %xmm0
movq 0x10(%rsp), %rbx
movss %xmm0, 0x28(%rsp)
movss %xmm0, 0x24(%rbx)
movq %rbp, %rdi
leaq 0x1a9e(%rip), %rsi      # 0x3f66
callq 0x1140
testq %rax, %rax
leaq 0x150(%rsp), %r14
movl %r15d, %r12d
je 0x2429
movss 0x4(%rbx), %xmm0
ucomiss 0x28(%rsp), %xmm0
jbe 0x2429
subss 0x28(%rsp), %xmm0
movss %xmm0, 0x24(%rbx)
cmpl $0x2, (%rbx)
jl 0x1f21
cvtss2sd %xmm0, %xmm0
leaq 0x1a66(%rip), %rdi      # 0x3f76
movb $0x1, %al
callq 0x10c0
jmp 0x2429
movq %r13, %rdi
leaq 0x1a69(%rip), %rsi      # 0x3f8f
callq 0x1140
testq %rax, %rax
je 0x2545
movss 0xc(%rsp), %xmm0
movq 0x10(%rsp), %rbx
movss %xmm0, 0x28(%rbx)
jmp 0x241e
movq %r13, %rdi
leaq 0x1a4c(%rip), %rsi      # 0x3f9b
callq 0x1140
testq %rax, %rax
je 0x256e
movss 0xc(%rsp), %xmm0
movq 0x10(%rsp), %rbx
movss %xmm0, 0x48(%rbx)
jmp 0x241e
movq %r13, %rdi
leaq 0x1a36(%rip), %rsi      # 0x3fae
callq 0x1140
testq %rax, %rax
je 0x2597
movss 0xc(%rsp), %xmm0
movq 0x10(%rsp), %rbx
movss %xmm0, 0x14(%rbx)
jmp 0x241e
movq %r13, %rdi
leaq 0x1a20(%rip), %rsi      # 0x3fc1
callq 0x1140
testq %rax, %rax
je 0x25c0
movss 0xc(%rsp), %xmm0
movq 0x10(%rsp), %rbx
movss %xmm0, 0x18(%rbx)
jmp 0x241e
movq %r13, %rdi
leaq 0x1a03(%rip), %rsi      # 0x3fcd
callq 0x1140
testq %rax, %rax
je 0x25e9
movss 0xc(%rsp), %xmm0
movq 0x10(%rsp), %rbx
movss %xmm0, 0x1c(%rbx)
jmp 0x241e
movq %r13, %rdi
leaq 0x19ea(%rip), %rsi      # 0x3fdd
callq 0x1140
testq %rax, %rax
je 0x2612
movss 0xc(%rsp), %xmm0
movq 0x10(%rsp), %rbx
movss %xmm0, 0x4c(%rbx)
jmp 0x241e
movq %r13, %rdi
leaq 0x19ce(%rip), %rsi      # 0x3fea
callq 0x1140
testq %rax, %rax
je 0x263b
movss 0xc(%rsp), %xmm0
movq 0x10(%rsp), %rbx
movss %xmm0, 0x50(%rbx)
jmp 0x241e
movq %r13, %rdi
leaq 0x19b0(%rip), %rsi      # 0x3ff5
callq 0x1140
testq %rax, %rax
je 0x2664
movss 0xc(%rsp), %xmm0
movq 0x10(%rsp), %rbx
movss %xmm0, 0x54(%rbx)
jmp 0x241e
movq %r13, %rdi
leaq 0x1991(%rip), %rsi      # 0x3fff
callq 0x1140
testq %rax, %rax
je 0x268d
movss 0xc(%rsp), %xmm0
movq 0x10(%rsp), %rbx
movss %xmm0, 0x58(%rbx)
jmp 0x241e
movq %r13, %rdi
leaq 0x1974(%rip), %rsi      # 0x400b
callq 0x1140
testq %rax, %rax
je 0x26b6
movss 0xc(%rsp), %xmm0
movq 0x10(%rsp), %rbx
movss %xmm0, 0x5c(%rbx)
jmp 0x241e
movq %r13, %rdi
leaq 0x195d(%rip), %rsi      # 0x401d
callq 0x1140
testq %rax, %rax
je 0x26df
movss 0xc(%rsp), %xmm0
movq 0x10(%rsp), %rbx
movss %xmm0, 0x60(%rbx)
jmp 0x241e
movq %r13, %rdi
leaq 0x1947(%rip), %rsi      # 0x4030
callq 0x1140
testq %rax, %rax
je 0x2708
movss 0xc(%rsp), %xmm0
movq 0x10(%rsp), %rbx
movss %xmm0, 0x64(%rbx)
jmp 0x241e
movq %r13, %rdi
leaq 0x192f(%rip), %rsi      # 0x4041
callq 0x1140
testq %rax, %rax
je 0x2731
movss 0xc(%rsp), %xmm0
movq 0x10(%rsp), %rbx
movss %xmm0, 0x68(%rbx)
jmp 0x241e
movq %r13, %rdi
leaq 0x191a(%rip), %rsi      # 0x4055
callq 0x1140
testq %rax, %rax
je 0x275a
movss 0xc(%rsp), %xmm0
movq 0x10(%rsp), %rbx
movss %xmm0, 0x6c(%rbx)
jmp 0x241e
movq %r13, %rdi
leaq 0x1906(%rip), %rsi      # 0x406a
callq 0x1140
testq %rax, %rax
je 0x2783
movss 0xc(%rsp), %xmm0
movq 0x10(%rsp), %rbx
movss %xmm0, 0x70(%rbx)
jmp 0x241e
movq %r13, %rdi
leaq 0x18ed(%rip), %rsi      # 0x407a
callq 0x1140
testq %rax, %rax
je 0x27ac
movss 0xc(%rsp), %xmm0
movq 0x10(%rsp), %rbx
movss %xmm0, 0x74(%rbx)
jmp 0x241e
movq %r13, %rdi
leaq 0x18cc(%rip), %rsi      # 0x4082
callq 0x1140
testq %rax, %rax
je 0x27d8
movss 0xc(%rsp), %xmm0
movq 0x10(%rsp), %rbx
movss %xmm0, 0x1590(%rbx)
jmp 0x241e
movq %r13, %rdi
leaq 0x18b9(%rip), %rsi      # 0x409b
callq 0x1140
testq %rax, %rax
je 0x27f8
movl $0x100, %edx            # imm = 0x100
movq 0x40(%rsp), %rdi
jmp 0x2836
movq %r13, %rdi
leaq 0x18a4(%rip), %rsi      # 0x40a6
callq 0x1140
testq %rax, %rax
je 0x2818
movl $0x100, %edx            # imm = 0x100
movq 0x38(%rsp), %rdi
jmp 0x2836
movq %r13, %rdi
leaq 0x188f(%rip), %rsi      # 0x40b1
callq 0x1140
testq %rax, %rax
je 0x284a
movl $0x100, %edx            # imm = 0x100
movq 0x30(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x1030
movq 0x10(%rsp), %rbx
jmp 0x241e
movq %r13, %rdi
leaq 0x1865(%rip), %rsi      # 0x40b9
callq 0x1140
testq %rax, %rax
je 0x2876
movss 0xc(%rsp), %xmm0
movq 0x10(%rsp), %rbx
movss %xmm0, 0x388(%rbx)
jmp 0x241e
movq %r13, %rdi
leaq 0x1843(%rip), %rsi      # 0x40c3
callq 0x1140
testq %rax, %rax
je 0x28a2
movss 0xc(%rsp), %xmm0
movq 0x10(%rsp), %rbx
movss %xmm0, 0x38c(%rbx)
jmp 0x241e
movq %r13, %rdi
leaq 0x154b(%rip), %rsi      # 0x3df7
callq 0x1140
testq %rax, %rax
je 0x28ca
movl 0x1c(%rsp), %eax
movq 0x10(%rsp), %rbx
movl %eax, 0x390(%rbx)
jmp 0x241e
movq %r13, %rdi
leaq 0x17fa(%rip), %rsi      # 0x40ce
callq 0x1140
testq %rax, %rax
je 0x28f6
movss 0xc(%rsp), %xmm0
movq 0x10(%rsp), %rbx
movss %xmm0, 0x394(%rbx)
jmp 0x241e
movq %r13, %rdi
leaq 0x17dd(%rip), %rsi      # 0x40dd
callq 0x1140
testq %rax, %rax
je 0x2922
movss 0xc(%rsp), %xmm0
movq 0x10(%rsp), %rbx
movss %xmm0, 0x398(%rbx)
jmp 0x241e
movq %r13, %rdi
leaq 0x17bf(%rip), %rsi      # 0x40eb
callq 0x1140
testq %rax, %rax
je 0x294e
movss 0xc(%rsp), %xmm0
movq 0x10(%rsp), %rbx
movss %xmm0, 0x39c(%rbx)
jmp 0x241e
movq %r13, %rdi
leaq 0x14af(%rip), %rsi      # 0x3e07
callq 0x1140
testq %rax, %rax
je 0x2976
movl 0x1c(%rsp), %eax
movq 0x10(%rsp), %rbx
movl %eax, 0x3a0(%rbx)
jmp 0x241e
movq %r13, %rdi
leaq 0x177d(%rip), %rsi      # 0x40fd
callq 0x1140
testq %rax, %rax
je 0x29a2
movss 0xc(%rsp), %xmm0
movq 0x10(%rsp), %rbx
movss %xmm0, 0x3a4(%rbx)
jmp 0x241e
movq %r13, %rdi
leaq 0x1479(%rip), %rsi      # 0x3e25
callq 0x1140
testq %rax, %rax
je 0x29c7
movl 0x1c(%rsp), %eax
movq 0x10(%rsp), %rbx
movl %eax, 0x78(%rbx)
jmp 0x241e
movq %r13, %rdi
leaq 0x1463(%rip), %rsi      # 0x3e34
callq 0x1140
testq %rax, %rax
je 0x29ec
movl 0x1c(%rsp), %eax
movq 0x10(%rsp), %rbx
movl %eax, 0x7c(%rbx)
jmp 0x241e
movq %r13, %rdi
leaq 0x144a(%rip), %rsi      # 0x3e40
callq 0x1140
testq %rax, %rax
je 0x2cbb
movl 0x1c(%rsp), %eax
movq 0x10(%rsp), %rbx
movl %eax, 0x80(%rbx)
jmp 0x241e
movq 0x20(%rsp), %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 0x2a45
movss %xmm1, 0x34(%rbx)
movaps %xmm1, %xmm6
movss 0x28(%rbx), %xmm3
ucomiss %xmm3, %xmm0
jbe 0x2a57
movss %xmm3, 0x48(%rbx)
movaps %xmm3, %xmm0
movss 0x4(%rbx), %xmm5
movss 0x2c(%rbx), %xmm4
ucomiss %xmm5, %xmm4
jbe 0x2abe
xorps %xmm0, %xmm0
cvtss2sd %xmm5, %xmm0
xorps %xmm1, %xmm1
cvtss2sd 0x8(%rbx), %xmm1
cvtss2sd %xmm2, %xmm2
cvtss2sd %xmm3, %xmm3
xorps %xmm5, %xmm5
cvtss2sd 0x38(%rbx), %xmm5
cvtss2sd %xmm4, %xmm4
cvtss2sd %xmm6, %xmm6
xorps %xmm7, %xmm7
cvtss2sd 0x3c(%rbx), %xmm7
leaq 0x16a0(%rip), %rdi      # 0x413c
movb $0x8, %al
callq 0x10c0
jmp 0x2bd8
leaq 0x12e1(%rip), %rdi      # 0x3d90
movq %r14, %rsi
xorl %eax, %eax
callq 0x10c0
jmp 0x2bd8
ucomiss %xmm5, %xmm2
ja 0x2a66
ucomiss %xmm2, %xmm6
ja 0x2a66
ucomiss %xmm2, %xmm0
ja 0x2a66
movaps %xmm2, %xmm1
subss %xmm0, %xmm1
ucomiss %xmm1, %xmm6
ja 0x2a66
movss 0x38(%rbx), %xmm7
movss 0x3c(%rbx), %xmm1
movaps %xmm3, %xmm0
addss %xmm7, %xmm0
addss %xmm1, %xmm0
ucomiss 0x8(%rbx), %xmm0
ja 0x2a66
movss 0x30(%rbx), %xmm0
xorps %xmm2, %xmm2
ucomiss %xmm2, %xmm0
jbe 0x2bef
ucomiss %xmm2, %xmm4
jbe 0x2b5a
xorps %xmm1, %xmm1
cvtss2sd %xmm4, %xmm1
movsd %xmm1, 0x20(%rsp)
cvtss2sd %xmm0, %xmm0
mulsd 0x4e1(%rip), %xmm0      # 0x3008
divsd 0x4e1(%rip), %xmm0      # 0x3010
callq 0x1100
mulsd 0x20(%rsp), %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x38(%rbx)
cmpl $0x2, (%rbx)
jl 0x2b5a
cvtss2sd %xmm0, %xmm0
leaq 0x16bd(%rip), %rdi      # 0x4210
movb $0x1, %al
callq 0x10c0
movss 0x34(%rbx), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x2c54
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0x20(%rsp)
xorps %xmm0, %xmm0
cvtss2sd 0x30(%rbx), %xmm0
mulsd 0x483(%rip), %xmm0      # 0x3008
divsd 0x483(%rip), %xmm0      # 0x3010
callq 0x1100
mulsd 0x20(%rsp), %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x3c(%rbx)
cmpl $0x1, (%rbx)
jle 0x2c54
leaq 0x167d(%rip), %rdi      # 0x422e
jmp 0x2c49
leaq 0x129f(%rip), %rdi      # 0x3e5c
leaq 0x770(%rsp), %r8
movq %r13, %rsi
movq 0x48(%rsp), %rdx
movl 0x2c(%rsp), %ecx
xorl %eax, %eax
callq 0x10c0
movl $0x1, %eax
addq $0x978, %rsp            # imm = 0x978
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
ucomiss %xmm2, %xmm4
jbe 0x2bff
ucomiss %xmm2, %xmm7
jbe 0x2bff
divss %xmm4, %xmm7
jmp 0x2c10
ucomiss %xmm2, %xmm6
jbe 0x2c35
ucomiss %xmm2, %xmm1
jbe 0x2c35
divss %xmm6, %xmm1
movaps %xmm1, %xmm7
xorps %xmm0, %xmm0
cvtss2sd %xmm7, %xmm0
callq 0x1080
mulsd 0x3ec(%rip), %xmm0      # 0x3010
divsd 0x3dc(%rip), %xmm0      # 0x3008
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x30(%rbx)
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x2c54
cmpl $0x2, (%rbx)
jl 0x2c54
leaq 0x1603(%rip), %rdi      # 0x424c
cvtss2sd %xmm0, %xmm0
movb $0x1, %al
callq 0x10c0
movss 0x14(%rbx), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x2c95
movss 0x18(%rbx), %xmm2
ucomiss %xmm1, %xmm2
jbe 0x2c95
movss 0x1c(%rbx), %xmm3
xorps %xmm2, %xmm2
ucomiss %xmm2, %xmm3
jbe 0x2c95
movss 0x10(%rbx), %xmm4
ucomiss %xmm2, %xmm4
movaps %xmm0, %xmm2
subss %xmm3, %xmm2
jne 0x2c8b
jnp 0x2c90
ucomiss %xmm2, %xmm4
jbe 0x2c95
movss %xmm2, 0x10(%rbx)
xorl %eax, %eax
ucomiss %xmm1, %xmm0
movss 0x8(%rbx), %xmm1
subss 0x20(%rbx), %xmm1
jne 0x2ca8
jnp 0x2cb1
ucomiss %xmm1, %xmm0
jbe 0x2bdd
movss %xmm1, 0x14(%rbx)
jmp 0x2bdd
leaq 0x1442(%rip), %rdi      # 0x4104
movq %r13, %rsi
jmp 0x2ab2