// File: matthewarcus[P]mmps/addgrid.cpp
// Function: main
int main(int argc, char* argv[])
{
  Image inImage;
  char* infilename = NULL;

  double gridx = 10.0;
  double gridy = 10.0;
  Rgb gridcolor(0,0,0);

  char *progname = argv[0];
  argc--;argv++;
  while (argc > 0 && argv[0][0] == '-') {
    if (strcmp(argv[0], "-grid") == 0) {
      argc--; argv++;
      if (argc == 0) { error(usage, progname); };
      gridx = strtod(argv[0],NULL);
      gridy = gridx;
    } else if (strcmp(argv[0], "-gridx") == 0) {
      argc--; argv++;
      if (argc == 0) { error(usage, progname); };
      gridx = strtod(argv[0],NULL);
    } else if (strcmp(argv[0], "-gridy") == 0) {
      argc--; argv++;
      if (argc == 0) { error(usage, progname); };
      gridy = strtod(argv[0],NULL);
    } else {
      error(usage, progname);
    }
    argc--; argv++;
  }
  if (argc != 1) {
    error(usage, progname);
  }

  infilename = argv[0];

  inImage.Read(infilename, true);
  inImage.AddGrid(gridx, gridy, gridcolor);
  inImage.Close();
  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
xorl %eax, %eax
movl %eax, -0x7c(%rbp)
movl %eax, %edx
leaq -0x40(%rbp), %rdi
movq %rdx, %rsi
callq 0x11780
movl -0x7c(%rbp), %ecx
movq $0x0, -0x48(%rbp)
movabsq $0x4024000000000000, %rax # imm = 0x4024000000000000
movq %rax, -0x50(%rbp)
movq %rax, -0x58(%rbp)
leaq -0x5b(%rbp), %rdi
movl %ecx, %esi
movl %ecx, %edx
callq 0x5db0
jmp 0x5b68
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x78(%rbp)
movl -0x8(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x8(%rbp)
movq -0x10(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x10(%rbp)
xorl %eax, %eax
cmpl $0x0, -0x8(%rbp)
movb %al, -0x7d(%rbp)
jle 0x5ba6
movq -0x10(%rbp), %rax
movq (%rax), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
sete %al
movb %al, -0x7d(%rbp)
movb -0x7d(%rbp), %al
testb $0x1, %al
jne 0x5bb2
jmp 0x5d25
movq -0x10(%rbp), %rax
movq (%rax), %rdi
leaq 0xd472(%rip), %rsi      # 0x13032
callq 0x5330
cmpl $0x0, %eax
jne 0x5c37
movl -0x8(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x8(%rbp)
movq -0x10(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x10(%rbp)
cmpl $0x0, -0x8(%rbp)
jne 0x5c13
movq 0x1565c(%rip), %rdi     # 0x1b248
movq -0x78(%rbp), %rsi
callq 0x5de0
jmp 0x5bf7
jmp 0x5c13
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x11840
jmp 0x5d9e
movq -0x10(%rbp), %rax
movq (%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x51e0
movsd %xmm0, -0x50(%rbp)
movsd -0x50(%rbp), %xmm0
movsd %xmm0, -0x58(%rbp)
jmp 0x5d0b
movq -0x10(%rbp), %rax
movq (%rax), %rdi
leaq 0xd3f3(%rip), %rsi      # 0x13038
callq 0x5330
cmpl $0x0, %eax
jne 0x5c95
movl -0x8(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x8(%rbp)
movq -0x10(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x10(%rbp)
cmpl $0x0, -0x8(%rbp)
jne 0x5c7e
movq 0x155d7(%rip), %rdi     # 0x1b248
movq -0x78(%rbp), %rsi
callq 0x5de0
jmp 0x5c7c
jmp 0x5c7e
movq -0x10(%rbp), %rax
movq (%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x51e0
movsd %xmm0, -0x50(%rbp)
jmp 0x5d09
movq -0x10(%rbp), %rax
movq (%rax), %rdi
leaq 0xd39c(%rip), %rsi      # 0x1303f
callq 0x5330
cmpl $0x0, %eax
jne 0x5cf3
movl -0x8(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x8(%rbp)
movq -0x10(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x10(%rbp)
cmpl $0x0, -0x8(%rbp)
jne 0x5cdc
movq 0x15579(%rip), %rdi     # 0x1b248
movq -0x78(%rbp), %rsi
callq 0x5de0
jmp 0x5cda
jmp 0x5cdc
movq -0x10(%rbp), %rax
movq (%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x51e0
movsd %xmm0, -0x58(%rbp)
jmp 0x5d07
movq 0x1554e(%rip), %rdi     # 0x1b248
movq -0x78(%rbp), %rsi
callq 0x5de0
jmp 0x5d05
jmp 0x5d07
jmp 0x5d09
jmp 0x5d0b
movl -0x8(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x8(%rbp)
movq -0x10(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x10(%rbp)
jmp 0x5b88
cmpl $0x1, -0x8(%rbp)
je 0x5d3f
movq 0x15516(%rip), %rdi     # 0x1b248
movq -0x78(%rbp), %rsi
callq 0x5de0
jmp 0x5d3d
jmp 0x5d3f
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rsi
leaq -0x40(%rbp), %rdi
movl $0x1, %edx
callq 0x11ad0
jmp 0x5d5e
movsd -0x50(%rbp), %xmm0
movsd -0x58(%rbp), %xmm1
leaq -0x40(%rbp), %rdi
leaq -0x5b(%rbp), %rsi
callq 0x12060
jmp 0x5d77
leaq -0x40(%rbp), %rdi
callq 0x11870
jmp 0x5d82
movl $0x0, -0x4(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x11840
movl -0x4(%rbp), %eax
addq $0x80, %rsp
popq %rbp
retq
movq -0x68(%rbp), %rdi
callq 0x53f0
nopw (%rax,%rax)