// File: /workspace/github_cpp_makefile_star2_O3/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
movq %rsi, %rbx
movl %edi, %r14d
movl %edi, 0xc(%rsp)
movq %rsi, 0x18(%rsp)
xorl %r13d, %r13d
movq %r13, 0x38(%rsp)
movq %r13, 0x28(%rsp)
movq %r13, 0x30(%rsp)
leaq 0x14(%rsp), %r12
movl $0x320, (%r12)          # imm = 0x320
movl $0x258, 0x10(%rsp)      # imm = 0x258
movb %r13b, 0x8(%rsp)
movb %r13b, 0x7(%rsp)
leaq 0x180(%rsp), %r15
movq %r15, %rdi
callq 0x5ea6
movw %r13w, 0xcc(%r15)
movb $0x3c, 0xce(%r15)
movw %r13w, 0x9(%rsp)
movb %r13b, 0xb(%rsp)
movl $0x18, %edi
callq 0x4210
movq %rax, %r15
leaq 0x8777(%rip), %rsi      # 0xd306
movq %rax, %rdi
movq %r12, %rdx
callq 0xacac
movq %r15, 0x40(%rsp)
movl $0x18, %edi
callq 0x4210
movq %rax, %r15
leaq 0x8756(%rip), %rsi      # 0xd309
leaq 0x10(%rsp), %rdx
movq %rax, %rdi
callq 0xacac
movq %r15, 0x48(%rsp)
movl $0x18, %edi
callq 0x4210
movq %rax, %r15
leaq 0x8733(%rip), %rsi      # 0xd30c
leaq 0x8(%rsp), %rdx
movq %rax, %rdi
callq 0xabf6
movq %r15, 0x50(%rsp)
movl $0x18, %edi
callq 0x4210
movq %rax, %r15
leaq 0x8715(%rip), %rsi      # 0xd314
leaq 0x30(%rsp), %rdx
movq %rax, %rdi
callq 0xac34
movq %r15, 0x58(%rsp)
movl $0x18, %edi
callq 0x4210
movq %rax, %r15
leaq 0x86f2(%rip), %rsi      # 0xd317
leaq 0x38(%rsp), %rdx
movq %rax, %rdi
callq 0xac34
movq %r15, 0x60(%rsp)
movl $0x18, %edi
callq 0x4210
movq %rax, %r15
leaq 0x86d1(%rip), %rsi      # 0xd31c
leaq 0x28(%rsp), %rdx
movq %rax, %rdi
callq 0xac34
movq %r15, 0x68(%rsp)
movl $0x18, %edi
callq 0x4210
movq %rax, %r15
leaq 0x86b1(%rip), %rsi      # 0xd322
movq %rax, %rdi
callq 0xabb2
leaq 0xe0f8(%rip), %r12      # 0x12d78
addq $0x10, %r12
movq %r12, (%r15)
leaq 0x9(%rsp), %rax
movq %rax, 0x10(%r15)
movq %r15, 0x70(%rsp)
movl $0x20, %edi
callq 0x4210
movq %rax, %r15
leaq 0x867d(%rip), %rsi      # 0xd326
leaq 0xe570(%rip), %rdx      # 0x13220
movsd 0x8390(%rip), %xmm0     # 0xd048
movq %rax, %rdi
callq 0xad2c
movq %r15, 0x78(%rsp)
movl $0x20, %edi
callq 0x4210
movq %rax, %r15
leaq 0x8653(%rip), %rsi      # 0xd32c
leaq 0xe508(%rip), %rdx      # 0x131e8
movsd 0x8360(%rip), %xmm0     # 0xd048
movq %rax, %rdi
callq 0xad2c
movq %r15, 0x80(%rsp)
movl $0x20, %edi
callq 0x4210
movq %rax, %r15
leaq 0x8629(%rip), %rsi      # 0xd335
leaq 0xe4cd(%rip), %rdx      # 0x131e0
movsd 0x832d(%rip), %xmm0     # 0xd048
movq %rax, %rdi
callq 0xad2c
movq %r15, 0x88(%rsp)
movl $0x18, %edi
callq 0x4210
movq %rax, %r15
leaq 0x85fe(%rip), %rsi      # 0xd33d
leaq 0xe4d2(%rip), %rdx      # 0x13218
movq %rax, %rdi
callq 0xabf6
movq %r15, 0x90(%rsp)
movl $0x20, %edi
callq 0x4210
movq %rax, %r15
leaq 0x85d7(%rip), %rsi      # 0xd341
leaq 0xe47f(%rip), %rdx      # 0x131f0
movsd 0x82cf(%rip), %xmm0     # 0xd048
movq %rax, %rdi
callq 0xad2c
movq %r15, 0x98(%rsp)
movl $0x20, %edi
callq 0x4210
movq %rax, %r15
leaq 0x85ac(%rip), %rsi      # 0xd349
leaq 0x180(%rsp), %rdx
movsd 0x82a3(%rip), %xmm0     # 0xd050
movq %rax, %rdi
callq 0xad2c
movq %r15, 0xa0(%rsp)
movl $0x20, %edi
callq 0x4210
movq %rax, %r15
leaq 0x188(%rsp), %rdx
leaq 0x8576(%rip), %rsi      # 0xd34f
movsd 0x826f(%rip), %xmm0     # 0xd050
movq %rax, %rdi
callq 0xad2c
movq %r15, 0xa8(%rsp)
movl $0x20, %edi
callq 0x4210
movq %rax, %r15
leaq 0x198(%rsp), %rdx
leaq 0x8548(%rip), %rsi      # 0xd355
movsd 0x823b(%rip), %xmm0     # 0xd050
movq %rax, %rdi
callq 0xad2c
movq %r15, 0xb0(%rsp)
movl $0x20, %edi
callq 0x4210
movq %rax, %r15
leaq 0x1a0(%rsp), %rdx
leaq 0x8519(%rip), %rsi      # 0xd35a
movsd 0x820f(%rip), %xmm0     # 0xd058
movq %rax, %rdi
callq 0xad2c
movq %r15, 0xb8(%rsp)
movl $0x20, %edi
callq 0x4210
movq %rax, %r15
leaq 0x1a8(%rsp), %rdx
leaq 0x84e9(%rip), %rsi      # 0xd35e
movsd 0x81cb(%rip), %xmm0     # 0xd048
movq %rax, %rdi
callq 0xad2c
movq %r15, 0xc0(%rsp)
movl $0x20, %edi
callq 0x4210
movq %rax, %r15
leaq 0x1c8(%rsp), %rdx
leaq 0x84bc(%rip), %rsi      # 0xd365
movsd 0x8197(%rip), %xmm0     # 0xd048
movq %rax, %rdi
callq 0xad2c
movq %r15, 0xc8(%rsp)
movl $0x20, %edi
callq 0x4210
movq %rax, %r15
leaq 0x1d0(%rsp), %rdx
leaq 0x848b(%rip), %rsi      # 0xd368
movsd 0x8163(%rip), %xmm0     # 0xd048
movq %rax, %rdi
callq 0xad2c
movq %r15, 0xd0(%rsp)
movl $0x20, %edi
callq 0x4210
movq %rax, %r15
leaq 0x1d8(%rsp), %rdx
leaq 0x845a(%rip), %rsi      # 0xd36b
movsd 0x812f(%rip), %xmm0     # 0xd048
movq %rax, %rdi
callq 0xad2c
movq %r15, 0xd8(%rsp)
movl $0x20, %edi
callq 0x4210
movq %rax, %r15
leaq 0x1b8(%rsp), %rdx
leaq 0x8429(%rip), %rsi      # 0xd36e
movsd 0x80fb(%rip), %xmm0     # 0xd048
movq %rax, %rdi
callq 0xad2c
movq %r15, 0xe0(%rsp)
movl $0x20, %edi
callq 0x4210
movq %rax, %r15
leaq 0x210(%rsp), %rdx
leaq 0x83f8(%rip), %rsi      # 0xd371
movsd 0x80c7(%rip), %xmm0     # 0xd048
movq %rax, %rdi
callq 0xad2c
movq %r15, 0xe8(%rsp)
movl $0x20, %edi
callq 0x4210
movq %rax, %r15
leaq 0x208(%rsp), %rdx
leaq 0x83ca(%rip), %rsi      # 0xd377
movsd 0x80ab(%rip), %xmm0     # 0xd060
movq %rax, %rdi
callq 0xad2c
movq %r15, 0xf0(%rsp)
movl $0x20, %edi
callq 0x4210
movq %rax, %r15
leaq 0x200(%rsp), %rdx
leaq 0x839c(%rip), %rsi      # 0xd37d
movsd 0x8067(%rip), %xmm0     # 0xd050
movq %rax, %rdi
callq 0xad2c
movq %r15, 0xf8(%rsp)
movl $0x20, %edi
callq 0x4210
movq %rax, %r15
leaq 0x1c0(%rsp), %rdx
leaq 0x836b(%rip), %rsi      # 0xd380
movsd 0x8033(%rip), %xmm0     # 0xd050
movq %rax, %rdi
callq 0xad2c
movq %r15, 0x100(%rsp)
movl $0x20, %edi
callq 0x4210
movq %rax, %r15
leaq 0x220(%rsp), %rdx
leaq 0x833b(%rip), %rsi      # 0xd384
movsd 0x7ff7(%rip), %xmm0     # 0xd048
movq %rax, %rdi
callq 0xad2c
movq %r15, 0x108(%rsp)
movl $0x20, %edi
callq 0x4210
movq %rax, %r15
leaq 0x228(%rsp), %rdx
leaq 0x830e(%rip), %rsi      # 0xd38b
movsd 0x7fc3(%rip), %xmm0     # 0xd048
movq %rax, %rdi
callq 0xad2c
movq %r15, 0x110(%rsp)
movl $0x20, %edi
callq 0x4210
movq %rax, %r15
leaq 0x230(%rsp), %rdx
leaq 0x82e2(%rip), %rsi      # 0xd393
movsd 0x7f8f(%rip), %xmm0     # 0xd048
movq %rax, %rdi
callq 0xad2c
movq %r15, 0x118(%rsp)
movl $0x20, %edi
callq 0x4210
movq %rax, %r15
leaq 0x238(%rsp), %rdx
leaq 0x82b4(%rip), %rsi      # 0xd399
movsd 0x7f5b(%rip), %xmm0     # 0xd048
movq %rax, %rdi
callq 0xad2c
movq %r15, 0x120(%rsp)
movl $0x18, %edi
callq 0x4210
movq %rax, %r15
leaq 0x828e(%rip), %rsi      # 0xd39f
leaq 0x7(%rsp), %rdx
movq %rax, %rdi
callq 0xabf6
movq %r15, 0x128(%rsp)
movl $0x18, %edi
callq 0x4210
movq %rax, %r15
leaq 0x244(%rsp), %rdx
leaq 0x8263(%rip), %rsi      # 0xd3a5
movq %rax, %rdi
callq 0xacac
movq %r15, 0x130(%rsp)
movl $0x18, %edi
callq 0x4210
movq %rax, %r15
leaq 0x248(%rsp), %rdx
leaq 0x823e(%rip), %rsi      # 0xd3ac
movq %rax, %rdi
callq 0xacac
movq %r15, 0x138(%rsp)
movl $0x18, %edi
callq 0x4210
movq %rax, %r15
leaq 0x8221(%rip), %rsi      # 0xd3b3
movq %rax, %rdi
callq 0xabb2
leaq 0x24c(%rsp), %rax
movq %r12, (%r15)
movq %rax, 0x10(%r15)
movq %r15, 0x140(%rsp)
movq $0x0, 0x148(%rsp)
movq (%rbx), %rax
movq %rax, 0x20(%rsp)
leal -0x1(%r14), %eax
movl %eax, 0xc(%rsp)
addq $0x8, %rbx
movq %rbx, 0x18(%rsp)
cmpl $0x1, %eax
jne 0x51f4
movq (%rbx), %rax
cmpb $0x2d, (%rax)
jne 0x51fe
cmpb $0x76, 0x1(%rax)
jne 0x51fe
cmpb $0x0, 0x2(%rax)
jne 0x51fe
callq 0x43b0
cmpl $0x2, %r14d
jl 0x52ac
leaq 0x80f5(%rip), %rbp      # 0xd2fa
xorl %r15d, %r15d
leaq 0xc(%rsp), %rbx
leaq 0x18(%rsp), %r14
leaq 0x40(%rsp), %r12
leaq 0x270(%rsp), %r13
movq %rbx, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0xabc2
cmpl $0x1, %eax
je 0x5290
cmpl $-0x1, %eax
jne 0x525c
movq 0xdfba(%rip), %rdx      # 0x131f8
movl $0x400, %esi            # imm = 0x400
movq %r13, %rdi
movq 0x20(%rsp), %rcx
xorl %eax, %eax
callq 0x42c0
movq %r13, %rdi
callq 0xab5c
jmp 0x5290
testb $0x1, %r15b
je 0x5285
movq 0xdf8f(%rip), %rdx      # 0x131f8
movl $0x400, %esi            # imm = 0x400
movq %r13, %rdi
movq 0x20(%rsp), %rcx
xorl %eax, %eax
callq 0x42c0
movq %r13, %rdi
callq 0xab5c
movq 0x18(%rsp), %rax
movq (%rax), %rbp
movb $0x1, %r15b
movl 0xc(%rsp), %eax
leal -0x1(%rax), %ecx
movl %ecx, 0xc(%rsp)
addq $0x8, 0x18(%rsp)
cmpl $0x1, %eax
jg 0x521f
jmp 0x52b3
leaq 0x8047(%rip), %rbp      # 0xd2fa
movq %rbp, %rdi
callq 0x6ffc
movq %rax, %rbx
testq %rax, %rax
jne 0x52ee
movq 0xdf2e(%rip), %rdx      # 0x131f8
leaq 0x270(%rsp), %r14
movl $0x400, %esi            # imm = 0x400
movq %r14, %rdi
movq 0x20(%rsp), %rcx
xorl %eax, %eax
callq 0x42c0
movq %r14, %rdi
callq 0xab5c
cmpb $0x1, 0x8(%rsp)
jne 0x5310
movq (%rbx), %rax
leaq 0x14(%rsp), %rsi
leaq 0x10(%rsp), %rdx
leaq 0x180(%rsp), %rcx
movq %rbx, %rdi
callq *0x10(%rax)
movslq 0x14(%rsp), %rsi
movslq 0x10(%rsp), %rdx
leaq 0x270(%rsp), %rdi
callq 0xb9f8
movq (%rbx), %rax
leaq 0x180(%rsp), %rsi
movq %rbx, %rdi
callq *0x8(%rax)
cmpq $0x0, 0x28(%rsp)
je 0x5389
leaq 0x150(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xb9f8
movq 0x28(%rsp), %rsi
leaq 0x150(%rsp), %rdi
xorl %edx, %edx
callq 0xbbe6
leaq 0x270(%rsp), %rdi
leaq 0x150(%rsp), %rsi
callq 0xbab4
leaq 0x150(%rsp), %rdi
callq 0xba4c
jmp 0x539b
leaq 0x270(%rsp), %rdi
leaq 0x9(%rsp), %rsi
callq 0xbba0
cmpb $0x1, 0x7(%rsp)
jne 0x53ba
leaq 0x270(%rsp), %rsi
leaq 0x180(%rsp), %rdx
movq %rbx, %rdi
callq 0x9018
movq 0x30(%rsp), %rdi
leaq 0x270(%rsp), %rsi
leaq 0x180(%rsp), %rcx
movq %rbx, %rdx
callq 0x4679
movq 0x38(%rsp), %rsi
leaq 0x270(%rsp), %rdi
callq 0xbe0a
leaq 0x270(%rsp), %rdi
callq 0xba4c
xorl %eax, %eax
addq $0x678, %rsp            # imm = 0x678
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x547e
jmp 0x5454
jmp 0x5454
jmp 0x5454
jmp 0x5454
jmp 0x543e
jmp 0x543e
jmp 0x543e
jmp 0x543e
jmp 0x543e
jmp 0x543e
jmp 0x543e
jmp 0x543e
jmp 0x543e
jmp 0x543e
jmp 0x543e
jmp 0x543e
jmp 0x543e
jmp 0x543e
jmp 0x543e
jmp 0x543e
jmp 0x543e
jmp 0x543e
jmp 0x5454
jmp 0x543e
jmp 0x543e
movq %rax, %rbx
movl $0x20, %esi
jmp 0x545c
jmp 0x5454
jmp 0x5454
jmp 0x5454
jmp 0x5454
jmp 0x5454
jmp 0x5454
movq %rax, %rbx
movl $0x18, %esi
movq %r15, %rdi
callq 0x4220
movq %rbx, %rdi
callq 0x4330
movq %rax, %rbx
leaq 0x150(%rsp), %rdi
callq 0xba4c
jmp 0x5481
movq %rax, %rbx
leaq 0x270(%rsp), %rdi
callq 0xba4c
jmp 0x5464