// File: /workspace/github_c_makefile_star2_O2/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
pushq %rax
movq %rsi, %rbx
movslq %edi, %r14
pushq $0x1
popq %r13
leaq 0x522b(%rip), %r12      # 0x668c
leaq 0x4(%rsp), %r15
cmpq %r14, %r13
jge 0x193f
movq (%rbx,%r13,8), %rbp
movzbl (%rbp), %eax
orl $0x2, %eax
cmpl $0x2f, %eax
jne 0x1943
incq %rbp
movq %rbp, %rdi
leaq 0x526f(%rip), %rsi      # 0x66ff
callq 0x12a5
testb %al, %al
jne 0x1955
movq %rbp, %rdi
leaq 0x4aa3(%rip), %rsi      # 0x5f4a
callq 0x12a5
testb %al, %al
jne 0x1955
movq %rbp, %rdi
movq %r12, %rsi
callq 0x12a5
testb %al, %al
je 0x14cf
movb $0x1, 0x7cf6(%rip)      # 0x91c0
jmp 0x1576
movq %rbp, %rdi
leaq 0x5229(%rip), %rsi      # 0x6702
leaq 0x7c10(%rip), %rdx      # 0x90f0
pushq $0x1
popq %rcx
movl $0xffff, %r8d           # imm = 0xFFFF
callq 0x12e8
testb %al, %al
je 0x1508
movl 0x7bf8(%rip), %esi      # 0x90f0
leaq 0x436a(%rip), %rdi      # 0x5869
xorl %eax, %eax
callq 0x1080
jmp 0x1576
movq %rbp, %rdi
leaq 0x459c(%rip), %rsi      # 0x5aae
callq 0x12a5
testb %al, %al
je 0x1524
movb $0x1, 0x7c9f(%rip)      # 0x91c1
jmp 0x1576
movq %rbp, %rdi
leaq 0x4359(%rip), %rsi      # 0x5887
callq 0x12a5
testb %al, %al
je 0x1540
movb $0x1, 0x7c84(%rip)      # 0x91c2
jmp 0x1576
movq %rbp, %rdi
leaq 0x4340(%rip), %rsi      # 0x588a
callq 0x12a5
testb %al, %al
je 0x155c
movb $0x1, 0x7c69(%rip)      # 0x91c3
jmp 0x1576
movq %rbp, %rdi
leaq 0x433e(%rip), %rsi      # 0x58a4
callq 0x12a5
testb %al, %al
je 0x157e
movb $0x1, 0x7c4e(%rip)      # 0x91c4
incq %r13
jmp 0x1466
movq %rbp, %rdi
leaq 0x4aa0(%rip), %rsi      # 0x6028
leaq 0x7bdd(%rip), %rdx      # 0x916c
pushq $-0x64
popq %rcx
pushq $0x64
popq %r8
callq 0x12e8
testb %al, %al
je 0x15b1
movl 0x7bc7(%rip), %esi      # 0x916c
leaq 0x42e1(%rip), %rdi      # 0x588d
jmp 0x14ff
movq %rbp, %rdi
leaq 0x42e5(%rip), %rsi      # 0x58a0
callq 0x12a5
testb %al, %al
je 0x15cd
movb $0x1, 0x7bfa(%rip)      # 0x91c5
jmp 0x1576
movq %rbp, %rdi
leaq 0x3aaf(%rip), %rsi      # 0x5086
leaq 0x7b0a(%rip), %rdx      # 0x90e8
pushq $0x1
popq %rcx
movl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
callq 0x12e8
testb %al, %al
jne 0x1576
movq %rbp, %rdi
leaq 0x428e(%rip), %rsi      # 0x5888
callq 0x12a5
testb %al, %al
je 0x160f
movb $0x1, 0x7bbc(%rip)      # 0x91c6
jmp 0x1576
movq %rbp, %rdi
leaq 0x428a(%rip), %rsi      # 0x58a3
callq 0x12a5
testb %al, %al
je 0x162e
movb $0x1, 0x7b9e(%rip)      # 0x91c7
jmp 0x1576
movq %rbp, %rdi
leaq 0x426e(%rip), %rsi      # 0x58a6
callq 0x12a5
testb %al, %al
je 0x164d
movb $0x1, 0x7b80(%rip)      # 0x91c8
jmp 0x1576
movq %rbp, %rdi
leaq 0x3bee(%rip), %rsi      # 0x5245
callq 0x12a5
testb %al, %al
je 0x166c
movb $0x1, 0x7b62(%rip)      # 0x91c9
jmp 0x1576
movq %rbp, %rdi
leaq 0x4233(%rip), %rsi      # 0x58a9
callq 0x12a5
testb %al, %al
je 0x169d
movb $0x1, 0x7b44(%rip)      # 0x91ca
leaq 0x4e7d(%rip), %rax      # 0x650a
movq %rax, 0x7a3c(%rip)      # 0x90d0
leaq 0x4216(%rip), %rax      # 0x58b1
jmp 0x16cc
movq %rbp, %rdi
leaq 0x4215(%rip), %rsi      # 0x58bc
callq 0x12a5
testb %al, %al
je 0x16f0
movb $0x1, 0x7b13(%rip)      # 0x91ca
leaq 0x4e4c(%rip), %rax      # 0x650a
movq %rax, 0x7a0b(%rip)      # 0x90d0
leaq 0x41f8(%rip), %rax      # 0x58c4
movq %rax, 0x7a0d(%rip)      # 0x90e0
leaq 0x41e0(%rip), %rax      # 0x58ba
movq %rax, 0x79f7(%rip)      # 0x90d8
movl $0x10, 0x79fd(%rip)     # 0x90e8
jmp 0x1576
movq %rbp, %rdi
leaq 0x41d6(%rip), %rsi      # 0x58d0
movq %r15, %rdx
pushq $0x1
popq %rcx
movl $0x3e8, %r8d            # imm = 0x3E8
callq 0x12e8
testb %al, %al
je 0x1727
movslq 0x4(%rsp), %rax
imulq $0x3e8, %rax, %rax      # imm = 0x3E8
movq %rax, 0x7a4e(%rip)      # 0x9170
jmp 0x1576
movq %rbp, %rdi
leaq 0x41a8(%rip), %rsi      # 0x58d9
leaq 0x4(%rsp), %rdx
xorl %ecx, %ecx
movl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
callq 0x12e8
testb %al, %al
je 0x175f
movslq 0x4(%rsp), %rax
imulq $0x3e8, %rax, %rax      # imm = 0x3E8
movq %rax, 0x7a1e(%rip)      # 0x9178
jmp 0x1576
movq %rbp, %rdi
leaq 0x417c(%rip), %rsi      # 0x58e5
leaq 0x4(%rsp), %rdx
xorl %ecx, %ecx
movl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
callq 0x12e8
testb %al, %al
je 0x1797
movslq 0x4(%rsp), %rax
imulq $0x3e8, %rax, %rax      # imm = 0x3E8
movq %rax, 0x7966(%rip)      # 0x90f8
jmp 0x1576
movq %rbp, %rdi
leaq 0x414c(%rip), %rsi      # 0x58ed
movq %r15, %rdx
xorl %ecx, %ecx
movl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
callq 0x12e8
testb %al, %al
je 0x17d8
movslq 0x4(%rsp), %rax
imulq $0x3e8, %rax, %rax      # imm = 0x3E8
movq %rax, 0x79b8(%rip)      # 0x9180
movzbl 0x79fc(%rip), %edi      # 0x91cb
leaq 0x4122(%rip), %rsi      # 0x58f8
jmp 0x1848
movq %rbp, %rdi
leaq 0x4135(%rip), %rsi      # 0x5917
movq %r15, %rdx
xorl %ecx, %ecx
movl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
callq 0x12e8
testb %al, %al
je 0x1819
movslq 0x4(%rsp), %rax
imulq $0x3e8, %rax, %rax      # imm = 0x3E8
movq %rax, 0x78f7(%rip)      # 0x9100
movzbl 0x79bb(%rip), %edi      # 0x91cb
leaq 0x410e(%rip), %rsi      # 0x5925
jmp 0x1848
movq %rbp, %rdi
leaq 0x4124(%rip), %rsi      # 0x5947
leaq 0x78de(%rip), %rdx      # 0x9108
pushq $0x1
popq %rcx
pushq $0x64
popq %r8
callq 0x12e8
testb %al, %al
je 0x1852
movzbl 0x798a(%rip), %edi      # 0x91cb
leaq 0x410c(%rip), %rsi      # 0x5954
callq 0x127c
jmp 0x1576
movq %rbp, %rdi
leaq 0x4119(%rip), %rsi      # 0x5975
callq 0x12a5
testb %al, %al
je 0x1871
movb $0x1, 0x7960(%rip)      # 0x91cc
jmp 0x1576
movq %rbp, %rdi
leaq 0x40fd(%rip), %rsi      # 0x5978
callq 0x12a5
testb %al, %al
je 0x1890
movb $0x1, 0x7942(%rip)      # 0x91cd
jmp 0x1576
movq %rbp, %rdi
leaq 0x40e1(%rip), %rsi      # 0x597b
callq 0x12a5
testb %al, %al
je 0x18af
movb $0x1, 0x7924(%rip)      # 0x91ce
jmp 0x1576
movq %rbp, %rdi
leaq 0x40cc(%rip), %rsi      # 0x5985
callq 0x12a5
testb %al, %al
je 0x18ce
movb $0x1, 0x7906(%rip)      # 0x91cf
jmp 0x1576
movq %rbp, %rdi
leaq 0x40b9(%rip), %rsi      # 0x5991
callq 0x12a5
testb %al, %al
je 0x18ed
movb $0x1, 0x78e8(%rip)      # 0x91d0
jmp 0x1576
movq %rbp, %rdi
leaq 0x47c4(%rip), %rsi      # 0x60bb
leaq 0x77ee(%rip), %rdx      # 0x90ec
pushq $0x1
popq %rcx
pushq $0x10
popq %r8
callq 0x12e8
testb %al, %al
je 0x1920
movl 0x77d8(%rip), %esi      # 0x90ec
leaq 0x4083(%rip), %rdi      # 0x599e
jmp 0x14ff
movq %rbp, %rdi
leaq 0x3feb(%rip), %rsi      # 0x5915
callq 0x12a5
testb %al, %al
je 0x1962
movb $0x1, 0x7891(%rip)      # 0x91cb
jmp 0x1576
xorl %eax, %eax
jmp 0x1946
movl %r13d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x13f9
pushq $0x1
popq %rdi
callq 0x1140
movq 0x768f(%rip), %rax      # 0x8ff8
movq (%rax), %rdi
movq (%rbx,%r13,8), %rdx
leaq 0x4041(%rip), %rsi      # 0x59b8
xorl %eax, %eax
callq 0x10b0
callq 0x13f9
pushq $0x4
jmp 0x195c