// File: /workspace/github_c_makefile_star2_O0/jrrk[P]cbzone/c_parseopts.c
// Function: parseopt
void parseopt(argc, argv, status)
     int argc;
     char* argv[];
     Bool status;
{
  int i;
  Bool early_exit = False;

  static char* optionnames[] = {
    "-xrm", "-delay", "-blocks", "-landers", "-tanks", "-missiles",
    "-salvos", "-coptersonly", "-quiet", "-scores", "-original",
    "-version", "-help", "-nooutput", "-mono", "-cursor",
    "-defaultcolormap", "-nofullscreen"};

#ifdef WIN32
  // Eric Fogelin: Fixed options (original game, in mono color, quiet)
  opt->mono = True;
  opt->loud = False;

  opt->mblocks = 8;
  opt->mlanders = 1;
  opt->mtanks = 1;
  opt->practice = True;

#else //X11
  for (argc--, argv++; argc>0; argc--, argv++) {
    for (i=0; i<MAXOPTIONS; i++)
      if (!strncmp(*argv,optionnames[i],strlen(*argv)))
        break;
    if (i < OPTIONINT) {
      argc--; argv++;
    }
    switch(i) {
    case 0:                     /* xrm */
      break;
    case 1:                     /* delay */
      opt->delay = getoptionint(*argv);
      break;
    case 2:                     /* blocks*/
      opt->mblocks = getoptionint(*argv);
      break;
    case 3:                     /* landers */
      opt->mlanders = getoptionint(*argv);
      break;
    case 4:                     /* tanks */
      opt->mtanks = getoptionint(*argv);
      break;
    case 5:                     /* missiles */
      opt->mmissiles = getoptionint(*argv);
      break;
    case 6:                     /* salvos */
      opt->msalvos = getoptionint(*argv);
      break;
    case 7:                     /* copter practice */
      opt->copters = True;
      break;
    case 8:                     /* quiet mode */
      opt->loud = False;
      break;
    case 9:                     /* scores only */
      opt->scores = True;
      break;
    case 10:                    /* original */
      opt->original = True;
      break;
    case 11:                    /* version */
      opt->version = True;
      break;
    case 12:                    /* help */
      opt->help = True;
      break;
    case 13:                    /* nooutput */
      opt->output = False;
      break;
    case 14:                    /* monocolor */
      opt->mono = True;
      break;
    case 15:                    /* cursor */
      opt->cursor = True;
      break;
    case 16:                    /* default colormap */
      opt->defaultcolormap = True;
      break;
    case 17:                    /* fullscreen */
      opt->fullscreen = False;
      break;
    }
  }
#endif //X11

  if (opt->scores || opt->help || opt->version)
    early_exit = True;

  if (opt->output) {
    pager("cbzone.motd");

    if (opt->scores)
      scores(-1);

    if (opt->version)
      printf("\nVersion \"%s\"\n", VERSION);

    if (opt->help && pager("cbzone.help"))
      printf("Sorry help information not available.\n");
  }

  if (early_exit)
#ifdef WIN32
     return;
#else //X11
    exit(0);
#endif

  if (!status)
    return;

#if 0 // Eric Fogelin: Allow copters and tanks
  if (opt->copters)
    opt->mtanks = 0;

  if (opt->original) {
    opt->mblocks = 8;
    opt->copters = False;
    opt->mlanders = 1;
    opt->mmissiles = 1;
    opt->mtanks = 1;
    opt->practice = True;
    opt->msalvos = 1;
  }
#endif

  opt->menemies = (opt->mtanks > opt->mmissiles ?
                   opt->mtanks : opt->mmissiles);
  if (!opt->menemies) {
    printf("Must have at least one missile or tank.\n");
#ifdef WIN32
     return;
#else //X11
     exit(1);
#endif
  }

  if (opt->msalvos == -1)
    opt->msalvos = opt->menemies;
  opt->mobjects = opt->mblocks + opt->mlanders + 2*opt->menemies +
    opt->msalvos + 1;
  opt->estart = 1;
  opt->lstart = opt->estart + opt->menemies;
  opt->sstart = opt->lstart + opt->mlanders;
  opt->bstart = opt->sstart + opt->menemies + opt->msalvos;

  if (opt->mmissiles == MMISSILES &&
      opt->mtanks == MTANKS &&
      opt->mlanders == MLANDERS &&
      opt->mblocks == MBLOCKS &&
      opt->delay <= DELAY &&
      opt->msalvos == opt->menemies)
    opt->practice = False;
  else
    opt->practice = True;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movl %edi, -0x4(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl $0x0, -0x1c(%rbp)
movl -0x4(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x4(%rbp)
movq -0x10(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x10(%rbp)
cmpl $0x0, -0x4(%rbp)
jle 0x12aa7
movl $0x0, -0x18(%rbp)
cmpl $0x10, -0x18(%rbp)
jge 0x128a3
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x30(%rbp)
movslq -0x18(%rbp), %rcx
leaq 0x7125(%rip), %rax      # 0x19990
movq (%rax,%rcx,8), %rax
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x5270
movq -0x30(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq %rax, %rdx
callq 0x5170
cmpl $0x0, %eax
jne 0x12896
jmp 0x128a3
jmp 0x12898
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x1284f
cmpl $0x7, -0x18(%rbp)
jge 0x128be
movl -0x4(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x4(%rbp)
movq -0x10(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x10(%rbp)
movl -0x18(%rbp), %eax
movq %rax, -0x38(%rbp)
subq $0x11, %rax
ja 0x12a8b
movq -0x38(%rbp), %rax
leaq 0x2236(%rip), %rcx      # 0x14b10
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
jmp 0x12a8b
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x127b0
movl %eax, %ecx
leaq 0x7063(%rip), %rax      # 0x19960
movq (%rax), %rax
movl %ecx, (%rax)
jmp 0x12a8b
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x127b0
movl %eax, %ecx
leaq 0x7044(%rip), %rax      # 0x19960
movq (%rax), %rax
movl %ecx, 0x4(%rax)
jmp 0x12a8b
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x127b0
movl %eax, %ecx
leaq 0x7024(%rip), %rax      # 0x19960
movq (%rax), %rax
movl %ecx, 0x8(%rax)
jmp 0x12a8b
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x127b0
movl %eax, %ecx
leaq 0x7004(%rip), %rax      # 0x19960
movq (%rax), %rax
movl %ecx, 0x14(%rax)
jmp 0x12a8b
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x127b0
movl %eax, %ecx
leaq 0x6fe4(%rip), %rax      # 0x19960
movq (%rax), %rax
movl %ecx, 0xc(%rax)
jmp 0x12a8b
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x127b0
movl %eax, %ecx
leaq 0x6fc4(%rip), %rax      # 0x19960
movq (%rax), %rax
movl %ecx, 0x10(%rax)
jmp 0x12a8b
leaq 0x6fb2(%rip), %rax      # 0x19960
movq (%rax), %rax
movl $0x1, 0x30(%rax)
jmp 0x12a8b
leaq 0x6f9c(%rip), %rax      # 0x19960
movq (%rax), %rax
movl $0x0, 0x34(%rax)
jmp 0x12a8b
leaq 0x6f86(%rip), %rax      # 0x19960
movq (%rax), %rax
movl $0x1, 0x40(%rax)
jmp 0x12a8b
leaq 0x6f70(%rip), %rax      # 0x19960
movq (%rax), %rax
movl $0x1, 0x4c(%rax)
jmp 0x12a8b
leaq 0x6f5a(%rip), %rax      # 0x19960
movq (%rax), %rax
movl $0x1, 0x44(%rax)
jmp 0x12a8b
leaq 0x6f47(%rip), %rax      # 0x19960
movq (%rax), %rax
movl $0x1, 0x48(%rax)
jmp 0x12a8b
leaq 0x6f34(%rip), %rax      # 0x19960
movq (%rax), %rax
movl $0x0, 0x3c(%rax)
jmp 0x12a8b
leaq 0x6f21(%rip), %rax      # 0x19960
movq (%rax), %rax
movl $0x1, 0x13c(%rax)
jmp 0x12a8b
leaq 0x6f0b(%rip), %rax      # 0x19960
movq (%rax), %rax
movl $0x1, 0x50(%rax)
jmp 0x12a8b
leaq 0x6ef8(%rip), %rax      # 0x19960
movq (%rax), %rax
movl $0x1, 0x144(%rax)
jmp 0x12a8b
leaq 0x6ee2(%rip), %rax      # 0x19960
movq (%rax), %rax
movl $0x0, 0x140(%rax)
jmp 0x12a8d
movl -0x4(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x4(%rbp)
movq -0x10(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x10(%rbp)
jmp 0x1283e
leaq 0x6eb2(%rip), %rax      # 0x19960
movq (%rax), %rax
cmpl $0x0, 0x40(%rax)
jne 0x12ad7
leaq 0x6ea2(%rip), %rax      # 0x19960
movq (%rax), %rax
cmpl $0x0, 0x48(%rax)
jne 0x12ad7
leaq 0x6e92(%rip), %rax      # 0x19960
movq (%rax), %rax
cmpl $0x0, 0x44(%rax)
je 0x12ade
movl $0x1, -0x1c(%rbp)
leaq 0x6e7b(%rip), %rax      # 0x19960
movq (%rax), %rax
cmpl $0x0, 0x3c(%rax)
je 0x12b6c
leaq 0x2103(%rip), %rdi      # 0x14bf8
callq 0x12660
leaq 0x6e5f(%rip), %rax      # 0x19960
movq (%rax), %rax
cmpl $0x0, 0x40(%rax)
je 0x12b16
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movb $0x0, %al
callq 0x12e80
leaq 0x6e43(%rip), %rax      # 0x19960
movq (%rax), %rax
cmpl $0x0, 0x44(%rax)
je 0x12b3b
leaq 0x20d7(%rip), %rdi      # 0x14c04
leaq 0x20df(%rip), %rsi      # 0x14c13
movb $0x0, %al
callq 0x5050
leaq 0x6e1e(%rip), %rax      # 0x19960
movq (%rax), %rax
cmpl $0x0, 0x48(%rax)
je 0x12b6a
leaq 0x20de(%rip), %rdi      # 0x14c30
callq 0x12660
cmpl $0x0, %eax
je 0x12b6a
leaq 0x20d9(%rip), %rdi      # 0x14c3c
movb $0x0, %al
callq 0x5050
jmp 0x12b6c
cmpl $0x0, -0x1c(%rbp)
je 0x12b79
xorl %edi, %edi
callq 0x5100
cmpl $0x0, -0x14(%rbp)
jne 0x12b84
jmp 0x12d8e
leaq 0x6dd5(%rip), %rax      # 0x19960
movq (%rax), %rax
movl 0x14(%rax), %eax
leaq 0x6dc8(%rip), %rcx      # 0x19960
movq (%rcx), %rcx
cmpl 0xc(%rcx), %eax
jle 0x12bb2
leaq 0x6db9(%rip), %rax      # 0x19960
movq (%rax), %rax
movl 0x14(%rax), %eax
movl %eax, -0x3c(%rbp)
jmp 0x12bc2
leaq 0x6da7(%rip), %rax      # 0x19960
movq (%rax), %rax
movl 0xc(%rax), %eax
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %ecx
leaq 0x6d94(%rip), %rax      # 0x19960
movq (%rax), %rax
movl %ecx, 0x18(%rax)
leaq 0x6d87(%rip), %rax      # 0x19960
movq (%rax), %rax
cmpl $0x0, 0x18(%rax)
jne 0x12bfa
leaq 0x207a(%rip), %rdi      # 0x14c63
movb $0x0, %al
callq 0x5050
movl $0x1, %edi
callq 0x5100
leaq 0x6d5f(%rip), %rax      # 0x19960
movq (%rax), %rax
cmpl $-0x1, 0x10(%rax)
jne 0x12c24
leaq 0x6d4f(%rip), %rax      # 0x19960
movq (%rax), %rax
movl 0x18(%rax), %ecx
leaq 0x6d42(%rip), %rax      # 0x19960
movq (%rax), %rax
movl %ecx, 0x10(%rax)
leaq 0x6d35(%rip), %rax      # 0x19960
movq (%rax), %rax
movl 0x4(%rax), %ecx
leaq 0x6d28(%rip), %rax      # 0x19960
movq (%rax), %rax
addl 0x8(%rax), %ecx
leaq 0x6d1b(%rip), %rax      # 0x19960
movq (%rax), %rax
movl 0x18(%rax), %eax
shll %eax
addl %eax, %ecx
leaq 0x6d0a(%rip), %rax      # 0x19960
movq (%rax), %rax
addl 0x10(%rax), %ecx
addl $0x1, %ecx
leaq 0x6cfa(%rip), %rax      # 0x19960
movq (%rax), %rax
movl %ecx, 0x1c(%rax)
leaq 0x6ced(%rip), %rax      # 0x19960
movq (%rax), %rax
movl $0x1, 0x20(%rax)
leaq 0x6cdc(%rip), %rax      # 0x19960
movq (%rax), %rax
movl 0x20(%rax), %ecx
leaq 0x6ccf(%rip), %rax      # 0x19960
movq (%rax), %rax
addl 0x18(%rax), %ecx
leaq 0x6cc2(%rip), %rax      # 0x19960
movq (%rax), %rax
movl %ecx, 0x24(%rax)
leaq 0x6cb5(%rip), %rax      # 0x19960
movq (%rax), %rax
movl 0x24(%rax), %ecx
leaq 0x6ca8(%rip), %rax      # 0x19960
movq (%rax), %rax
addl 0x8(%rax), %ecx
leaq 0x6c9b(%rip), %rax      # 0x19960
movq (%rax), %rax
movl %ecx, 0x28(%rax)
leaq 0x6c8e(%rip), %rax      # 0x19960
movq (%rax), %rax
movl 0x28(%rax), %ecx
leaq 0x6c81(%rip), %rax      # 0x19960
movq (%rax), %rax
addl 0x18(%rax), %ecx
leaq 0x6c74(%rip), %rax      # 0x19960
movq (%rax), %rax
addl 0x10(%rax), %ecx
leaq 0x6c67(%rip), %rax      # 0x19960
movq (%rax), %rax
movl %ecx, 0x2c(%rax)
leaq 0x6c5a(%rip), %rax      # 0x19960
movq (%rax), %rax
cmpl $0x1, 0xc(%rax)
jne 0x12d7d
leaq 0x6c4a(%rip), %rax      # 0x19960
movq (%rax), %rax
cmpl $0x1, 0x14(%rax)
jne 0x12d7d
leaq 0x6c3a(%rip), %rax      # 0x19960
movq (%rax), %rax
cmpl $0x4, 0x8(%rax)
jne 0x12d7d
leaq 0x6c2a(%rip), %rax      # 0x19960
movq (%rax), %rax
cmpl $0x8, 0x4(%rax)
jne 0x12d7d
leaq 0x6c1a(%rip), %rax      # 0x19960
movq (%rax), %rax
cmpl $0x5, (%rax)
jg 0x12d7d
leaq 0x6c0b(%rip), %rax      # 0x19960
movq (%rax), %rax
movl 0x10(%rax), %eax
leaq 0x6bfe(%rip), %rcx      # 0x19960
movq (%rcx), %rcx
cmpl 0x18(%rcx), %eax
jne 0x12d7d
leaq 0x6bef(%rip), %rax      # 0x19960
movq (%rax), %rax
movl $0x0, 0x38(%rax)
jmp 0x12d8e
leaq 0x6bdc(%rip), %rax      # 0x19960
movq (%rax), %rax
movl $0x1, 0x38(%rax)
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nop