// File: /workspace/github_c_makefile_star2_O1/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 0x1906(%rip), %rsi      # 0x3770
leaq 0x150(%rsp), %r15
movl $0x620, %edx            # imm = 0x620
movq %r15, %rdi
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 0x11fd(%rip), %rsi      # 0x30a0
movq %r14, %rdi
callq 0x1120
testq %rax, %rax
je 0x2a04
movq %rax, %r12
leaq 0x1efa(%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
xorl %r13d, %r13d
movl $0x0, 0x1c(%rsp)
movq %rbp, %rdi
movl $0x100, %esi            # imm = 0x100
movq %r12, %rdx
callq 0x10e0
testq %rax, %rax
je 0x297b
incl %r13d
movq %rbp, %rdi
callq 0x10a0
cmpq $0x3, %rax
jb 0x1f04
movb 0x770(%rsp), %al
cmpb $0x23, %al
je 0x1f04
cmpb $0x20, %al
je 0x1f04
cmpb $0x9, %al
je 0x1f04
movq %rbp, %rdi
leaq 0x1e92(%rip), %rsi      # 0x3ddd
callq 0x1140
movq %rax, 0x20(%rsp)
testq %rax, %rax
je 0x1fc0
cmpl $0x2, (%rbx)
jl 0x1f70
leaq 0x1e7d(%rip), %rdi      # 0x3de3
movq %rbp, %rsi
xorl %eax, %eax
callq 0x10c0
movq 0x20(%rsp), %r15
leaq 0x5(%r15), %rsi
leaq 0x870(%rsp), %r14
movq %r14, %rdi
callq 0x1050
movabsq $0x7375696461725f, %rax # imm = 0x7375696461725F
movq %rax, (%r15)
leaq 0x7(%r15), %rdi
movq %r14, %rsi
callq 0x1050
cmpl $0x2, (%rbx)
leaq 0x150(%rsp), %r15
jl 0x1fc0
leaq 0x1e36(%rip), %rdi      # 0x3dec
movq %rbp, %rsi
xorl %eax, %eax
callq 0x10c0
movq %r15, %rdi
callq 0x10a0
movq %rax, %r14
testl %r14d, %r14d
jle 0x1f04
movq %r12, 0x10(%rsp)
xorl %r12d, %r12d
andl $0x7fffffff, %r14d      # imm = 0x7FFFFFFF
movq %rbp, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x1040
testl %eax, %eax
je 0x201e
incq %r12
addq $0x20, %r15
movq %r15, %rdi
callq 0x10a0
movq %rax, %r14
testl %r14d, %r14d
jg 0x1fdc
leaq 0x150(%rsp), %r15
movq 0x10(%rsp), %r12
jmp 0x1f04
cmpl $0x2, (%rbx)
jl 0x2034
leaq 0x1db9(%rip), %rdi      # 0x3de3
movq %rbp, %rsi
xorl %eax, %eax
callq 0x10c0
movzbl 0x770(%rsp,%r14), %ecx
cmpl $0x20, %ecx
je 0x204d
xorl %eax, %eax
cmpl $0x9, %ecx
jne 0x21db
movq %rbx, 0x28(%rsp)
leaq (%rsp,%r14), %rbx
addq $0x770, %rbx            # imm = 0x770
movzbl (%rbx), %eax
cmpl $0x20, %eax
je 0x206a
cmpl $0x9, %eax
jne 0x206f
incq %rbx
jmp 0x205d
movb $0x0, 0x50(%rsp)
xorl %eax, %eax
movl %eax, 0x18(%rsp)
movl %eax, 0xc(%rsp)
movq %r15, %rdi
leaq 0x2023(%rip), %rsi      # 0x40ab
callq 0x1140
testq %rax, %rax
je 0x20d6
xorl %eax, %eax
movzbl (%rbx,%rax), %ecx
cmpq $0x20, %rcx
ja 0x20ae
movabsq $0x100002600, %rdx      # imm = 0x100002600
btq %rcx, %rdx
jb 0x20c2
movb %cl, 0x50(%rsp,%rax)
incq %rax
cmpq $0x100, %rax            # imm = 0x100
jne 0x2094
movl $0x100, %eax            # imm = 0x100
movl %eax, %ecx
movb $0x0, 0x50(%rsp,%rcx)
movl $0x0, 0x1c(%rsp)
jmp 0x21d6
leaq 0x1d1a(%rip), %rdi      # 0x3df7
movq %r15, %rsi
movq %r14, %rdx
callq 0x1040
testl %eax, %eax
je 0x21b8
leaq 0x1d10(%rip), %rdi      # 0x3e07
movq %r15, %rsi
movq %r14, %rdx
callq 0x1040
testl %eax, %eax
je 0x21b8
leaq 0x1d04(%rip), %rdi      # 0x3e15
movq %r15, %rsi
movq %r14, %rdx
callq 0x1040
testl %eax, %eax
je 0x21b8
leaq 0x1cfa(%rip), %rdi      # 0x3e25
movq %r15, %rsi
movq %r14, %rdx
callq 0x1040
testl %eax, %eax
je 0x21b8
leaq 0x1cf3(%rip), %rdi      # 0x3e34
movq %r15, %rsi
movq %r14, %rdx
callq 0x1040
testl %eax, %eax
je 0x21b8
leaq 0x1ce9(%rip), %rdi      # 0x3e40
movq %r15, %rsi
movq %r14, %rdx
callq 0x1040
testl %eax, %eax
je 0x21b8
leaq 0x1cdc(%rip), %rdi      # 0x3e49
movq %r15, %rsi
movq %r14, %rdx
callq 0x1040
testl %eax, %eax
je 0x21b8
movl $0x0, 0x1c(%rsp)
movq %rbx, %rdi
leaq 0x1ccb(%rip), %rsi      # 0x3e59
leaq 0xc(%rsp), %rdx
xorl %eax, %eax
callq 0x1110
cmpq $0x0, 0x20(%rsp)
je 0x21d6
movss 0xc(%rsp), %xmm0
mulss 0x15b8(%rip), %xmm0     # 0x3768
movss %xmm0, 0xc(%rsp)
jmp 0x21d6
movq %rbx, %rdi
leaq 0x1c94(%rip), %rsi      # 0x3e56
leaq 0x18(%rsp), %rdx
xorl %eax, %eax
callq 0x1110
movl $0x1, 0x1c(%rsp)
movq 0x28(%rsp), %rbx
testl %eax, %eax
jle 0x2c15
movq %r15, %rdi
leaq 0x1d0a(%rip), %rsi      # 0x3ef7
movq %r14, %rdx
callq 0x1040
cmpl $0x1, %eax
sbbl $0x0, %r12d
movslq %r12d, %rax
shlq $0x5, %rax
leaq (%rsp,%rax), %r14
addq $0x150, %r14            # imm = 0x150
movq %r14, %rdi
leaq 0x1bfd(%rip), %rsi      # 0x3e15
callq 0x1140
testq %rax, %rax
je 0x223a
movl 0x18(%rsp), %eax
movl %eax, (%rbx)
leaq 0x150(%rsp), %r15
movq 0x10(%rsp), %r12
jmp 0x2334
movq %r14, %rdi
leaq 0x1c59(%rip), %rsi      # 0x3e9d
callq 0x1140
testq %rax, %rax
leaq 0x150(%rsp), %r15
movq 0x10(%rsp), %r12
je 0x226b
movss 0xc(%rsp), %xmm0
movss %xmm0, 0x4(%rbx)
jmp 0x2334
movq %r14, %rdi
leaq 0x1c34(%rip), %rsi      # 0x3ea9
callq 0x1140
testq %rax, %rax
je 0x228f
movss 0xc(%rsp), %xmm0
movss %xmm0, 0x8(%rbx)
jmp 0x2334
movq %r14, %rdi
leaq 0x1c1c(%rip), %rsi      # 0x3eb5
callq 0x1140
testq %rax, %rax
je 0x22b3
movss 0xc(%rsp), %xmm0
movss %xmm0, 0x40(%rbx)
jmp 0x2334
movq %r14, %rdi
leaq 0x1c0a(%rip), %rsi      # 0x3ec7
callq 0x1140
testq %rax, %rax
je 0x22d4
movss 0xc(%rsp), %xmm0
movss %xmm0, 0x44(%rbx)
jmp 0x2334
movq %r14, %rdi
leaq 0x1bfe(%rip), %rsi      # 0x3edc
callq 0x1140
testq %rax, %rax
je 0x22f5
movss 0xc(%rsp), %xmm0
movss %xmm0, 0xc(%rbx)
jmp 0x2334
movq %r14, %rdi
leaq 0x1be7(%rip), %rsi      # 0x3ee6
callq 0x1140
testq %rax, %rax
je 0x2316
movss 0xc(%rsp), %xmm0
movss %xmm0, 0x10(%rbx)
jmp 0x2334
movq %r14, %rdi
leaq 0x1b29(%rip), %rsi      # 0x3e49
callq 0x1140
testq %rax, %rax
je 0x2394
movl 0x18(%rsp), %eax
movl %eax, 0x84(%rbx)
cmpl $0x2, (%rbx)
jl 0x1f04
cmpl $0x0, 0x1c(%rsp)
je 0x2366
movl 0x18(%rsp), %edx
leaq 0x1dd5(%rip), %rdi      # 0x4124
movq %r14, %rsi
xorl %eax, %eax
callq 0x10c0
movl $0x1, 0x1c(%rsp)
jmp 0x1f04
cmpb $0x0, 0x50(%rsp)
je 0x295c
movl $0x0, 0x1c(%rsp)
leaq 0x1dac(%rip), %rdi      # 0x412c
movq %r14, %rsi
leaq 0x50(%rsp), %rdx
xorl %eax, %eax
callq 0x10c0
jmp 0x1f04
movq %r14, %rdi
leaq 0x1b52(%rip), %rsi      # 0x3ef0
callq 0x1140
testq %rax, %rax
je 0x23b8
movss 0xc(%rsp), %xmm0
movss %xmm0, 0x20(%rbx)
jmp 0x2228
movq %r14, %rdi
leaq 0x1b42(%rip), %rsi      # 0x3f04
callq 0x1140
testq %rax, %rax
je 0x23dc
movss 0xc(%rsp), %xmm0
movss %xmm0, 0x2c(%rbx)
jmp 0x2228
movq %r14, %rdi
leaq 0x1b31(%rip), %rsi      # 0x3f17
callq 0x1140
testq %rax, %rax
je 0x2400
movss 0xc(%rsp), %xmm0
movss %xmm0, 0x38(%rbx)
jmp 0x2228
movq %r14, %rdi
leaq 0x1b1f(%rip), %rsi      # 0x3f29
callq 0x1140
testq %rax, %rax
je 0x2424
movss 0xc(%rsp), %xmm0
movss %xmm0, 0x30(%rbx)
jmp 0x2228
movq %r14, %rdi
leaq 0x1b07(%rip), %rsi      # 0x3f35
callq 0x1140
testq %rax, %rax
je 0x2448
movss 0xc(%rsp), %xmm0
movss %xmm0, 0x34(%rbx)
jmp 0x2228
movq %r14, %rdi
leaq 0x1af6(%rip), %rsi      # 0x3f48
callq 0x1140
testq %rax, %rax
je 0x246c
movss 0xc(%rsp), %xmm0
movss %xmm0, 0x3c(%rbx)
jmp 0x2228
movq %r14, %rdi
leaq 0x1ae4(%rip), %rsi      # 0x3f5a
callq 0x1140
testq %rax, %rax
je 0x24f1
movss 0xc(%rsp), %xmm0
movss %xmm0, 0x20(%rsp)
movss %xmm0, 0x24(%rbx)
movq %rbp, %rdi
leaq 0x1acb(%rip), %rsi      # 0x3f66
callq 0x1140
testq %rax, %rax
leaq 0x150(%rsp), %r15
movq 0x10(%rsp), %r12
je 0x2334
movss 0x4(%rbx), %xmm0
ucomiss 0x20(%rsp), %xmm0
jbe 0x2334
subss 0x20(%rsp), %xmm0
movss %xmm0, 0x24(%rbx)
cmpl $0x2, (%rbx)
jl 0x2334
cvtss2sd %xmm0, %xmm0
leaq 0x1a91(%rip), %rdi      # 0x3f76
movb $0x1, %al
callq 0x10c0
jmp 0x2334
movq %r14, %rdi
leaq 0x1a94(%rip), %rsi      # 0x3f8f
callq 0x1140
testq %rax, %rax
je 0x2515
movss 0xc(%rsp), %xmm0
movss %xmm0, 0x28(%rbx)
jmp 0x2228
movq %r14, %rdi
leaq 0x1a7c(%rip), %rsi      # 0x3f9b
callq 0x1140
testq %rax, %rax
je 0x2539
movss 0xc(%rsp), %xmm0
movss %xmm0, 0x48(%rbx)
jmp 0x2228
movq %r14, %rdi
leaq 0x1a6b(%rip), %rsi      # 0x3fae
callq 0x1140
testq %rax, %rax
je 0x255d
movss 0xc(%rsp), %xmm0
movss %xmm0, 0x14(%rbx)
jmp 0x2228
movq %r14, %rdi
leaq 0x1a5a(%rip), %rsi      # 0x3fc1
callq 0x1140
testq %rax, %rax
je 0x2581
movss 0xc(%rsp), %xmm0
movss %xmm0, 0x18(%rbx)
jmp 0x2228
movq %r14, %rdi
leaq 0x1a42(%rip), %rsi      # 0x3fcd
callq 0x1140
testq %rax, %rax
je 0x25a5
movss 0xc(%rsp), %xmm0
movss %xmm0, 0x1c(%rbx)
jmp 0x2228
movq %r14, %rdi
leaq 0x1a2e(%rip), %rsi      # 0x3fdd
callq 0x1140
testq %rax, %rax
je 0x25c9
movss 0xc(%rsp), %xmm0
movss %xmm0, 0x4c(%rbx)
jmp 0x2228
movq %r14, %rdi
leaq 0x1a17(%rip), %rsi      # 0x3fea
callq 0x1140
testq %rax, %rax
je 0x25ed
movss 0xc(%rsp), %xmm0
movss %xmm0, 0x50(%rbx)
jmp 0x2228
movq %r14, %rdi
leaq 0x19fe(%rip), %rsi      # 0x3ff5
callq 0x1140
testq %rax, %rax
je 0x2611
movss 0xc(%rsp), %xmm0
movss %xmm0, 0x54(%rbx)
jmp 0x2228
movq %r14, %rdi
leaq 0x19e4(%rip), %rsi      # 0x3fff
callq 0x1140
testq %rax, %rax
je 0x2635
movss 0xc(%rsp), %xmm0
movss %xmm0, 0x58(%rbx)
jmp 0x2228
movq %r14, %rdi
leaq 0x19cc(%rip), %rsi      # 0x400b
callq 0x1140
testq %rax, %rax
je 0x2659
movss 0xc(%rsp), %xmm0
movss %xmm0, 0x5c(%rbx)
jmp 0x2228
movq %r14, %rdi
leaq 0x19ba(%rip), %rsi      # 0x401d
callq 0x1140
testq %rax, %rax
je 0x267d
movss 0xc(%rsp), %xmm0
movss %xmm0, 0x60(%rbx)
jmp 0x2228
movq %r14, %rdi
leaq 0x19a9(%rip), %rsi      # 0x4030
callq 0x1140
testq %rax, %rax
je 0x26a1
movss 0xc(%rsp), %xmm0
movss %xmm0, 0x64(%rbx)
jmp 0x2228
movq %r14, %rdi
leaq 0x1996(%rip), %rsi      # 0x4041
callq 0x1140
testq %rax, %rax
je 0x26c5
movss 0xc(%rsp), %xmm0
movss %xmm0, 0x68(%rbx)
jmp 0x2228
movq %r14, %rdi
leaq 0x1986(%rip), %rsi      # 0x4055
callq 0x1140
testq %rax, %rax
je 0x26e9
movss 0xc(%rsp), %xmm0
movss %xmm0, 0x6c(%rbx)
jmp 0x2228
movq %r14, %rdi
leaq 0x1977(%rip), %rsi      # 0x406a
callq 0x1140
testq %rax, %rax
je 0x270d
movss 0xc(%rsp), %xmm0
movss %xmm0, 0x70(%rbx)
jmp 0x2228
movq %r14, %rdi
leaq 0x1963(%rip), %rsi      # 0x407a
callq 0x1140
testq %rax, %rax
je 0x2731
movss 0xc(%rsp), %xmm0
movss %xmm0, 0x74(%rbx)
jmp 0x2228
movq %r14, %rdi
leaq 0x1947(%rip), %rsi      # 0x4082
callq 0x1140
testq %rax, %rax
je 0x2758
movss 0xc(%rsp), %xmm0
movss %xmm0, 0x1590(%rbx)
jmp 0x2228
movq %r14, %rdi
leaq 0x1939(%rip), %rsi      # 0x409b
callq 0x1140
testq %rax, %rax
je 0x2778
movl $0x100, %edx            # imm = 0x100
movq 0x40(%rsp), %rdi
jmp 0x27b6
movq %r14, %rdi
leaq 0x1924(%rip), %rsi      # 0x40a6
callq 0x1140
testq %rax, %rax
je 0x2798
movl $0x100, %edx            # imm = 0x100
movq 0x38(%rsp), %rdi
jmp 0x27b6
movq %r14, %rdi
leaq 0x190f(%rip), %rsi      # 0x40b1
callq 0x1140
testq %rax, %rax
je 0x27c5
movl $0x100, %edx            # imm = 0x100
movq 0x30(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x1030
jmp 0x2228
movq %r14, %rdi
leaq 0x18ea(%rip), %rsi      # 0x40b9
callq 0x1140
testq %rax, %rax
je 0x27ec
movss 0xc(%rsp), %xmm0
movss %xmm0, 0x388(%rbx)
jmp 0x2228
movq %r14, %rdi
leaq 0x18cd(%rip), %rsi      # 0x40c3
callq 0x1140
testq %rax, %rax
je 0x2813
movss 0xc(%rsp), %xmm0
movss %xmm0, 0x38c(%rbx)
jmp 0x2228
movq %r14, %rdi
leaq 0x15da(%rip), %rsi      # 0x3df7
callq 0x1140
testq %rax, %rax
je 0x2836
movl 0x18(%rsp), %eax
movl %eax, 0x390(%rbx)
jmp 0x2228
movq %r14, %rdi
leaq 0x188e(%rip), %rsi      # 0x40ce
callq 0x1140
testq %rax, %rax
je 0x285d
movss 0xc(%rsp), %xmm0
movss %xmm0, 0x394(%rbx)
jmp 0x2228
movq %r14, %rdi
leaq 0x1876(%rip), %rsi      # 0x40dd
callq 0x1140
testq %rax, %rax
je 0x2884
movss 0xc(%rsp), %xmm0
movss %xmm0, 0x398(%rbx)
jmp 0x2228
movq %r14, %rdi
leaq 0x185d(%rip), %rsi      # 0x40eb
callq 0x1140
testq %rax, %rax
je 0x28ab
movss 0xc(%rsp), %xmm0
movss %xmm0, 0x39c(%rbx)
jmp 0x2228
movq %r14, %rdi
leaq 0x1552(%rip), %rsi      # 0x3e07
callq 0x1140
testq %rax, %rax
je 0x28ce
movl 0x18(%rsp), %eax
movl %eax, 0x3a0(%rbx)
jmp 0x2228
movq %r14, %rdi
leaq 0x1825(%rip), %rsi      # 0x40fd
callq 0x1140
testq %rax, %rax
je 0x28f5
movss 0xc(%rsp), %xmm0
movss %xmm0, 0x3a4(%rbx)
jmp 0x2228
movq %r14, %rdi
leaq 0x1526(%rip), %rsi      # 0x3e25
callq 0x1140
testq %rax, %rax
je 0x2915
movl 0x18(%rsp), %eax
movl %eax, 0x78(%rbx)
jmp 0x2228
movq %r14, %rdi
leaq 0x1515(%rip), %rsi      # 0x3e34
callq 0x1140
testq %rax, %rax
je 0x2935
movl 0x18(%rsp), %eax
movl %eax, 0x7c(%rbx)
jmp 0x2228
movq %r14, %rdi
leaq 0x1501(%rip), %rsi      # 0x3e40
callq 0x1140
testq %rax, %rax
je 0x2c3b
movl 0x18(%rsp), %eax
movl %eax, 0x80(%rbx)
jmp 0x2228
xorps %xmm0, %xmm0
cvtss2sd 0xc(%rsp), %xmm0
leaq 0x17c8(%rip), %rdi      # 0x4134
movq %r14, %rsi
movb $0x1, %al
callq 0x10c0
jmp 0x1efc
movq %r12, %rdi
callq 0x1090
movss 0x24(%rbx), %xmm2
movss 0x34(%rbx), %xmm3
movss 0x48(%rbx), %xmm0
movaps %xmm2, %xmm1
subss %xmm0, %xmm1
ucomiss %xmm1, %xmm3
jbe 0x29a3
movss %xmm1, 0x34(%rbx)
movss 0x28(%rbx), %xmm3
ucomiss %xmm3, %xmm0
jbe 0x29b2
movss %xmm3, 0x48(%rbx)
movss 0x4(%rbx), %xmm1
movss 0x2c(%rbx), %xmm4
ucomiss %xmm1, %xmm4
jbe 0x2a2c
xorps %xmm0, %xmm0
cvtss2sd %xmm1, %xmm0
xorps %xmm1, %xmm1
cvtss2sd 0x8(%rbx), %xmm1
cvtss2sd %xmm2, %xmm2
cvtss2sd %xmm3, %xmm3
cvtss2sd %xmm4, %xmm4
xorps %xmm5, %xmm5
cvtss2sd 0x38(%rbx), %xmm5
xorps %xmm6, %xmm6
cvtss2sd 0x34(%rbx), %xmm6
xorps %xmm7, %xmm7
cvtss2sd 0x3c(%rbx), %xmm7
leaq 0x1741(%rip), %rdi      # 0x413c
movb $0x8, %al
callq 0x10c0
jmp 0x2a15
leaq 0x1385(%rip), %rdi      # 0x3d90
movq %r14, %rsi
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 %xmm1, %xmm2
ja 0x29c1
movss 0x34(%rbx), %xmm0
ucomiss %xmm2, %xmm0
ja 0x29c1
movss 0x48(%rbx), %xmm5
ucomiss %xmm2, %xmm5
ja 0x29c1
movaps %xmm2, %xmm6
subss %xmm5, %xmm6
ucomiss %xmm6, %xmm0
ja 0x29c1
movss 0x38(%rbx), %xmm6
movss 0x3c(%rbx), %xmm5
movaps %xmm3, %xmm7
addss %xmm6, %xmm7
addss %xmm5, %xmm7
ucomiss 0x8(%rbx), %xmm7
ja 0x29c1
movss 0x30(%rbx), %xmm1
xorps %xmm2, %xmm2
ucomiss %xmm2, %xmm1
jbe 0x2b32
ucomiss %xmm2, %xmm4
jbe 0x2add
xorps %xmm0, %xmm0
cvtss2sd %xmm4, %xmm0
movsd %xmm0, 0x20(%rsp)
xorps %xmm0, %xmm0
cvtss2sd %xmm1, %xmm0
mulsd 0x55e(%rip), %xmm0      # 0x3008
divsd 0x55e(%rip), %xmm0      # 0x3010
callq 0x1100
mulsd 0x20(%rsp), %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x38(%rbx)
cmpl $0x2, (%rbx)
jl 0x2add
cvtss2sd %xmm0, %xmm0
leaq 0x173a(%rip), %rdi      # 0x4210
movb $0x1, %al
callq 0x10c0
movss 0x34(%rbx), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x2ba2
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0x20(%rsp)
xorps %xmm0, %xmm0
cvtss2sd 0x30(%rbx), %xmm0
mulsd 0x500(%rip), %xmm0      # 0x3008
divsd 0x500(%rip), %xmm0      # 0x3010
callq 0x1100
mulsd 0x20(%rsp), %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x3c(%rbx)
cmpl $0x1, (%rbx)
jle 0x2ba2
leaq 0x16fe(%rip), %rdi      # 0x422e
jmp 0x2b97
ucomiss %xmm2, %xmm4
jbe 0x2b45
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm6
jbe 0x2b45
divss %xmm4, %xmm6
jmp 0x2b59
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x2b7e
ucomiss %xmm1, %xmm5
jbe 0x2b7e
divss %xmm0, %xmm5
movaps %xmm5, %xmm6
xorps %xmm0, %xmm0
cvtss2sd %xmm6, %xmm0
callq 0x1080
mulsd 0x4a3(%rip), %xmm0      # 0x3010
divsd 0x493(%rip), %xmm0      # 0x3008
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x30(%rbx)
movss 0x30(%rbx), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x2ba2
cmpl $0x2, (%rbx)
jl 0x2ba2
leaq 0x16b5(%rip), %rdi      # 0x424c
cvtss2sd %xmm0, %xmm0
movb $0x1, %al
callq 0x10c0
movss 0x14(%rbx), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x2be3
movss 0x18(%rbx), %xmm2
ucomiss %xmm1, %xmm2
jbe 0x2be3
movss 0x1c(%rbx), %xmm3
xorps %xmm2, %xmm2
ucomiss %xmm2, %xmm3
jbe 0x2be3
movss 0x10(%rbx), %xmm4
ucomiss %xmm2, %xmm4
movaps %xmm0, %xmm2
subss %xmm3, %xmm2
jne 0x2bd9
jnp 0x2bde
ucomiss %xmm2, %xmm4
jbe 0x2be3
movss %xmm2, 0x10(%rbx)
ucomiss %xmm1, %xmm0
jne 0x2bea
jnp 0x2bff
movss 0x8(%rbx), %xmm1
subss 0x20(%rbx), %xmm1
xorl %eax, %eax
ucomiss %xmm1, %xmm0
jbe 0x2a1a
movss 0x8(%rbx), %xmm0
subss 0x20(%rbx), %xmm0
movss %xmm0, 0x14(%rbx)
xorl %eax, %eax
jmp 0x2a1a
leaq 0x1240(%rip), %rdi      # 0x3e5c
leaq 0x770(%rsp), %r8
movq %r15, %rsi
movq 0x48(%rsp), %rdx
movl %r13d, %ecx
xorl %eax, %eax
callq 0x10c0
jmp 0x2a15
leaq 0x14c2(%rip), %rdi      # 0x4104
jmp 0x2a0b