// File: /workspace/github_c_makefile_star2_O3/salextpuru[P]speccy-toochain/src/zmakebas/zmakebas.c
// Function: parse_options
void parse_options(int argc,char *argv[])
{
int done=0;

done=0;
opterr=0;
startlabel[0]=0;

do
  switch(getopt(argc,argv,"a:hi:ln:o:rs:"))
    {
    case 'a':
      if(*optarg=='@')
        if(strlen(optarg+1)>MAX_LABEL_LEN)
          fprintf(stderr,"Auto-start label too long\n"),exit(1);
        else
          strcpy(startlabel,optarg+1);
      else
        {
        startline=(unsigned int)atoi(optarg);
        if(startline>9999)
          fprintf(stderr,"Auto-start line must be in the range 0 to 9999.\n"),
            exit(1);
        }
      break;
    case 'h':	/* usage help */
      usage_help();
      exit(1);
    case 'i':
      autoincr=(int)atoi(optarg);
      /* this is unnecessarily restrictive but keeps things a bit sane */
      if(autoincr<1 || autoincr>1000)
        fprintf(stderr,"Label line incr. must be in the range 1 to 1000.\n"),
          exit(1);
      break;
    case 'l':
      use_labels=1;
      break;
    case 'n':
      strncpy(speccy_filename,optarg,10);
      speccy_filename[10]=0;
      break;
    case 'o':
      strcpy(outfile,optarg);
      break;
    case 'r':	/* output raw file */
      output_tap=0; break;
    case 's':
      autostart=(int)atoi(optarg);
      if(autostart<0 || autostart>9999)
        fprintf(stderr,"Label start line must be in the range 0 to 9999.\n"),
          exit(1);
      break;
    case '?':
      switch(optopt)
        {
        case 'a':
          fprintf(stderr,"The `a' option takes a line number arg.\n");
          break;
        case 'i':
          fprintf(stderr,"The `i' option takes a line incr. arg.\n");
          break;
        case 'n':
          fprintf(stderr,"The `n' option takes a Spectrum filename arg.\n");
          break;
        case 'o':
          fprintf(stderr,"The `o' option takes a filename arg.\n");
          break;
        case 's':
          fprintf(stderr,"The `s' option takes a line number arg.\n");
          break;
        default:
          fprintf(stderr,"Option `%c' not recognised.\n",optopt);
        }
      exit(1);
    case -1:
      done=1;
    }
while(!done);

if(optind<argc-1)	/* two or more remaining args */
  usage_help(),exit(1);

if(optind==argc-1)	/* one remaining arg */
  strcpy(infile,argv[optind]);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movl %edi, %ebp
movl $0x0, 0x4eeb(%rip)      # 0x871c
movb $0x0, 0x4ef8(%rip)      # 0x8730
leaq 0x1b5a(%rip), %r14      # 0x5399
leaq 0x181a(%rip), %r12      # 0x5060
movl $0xfffffc17, %r13d      # imm = 0xFFFFFC17
movl %ebp, %edi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x345c
leal -0x61(%rax), %ecx
cmpl $0x12, %ecx
ja 0x3940
movslq (%r12,%rcx,4), %rax
addq %r12, %rax
jmpq *%rax
movq 0x4eab(%rip), %r15      # 0x8720
cmpb $0x40, (%r15)
jne 0x3950
incq %r15
movq %r15, %rdi
callq 0x3080
cmpq $0x11, %rax
jae 0x39f0
leaq 0x4e95(%rip), %rdi      # 0x8730
movq %r15, %rsi
callq 0x30e0
jmp 0x384c
movq 0x4e74(%rip), %rdi      # 0x8720
callq 0x31b0
movl %eax, 0x4e39(%rip)      # 0x86f0
cmpl $0x2710, %eax           # imm = 0x2710
jb 0x384c
jmp 0x39bb
movq 0x4e56(%rip), %rsi      # 0x8720
leaq 0x4e7f(%rip), %rdi      # 0x8750
callq 0x30e0
jmp 0x384c
movq 0x4e3e(%rip), %rdi      # 0x8720
callq 0x31b0
movl %eax, 0x4e07(%rip)      # 0x86f4
addl %r13d, %eax
cmpl %r13d, %eax
ja 0x384c
jmp 0x39c0
movq 0x4e1b(%rip), %rsi      # 0x8720
movl $0xa, %edx
leaq 0x4e30(%rip), %rdi      # 0x8741
callq 0x30a0
movb $0x0, 0x4e2e(%rip)      # 0x874b
jmp 0x384c
movl $0x1, 0x4de4(%rip)      # 0x8710
jmp 0x384c
movl $0x0, 0x4dad(%rip)      # 0x86e8
jmp 0x384c
cmpl $-0x1, %eax
je 0x396e
cmpl $0x3f, %eax
jne 0x384c
jmp 0x39c5
movq %r15, %rdi
callq 0x31b0
movl %eax, 0x4d8e(%rip)      # 0x86ec
cmpl $0x2710, %eax           # imm = 0x2710
jb 0x384c
callq 0x32f9
movslq 0x4d83(%rip), %rax      # 0x86f8
decl %ebp
cmpl %ebp, %eax
jl 0x39ac
cmpl %ebp, %eax
jne 0x399d
movq (%rbx,%rax,8), %rsi
leaq 0x51c6(%rip), %rdi      # 0x8b50
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x30e0
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x3778
movl $0x1, %edi
callq 0x3150
callq 0x32af
callq 0x32d4
movl 0x4d4d(%rip), %edx      # 0x8718
movq 0x4606(%rip), %rax      # 0x7fd8
movq (%rax), %rdi
cmpl $0x6d, %edx
jle 0x39f5
cmpl $0x6e, %edx
je 0x3a06
cmpl $0x6f, %edx
je 0x3a0d
cmpl $0x73, %edx
jne 0x3a1b
callq 0x3246
jmp 0x39b1
callq 0x331e
cmpl $0x61, %edx
je 0x3a14
cmpl $0x69, %edx
jne 0x3a1b
callq 0x3285
jmp 0x39b1
callq 0x3270
jmp 0x39b1
callq 0x325b
jmp 0x39b1
callq 0x329a
jmp 0x39b1
leaq 0x1b04(%rip), %rsi      # 0x5526
xorl %eax, %eax
callq 0x3190
jmp 0x39b1