// File: /workspace/github_cpp_makefile_star2_O1/matthewarcus[P]mmps/stars.cpp
// Function: main
int main(int argc, char* argv[])
{
  const char* outfilename = NULL;
  const char* backfilename = NULL;
  const char* starlist = NULL;
  int width = 800;
  int height = 600;

  bool adjust = false;
  bool addgrid = false;
  TransformParams params;
  params.gridcolor = Rgb(0,0,60);

  Rgb bg(0,0,0);

  const char* type = "perspective";
  bool typeset = false;

  // array of pointers. Dynamic allocation is less typing than
  // stack allocating everything.
  OptSpec *optspecs [] = {
    // General options
    new IntSpec ("-w", width),
    new IntSpec ("-h", height),
    new BoolSpec ("-adjust", adjust),
    new StringSpec ("-f", starlist),
    new StringSpec ("-out", outfilename),
    new StringSpec ("-back", backfilename),
    new RgbSpec ("-bg", bg),
    new DoubleSpec("-year", year),
    new DoubleSpec("-magfact", magfact),
    new DoubleSpec("-topmag", topmag),
    new BoolSpec("-bv", dobv),
    new DoubleSpec("-bvfact", bvfact),

    // First the params options
    new DoubleSpec ("-tilt", params.tilt, 2 * pi / 360.0 ),
    new DoubleSpec ("-turn", params.turn, 2 * pi / 360.0 ),
    new DoubleSpec ("-dec", params.lat, 2 * pi / 360.0 ),
    new DoubleSpec ("-ra", params.lon, -2 * pi / 24.0 ),
    new DoubleSpec ("-scale", params.scale),
    new DoubleSpec ("-x", params.x),
    new DoubleSpec ("-y", params.y),
    new DoubleSpec ("-z", params.z),
    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),

    // Grid options
    new BoolSpec ("-grid", addgrid),
    new IntSpec ("-gridx", params.gridx),
    new IntSpec ("-gridy", params.gridy),
    new RgbSpec ("-gridcolor", params.gridcolor),

    NULL // Finish up
  };

  char *progname = argv[0];
  argc--;argv++;
  if (argc == 1 && strcmp(argv[0],"-v") == 0) {
    fprintf(stderr,"MMPS Version %s\n", VERSION);
    exit(0);
  }
  while (argc > 0) {
    int result = OptSpec::ReadOpts(argc, argv, optspecs);
    if (result == -1) {
      error(usage, progname);
    } else if (result != 1) {
      if (typeset) { error(usage, progname); };
      type = argv[0];
      typeset = true;
    }
    argc--; argv++;
  }

  Transform* transform = Transform::GetTransform(type);
  if (transform == NULL) {
    error(usage, progname);
  }

  if (adjust) {
    transform->AdjustSize(width, height, params);
  }
  Image outImage(width,height);
  transform->Init(params);
  if (backfilename != NULL) {
    Image backImage;
    backImage.Read(backfilename);
    outImage.Copy(backImage);
  } else {
    outImage.Fill(bg);
  }
  if (addgrid) {
    transform->AddLines(outImage, params);
  }
  AddStars(starlist, outImage, *transform, params);
  outImage.Write(outfilename);
  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x678, %rsp            # imm = 0x678
movl %edi, 0x4(%rsp)
movq %rsi, 0x10(%rsp)
xorl %r15d, %r15d
movq %r15, 0x38(%rsp)
movq %r15, 0x28(%rsp)
movq %r15, 0x30(%rsp)
leaq 0x1c(%rsp), %rbx
movl $0x320, (%rbx)          # imm = 0x320
movl $0x258, 0xc(%rsp)       # imm = 0x258
movb %r15b, 0x3(%rsp)
movb %r15b, 0x2(%rsp)
leaq 0x180(%rsp), %r14
movq %r14, %rdi
callq 0x5b9a
movw %r15w, 0xcc(%r14)
movb $0x3c, 0xce(%r14)
movw %r15w, 0x9(%rsp)
movb %r15b, 0xb(%rsp)
movl $0x18, %edi
callq 0x4220
movq %rax, %r14
leaq 0x87e5(%rip), %rsi      # 0xd306
movq %rax, %rdi
movq %rbx, %rdx
callq 0xaa4a
movq %r14, 0x40(%rsp)
movl $0x18, %edi
callq 0x4220
movq %rax, %r14
leaq 0x87c4(%rip), %rsi      # 0xd309
leaq 0xc(%rsp), %rdx
movq %rax, %rdi
callq 0xaa4a
movq %r14, 0x48(%rsp)
movl $0x18, %edi
callq 0x4220
movq %rax, %r14
leaq 0x87a1(%rip), %rsi      # 0xd30c
leaq 0x3(%rsp), %rdx
movq %rax, %rdi
callq 0xa994
movq %r14, 0x50(%rsp)
movl $0x18, %edi
callq 0x4220
movq %rax, %r14
leaq 0x8783(%rip), %rsi      # 0xd314
leaq 0x30(%rsp), %rdx
movq %rax, %rdi
callq 0xa9d2
movq %r14, 0x58(%rsp)
movl $0x18, %edi
callq 0x4220
movq %rax, %r14
leaq 0x8760(%rip), %rsi      # 0xd317
leaq 0x38(%rsp), %rdx
movq %rax, %rdi
callq 0xa9d2
movq %r14, 0x60(%rsp)
movl $0x18, %edi
callq 0x4220
movq %rax, %r14
leaq 0x873f(%rip), %rsi      # 0xd31c
leaq 0x28(%rsp), %rdx
movq %rax, %rdi
callq 0xa9d2
movq %r14, 0x68(%rsp)
movl $0x18, %edi
callq 0x4220
movq %rax, %r14
leaq 0x871f(%rip), %rsi      # 0xd322
movq %rax, %rdi
callq 0xa942
leaq 0xe166(%rip), %rbx      # 0x12d78
addq $0x10, %rbx
movq %rbx, (%r14)
leaq 0x9(%rsp), %rax
movq %rax, 0x10(%r14)
movq %r14, 0x70(%rsp)
movl $0x20, %edi
callq 0x4220
movq %rax, %r14
leaq 0x86eb(%rip), %rsi      # 0xd326
leaq 0xe5e6(%rip), %rdx      # 0x13228
movsd 0x83fe(%rip), %xmm0     # 0xd048
movq %rax, %rdi
callq 0xaaca
movq %r14, 0x78(%rsp)
movl $0x20, %edi
callq 0x4220
movq %rax, %r14
leaq 0x86c1(%rip), %rsi      # 0xd32c
leaq 0xe57e(%rip), %rdx      # 0x131f0
movsd 0x83ce(%rip), %xmm0     # 0xd048
movq %rax, %rdi
callq 0xaaca
movq %r14, 0x80(%rsp)
movl $0x20, %edi
callq 0x4220
movq %rax, %r14
leaq 0x8697(%rip), %rsi      # 0xd335
leaq 0xe543(%rip), %rdx      # 0x131e8
movsd 0x839b(%rip), %xmm0     # 0xd048
movq %rax, %rdi
callq 0xaaca
movq %r14, 0x88(%rsp)
movl $0x18, %edi
callq 0x4220
movq %rax, %r14
leaq 0x866c(%rip), %rsi      # 0xd33d
leaq 0xe548(%rip), %rdx      # 0x13220
movq %rax, %rdi
callq 0xa994
movq %r14, 0x90(%rsp)
movl $0x20, %edi
callq 0x4220
movq %rax, %r14
leaq 0x8645(%rip), %rsi      # 0xd341
leaq 0xe4f5(%rip), %rdx      # 0x131f8
movsd 0x833d(%rip), %xmm0     # 0xd048
movq %rax, %rdi
callq 0xaaca
movq %r14, 0x98(%rsp)
movl $0x20, %edi
callq 0x4220
movq %rax, %r14
leaq 0x861a(%rip), %rsi      # 0xd349
leaq 0x180(%rsp), %rdx
movsd 0x8311(%rip), %xmm0     # 0xd050
movq %rax, %rdi
callq 0xaaca
movq %r14, 0xa0(%rsp)
movl $0x20, %edi
callq 0x4220
movq %rax, %r14
leaq 0x188(%rsp), %rdx
leaq 0x85e4(%rip), %rsi      # 0xd34f
movsd 0x82dd(%rip), %xmm0     # 0xd050
movq %rax, %rdi
callq 0xaaca
movq %r14, 0xa8(%rsp)
movl $0x20, %edi
callq 0x4220
movq %rax, %r14
leaq 0x198(%rsp), %rdx
leaq 0x85b6(%rip), %rsi      # 0xd355
movsd 0x82a9(%rip), %xmm0     # 0xd050
movq %rax, %rdi
callq 0xaaca
movq %r14, 0xb0(%rsp)
movl $0x20, %edi
callq 0x4220
movq %rax, %r14
leaq 0x1a0(%rsp), %rdx
leaq 0x8587(%rip), %rsi      # 0xd35a
movsd 0x827d(%rip), %xmm0     # 0xd058
movq %rax, %rdi
callq 0xaaca
movq %r14, 0xb8(%rsp)
movl $0x20, %edi
callq 0x4220
movq %rax, %r14
leaq 0x1a8(%rsp), %rdx
leaq 0x8557(%rip), %rsi      # 0xd35e
movsd 0x8239(%rip), %xmm0     # 0xd048
movq %rax, %rdi
callq 0xaaca
movq %r14, 0xc0(%rsp)
movl $0x20, %edi
callq 0x4220
movq %rax, %r14
leaq 0x1c8(%rsp), %rdx
leaq 0x852a(%rip), %rsi      # 0xd365
movsd 0x8205(%rip), %xmm0     # 0xd048
movq %rax, %rdi
callq 0xaaca
movq %r14, 0xc8(%rsp)
movl $0x20, %edi
callq 0x4220
movq %rax, %r14
leaq 0x1d0(%rsp), %rdx
leaq 0x84f9(%rip), %rsi      # 0xd368
movsd 0x81d1(%rip), %xmm0     # 0xd048
movq %rax, %rdi
callq 0xaaca
movq %r14, 0xd0(%rsp)
movl $0x20, %edi
callq 0x4220
movq %rax, %r14
leaq 0x1d8(%rsp), %rdx
leaq 0x84c8(%rip), %rsi      # 0xd36b
movsd 0x819d(%rip), %xmm0     # 0xd048
movq %rax, %rdi
callq 0xaaca
movq %r14, 0xd8(%rsp)
movl $0x20, %edi
callq 0x4220
movq %rax, %r14
leaq 0x1b8(%rsp), %rdx
leaq 0x8497(%rip), %rsi      # 0xd36e
movsd 0x8169(%rip), %xmm0     # 0xd048
movq %rax, %rdi
callq 0xaaca
movq %r14, 0xe0(%rsp)
movl $0x20, %edi
callq 0x4220
movq %rax, %r14
leaq 0x210(%rsp), %rdx
leaq 0x8466(%rip), %rsi      # 0xd371
movsd 0x8135(%rip), %xmm0     # 0xd048
movq %rax, %rdi
callq 0xaaca
movq %r14, 0xe8(%rsp)
movl $0x20, %edi
callq 0x4220
movq %rax, %r14
leaq 0x208(%rsp), %rdx
leaq 0x8438(%rip), %rsi      # 0xd377
movsd 0x8119(%rip), %xmm0     # 0xd060
movq %rax, %rdi
callq 0xaaca
movq %r14, 0xf0(%rsp)
movl $0x20, %edi
callq 0x4220
movq %rax, %r14
leaq 0x200(%rsp), %rdx
leaq 0x840a(%rip), %rsi      # 0xd37d
movsd 0x80d5(%rip), %xmm0     # 0xd050
movq %rax, %rdi
callq 0xaaca
movq %r14, 0xf8(%rsp)
movl $0x20, %edi
callq 0x4220
movq %rax, %r14
leaq 0x1c0(%rsp), %rdx
leaq 0x83d9(%rip), %rsi      # 0xd380
movsd 0x80a1(%rip), %xmm0     # 0xd050
movq %rax, %rdi
callq 0xaaca
movq %r14, 0x100(%rsp)
movl $0x20, %edi
callq 0x4220
movq %rax, %r14
leaq 0x220(%rsp), %rdx
leaq 0x83a9(%rip), %rsi      # 0xd384
movsd 0x8065(%rip), %xmm0     # 0xd048
movq %rax, %rdi
callq 0xaaca
movq %r14, 0x108(%rsp)
movl $0x20, %edi
callq 0x4220
movq %rax, %r14
leaq 0x228(%rsp), %rdx
leaq 0x837c(%rip), %rsi      # 0xd38b
movsd 0x8031(%rip), %xmm0     # 0xd048
movq %rax, %rdi
callq 0xaaca
movq %r14, 0x110(%rsp)
movl $0x20, %edi
callq 0x4220
movq %rax, %r14
leaq 0x230(%rsp), %rdx
leaq 0x8350(%rip), %rsi      # 0xd393
movsd 0x7ffd(%rip), %xmm0     # 0xd048
movq %rax, %rdi
callq 0xaaca
movq %r14, 0x118(%rsp)
movl $0x20, %edi
callq 0x4220
movq %rax, %r14
leaq 0x238(%rsp), %rdx
leaq 0x8322(%rip), %rsi      # 0xd399
movsd 0x7fc9(%rip), %xmm0     # 0xd048
movq %rax, %rdi
callq 0xaaca
movq %r14, 0x120(%rsp)
movl $0x18, %edi
callq 0x4220
movq %rax, %r14
leaq 0x82fc(%rip), %rsi      # 0xd39f
leaq 0x2(%rsp), %rdx
movq %rax, %rdi
callq 0xa994
movq %r14, 0x128(%rsp)
movl $0x18, %edi
callq 0x4220
movq %rax, %r14
leaq 0x244(%rsp), %rdx
leaq 0x82d1(%rip), %rsi      # 0xd3a5
movq %rax, %rdi
callq 0xaa4a
movq %r14, 0x130(%rsp)
movl $0x18, %edi
callq 0x4220
movq %rax, %r14
leaq 0x248(%rsp), %rdx
leaq 0x82ac(%rip), %rsi      # 0xd3ac
movq %rax, %rdi
callq 0xaa4a
movq %r14, 0x138(%rsp)
movl $0x18, %edi
callq 0x4220
movq %rax, %r14
leaq 0x828f(%rip), %rsi      # 0xd3b3
movq %rax, %rdi
callq 0xa942
leaq 0x24c(%rsp), %rax
movq %rbx, (%r14)
movq %rax, 0x10(%r14)
movq %r14, 0x140(%rsp)
movq $0x0, 0x148(%rsp)
movq 0x10(%rsp), %rax
movq (%rax), %rcx
movq %rcx, 0x20(%rsp)
movl 0x4(%rsp), %ecx
decl %ecx
movl %ecx, 0x4(%rsp)
addq $0x8, %rax
movq %rax, 0x10(%rsp)
cmpl $0x1, %ecx
jne 0x518b
movq (%rax), %rdi
leaq 0x8240(%rip), %rsi      # 0xd3be
callq 0x4270
testl %eax, %eax
je 0x53a2
cmpl $0x0, 0x4(%rsp)
jle 0x5244
leaq 0x815d(%rip), %rbp      # 0xd2fa
xorl %r14d, %r14d
leaq 0x4(%rsp), %rbx
leaq 0x10(%rsp), %r15
leaq 0x40(%rsp), %r12
leaq 0x270(%rsp), %r13
movq %rbx, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0xa952
cmpl $0x1, %eax
je 0x5228
cmpl $-0x1, %eax
jne 0x51f4
movq 0xe02a(%rip), %rdx      # 0x13200
movl $0x400, %esi            # imm = 0x400
movq %r13, %rdi
movq 0x20(%rsp), %rcx
xorl %eax, %eax
callq 0x42d0
movq %r13, %rdi
callq 0xa8ec
jmp 0x5228
testb $0x1, %r14b
je 0x521d
movq 0xdfff(%rip), %rdx      # 0x13200
movl $0x400, %esi            # imm = 0x400
movq %r13, %rdi
movq 0x20(%rsp), %rcx
xorl %eax, %eax
callq 0x42d0
movq %r13, %rdi
callq 0xa8ec
movq 0x10(%rsp), %rax
movq (%rax), %rbp
movb $0x1, %r14b
movl 0x4(%rsp), %eax
leal -0x1(%rax), %ecx
movl %ecx, 0x4(%rsp)
addq $0x8, 0x10(%rsp)
cmpl $0x1, %eax
jg 0x51b7
jmp 0x524b
leaq 0x80af(%rip), %rbp      # 0xd2fa
movq %rbp, %rdi
callq 0x6c6a
movq %rax, %rbx
testq %rax, %rax
jne 0x5286
movq 0xdf9e(%rip), %rdx      # 0x13200
leaq 0x270(%rsp), %r15
movl $0x400, %esi            # imm = 0x400
movq %r15, %rdi
movq 0x20(%rsp), %rcx
xorl %eax, %eax
callq 0x42d0
movq %r15, %rdi
callq 0xa8ec
cmpb $0x1, 0x3(%rsp)
jne 0x52a8
movq (%rbx), %rax
leaq 0x1c(%rsp), %rsi
leaq 0xc(%rsp), %rdx
leaq 0x180(%rsp), %rcx
movq %rbx, %rdi
callq *0x10(%rax)
movslq 0x1c(%rsp), %rsi
movslq 0xc(%rsp), %rdx
leaq 0x270(%rsp), %rdi
callq 0xb794
movq (%rbx), %rax
leaq 0x180(%rsp), %rsi
movq %rbx, %rdi
callq *0x8(%rax)
cmpq $0x0, 0x28(%rsp)
je 0x5321
leaq 0x150(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xb794
movq 0x28(%rsp), %rsi
leaq 0x150(%rsp), %rdi
xorl %edx, %edx
callq 0xb96e
leaq 0x270(%rsp), %rdi
leaq 0x150(%rsp), %rsi
callq 0xb850
leaq 0x150(%rsp), %rdi
callq 0xb7e8
jmp 0x5333
leaq 0x270(%rsp), %rdi
leaq 0x9(%rsp), %rsi
callq 0xb928
cmpb $0x1, 0x2(%rsp)
jne 0x5352
leaq 0x270(%rsp), %rsi
leaq 0x180(%rsp), %rdx
movq %rbx, %rdi
callq 0x8d30
movq 0x30(%rsp), %rdi
leaq 0x270(%rsp), %rsi
leaq 0x180(%rsp), %rcx
movq %rbx, %rdx
callq 0x4689
movq 0x38(%rsp), %rsi
leaq 0x270(%rsp), %rdi
callq 0xbb86
leaq 0x270(%rsp), %rdi
callq 0xb7e8
xorl %eax, %eax
addq $0x678, %rsp            # imm = 0x678
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x43c0
jmp 0x541b
jmp 0x53f1
jmp 0x53f1
jmp 0x53f1
jmp 0x53f1
jmp 0x53db
jmp 0x53db
jmp 0x53db
jmp 0x53db
jmp 0x53db
jmp 0x53db
jmp 0x53db
jmp 0x53db
jmp 0x53db
jmp 0x53db
jmp 0x53db
jmp 0x53db
jmp 0x53db
jmp 0x53db
jmp 0x53db
jmp 0x53db
jmp 0x53db
jmp 0x53db
jmp 0x53f1
jmp 0x53db
jmp 0x53db
movq %rax, %rbx
movl $0x20, %esi
jmp 0x53f9
jmp 0x53f1
jmp 0x53f1
jmp 0x53f1
jmp 0x53f1
jmp 0x53f1
jmp 0x53f1
movq %rax, %rbx
movl $0x18, %esi
movq %r14, %rdi
callq 0x4230
movq %rbx, %rdi
callq 0x4340
movq %rax, %rbx
leaq 0x150(%rsp), %rdi
callq 0xb7e8
jmp 0x541e
movq %rax, %rbx
leaq 0x270(%rsp), %rdi
callq 0xb7e8
jmp 0x5401
nopl (%rax)