// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/apps/img2pd/img2pd.cpp
// Function: main
static int 
ParseArgs(int argc, char **argv)
{
  // Parse arguments
  argc--; argv++;
  while (argc > 0) {
    if ((*argv)[0] == '-') {
      if (!strcmp(*argv, "-v")) {
        print_verbose = 1;
      }
      else if (!strcmp(*argv, "-debug")) {
        print_debug = 1;
      }
      else if (!strcmp(*argv, "-list")) {
        argc--; argv++; input_list_filenames.Insert(*argv);
      }
      else if (!strcmp(*argv, "-image")) {
        argc--; argv++; input_image_filenames.Insert(*argv);
      }
      else if (!strcmp(*argv, "-directory")) {
        argc--; argv++; input_image_directories.Insert(*argv);
      }
      else {
        RNFail("Invalid program argument: %s", *argv);
        exit(1);
      }
      argv++; argc--;
    }
    else {
      if (strstr(*argv, ".pd")) output_pixel_database_filename = *argv;
      else if (strstr(*argv, ".png")) input_image_filenames.Insert(*argv);
      else if (strstr(*argv, ".PNG")) input_image_filenames.Insert(*argv);
      else if (strstr(*argv, ".jpeg")) input_image_filenames.Insert(*argv);
      else if (strstr(*argv, ".JPEG")) input_image_filenames.Insert(*argv);
      else if (strstr(*argv, ".jpg")) input_image_filenames.Insert(*argv);
      else if (strstr(*argv, ".JPG")) input_image_filenames.Insert(*argv);
      else if (strstr(*argv, ".txt")) input_list_filenames.Insert(*argv);
      else input_image_directories.Insert(*argv);
      argv++; argc--;
    }
  }

  // Check inputs
  RNBoolean input_found = FALSE;
  if (!input_image_filenames.IsEmpty()) input_found = TRUE;
  if (!input_list_filenames.IsEmpty()) input_found = TRUE;
  if (!input_image_directories.IsEmpty()) input_found = TRUE;
  
  // Check program arguments
  if (!output_pixel_database_filename || !input_found) {
    RNFail("Usage: img2pd output.pd [inputoptions].\n");
    return 0;
  }

  // Return OK status 
  return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1078, %rsp           # imm = 0x1078
cmpl $0x2, %edi
jl 0x628e
movq %rsi, %r15
movl %edi, %r13d
leaq 0x4f02a(%rip), %rbp     # 0x550cd
leaq 0x8(%r15), %rbx
leal -0x1(%r13), %r14d
movq 0x8(%r15), %r12
cmpb $0x2d, (%r12)
jne 0x6148
cmpb $0x76, 0x1(%r12)
jne 0x60ce
cmpb $0x0, 0x2(%r12)
je 0x6217
movq %r12, %rdi
leaq 0x4efb9(%rip), %rsi     # 0x55091
callq 0x54a0
testl %eax, %eax
je 0x61f3
movq %r12, %rdi
leaq 0x4efa9(%rip), %rsi     # 0x55098
callq 0x54a0
testl %eax, %eax
je 0x61fc
movq %r12, %rdi
leaq 0x4ef98(%rip), %rsi     # 0x5509e
callq 0x54a0
testl %eax, %eax
je 0x6220
movq %r12, %rdi
leaq 0x4ef88(%rip), %rsi     # 0x550a5
callq 0x54a0
testl %eax, %eax
jne 0x6520
addl $-0x2, %r13d
movq 0x10(%r15), %rsi
addq $0x10, %r15
movl 0x703a8(%rip), %edx     # 0x764e4
leaq 0x70395(%rip), %rdi     # 0x764d8
jmp 0x6239
movq %r12, %rdi
movq %rbp, %rsi
callq 0x50d0
testq %rax, %rax
je 0x6164
movq %r12, 0x70391(%rip)     # 0x764f0
jmp 0x6244
movq %r12, %rdi
leaq 0x4ef63(%rip), %rsi     # 0x550d1
callq 0x50d0
testq %rax, %rax
jne 0x61dc
movq %r12, %rdi
leaq 0x4ef54(%rip), %rsi     # 0x550d6
callq 0x50d0
testq %rax, %rax
jne 0x61dc
movq %r12, %rdi
leaq 0x4ef45(%rip), %rsi     # 0x550db
callq 0x50d0
testq %rax, %rax
jne 0x61dc
movq %r12, %rdi
leaq 0x4ef37(%rip), %rsi     # 0x550e1
callq 0x50d0
testq %rax, %rax
jne 0x61dc
movq %r12, %rdi
leaq 0x4ef29(%rip), %rsi     # 0x550e7
callq 0x50d0
testq %rax, %rax
jne 0x61dc
movq %r12, %rdi
leaq 0x4ef1a(%rip), %rsi     # 0x550ec
callq 0x50d0
testq %rax, %rax
je 0x6256
movl 0x702e2(%rip), %edx     # 0x764c4
leaq 0x702cf(%rip), %rdi     # 0x764b8
movq %r12, %rsi
callq 0x21d1a
jmp 0x6244
movb $0x1, 0x70302(%rip)     # 0x764fc
jmp 0x6244
addl $-0x2, %r13d
movq 0x10(%r15), %rsi
addq $0x10, %r15
movl 0x702c6(%rip), %edx     # 0x764d4
leaq 0x702b3(%rip), %rdi     # 0x764c8
jmp 0x6239
movb $0x1, 0x702ca(%rip)     # 0x764e8
jmp 0x6244
addl $-0x2, %r13d
movq 0x10(%r15), %rsi
addq $0x10, %r15
movl 0x70292(%rip), %edx     # 0x764c4
leaq 0x7027f(%rip), %rdi     # 0x764b8
callq 0x21d1a
movl %r13d, %r14d
movq %r15, %rbx
movq %rbx, %r15
movl %r14d, %r13d
cmpl $0x1, %r14d
jg 0x60a3
jmp 0x628e
movq %r12, %rdi
leaq 0x4ee91(%rip), %rsi     # 0x550f1
callq 0x50d0
testq %rax, %rax
je 0x627c
movl 0x70264(%rip), %edx     # 0x764d4
leaq 0x70251(%rip), %rdi     # 0x764c8
jmp 0x61e9
movl 0x70262(%rip), %edx     # 0x764e4
leaq 0x7024f(%rip), %rdi     # 0x764d8
jmp 0x61e9
movl 0x70240(%rip), %eax     # 0x764d4
orl 0x7024a(%rip), %eax     # 0x764e4
orl 0x70224(%rip), %eax     # 0x764c4
setne %al
cmpq $0x0, 0x70245(%rip)     # 0x764f0
je 0x653b
testb %al, %al
je 0x653b
movq %rsp, %rbx
movq %rbx, %rdi
callq 0x219e8
movq %rbx, %rdi
xorl %esi, %esi
callq 0x55a0
cmpb $0x1, 0x70213(%rip)     # 0x764e8
jne 0x62fb
movq 0x70212(%rip), %rsi     # 0x764f0
leaq 0x4ed1f(%rip), %rdi     # 0x55004
xorl %eax, %eax
callq 0x5060
movq 0x6fcad(%rip), %rax     # 0x75fa0
movq (%rax), %rdi
callq 0x53a0
leaq 0x10(%rsp), %rbx
movq %rbx, %rdi
callq 0x6634
movq 0x701e1(%rip), %rsi     # 0x764f0
leaq 0x4ed03(%rip), %rdx     # 0x55019
movq %rbx, %rdi
callq 0x7034
testl %eax, %eax
je 0x654b
cmpl $0x0, 0x70197(%rip)     # 0x764c4
jle 0x6361
xorl %r14d, %r14d
leaq 0x10(%rsp), %rbx
movq 0x7017a(%rip), %rax     # 0x764b8
movq (%rax,%r14,8), %rsi
movq %rbx, %rdi
callq 0x659a
testl %eax, %eax
je 0x6516
incq %r14
movslq 0x70168(%rip), %rax     # 0x764c4
cmpq %rax, %r14
jl 0x6337
cmpl $0x0, 0x7016c(%rip)     # 0x764d4
jle 0x63e3
leaq 0x4f1c1(%rip), %r14     # 0x55532
leaq 0x70(%rsp), %r15
leaq 0x10(%rsp), %r12
xorl %ebx, %ebx
movq 0x70144(%rip), %rax     # 0x764c8
movq (%rax,%rbx,8), %rbp
movq %rbp, %rdi
leaq 0x52001(%rip), %rsi     # 0x58393
callq 0x53b0
testq %rax, %rax
je 0x64f2
movq %rax, %r13
movq %r13, %rdi
movq %r14, %rsi
movq %r15, %rdx
xorl %eax, %eax
callq 0x5620
cmpl $0x1, %eax
jne 0x63cc
movq %r12, %rdi
movq %r15, %rsi
callq 0x659a
testl %eax, %eax
jne 0x63a3
jmp 0x6516
movq %r13, %rdi
callq 0x5320
incq %rbx
movslq 0x700f6(%rip), %rax     # 0x764d4
cmpq %rax, %rbx
jl 0x637d
cmpl $0x0, 0x700fa(%rip)     # 0x764e4
jle 0x6480
leaq 0x4ed6d(%rip), %rbx     # 0x55164
leaq 0x70(%rsp), %r14
leaq 0x10(%rsp), %r15
xorl %ebp, %ebp
movq 0x700ce(%rip), %rax     # 0x764d8
movq (%rax,%rbp,8), %r12
movq %r12, %rdi
callq 0x5520
testq %rax, %rax
je 0x6505
movq %rax, %r13
movq %rax, %rdi
callq 0x5530
testq %rax, %rax
je 0x6469
cmpb $0x2e, 0x13(%rax)
je 0x645f
addq $0x13, %rax
movq %r14, %rdi
movq %rbx, %rsi
movq %r12, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x50b0
movq %r15, %rdi
movq %r14, %rsi
callq 0x659a
testl %eax, %eax
je 0x6516
movq %r13, %rdi
callq 0x5530
jmp 0x642a
movq %r13, %rdi
callq 0x5590
incq %rbp
movslq 0x70069(%rip), %rax     # 0x764e4
cmpq %rax, %rbp
jl 0x6403
leaq 0x10(%rsp), %rdi
callq 0x7152
testl %eax, %eax
je 0x6562
cmpb $0x1, 0x7004f(%rip)     # 0x764e8
jne 0x64d4
movq %rsp, %rdi
callq 0x21a4a
leaq 0x4ebc7(%rip), %rdi     # 0x55071
movb $0x1, %al
callq 0x5060
movl 0x70041(%rip), %esi     # 0x764f8
leaq 0x4ebc2(%rip), %rdi     # 0x55080
xorl %eax, %eax
callq 0x5060
movq 0x6fad4(%rip), %rax     # 0x75fa0
movq (%rax), %rdi
callq 0x53a0
leaq 0x10(%rsp), %rdi
callq 0x672e
xorl %eax, %eax
addq $0x1078, %rsp           # imm = 0x1078
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x4ec2c(%rip), %rdi     # 0x55125
movq %rbp, %rsi
xorl %eax, %eax
callq 0x24732
jmp 0x6516
leaq 0x4ec3b(%rip), %rdi     # 0x55147
movq %r12, %rsi
xorl %eax, %eax
callq 0x24732
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x53d0
leaq 0x4eb89(%rip), %rdi     # 0x550b0
movq %r12, %rsi
xorl %eax, %eax
callq 0x24732
movl $0x1, %edi
callq 0x53d0
leaq 0x4ebb4(%rip), %rdi     # 0x550f6
xorl %eax, %eax
callq 0x24732
jmp 0x6516
movq 0x6ff9e(%rip), %rsi     # 0x764f0
leaq 0x4eac3(%rip), %rdi     # 0x5501c
xorl %eax, %eax
callq 0x24732
jmp 0x6516
movq 0x6ff87(%rip), %rsi     # 0x764f0
leaq 0x4ead6(%rip), %rdi     # 0x55046
xorl %eax, %eax
callq 0x24732
jmp 0x6516
jmp 0x6585
jmp 0x6585
jmp 0x6585
jmp 0x6585
jmp 0x6585
jmp 0x6585
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x672e
movq %rbx, %rdi
callq 0x55e0