// File: /workspace/github_cpp_makefile_star2_O1/matthewarcus[P]mmps/project.cpp
// Function: main
int main(int argc, char* argv[])
{
  Image inImage;
  const char *infilename = "images/earth.ppm";
  const char *outfilename = NULL;
  const char *backfilename = NULL;
  int width = 800;
  int height = 600;
  bool adjust = false;

  TransformParams params;
  // Multi image stuff
  double xinc = 0.0;
  double yinc = 0.0;
  double zinc = 0.0;
  double turninc = 0.0;
  double tiltinc = 0.0;
  double latinc = 0.0;
  double loninc = 0.0;
  double timeinc = 0.0;
  double dateinc = 0.0;
  int loop = 1;

  bool invert = false; // Apply the inverse mapping

  // array of pointers. Dynamic allocation is less typing than
  // stack allocating everything.
  OptSpec *optspecs [] = {
    // General options
    new RgbSpec ("-bg", params.background),
    new IntSpec ("-w", width),
    new IntSpec ("-h", height),
    new BoolSpec ("-adjust", adjust),
    new StringSpec ("-f", infilename),
    new StringSpec ("-out", outfilename),
    new StringSpec ("-back", backfilename),
    new BoolSpec ("-i", invert),

    // First the projection parameters
    new DoubleSpec ("-tilt", params.tilt, 2 * pi / 360.0 ),
    new DoubleSpec ("-turn", params.turn, 2 * pi / 360.0 ),
    new DoubleSpec ("-rotate", params.rotate, 2 * pi / 360.0 ),
    new DoubleSpec ("-lat", params.lat, 2 * pi / 360.0 ),
    new DoubleSpec ("-long", params.lon, 2 * pi / 360.0 ),
    new DoubleSpec ("-scale", params.scale),
    new DoubleSpec ("-radius", params.radius, 2 * pi / 360.0 ),
    new DoubleSpec ("-x", params.x),
    new DoubleSpec ("-y", params.y),
    new DoubleSpec ("-z", params.z),
    new DoubleSpec ("-ox", params.ox),
    new DoubleSpec ("-oy", params.oy),
    new DoubleSpec ("-oz", params.oz),
    new DoubleSpec ("-a", params.a),
    new DoubleSpec ("-date", params.date),
    new DoubleSpec ("-time", params.time, 2 * pi / 24.0),
    new DoubleSpec ("-p", params.p, 2 * pi / 360.0),
    new DoubleSpec ("-aw", params.aw, 2 * pi / 360.0),
    new DoubleSpec ("-conic", params.conic),
    new DoubleSpec ("-conicr", params.conicr),
    new DoubleSpec ("-xoff", params.xoff),
    new DoubleSpec ("-yoff", params.yoff),
    new BoolSpec ("-sun", params.sun),

    // Grid and dial options
    // These accumulate in a list and are 'executed' in order.
    new CmdSpec ("-color", 1), // Set color
    new CmdSpec ("-gridx", 1), // Set grid coordinates
    new CmdSpec ("-gridy", 1),
    new CmdSpec ("-gridoff", 1), // Angular offset
    new CmdSpec ("-dlat", 1), // Set dial origin
    new CmdSpec ("-dlong", 1),

    new CmdSpec ("-grid", 0),
    new CmdSpec ("-localhours",0),
    new CmdSpec ("-temporaryhours",0),
    new CmdSpec ("-altitudes",0),
    new CmdSpec ("-analemma",0),
    new CmdSpec ("-tropics",0),
    new CmdSpec ("-arctics",0),
    new CmdSpec ("-dateline",1),
    new CmdSpec ("-datetime",1),

    // Backwards compatible - set default initial color
    new RgbSpec ("-gridcolor", params.gridcolor),

    // Loop options
    new IntSpec ("-loop", loop ),
    new DoubleSpec ("-tiltinc", tiltinc, 2 * pi / 360.0 ),
    new DoubleSpec ("-turninc", tiltinc, 2 * pi / 360.0 ),
    new DoubleSpec ("-latinc", latinc, 2 * pi / 360.0 ),
    new DoubleSpec ("-longinc", loninc, 2 * pi / 360.0 ),
    new DoubleSpec ("-xinc", xinc),
    new DoubleSpec ("-yinc", yinc),
    new DoubleSpec ("-zinc", zinc),
    new DoubleSpec ("-dateinc", dateinc, 2 * pi / 365.25),
    new DoubleSpec ("-timeinc", timeinc, 2 * pi / 24.0),

    NULL // Finish up
  };
  
  char *progname = argv[0];
  argc--;argv++;
  if (argc == 1 && strcmp(argv[0],"-v") == 0) {
    fprintf(stderr,"MMPS Version %s " __DATE__ "\n", VERSION);
    exit(0);
  }

  Transform* transform = NULL;

  while (argc > 0) {
    int result = OptSpec::ReadOpts(argc, argv, optspecs);
    if (result == -1) {
      // Assume error has been reported by ReadOpts
      error(usage, progname);
    } else if (result != 1) {
      // Option not recognized
      // Is it a transform>?
      Transform *t = Transform::GetTransform(argv[0]);
      if (t == NULL) {
	fprintf(stderr,"Unrecognized option %s\n",argv[0]);
	error(usage, progname);
      } else {
	if (transform == NULL) {
	  // Found a transform
	  transform = t;
	} else {
	  // Oops, two transforms
	  fprintf(stderr,"Can only specify one projection type\n");
	  error(usage, progname); 
	}
      }
    }
    argc--; argv++;
  }

  if (transform == NULL) {
    fprintf(stderr,"Need to specify a projection type\n");
    error(usage, progname);
  }

  inImage.Read(infilename);

  if (adjust) {
    transform->AdjustSize(width, height, params);
  }
  Image outImage(width, height);
  Image backImage;
  if (backfilename != NULL) {
    backImage.Read(backfilename);
  }
  for (int i = 0; i < loop; i++) {
    if (backfilename != NULL) {
      outImage.Copy(backImage);
      params.noback = true;
    }
    transform->Init(params);
    if (invert) {
      transform->TransformImageInv(inImage, outImage, params);
      // No commands for inverse transformation yet
    } else {
      transform->TransformImage(inImage, outImage, params);
      transform->DoCommands(outImage, params, CmdSpec::getcmdlist());
    }
    if (loop > 1) {
      char fname[256];
      sprintf(fname, "%s%04d.ppm", outfilename, i);
      outImage.Write(fname);
      fprintf(stderr, "Written %s\n", fname);
    } else {
      outImage.Write(outfilename);
    }      
    params.turn += turninc;
    params.tilt += tiltinc;
    params.lat += latinc;
    params.lon += loninc;
    params.x += xinc;
    params.y += yinc;
    params.z += zinc;
    params.time += timeinc;
    params.date += dateinc;
  }
  delete(transform);
  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x7f8, %rsp            # imm = 0x7F8
movl %edi, 0x8(%rsp)
movq %rsi, 0x18(%rsp)
xorl %ebx, %ebx
leaq 0x390(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xbb80
leaq 0x8bdd(%rip), %rax      # 0xd27d
movq %rax, 0x78(%rsp)
movq %rbx, 0x38(%rsp)
movq %rbx, 0x30(%rsp)
movl $0x320, 0x14(%rsp)      # imm = 0x320
movl $0x258, 0x10(%rsp)      # imm = 0x258
movb $0x0, 0x7(%rsp)
leaq 0x80(%rsp), %rdi
callq 0x6252
xorl %eax, %eax
movq %rax, 0x70(%rsp)
movq %rax, 0x68(%rsp)
movq %rax, 0x60(%rsp)
movq %rax, 0x28(%rsp)
movq %rax, 0x58(%rsp)
movq %rax, 0x50(%rsp)
movq %rax, 0x48(%rsp)
movq %rax, 0x40(%rsp)
movl $0x1, 0xc(%rsp)
movb $0x0, 0x6(%rsp)
movl $0x18, %edi
callq 0x4210
movq %rax, %r14
leaq 0x8b72(%rip), %rsi      # 0xd28e
movq %rax, %rdi
callq 0xaf6a
leaq 0x140(%rsp), %rax
leaq 0xe64d(%rip), %rbx      # 0x12d80
addq $0x10, %rbx
movq %rbx, (%r14)
movq %rax, 0x10(%r14)
movq %r14, 0x170(%rsp)
movl $0x18, %edi
callq 0x4210
movq %rax, %r14
leaq 0x8b38(%rip), %rsi      # 0xd292
leaq 0x14(%rsp), %rdx
movq %rax, %rdi
callq 0xb072
movq %r14, 0x178(%rsp)
movl $0x18, %edi
callq 0x4210
movq %rax, %r14
leaq 0x8b12(%rip), %rsi      # 0xd295
leaq 0x10(%rsp), %rdx
movq %rax, %rdi
callq 0xb072
movq %r14, 0x180(%rsp)
movl $0x18, %edi
callq 0x4210
movq %rax, %r14
leaq 0x8aec(%rip), %rsi      # 0xd298
leaq 0x7(%rsp), %rdx
movq %rax, %rdi
callq 0xafbc
movq %r14, 0x188(%rsp)
movl $0x18, %edi
callq 0x4210
movq %rax, %r14
leaq 0x8acb(%rip), %rsi      # 0xd2a0
leaq 0x78(%rsp), %rdx
movq %rax, %rdi
callq 0xaffa
movq %r14, 0x190(%rsp)
movl $0x18, %edi
callq 0x4210
movq %rax, %r14
leaq 0x8aa5(%rip), %rsi      # 0xd2a3
leaq 0x38(%rsp), %rdx
movq %rax, %rdi
callq 0xaffa
movq %r14, 0x198(%rsp)
movl $0x18, %edi
callq 0x4210
movq %rax, %r14
leaq 0x8a81(%rip), %rsi      # 0xd2a8
leaq 0x30(%rsp), %rdx
movq %rax, %rdi
callq 0xaffa
movq %r14, 0x1a0(%rsp)
movl $0x18, %edi
callq 0x4210
movq %rax, %r14
leaq 0x8a5e(%rip), %rsi      # 0xd2ae
leaq 0x6(%rsp), %rdx
movq %rax, %rdi
callq 0xafbc
movq %r14, 0x1a8(%rsp)
movl $0x20, %edi
callq 0x4210
movq %rax, %r14
leaq 0x8a38(%rip), %rsi      # 0xd2b1
leaq 0x80(%rsp), %rdx
movsd 0x877f(%rip), %xmm0     # 0xd008
movq %rax, %rdi
callq 0xb0f2
movq %r14, 0x1b0(%rsp)
movl $0x20, %edi
callq 0x4210
movq %rax, %r14
leaq 0x88(%rsp), %rdx
leaq 0x8a02(%rip), %rsi      # 0xd2b7
movsd 0x874b(%rip), %xmm0     # 0xd008
movq %rax, %rdi
callq 0xb0f2
movq %r14, 0x1b8(%rsp)
movl $0x20, %edi
callq 0x4210
movq %rax, %r14
leaq 0x90(%rsp), %rdx
leaq 0x89d4(%rip), %rsi      # 0xd2bd
movsd 0x8717(%rip), %xmm0     # 0xd008
movq %rax, %rdi
callq 0xb0f2
movq %r14, 0x1c0(%rsp)
movl $0x20, %edi
callq 0x4210
movq %rax, %r14
leaq 0x98(%rsp), %rdx
leaq 0x89a8(%rip), %rsi      # 0xd2c5
movsd 0x86e3(%rip), %xmm0     # 0xd008
movq %rax, %rdi
callq 0xb0f2
movq %r14, 0x1c8(%rsp)
movl $0x20, %edi
callq 0x4210
movq %rax, %r14
leaq 0xa0(%rsp), %rdx
leaq 0x8979(%rip), %rsi      # 0xd2ca
movsd 0x86af(%rip), %xmm0     # 0xd008
movq %rax, %rdi
callq 0xb0f2
movq %r14, 0x1d0(%rsp)
movl $0x20, %edi
callq 0x4210
movq %rax, %r14
leaq 0xa8(%rsp), %rdx
leaq 0x894b(%rip), %rsi      # 0xd2d0
movsd 0x8683(%rip), %xmm0     # 0xd010
movq %rax, %rdi
callq 0xb0f2
movq %r14, 0x1d8(%rsp)
movl $0x20, %edi
callq 0x4210
movq %rax, %r14
leaq 0xb0(%rsp), %rdx
leaq 0x891e(%rip), %rsi      # 0xd2d7
movsd 0x8647(%rip), %xmm0     # 0xd008
movq %rax, %rdi
callq 0xb0f2
movq %r14, 0x1e0(%rsp)
movl $0x20, %edi
callq 0x4210
movq %rax, %r14
leaq 0xc8(%rsp), %rdx
leaq 0x88f2(%rip), %rsi      # 0xd2df
movsd 0x861b(%rip), %xmm0     # 0xd010
movq %rax, %rdi
callq 0xb0f2
movq %r14, 0x1e8(%rsp)
movl $0x20, %edi
callq 0x4210
movq %rax, %r14
leaq 0xd0(%rsp), %rdx
leaq 0x88c1(%rip), %rsi      # 0xd2e2
movsd 0x85e7(%rip), %xmm0     # 0xd010
movq %rax, %rdi
callq 0xb0f2
movq %r14, 0x1f0(%rsp)
movl $0x20, %edi
callq 0x4210
movq %rax, %r14
leaq 0xd8(%rsp), %rdx
leaq 0x8890(%rip), %rsi      # 0xd2e5
movsd 0x85b3(%rip), %xmm0     # 0xd010
movq %rax, %rdi
callq 0xb0f2
movq %r14, 0x1f8(%rsp)
movl $0x20, %edi
callq 0x4210
movq %rax, %r14
leaq 0xe0(%rsp), %rdx
leaq 0x885f(%rip), %rsi      # 0xd2e8
movsd 0x857f(%rip), %xmm0     # 0xd010
movq %rax, %rdi
callq 0xb0f2
movq %r14, 0x200(%rsp)
movl $0x20, %edi
callq 0x4210
movq %rax, %r14
leaq 0xe8(%rsp), %rdx
leaq 0x882f(%rip), %rsi      # 0xd2ec
movsd 0x854b(%rip), %xmm0     # 0xd010
movq %rax, %rdi
callq 0xb0f2
movq %r14, 0x208(%rsp)
movl $0x20, %edi
callq 0x4210
movq %rax, %r14
leaq 0xf0(%rsp), %rdx
leaq 0x87ff(%rip), %rsi      # 0xd2f0
movsd 0x8517(%rip), %xmm0     # 0xd010
movq %rax, %rdi
callq 0xb0f2
movq %r14, 0x210(%rsp)
movl $0x20, %edi
callq 0x4210
movq %rax, %r14
leaq 0xb8(%rsp), %rdx
leaq 0x87cf(%rip), %rsi      # 0xd2f4
movsd 0x84e3(%rip), %xmm0     # 0xd010
movq %rax, %rdi
callq 0xb0f2
movq %r14, 0x218(%rsp)
movl $0x20, %edi
callq 0x4210
movq %rax, %r14
leaq 0x110(%rsp), %rdx
leaq 0x879e(%rip), %rsi      # 0xd2f7
movsd 0x84af(%rip), %xmm0     # 0xd010
movq %rax, %rdi
callq 0xb0f2
movq %r14, 0x220(%rsp)
movl $0x20, %edi
callq 0x4210
movq %rax, %r14
leaq 0x108(%rsp), %rdx
leaq 0x8770(%rip), %rsi      # 0xd2fd
movsd 0x8483(%rip), %xmm0     # 0xd018
movq %rax, %rdi
callq 0xb0f2
movq %r14, 0x228(%rsp)
movl $0x20, %edi
callq 0x4210
movq %rax, %r14
leaq 0x100(%rsp), %rdx
leaq 0x8742(%rip), %rsi      # 0xd303
movsd 0x843f(%rip), %xmm0     # 0xd008
movq %rax, %rdi
callq 0xb0f2
movq %r14, 0x230(%rsp)
movl $0x20, %edi
callq 0x4210
movq %rax, %r14
leaq 0xc0(%rsp), %rdx
leaq 0x8711(%rip), %rsi      # 0xd306
movsd 0x840b(%rip), %xmm0     # 0xd008
movq %rax, %rdi
callq 0xb0f2
movq %r14, 0x238(%rsp)
movl $0x20, %edi
callq 0x4210
movq %rax, %r14
leaq 0x120(%rsp), %rdx
leaq 0x86e1(%rip), %rsi      # 0xd30a
movsd 0x83df(%rip), %xmm0     # 0xd010
movq %rax, %rdi
callq 0xb0f2
movq %r14, 0x240(%rsp)
movl $0x20, %edi
callq 0x4210
movq %rax, %r14
leaq 0x128(%rsp), %rdx
leaq 0x86b4(%rip), %rsi      # 0xd311
movsd 0x83ab(%rip), %xmm0     # 0xd010
movq %rax, %rdi
callq 0xb0f2
movq %r14, 0x248(%rsp)
movl $0x20, %edi
callq 0x4210
movq %rax, %r14
leaq 0x130(%rsp), %rdx
leaq 0x8688(%rip), %rsi      # 0xd319
movsd 0x8377(%rip), %xmm0     # 0xd010
movq %rax, %rdi
callq 0xb0f2
movq %r14, 0x250(%rsp)
movl $0x20, %edi
callq 0x4210
movq %rax, %r14
leaq 0x138(%rsp), %rdx
leaq 0x865a(%rip), %rsi      # 0xd31f
movsd 0x8343(%rip), %xmm0     # 0xd010
movq %rax, %rdi
callq 0xb0f2
movq %r14, 0x258(%rsp)
movl $0x18, %edi
callq 0x4210
movq %rax, %r14
leaq 0xf8(%rsp), %rdx
leaq 0x862c(%rip), %rsi      # 0xd325
movq %rax, %rdi
callq 0xafbc
movq %r14, 0x260(%rsp)
movl $0x18, %edi
callq 0x4210
movq %rax, %r14
leaq 0x860d(%rip), %rsi      # 0xd32a
movq %rax, %rdi
movl $0x1, %edx
callq 0xb186
movq %r14, 0x268(%rsp)
movl $0x18, %edi
callq 0x4210
movq %rax, %r14
leaq 0x85eb(%rip), %rsi      # 0xd331
movq %rax, %rdi
movl $0x1, %edx
callq 0xb186
movq %r14, 0x270(%rsp)
movl $0x18, %edi
callq 0x4210
movq %rax, %r14
leaq 0x85c9(%rip), %rsi      # 0xd338
movq %rax, %rdi
movl $0x1, %edx
callq 0xb186
movq %r14, 0x278(%rsp)
movl $0x18, %edi
callq 0x4210
movq %rax, %r14
leaq 0x85a7(%rip), %rsi      # 0xd33f
movq %rax, %rdi
movl $0x1, %edx
callq 0xb186
movq %r14, 0x280(%rsp)
movl $0x18, %edi
callq 0x4210
movq %rax, %r14
leaq 0x8587(%rip), %rsi      # 0xd348
movq %rax, %rdi
movl $0x1, %edx
callq 0xb186
movq %r14, 0x288(%rsp)
movl $0x18, %edi
callq 0x4210
movq %rax, %r14
leaq 0x8564(%rip), %rsi      # 0xd34e
movq %rax, %rdi
movl $0x1, %edx
callq 0xb186
movq %r14, 0x290(%rsp)
movl $0x18, %edi
callq 0x4210
movq %rax, %r14
leaq 0x8542(%rip), %rsi      # 0xd355
movq %rax, %rdi
xorl %edx, %edx
callq 0xb186
movq %r14, 0x298(%rsp)
movl $0x18, %edi
callq 0x4210
movq %rax, %r14
leaq 0x8522(%rip), %rsi      # 0xd35b
movq %rax, %rdi
xorl %edx, %edx
callq 0xb186
movq %r14, 0x2a0(%rsp)
movl $0x18, %edi
callq 0x4210
movq %rax, %r14
leaq 0x8508(%rip), %rsi      # 0xd367
movq %rax, %rdi
xorl %edx, %edx
callq 0xb186
movq %r14, 0x2a8(%rsp)
movl $0x18, %edi
callq 0x4210
movq %rax, %r14
leaq 0x84f2(%rip), %rsi      # 0xd377
movq %rax, %rdi
xorl %edx, %edx
callq 0xb186
movq %r14, 0x2b0(%rsp)
movl $0x18, %edi
callq 0x4210
movq %rax, %r14
leaq 0x84d7(%rip), %rsi      # 0xd382
movq %rax, %rdi
xorl %edx, %edx
callq 0xb186
movq %r14, 0x2b8(%rsp)
movl $0x18, %edi
callq 0x4210
movq %rax, %r14
leaq 0x84bb(%rip), %rsi      # 0xd38c
movq %rax, %rdi
xorl %edx, %edx
callq 0xb186
movq %r14, 0x2c0(%rsp)
movl $0x18, %edi
callq 0x4210
movq %rax, %r14
leaq 0x849e(%rip), %rsi      # 0xd395
movq %rax, %rdi
xorl %edx, %edx
callq 0xb186
movq %r14, 0x2c8(%rsp)
movl $0x18, %edi
callq 0x4210
movq %rax, %r14
leaq 0x8481(%rip), %rsi      # 0xd39e
movq %rax, %rdi
movl $0x1, %edx
callq 0xb186
movq %r14, 0x2d0(%rsp)
movl $0x18, %edi
callq 0x4210
movq %rax, %r14
leaq 0x8462(%rip), %rsi      # 0xd3a8
movq %rax, %rdi
movl $0x1, %edx
callq 0xb186
movq %r14, 0x2d8(%rsp)
movl $0x18, %edi
callq 0x4210
movq %rax, %r14
leaq 0x8443(%rip), %rsi      # 0xd3b2
movq %rax, %rdi
callq 0xaf6a
leaq 0x14c(%rsp), %rax
movq %rbx, (%r14)
movq %rax, 0x10(%r14)
movq %r14, 0x2e0(%rsp)
movl $0x18, %edi
callq 0x4210
movq %rax, %r14
leaq 0x841b(%rip), %rsi      # 0xd3bd
leaq 0xc(%rsp), %rdx
movq %rax, %rdi
callq 0xb072
movq %r14, 0x2e8(%rsp)
movl $0x20, %edi
callq 0x4210
movq %rax, %r14
leaq 0x83f8(%rip), %rsi      # 0xd3c3
leaq 0x28(%rsp), %rdx
movsd 0x8030(%rip), %xmm0     # 0xd008
movq %rax, %rdi
callq 0xb0f2
movq %r14, 0x2f0(%rsp)
movl $0x20, %edi
callq 0x4210
movq %rax, %r14
leaq 0x83d0(%rip), %rsi      # 0xd3cc
leaq 0x28(%rsp), %rdx
movsd 0x7fff(%rip), %xmm0     # 0xd008
movq %rax, %rdi
callq 0xb0f2
movq %r14, 0x2f8(%rsp)
movl $0x20, %edi
callq 0x4210
movq %rax, %r14
leaq 0x83a8(%rip), %rsi      # 0xd3d5
leaq 0x58(%rsp), %rdx
movsd 0x7fce(%rip), %xmm0     # 0xd008
movq %rax, %rdi
callq 0xb0f2
movq %r14, 0x300(%rsp)
movl $0x20, %edi
callq 0x4210
movq %rax, %r14
leaq 0x837f(%rip), %rsi      # 0xd3dd
leaq 0x50(%rsp), %rdx
movsd 0x7f9d(%rip), %xmm0     # 0xd008
movq %rax, %rdi
callq 0xb0f2
movq %r14, 0x308(%rsp)
movl $0x20, %edi
callq 0x4210
movq %rax, %r14
leaq 0x8357(%rip), %rsi      # 0xd3e6
leaq 0x70(%rsp), %rdx
movsd 0x7f74(%rip), %xmm0     # 0xd010
movq %rax, %rdi
callq 0xb0f2
movq %r14, 0x310(%rsp)
movl $0x20, %edi
callq 0x4210
movq %rax, %r14
leaq 0x832c(%rip), %rsi      # 0xd3ec
leaq 0x68(%rsp), %rdx
movsd 0x7f43(%rip), %xmm0     # 0xd010
movq %rax, %rdi
callq 0xb0f2
movq %r14, 0x318(%rsp)
movl $0x20, %edi
callq 0x4210
movq %rax, %r14
leaq 0x8301(%rip), %rsi      # 0xd3f2
leaq 0x60(%rsp), %rdx
movsd 0x7f12(%rip), %xmm0     # 0xd010
movq %rax, %rdi
callq 0xb0f2
movq %r14, 0x320(%rsp)
movl $0x20, %edi
callq 0x4210
movq %rax, %r14
leaq 0x82d6(%rip), %rsi      # 0xd3f8
leaq 0x40(%rsp), %rdx
movsd 0x7ef1(%rip), %xmm0     # 0xd020
movq %rax, %rdi
callq 0xb0f2
movq %r14, 0x328(%rsp)
movl $0x20, %edi
callq 0x4210
movq %rax, %r14
leaq 0x82ae(%rip), %rsi      # 0xd401
leaq 0x48(%rsp), %rdx
movsd 0x7eb8(%rip), %xmm0     # 0xd018
movq %rax, %rdi
callq 0xb0f2
movq %r14, 0x330(%rsp)
movq $0x0, 0x338(%rsp)
movq 0x18(%rsp), %rax
movq (%rax), %rcx
movq %rcx, 0x20(%rsp)
movl 0x8(%rsp), %ecx
decl %ecx
movl %ecx, 0x8(%rsp)
addq $0x8, %rax
movq %rax, 0x18(%rsp)
cmpl $0x1, %ecx
jne 0x51b8
movq (%rax), %rdi
leaq 0x825f(%rip), %rsi      # 0xd40a
callq 0x4250
testl %eax, %eax
je 0x5609
cmpl $0x0, 0x8(%rsp)
jle 0x52e7
leaq 0x8(%rsp), %r14
leaq 0x18(%rsp), %r12
leaq 0x170(%rsp), %r13
leaq 0x3f0(%rsp), %rbp
xorl %ebx, %ebx
movq %r14, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0xaf7a
cmpl $0x1, %eax
je 0x521a
cmpl $-0x1, %eax
jne 0x521f
movq 0xdfd2(%rip), %rdx      # 0x131d0
movl $0x400, %esi            # imm = 0x400
movq %rbp, %rdi
movq 0x20(%rsp), %rcx
xorl %eax, %eax
callq 0x42a0
movq %rbp, %rdi
callq 0xaf14
movq %rbx, %r15
jmp 0x5239
movq 0x18(%rsp), %rax
movq (%rax), %rdi
callq 0x7322
movq %rax, %r15
testq %rax, %rax
je 0x5257
testq %rbx, %rbx
jne 0x529f
movl 0x8(%rsp), %eax
addq $0x8, 0x18(%rsp)
leal -0x1(%rax), %ecx
movl %ecx, 0x8(%rsp)
movq %r15, %rbx
cmpl $0x1, %eax
jg 0x51df
jmp 0x52ea
movq 0xdd82(%rip), %rax      # 0x12fe0
movq (%rax), %rdi
movq 0x18(%rsp), %rax
movq (%rax), %rdx
leaq 0x81c1(%rip), %rsi      # 0xd431
xorl %eax, %eax
callq 0x4270
movq 0xdf52(%rip), %rdx      # 0x131d0
movl $0x400, %esi            # imm = 0x400
movq %rbp, %rdi
movq 0x20(%rsp), %rcx
xorl %eax, %eax
callq 0x42a0
movq %rbp, %rdi
callq 0xaf14
jmp 0x521a
movq 0xdd3a(%rip), %rax      # 0x12fe0
movq (%rax), %rcx
movl $0x25, %esi
movl $0x1, %edx
leaq 0x818f(%rip), %rdi      # 0xd449
callq 0x4360
movq 0xdf0a(%rip), %rdx      # 0x131d0
movl $0x400, %esi            # imm = 0x400
movq %rbp, %rdi
movq 0x20(%rsp), %rcx
xorl %eax, %eax
callq 0x42a0
movq %rbp, %rdi
callq 0xaf14
jmp 0x521a
xorl %r15d, %r15d
testq %r15, %r15
je 0x55b9
movq 0x78(%rsp), %rsi
leaq 0x390(%rsp), %rdi
xorl %edx, %edx
callq 0xbd5a
cmpb $0x1, 0x7(%rsp)
jne 0x5329
movq (%r15), %rax
leaq 0x14(%rsp), %rsi
leaq 0x10(%rsp), %rdx
leaq 0x80(%rsp), %rcx
movq %r15, %rdi
callq *0x10(%rax)
movslq 0x14(%rsp), %rsi
movslq 0x10(%rsp), %rdx
leaq 0x3c0(%rsp), %rdi
callq 0xbb80
leaq 0x360(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xbb80
movq 0x30(%rsp), %rsi
testq %rsi, %rsi
je 0x536a
leaq 0x360(%rsp), %rdi
xorl %edx, %edx
callq 0xbd5a
cmpl $0x0, 0xc(%rsp)
jle 0x5570
leaq 0x80(%rsp), %r14
leaq 0x390(%rsp), %rbx
leaq 0x3c0(%rsp), %r12
xorl %r13d, %r13d
cmpq $0x0, 0x30(%rsp)
je 0x53b0
movq %r12, %rdi
leaq 0x360(%rsp), %rsi
callq 0xbc3c
movb $0x1, 0x118(%rsp)
movq (%r15), %rax
movq %r15, %rdi
movq %r14, %rsi
callq *0x8(%rax)
cmpb $0x1, 0x6(%rsp)
jne 0x53d6
movq %r15, %rdi
movq %rbx, %rsi
movq %r12, %rdx
movq %r14, %rcx
callq 0x6da6
jmp 0x541c
movq %r15, %rdi
movq %rbx, %rsi
movq %r12, %rdx
movq %r14, %rcx
callq 0x6a86
leaq 0x348(%rsp), %rdi
leaq 0xddfa(%rip), %rsi      # 0x131f0
callq 0x56fe
movq %r15, %rdi
movq %r12, %rsi
movq %r14, %rdx
leaq 0x348(%rsp), %rbp
movq %rbp, %rcx
callq 0x95d4
movq %rbp, %rdi
callq 0x5798
cmpl $0x2, 0xc(%rsp)
jge 0x551e
movq 0x38(%rsp), %rsi
movq %r12, %rdi
callq 0xbf72
movsd 0x88(%rsp), %xmm0
addsd 0x7be3(%rip), %xmm0     # 0xd028
movsd %xmm0, 0x88(%rsp)
movsd 0x28(%rsp), %xmm0
addsd 0x80(%rsp), %xmm0
movsd %xmm0, 0x80(%rsp)
movsd 0x58(%rsp), %xmm0
addsd 0x98(%rsp), %xmm0
movsd %xmm0, 0x98(%rsp)
movsd 0x50(%rsp), %xmm0
addsd 0xa0(%rsp), %xmm0
movsd %xmm0, 0xa0(%rsp)
movsd 0x70(%rsp), %xmm0
addsd 0xc8(%rsp), %xmm0
movsd %xmm0, 0xc8(%rsp)
movsd 0x68(%rsp), %xmm0
addsd 0xd0(%rsp), %xmm0
movsd %xmm0, 0xd0(%rsp)
movsd 0x60(%rsp), %xmm0
addsd 0xd8(%rsp), %xmm0
movsd %xmm0, 0xd8(%rsp)
movsd 0x48(%rsp), %xmm0
addsd 0x108(%rsp), %xmm0
movsd %xmm0, 0x108(%rsp)
movsd 0x40(%rsp), %xmm0
addsd 0x110(%rsp), %xmm0
movsd %xmm0, 0x110(%rsp)
incl %r13d
cmpl 0xc(%rsp), %r13d
jl 0x5390
jmp 0x5570
movq %rbx, %rbp
movq 0x38(%rsp), %rdx
leaq 0x3f0(%rsp), %rbx
movq %rbx, %rdi
leaq 0x7f5a(%rip), %rsi      # 0xd492
movl %r13d, %ecx
xorl %eax, %eax
callq 0x4060
movq %r12, %rdi
movq %rbx, %rsi
callq 0xbf72
movq 0xda8c(%rip), %rax      # 0x12fe0
movq (%rax), %rdi
leaq 0x7f3f(%rip), %rsi      # 0xd49d
movq %rbx, %rdx
xorl %eax, %eax
callq 0x4270
movq %rbp, %rbx
jmp 0x5434
testq %r15, %r15
je 0x557e
movq (%r15), %rax
movq %r15, %rdi
callq *0x40(%rax)
leaq 0x360(%rsp), %rdi
callq 0xbbd4
leaq 0x3c0(%rsp), %rdi
callq 0xbbd4
leaq 0x390(%rsp), %rdi
callq 0xbbd4
xorl %eax, %eax
addq $0x7f8, %rsp            # imm = 0x7F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xda20(%rip), %rax      # 0x12fe0
movq (%rax), %rcx
leaq 0x7ea5(%rip), %rdi      # 0xd46f
movl $0x22, %esi
movl $0x1, %edx
callq 0x4360
movq 0xdbf0(%rip), %rdx      # 0x131d0
leaq 0x3f0(%rsp), %rbx
movl $0x400, %esi            # imm = 0x400
movq %rbx, %rdi
movq 0x20(%rsp), %rcx
xorl %eax, %eax
callq 0x42a0
movq %rbx, %rdi
callq 0xaf14
jmp 0x52f3
callq 0x4390
jmp 0x56cb
movq %rax, %rbx
jmp 0x56db
jmp 0x56c6
jmp 0x5680
jmp 0x5680
jmp 0x5680
jmp 0x5680
jmp 0x5680
jmp 0x5680
jmp 0x5680
jmp 0x5680
jmp 0x5680
jmp 0x5698
jmp 0x5698
jmp 0x5698
jmp 0x5698
jmp 0x5698
jmp 0x5698
jmp 0x5698
jmp 0x5698
jmp 0x5698
jmp 0x5698
jmp 0x5698
jmp 0x5698
jmp 0x5698
jmp 0x5698
jmp 0x5698
jmp 0x5698
jmp 0x5698
jmp 0x5698
jmp 0x5680
jmp 0x5680
jmp 0x5680
jmp 0x5680
jmp 0x5680
jmp 0x5680
jmp 0x5680
jmp 0x5680
jmp 0x5680
jmp 0x5680
jmp 0x5680
jmp 0x5680
jmp 0x5680
jmp 0x5680
jmp 0x5680
jmp 0x5680
jmp 0x5680
jmp 0x5680
jmp 0x5680
jmp 0x5680
jmp 0x5680
movq %rax, %rbx
movl $0x20, %esi
jmp 0x56a0
jmp 0x5698
jmp 0x5698
jmp 0x5698
jmp 0x5698
jmp 0x5698
jmp 0x5698
jmp 0x5698
movq %rax, %rbx
movl $0x18, %esi
movq %r14, %rdi
callq 0x4220
jmp 0x56e8
jmp 0x56c6
jmp 0x56c6
jmp 0x56c6
movq %rax, %rbx
leaq 0x348(%rsp), %rdi
callq 0x5798
jmp 0x56ce
jmp 0x56cb
jmp 0x56c6
movq %rax, %rbx
jmp 0x56e8
movq %rax, %rbx
leaq 0x360(%rsp), %rdi
callq 0xbbd4
leaq 0x3c0(%rsp), %rdi
callq 0xbbd4
leaq 0x390(%rsp), %rdi
callq 0xbbd4
movq %rbx, %rdi
callq 0x4310
nop