// File: /workspace/github_c_makefile_star2_O1/LenShustek[P]miditones/miditones.c
// Function: HandleOptions
int HandleOptions (int argc, char *argv[]) {
   /* returns the index of the first argument that is not an option,
   i.e. does not start with a dash or a slash */
   int i, firstnonoption = 0;
   for (i = 1; i < argc; i++) {
      if (argv[i][0] == '/' || argv[i][0] == '-') {
         int tempint;
         char *arg = argv[i] + 1;
         if (opt_key(arg, "h") || opt_key(arg, "?")) {
            SayUsage(argv[0]); exit(1); }
         else if (opt_key(arg, "b")) binaryoutput = true;
         else if (opt_int(arg, "c", &channel_mask, 1, 0xffff))
            printf("Channel (track) mask is %04X\n", channel_mask);
         else if (opt_key(arg, "d")) do_header = true;
         else if (opt_key(arg, "dp")) define_progmem = true;
         else if (opt_key(arg, "lg")) loggen = true;
         else if (opt_key(arg, "i")) instrumentoutput = true;
         else if (opt_int(arg, "k", &keyshift, -100, 100))
            printf("Using keyshift %d\n", keyshift);
         else if (opt_key(arg, "lp")) logparse = true;
         else if (opt_int(arg, "n", &outfile_maxitems, 1, INT_MAX));
         else if (opt_key(arg, "p")) parseonly = true;
         else if (opt_key(arg, "pi")) percussion_ignore = true;
         else if (opt_key(arg, "pt")) percussion_translate = true;
         else if (opt_key(arg, "r")) gen_restart = true;
         else if (opt_key(arg, "asm1802")) {
            asm_output = true; comment = ";"; byteop = "    db  "; hex = "$"; outfile_maxitems = 16; }
         else if (opt_key(arg, "asm6502")) {
            asm_output = true; comment = ";"; byteop = "    .byte  "; hex = "$"; outfile_maxitems = 16; }
         else if (opt_int(arg, "delaymin", &tempint, 1, 1000)) delaymin_usec = tempint * 1000;
         else if (opt_int(arg, "releasetime", &tempint, 0, INT_MAX)) releasetime_usec = tempint * 1000;
         else if (opt_int(arg, "notemin", &tempint, 0, INT_MAX)) notemin_usec = tempint * 1000;
         else if (opt_int(arg, "attacktime", &tempint, 0, INT_MAX)) {
            attacktime_usec = tempint * 1000;
            check_option(volume_output, "-attacktime only works with -v"); }
         else if (opt_int(arg, "attacknotemax", &tempint, 0, INT_MAX)) {
            attacknotemax_usec = tempint * 1000;
            check_option(volume_output, "-attacknotemax only works with -v"); }
         else if (opt_int(arg, "sustainlevel", &sustainlevel_pct, 1, 100))
            check_option(volume_output, "-sustainlevel only works with -v");
         else if (opt_key(arg, "s1")) strategy1 = true;
         else if (opt_key(arg, "s2")) strategy2 = true;
         else if (opt_key(arg, "scorename")) scorename = true;
         else if (opt_key(arg, "showskipped")) showskipped = true;
         else if (opt_key(arg, "noduplicates")) noduplicates = true;
         else if (opt_int(arg, "t", &num_tonegens, 1, MAX_TONEGENS))
            printf("Using %d tone generators\n", num_tonegens);
         else if (opt_key(arg, "v")) volume_output = true;
         /* add more  option switches here */
         else {
            fprintf(stderr, "\n*** bad option: %s\n\n", argv[i]);
            SayUsage(argv[0]);
            exit(4); } }
      else {
         firstnonoption = i;
         break; } }
   return firstnonoption; }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, 0x8(%rsp)
cmpl $0x2, %edi
jl 0x1ae9
movl %edi, %eax
movq %rax, 0x10(%rsp)
movl $0x1, %ebx
leaq 0x430a(%rip), %r12      # 0x5887
leaq 0x4306(%rip), %r15      # 0x588a
movq 0x8(%rsp), %rax
movq (%rax,%rbx,8), %r14
movzbl (%r14), %eax
orl $0x2, %eax
cmpl $0x2f, %eax
jne 0x1aeb
callq 0x1160
movq %rax, %r13
movq (%rax), %rax
movsbq 0x1(%r14), %rcx
cmpl $0x68, (%rax,%rcx,4)
jne 0x15be
cmpb $0x0, 0x2(%r14)
je 0x1afc
leaq 0x1(%r14), %rbp
movsbq (%rbp), %rcx
cmpl $0x3f, (%rax,%rcx,4)
jne 0x15d8
cmpb $0x0, 0x2(%r14)
je 0x1afc
movsbq (%rbp), %rcx
cmpl $0x62, (%rax,%rcx,4)
jne 0x15ee
cmpb $0x0, 0x2(%r14)
je 0x16df
movq %rbp, %rdi
leaq 0x510a(%rip), %rsi      # 0x6702
leaq 0x7af1(%rip), %rdx      # 0x90f0
movl $0x1, %ecx
movl $0xffff, %r8d           # imm = 0xFFFF
callq 0x143f
testb %al, %al
je 0x162c
movl 0x7ad7(%rip), %esi      # 0x90f0
leaq 0x4249(%rip), %rdi      # 0x5869
xorl %eax, %eax
callq 0x1080
jmp 0x187f
movq (%r13), %rax
movsbq (%rbp), %rcx
cmpl $0x64, (%rax,%rcx,4)
jne 0x1646
cmpb $0x0, 0x2(%r14)
je 0x177d
xorl %ecx, %ecx
movsbq (%rbp,%rcx), %rdx
movsbl (%rcx,%r12), %esi
cmpl %esi, (%rax,%rdx,4)
jne 0x166c
incq %rcx
cmpq $0x2, %rcx
jne 0x1648
cmpb $0x0, 0x3(%r14)
je 0x1789
xorl %ecx, %ecx
movsbq (%rbp,%rcx), %rdx
movsbl (%rcx,%r15), %esi
cmpl %esi, (%rax,%rdx,4)
jne 0x1692
incq %rcx
cmpq $0x2, %rcx
jne 0x166e
cmpb $0x0, 0x3(%r14)
je 0x1795
movsbq (%rbp), %rcx
cmpl $0x69, (%rax,%rcx,4)
jne 0x16a8
cmpb $0x0, 0x2(%r14)
je 0x17a1
movq %rbp, %rdi
leaq 0x4976(%rip), %rsi      # 0x6028
leaq 0x7ab3(%rip), %rdx      # 0x916c
movl $0xffffff9c, %ecx       # imm = 0xFFFFFF9C
movl $0x64, %r8d
callq 0x143f
testb %al, %al
je 0x16eb
movl 0x7a99(%rip), %esi      # 0x916c
leaq 0x41b3(%rip), %rdi      # 0x588d
jmp 0x1620
movb $0x1, 0x7ada(%rip)      # 0x91c0
jmp 0x187f
movq (%r13), %rax
xorl %ecx, %ecx
movsbq (%rbp,%rcx), %rdx
leaq 0x41a2(%rip), %rsi      # 0x58a0
movsbl (%rcx,%rsi), %esi
cmpl %esi, (%rax,%rdx,4)
jne 0x171b
incq %rcx
cmpq $0x2, %rcx
jne 0x16f1
cmpb $0x0, 0x3(%r14)
je 0x17ad
movq %rbp, %rdi
leaq 0x3961(%rip), %rsi      # 0x5086
leaq 0x79bc(%rip), %rdx      # 0x90e8
movl $0x1, %ecx
movl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
callq 0x143f
testb %al, %al
jne 0x187f
movq (%r13), %rax
movsbq (%rbp), %rcx
cmpl $0x70, (%rax,%rcx,4)
jne 0x175e
cmpb $0x0, 0x2(%r14)
je 0x17f7
movq %rbp, %rdi
leaq 0x413b(%rip), %rsi      # 0x58a3
callq 0x13fa
testb %al, %al
je 0x17b9
movb $0x1, 0x7a4f(%rip)      # 0x91c7
jmp 0x187f
movb $0x1, 0x7a3d(%rip)      # 0x91c1
jmp 0x187f
movb $0x1, 0x7a32(%rip)      # 0x91c2
jmp 0x187f
movb $0x1, 0x7a27(%rip)      # 0x91c3
jmp 0x187f
movb $0x1, 0x7a1c(%rip)      # 0x91c4
jmp 0x187f
movb $0x1, 0x7a11(%rip)      # 0x91c5
jmp 0x187f
movq %rbp, %rdi
leaq 0x40e3(%rip), %rsi      # 0x58a6
callq 0x13fa
testb %al, %al
je 0x17d8
movb $0x1, 0x79f5(%rip)      # 0x91c8
jmp 0x187f
movq %rbp, %rdi
leaq 0x3a63(%rip), %rsi      # 0x5245
callq 0x13fa
testb %al, %al
je 0x1800
movb $0x1, 0x79d7(%rip)      # 0x91c9
jmp 0x187f
movb $0x1, 0x79c8(%rip)      # 0x91c6
jmp 0x187f
movq %rbp, %rdi
leaq 0x409f(%rip), %rsi      # 0x58a9
callq 0x13fa
testb %al, %al
je 0x1831
movb $0x1, 0x79b0(%rip)      # 0x91ca
leaq 0x4ce9(%rip), %rax      # 0x650a
movq %rax, 0x78a8(%rip)      # 0x90d0
leaq 0x4082(%rip), %rax      # 0x58b1
jmp 0x1860
movq %rbp, %rdi
leaq 0x4081(%rip), %rsi      # 0x58bc
callq 0x13fa
testb %al, %al
je 0x1892
movb $0x1, 0x797f(%rip)      # 0x91ca
leaq 0x4cb8(%rip), %rax      # 0x650a
movq %rax, 0x7877(%rip)      # 0x90d0
leaq 0x4064(%rip), %rax      # 0x58c4
movq %rax, 0x7879(%rip)      # 0x90e0
leaq 0x404c(%rip), %rax      # 0x58ba
movq %rax, 0x7863(%rip)      # 0x90d8
movl $0x10, 0x7869(%rip)     # 0x90e8
incq %rbx
cmpq 0x10(%rsp), %rbx
jne 0x1584
jmp 0x1ae9
movq %rbp, %rdi
leaq 0x4034(%rip), %rsi      # 0x58d0
leaq 0x4(%rsp), %r14
movq %r14, %rdx
movl $0x1, %ecx
movl $0x3e8, %r8d            # imm = 0x3E8
callq 0x143f
testb %al, %al
je 0x18cd
movslq 0x4(%rsp), %rax
imulq $0x3e8, %rax, %rax      # imm = 0x3E8
movq %rax, 0x78a5(%rip)      # 0x9170
jmp 0x187f
movq %rbp, %rdi
leaq 0x4002(%rip), %rsi      # 0x58d9
movq %r14, %rdx
xorl %ecx, %ecx
movl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
callq 0x143f
testb %al, %al
je 0x1903
movslq 0x4(%rsp), %rax
imulq $0x3e8, %rax, %rax      # imm = 0x3E8
movq %rax, 0x787a(%rip)      # 0x9178
jmp 0x187f
movq %rbp, %rdi
leaq 0x3fd8(%rip), %rsi      # 0x58e5
movq %r14, %rdx
xorl %ecx, %ecx
movl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
callq 0x143f
testb %al, %al
je 0x1939
movslq 0x4(%rsp), %rax
imulq $0x3e8, %rax, %rax      # imm = 0x3E8
movq %rax, 0x77c4(%rip)      # 0x90f8
jmp 0x187f
movq %rbp, %rdi
leaq 0x3faa(%rip), %rsi      # 0x58ed
movq %r14, %rdx
xorl %ecx, %ecx
movl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
callq 0x143f
testb %al, %al
je 0x197a
movslq 0x4(%rsp), %rax
imulq $0x3e8, %rax, %rax      # imm = 0x3E8
movq %rax, 0x7816(%rip)      # 0x9180
movzbl 0x785a(%rip), %edi      # 0x91cb
leaq 0x3f80(%rip), %rsi      # 0x58f8
jmp 0x19ee
movq %rbp, %rdi
leaq 0x3f93(%rip), %rsi      # 0x5917
movq %r14, %rdx
xorl %ecx, %ecx
movl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
callq 0x143f
testb %al, %al
je 0x19bb
movslq 0x4(%rsp), %rax
imulq $0x3e8, %rax, %rax      # imm = 0x3E8
movq %rax, 0x7755(%rip)      # 0x9100
movzbl 0x7819(%rip), %edi      # 0x91cb
leaq 0x3f6c(%rip), %rsi      # 0x5925
jmp 0x19ee
movq %rbp, %rdi
leaq 0x3f82(%rip), %rsi      # 0x5947
leaq 0x773c(%rip), %rdx      # 0x9108
movl $0x1, %ecx
movl $0x64, %r8d
callq 0x143f
testb %al, %al
je 0x19f8
movzbl 0x77e4(%rip), %edi      # 0x91cb
leaq 0x3f66(%rip), %rsi      # 0x5954
callq 0x13ec
jmp 0x187f
movq %rbp, %rdi
leaq 0x3f73(%rip), %rsi      # 0x5975
callq 0x13fa
testb %al, %al
je 0x1a17
movb $0x1, 0x77ba(%rip)      # 0x91cc
jmp 0x187f
movq %rbp, %rdi
leaq 0x3f57(%rip), %rsi      # 0x5978
callq 0x13fa
testb %al, %al
je 0x1a36
movb $0x1, 0x779c(%rip)      # 0x91cd
jmp 0x187f
movq %rbp, %rdi
leaq 0x3f3b(%rip), %rsi      # 0x597b
callq 0x13fa
testb %al, %al
je 0x1a55
movb $0x1, 0x777e(%rip)      # 0x91ce
jmp 0x187f
movq %rbp, %rdi
leaq 0x3f26(%rip), %rsi      # 0x5985
callq 0x13fa
testb %al, %al
je 0x1a74
movb $0x1, 0x7760(%rip)      # 0x91cf
jmp 0x187f
movq %rbp, %rdi
leaq 0x3f13(%rip), %rsi      # 0x5991
callq 0x13fa
testb %al, %al
je 0x1a93
movb $0x1, 0x7742(%rip)      # 0x91d0
jmp 0x187f
movq %rbp, %rdi
leaq 0x461e(%rip), %rsi      # 0x60bb
leaq 0x7648(%rip), %rdx      # 0x90ec
movl $0x1, %ecx
movl $0x10, %r8d
callq 0x143f
testb %al, %al
je 0x1aca
movl 0x762e(%rip), %esi      # 0x90ec
leaq 0x3ed9(%rip), %rdi      # 0x599e
jmp 0x1620
movq %rbp, %rdi
leaq 0x3e41(%rip), %rsi      # 0x5915
callq 0x13fa
testb %al, %al
je 0x1b01
movb $0x1, 0x76e7(%rip)      # 0x91cb
jmp 0x187f
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x122b
movq 0x8(%rsp), %rdi
movq %rbx, %rsi
callq 0x11fe