// File: /workspace/github_cpp_makefile_star2_O2/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 $0x2a8, %rsp            # imm = 0x2A8
andq $0x0, 0x38(%rsp)
movq %rsi, %r14
andq $0x0, 0x28(%rsp)
movl %edi, %ebx
andq $0x0, 0x30(%rsp)
movl %edi, 0xc(%rsp)
movq %rsi, 0x18(%rsp)
leaq 0x14(%rsp), %r12
movl $0x320, (%r12)          # imm = 0x320
movl $0x258, 0x10(%rsp)      # imm = 0x258
xorl %ebp, %ebp
movb %bpl, 0x8(%rsp)
movb %bpl, 0x7(%rsp)
leaq 0x1b8(%rsp), %r15
movq %r15, %rdi
callq 0x58a6
andw $0x0, 0xcc(%r15)
movb $0x3c, 0xce(%r15)
andw $0x0, 0x9(%rsp)
movb %bpl, 0xb(%rsp)
pushq $0x18
popq %rdi
callq 0x4220
movq %rax, %r15
leaq 0x7904(%rip), %rsi      # 0xc306
movq %rax, %rdi
movq %r12, %rdx
callq 0x9f72
movq %r15, 0x70(%rsp)
pushq $0x18
popq %rdi
callq 0x4220
movq %rax, %r15
leaq 0x78e5(%rip), %rsi      # 0xc309
leaq 0x10(%rsp), %rdx
movq %rax, %rdi
callq 0x9f72
movq %r15, 0x78(%rsp)
pushq $0x18
popq %rdi
callq 0x4220
movq %rax, %r15
leaq 0x78c4(%rip), %rsi      # 0xc30c
leaq 0x8(%rsp), %rdx
movq %rax, %rdi
callq 0x9eb2
movq %r15, 0x80(%rsp)
pushq $0x18
popq %rdi
callq 0x4220
movq %rax, %r15
leaq 0x78a5(%rip), %rsi      # 0xc314
leaq 0x30(%rsp), %rdx
movq %rax, %rdi
callq 0x9eee
movq %r15, 0x88(%rsp)
pushq $0x18
popq %rdi
callq 0x4220
movq %rax, %r15
leaq 0x7881(%rip), %rsi      # 0xc317
leaq 0x38(%rsp), %rdx
movq %rax, %rdi
callq 0x9eee
movq %r15, 0x90(%rsp)
pushq $0x18
popq %rdi
callq 0x4220
movq %rax, %r15
leaq 0x785f(%rip), %rsi      # 0xc31c
leaq 0x28(%rsp), %rdx
movq %rax, %rdi
callq 0x9eee
movq %r15, 0x98(%rsp)
pushq $0x18
popq %rdi
callq 0x4220
movq %rax, %r15
leaq 0x783e(%rip), %rsi      # 0xc322
leaq 0x9(%rsp), %rdx
movq %rax, %rdi
callq 0x5266
movq %r15, 0xa0(%rsp)
pushq $0x20
popq %rdi
callq 0x4220
movq %rax, %r15
leaq 0x781b(%rip), %rsi      # 0xc326
leaq 0xd726(%rip), %rdx      # 0x12238
movsd 0x752e(%rip), %xmm0     # 0xc048
movq %rax, %rdi
callq 0x9ffe
movq %r15, 0xa8(%rsp)
pushq $0x20
popq %rdi
callq 0x4220
movq %rax, %r15
leaq 0x77f0(%rip), %rsi      # 0xc32c
leaq 0xd6bd(%rip), %rdx      # 0x12200
movsd 0x74fd(%rip), %xmm0     # 0xc048
movq %rax, %rdi
callq 0x9ffe
movq %r15, 0xb0(%rsp)
pushq $0x20
popq %rdi
callq 0x4220
movq %rax, %r15
leaq 0x77c8(%rip), %rsi      # 0xc335
leaq 0xd684(%rip), %rdx      # 0x121f8
movsd 0x74cc(%rip), %xmm0     # 0xc048
movq %rax, %rdi
callq 0x9ffe
movq %r15, 0xb8(%rsp)
pushq $0x18
popq %rdi
callq 0x4220
movq %rax, %r15
leaq 0x779f(%rip), %rsi      # 0xc33d
leaq 0xd68b(%rip), %rdx      # 0x12230
movq %rax, %rdi
callq 0x9eb2
movq %r15, 0xc0(%rsp)
pushq $0x20
popq %rdi
callq 0x4220
movq %rax, %r15
leaq 0x777a(%rip), %rsi      # 0xc341
leaq 0xd63a(%rip), %rdx      # 0x12208
movsd 0x7472(%rip), %xmm0     # 0xc048
movq %rax, %rdi
callq 0x9ffe
movq %r15, 0xc8(%rsp)
pushq $0x20
popq %rdi
callq 0x4220
movq %rax, %r15
leaq 0x7751(%rip), %rsi      # 0xc349
leaq 0x1b8(%rsp), %rdx
movsd 0x7448(%rip), %xmm0     # 0xc050
movq %rax, %rdi
callq 0x9ffe
movq %r15, 0xd0(%rsp)
pushq $0x20
popq %rdi
callq 0x4220
movq %rax, %r15
leaq 0x1c0(%rsp), %rdx
leaq 0x771d(%rip), %rsi      # 0xc34f
movsd 0x7416(%rip), %xmm0     # 0xc050
movq %rax, %rdi
callq 0x9ffe
movq %r15, 0xd8(%rsp)
pushq $0x20
popq %rdi
callq 0x4220
movq %rax, %r15
leaq 0x1d0(%rsp), %rdx
leaq 0x76f1(%rip), %rsi      # 0xc355
movsd 0x73e4(%rip), %xmm0     # 0xc050
movq %rax, %rdi
callq 0x9ffe
movq %r15, 0xe0(%rsp)
pushq $0x20
popq %rdi
callq 0x4220
movq %rax, %r15
leaq 0x1d8(%rsp), %rdx
leaq 0x76c4(%rip), %rsi      # 0xc35a
movsd 0x73ba(%rip), %xmm0     # 0xc058
movq %rax, %rdi
callq 0x9ffe
movq %r15, 0xe8(%rsp)
pushq $0x20
popq %rdi
callq 0x4220
movq %rax, %r15
leaq 0x1e0(%rsp), %rdx
leaq 0x7696(%rip), %rsi      # 0xc35e
movsd 0x7378(%rip), %xmm0     # 0xc048
movq %rax, %rdi
callq 0x9ffe
movq %r15, 0xf0(%rsp)
pushq $0x20
popq %rdi
callq 0x4220
movq %rax, %r15
leaq 0x200(%rsp), %rdx
leaq 0x766b(%rip), %rsi      # 0xc365
movsd 0x7346(%rip), %xmm0     # 0xc048
movq %rax, %rdi
callq 0x9ffe
movq %r15, 0xf8(%rsp)
pushq $0x20
popq %rdi
callq 0x4220
movq %rax, %r15
leaq 0x208(%rsp), %rdx
leaq 0x763c(%rip), %rsi      # 0xc368
movsd 0x7314(%rip), %xmm0     # 0xc048
movq %rax, %rdi
callq 0x9ffe
movq %r15, 0x100(%rsp)
pushq $0x20
popq %rdi
callq 0x4220
movq %rax, %r15
leaq 0x210(%rsp), %rdx
leaq 0x760d(%rip), %rsi      # 0xc36b
movsd 0x72e2(%rip), %xmm0     # 0xc048
movq %rax, %rdi
callq 0x9ffe
movq %r15, 0x108(%rsp)
pushq $0x20
popq %rdi
callq 0x4220
movq %rax, %r15
leaq 0x1f0(%rsp), %rdx
leaq 0x75de(%rip), %rsi      # 0xc36e
movsd 0x72b0(%rip), %xmm0     # 0xc048
movq %rax, %rdi
callq 0x9ffe
movq %r15, 0x110(%rsp)
pushq $0x20
popq %rdi
callq 0x4220
movq %rax, %r15
leaq 0x248(%rsp), %rdx
leaq 0x75af(%rip), %rsi      # 0xc371
movsd 0x727e(%rip), %xmm0     # 0xc048
movq %rax, %rdi
callq 0x9ffe
movq %r15, 0x118(%rsp)
pushq $0x20
popq %rdi
callq 0x4220
movq %rax, %r15
leaq 0x240(%rsp), %rdx
leaq 0x7583(%rip), %rsi      # 0xc377
movsd 0x7264(%rip), %xmm0     # 0xc060
movq %rax, %rdi
callq 0x9ffe
movq %r15, 0x120(%rsp)
pushq $0x20
popq %rdi
callq 0x4220
movq %rax, %r15
leaq 0x238(%rsp), %rdx
leaq 0x7557(%rip), %rsi      # 0xc37d
movsd 0x7222(%rip), %xmm0     # 0xc050
movq %rax, %rdi
callq 0x9ffe
movq %r15, 0x128(%rsp)
pushq $0x20
popq %rdi
callq 0x4220
movq %rax, %r15
leaq 0x1f8(%rsp), %rdx
leaq 0x7528(%rip), %rsi      # 0xc380
movsd 0x71f0(%rip), %xmm0     # 0xc050
movq %rax, %rdi
callq 0x9ffe
movq %r15, 0x130(%rsp)
pushq $0x20
popq %rdi
callq 0x4220
movq %rax, %r15
leaq 0x258(%rsp), %rdx
leaq 0x74fa(%rip), %rsi      # 0xc384
movsd 0x71b6(%rip), %xmm0     # 0xc048
movq %rax, %rdi
callq 0x9ffe
movq %r15, 0x138(%rsp)
pushq $0x20
popq %rdi
callq 0x4220
movq %rax, %r15
leaq 0x260(%rsp), %rdx
leaq 0x74cf(%rip), %rsi      # 0xc38b
movsd 0x7184(%rip), %xmm0     # 0xc048
movq %rax, %rdi
callq 0x9ffe
movq %r15, 0x140(%rsp)
pushq $0x20
popq %rdi
callq 0x4220
movq %rax, %r15
leaq 0x268(%rsp), %rdx
leaq 0x74a5(%rip), %rsi      # 0xc393
movsd 0x7152(%rip), %xmm0     # 0xc048
movq %rax, %rdi
callq 0x9ffe
movq %r15, 0x148(%rsp)
pushq $0x20
popq %rdi
callq 0x4220
movq %rax, %r15
leaq 0x270(%rsp), %rdx
leaq 0x7479(%rip), %rsi      # 0xc399
movsd 0x7120(%rip), %xmm0     # 0xc048
movq %rax, %rdi
callq 0x9ffe
movq %r15, 0x150(%rsp)
pushq $0x18
popq %rdi
callq 0x4220
movq %rax, %r15
leaq 0x7455(%rip), %rsi      # 0xc39f
leaq 0x7(%rsp), %rdx
movq %rax, %rdi
callq 0x9eb2
movq %r15, 0x158(%rsp)
pushq $0x18
popq %rdi
callq 0x4220
movq %rax, %r15
leaq 0x27c(%rsp), %rdx
leaq 0x742c(%rip), %rsi      # 0xc3a5
movq %rax, %rdi
callq 0x9f72
movq %r15, 0x160(%rsp)
pushq $0x18
popq %rdi
callq 0x4220
movq %rax, %r15
leaq 0x280(%rsp), %rdx
leaq 0x7409(%rip), %rsi      # 0xc3ac
movq %rax, %rdi
callq 0x9f72
leaq 0x284(%rsp), %r12
movq %r15, 0x168(%rsp)
pushq $0x18
popq %rdi
callq 0x4220
movq %rax, %r15
leaq 0x73e6(%rip), %rsi      # 0xc3b3
movq %rax, %rdi
movq %r12, %rdx
callq 0x5266
movq %r15, 0x170(%rsp)
andq $0x0, 0x178(%rsp)
movq (%r14), %rax
movq %rax, 0x20(%rsp)
decl %ebx
movl %ebx, 0xc(%rsp)
addq $0x8, %r14
movq %r14, 0x18(%rsp)
cmpl $0x1, %ebx
jne 0x501d
movq (%r14), %rax
cmpb $0x2d, (%rax)
jne 0x501d
cmpb $0x76, 0x1(%rax)
jne 0x501d
cmpb $0x0, 0x2(%rax)
je 0x51c1
leaq 0x72d6(%rip), %rbp      # 0xc2fa
xorl %r15d, %r15d
leaq 0xc(%rsp), %r14
leaq 0x18(%rsp), %r12
leaq 0x70(%rsp), %r13
testl %ebx, %ebx
jle 0x5099
movq %r14, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x9e7e
cmpl $0x1, %eax
je 0x5087
cmpl $-0x1, %eax
jne 0x5065
movq 0xd1b7(%rip), %rdi      # 0x12210
movq 0x20(%rsp), %rsi
callq 0x528f
jmp 0x5087
testb $0x1, %r15b
je 0x507c
movq 0xd19e(%rip), %rdi      # 0x12210
movq 0x20(%rsp), %rsi
callq 0x528f
movq 0x18(%rsp), %rax
movq (%rax), %rbp
movb $0x1, %r15b
movl 0xc(%rsp), %ebx
decl %ebx
movl %ebx, 0xc(%rsp)
addq $0x8, 0x18(%rsp)
jmp 0x5036
movq %rbp, %rdi
callq 0x678e
movq %rax, %rbx
testq %rax, %rax
jne 0x50ba
movq 0xd160(%rip), %rdi      # 0x12210
movq 0x20(%rsp), %rsi
callq 0x528f
cmpb $0x1, 0x8(%rsp)
jne 0x50dc
movq (%rbx), %rax
leaq 0x14(%rsp), %rsi
leaq 0x10(%rsp), %rdx
leaq 0x1b8(%rsp), %rcx
movq %rbx, %rdi
callq *0x10(%rax)
movslq 0x14(%rsp), %rsi
movslq 0x10(%rsp), %rdx
leaq 0x40(%rsp), %rdi
callq 0xabca
movq (%rbx), %rax
leaq 0x1b8(%rsp), %rsi
movq %rbx, %rdi
callq *0x8(%rax)
cmpq $0x0, 0x28(%rsp)
je 0x514f
leaq 0x188(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xabca
movq 0x28(%rsp), %rsi
leaq 0x188(%rsp), %rdi
xorl %edx, %edx
callq 0xad4e
leaq 0x40(%rsp), %rdi
leaq 0x188(%rsp), %rsi
callq 0xac66
leaq 0x188(%rsp), %rdi
callq 0xac02
jmp 0x515e
leaq 0x40(%rsp), %rdi
leaq 0x9(%rsp), %rsi
callq 0xad14
cmpb $0x1, 0x7(%rsp)
jne 0x517a
leaq 0x40(%rsp), %rsi
leaq 0x1b8(%rsp), %rdx
movq %rbx, %rdi
callq 0x86ce
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rsi
leaq 0x1b8(%rsp), %rcx
movq %rbx, %rdx
callq 0x4519
movq 0x38(%rsp), %rsi
leaq 0x40(%rsp), %rdi
callq 0xaf56
leaq 0x40(%rsp), %rdi
callq 0xac02
xorl %eax, %eax
addq $0x2a8, %rsp            # imm = 0x2A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xce18(%rip), %rax      # 0x11fe0
movq (%rax), %rdi
leaq 0x71ec(%rip), %rsi      # 0xc3be
leaq 0x71f6(%rip), %rdx      # 0xc3cf
xorl %eax, %eax
callq 0x42b0
xorl %edi, %edi
callq 0x4250
jmp 0x5256
jmp 0x522e
jmp 0x522e
jmp 0x522e
jmp 0x522e
jmp 0x521b
jmp 0x521b
jmp 0x521b
jmp 0x521b
jmp 0x521b
jmp 0x521b
jmp 0x521b
jmp 0x521b
jmp 0x521b
jmp 0x521b
jmp 0x521b
jmp 0x521b
jmp 0x521b
jmp 0x521b
jmp 0x521b
jmp 0x521b
jmp 0x521b
jmp 0x521b
jmp 0x522e
jmp 0x521b
jmp 0x521b
movq %rax, %rbx
pushq $0x20
jmp 0x5233
jmp 0x522e
jmp 0x522e
jmp 0x522e
jmp 0x522e
jmp 0x522e
jmp 0x522e
movq %rax, %rbx
pushq $0x18
popq %rsi
movq %r15, %rdi
callq 0x4230
movq %rbx, %rdi
callq 0x4360
movq %rax, %rbx
leaq 0x188(%rsp), %rdi
callq 0xac02
jmp 0x5259
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0xac02
jmp 0x523c
nop