// File: /workspace/github_cpp_makefile_star2_O1/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 0x6280
movq %rsi, %r15
movl %edi, %ebp
leaq 0x4e03e(%rip), %r12     # 0x540d0
leaq 0x8(%r15), %rbx
leal -0x1(%rbp), %r14d
movq 0x8(%r15), %r13
cmpb $0x2d, (%r13)
jne 0x6139
movq %r13, %rdi
leaq 0x4dfde(%rip), %rsi     # 0x54091
callq 0x5490
testl %eax, %eax
je 0x6155
movq %r13, %rdi
leaq 0x4dfca(%rip), %rsi     # 0x54094
callq 0x5490
testl %eax, %eax
je 0x61f0
movq %r13, %rdi
leaq 0x4dfba(%rip), %rsi     # 0x5409b
callq 0x5490
testl %eax, %eax
je 0x61f9
movq %r13, %rdi
leaq 0x4dfa9(%rip), %rsi     # 0x540a1
callq 0x5490
testl %eax, %eax
je 0x6213
movq %r13, %rdi
leaq 0x4df99(%rip), %rsi     # 0x540a8
callq 0x5490
testl %eax, %eax
jne 0x652d
addl $-0x2, %ebp
movq 0x10(%r15), %rsi
addq $0x10, %r15
movl 0x6f3b7(%rip), %edx     # 0x754e4
leaq 0x6f3a4(%rip), %rdi     # 0x754d8
jmp 0x622b
movq %r13, %rdi
movq %r12, %rsi
callq 0x50d0
testq %rax, %rax
je 0x6161
movq %r13, 0x6f3a0(%rip)     # 0x754f0
jmp 0x6236
movb $0x1, 0x6f38c(%rip)     # 0x754e8
jmp 0x6236
movq %r13, %rdi
leaq 0x4df69(%rip), %rsi     # 0x540d4
callq 0x50d0
testq %rax, %rax
jne 0x61d9
movq %r13, %rdi
leaq 0x4df5a(%rip), %rsi     # 0x540d9
callq 0x50d0
testq %rax, %rax
jne 0x61d9
movq %r13, %rdi
leaq 0x4df4b(%rip), %rsi     # 0x540de
callq 0x50d0
testq %rax, %rax
jne 0x61d9
movq %r13, %rdi
leaq 0x4df3d(%rip), %rsi     # 0x540e4
callq 0x50d0
testq %rax, %rax
jne 0x61d9
movq %r13, %rdi
leaq 0x4df2f(%rip), %rsi     # 0x540ea
callq 0x50d0
testq %rax, %rax
jne 0x61d9
movq %r13, %rdi
leaq 0x4df20(%rip), %rsi     # 0x540ef
callq 0x50d0
testq %rax, %rax
je 0x6248
movl 0x6f2e5(%rip), %edx     # 0x754c4
leaq 0x6f2d2(%rip), %rdi     # 0x754b8
movq %r13, %rsi
callq 0x21e7a
jmp 0x6236
movb $0x1, 0x6f305(%rip)     # 0x754fc
jmp 0x6236
addl $-0x2, %ebp
movq 0x10(%r15), %rsi
addq $0x10, %r15
movl 0x6f2ca(%rip), %edx     # 0x754d4
leaq 0x6f2b7(%rip), %rdi     # 0x754c8
jmp 0x622b
addl $-0x2, %ebp
movq 0x10(%r15), %rsi
addq $0x10, %r15
movl 0x6f2a0(%rip), %edx     # 0x754c4
leaq 0x6f28d(%rip), %rdi     # 0x754b8
callq 0x21e7a
movl %ebp, %r14d
movq %r15, %rbx
movq %rbx, %r15
movl %r14d, %ebp
cmpl $0x1, %r14d
jg 0x6092
jmp 0x6280
movq %r13, %rdi
leaq 0x4dea2(%rip), %rsi     # 0x540f4
callq 0x50d0
testq %rax, %rax
je 0x626e
movl 0x6f272(%rip), %edx     # 0x754d4
leaq 0x6f25f(%rip), %rdi     # 0x754c8
jmp 0x61e6
movl 0x6f270(%rip), %edx     # 0x754e4
leaq 0x6f25d(%rip), %rdi     # 0x754d8
jmp 0x61e6
movl 0x6f24e(%rip), %eax     # 0x754d4
orl 0x6f258(%rip), %eax     # 0x754e4
orl 0x6f232(%rip), %eax     # 0x754c4
sete %al
cmpq $0x0, 0x6f253(%rip)     # 0x754f0
je 0x6548
testb %al, %al
jne 0x6548
movq %rsp, %rbx
movq %rbx, %rdi
callq 0x21b48
movq %rbx, %rdi
xorl %esi, %esi
callq 0x5590
cmpb $0x1, 0x6f221(%rip)     # 0x754e8
jne 0x62ed
movq 0x6f220(%rip), %rsi     # 0x754f0
leaq 0x4dd2d(%rip), %rdi     # 0x54004
xorl %eax, %eax
callq 0x5060
movq 0x6ecbb(%rip), %rax     # 0x74fa0
movq (%rax), %rdi
callq 0x5390
leaq 0x10(%rsp), %rbx
movq %rbx, %rdi
callq 0x6640
movq 0x6f1ef(%rip), %rsi     # 0x754f0
leaq 0x4dd11(%rip), %rdx     # 0x54019
movq %rbx, %rdi
callq 0x7048
testl %eax, %eax
je 0x6558
cmpl $0x0, 0x6f1a5(%rip)     # 0x754c4
jle 0x6353
xorl %r14d, %r14d
leaq 0x10(%rsp), %rbx
movq 0x6f188(%rip), %rax     # 0x754b8
movq (%rax,%r14,8), %rsi
movq %rbx, %rdi
callq 0x65a7
testl %eax, %eax
je 0x6523
incq %r14
movslq 0x6f176(%rip), %rax     # 0x754c4
cmpq %rax, %r14
jl 0x6329
cmpl $0x0, 0x6f17a(%rip)     # 0x754d4
jle 0x63e1
leaq 0x4e1cb(%rip), %r14     # 0x54532
leaq 0x70(%rsp), %r15
leaq 0x10(%rsp), %r12
xorl %ebx, %ebx
movq 0x6f14e(%rip), %rax     # 0x754c8
movq (%rax,%rbx,8), %rbp
movq %rbp, %rdi
leaq 0x50fdb(%rip), %rsi     # 0x57363
callq 0x53a0
testq %rax, %rax
je 0x64ff
movq %rax, %r13
movq %r13, %rdi
movq %r14, %rsi
movq %r15, %rdx
xorl %eax, %eax
callq 0x5610
movl %eax, %ebp
cmpl $0x1, %eax
jne 0x63c1
movq %r12, %rdi
movq %r15, %rsi
callq 0x65a7
testl %eax, %eax
jne 0x6399
jmp 0x63c9
movq %r13, %rdi
callq 0x5310
cmpl $0x1, %ebp
je 0x6523
incq %rbx
movslq 0x6f0f8(%rip), %rax     # 0x754d4
cmpq %rax, %rbx
jl 0x6373
cmpl $0x0, 0x6f0fc(%rip)     # 0x754e4
jle 0x648d
leaq 0x4dd72(%rip), %rbx     # 0x54167
leaq 0x70(%rsp), %r14
leaq 0x10(%rsp), %r15
xorl %ebp, %ebp
movq 0x6f0d0(%rip), %rax     # 0x754d8
movq (%rax,%rbp,8), %r12
movq %r12, %rdi
callq 0x5510
testq %rax, %rax
je 0x6512
movq %rax, %r13
movq %rax, %rdi
callq 0x5520
testq %rax, %rax
je 0x6472
movl $0x4, %ecx
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 0x65a7
movl %eax, %ecx
xorl $0x1, %ecx
testb $0x3, %cl
jne 0x6523
movq %r13, %rdi
callq 0x5520
jmp 0x6428
movq %r13, %rdi
callq 0x5580
incq %rbp
movslq 0x6f060(%rip), %rax     # 0x754e4
cmpq %rax, %rbp
jl 0x6401
leaq 0x10(%rsp), %rdi
callq 0x7166
testl %eax, %eax
je 0x656f
cmpb $0x1, 0x6f042(%rip)     # 0x754e8
jne 0x64e1
movq %rsp, %rdi
callq 0x21baa
leaq 0x4dbba(%rip), %rdi     # 0x54071
movb $0x1, %al
callq 0x5060
movl 0x6f034(%rip), %esi     # 0x754f8
leaq 0x4dbb5(%rip), %rdi     # 0x54080
xorl %eax, %eax
callq 0x5060
movq 0x6eac7(%rip), %rax     # 0x74fa0
movq (%rax), %rdi
callq 0x5390
leaq 0x10(%rsp), %rdi
callq 0x6742
xorl %eax, %eax
addq $0x1078, %rsp           # imm = 0x1078
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x4dc22(%rip), %rdi     # 0x54128
movq %rbp, %rsi
xorl %eax, %eax
callq 0x24b9e
jmp 0x6523
leaq 0x4dc31(%rip), %rdi     # 0x5414a
movq %r12, %rsi
xorl %eax, %eax
callq 0x24b9e
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x53c0
leaq 0x4db7f(%rip), %rdi     # 0x540b3
movq %r13, %rsi
xorl %eax, %eax
callq 0x24b9e
movl $0x1, %edi
callq 0x53c0
leaq 0x4dbaa(%rip), %rdi     # 0x540f9
xorl %eax, %eax
callq 0x24b9e
jmp 0x6523
movq 0x6ef91(%rip), %rsi     # 0x754f0
leaq 0x4dab6(%rip), %rdi     # 0x5401c
xorl %eax, %eax
callq 0x24b9e
jmp 0x6523
movq 0x6ef7a(%rip), %rsi     # 0x754f0
leaq 0x4dac9(%rip), %rdi     # 0x54046
xorl %eax, %eax
callq 0x24b9e
jmp 0x6523
jmp 0x6592
jmp 0x6592
jmp 0x6592
jmp 0x6592
jmp 0x6592
jmp 0x6592
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x6742
movq %rbx, %rdi
callq 0x55d0