// File: blackle[P]LZMA-Vizualizer/LzmaSpec.cpp
// Function: parse_args(int, char**)
static int parse_args(int argc, char** argv) {
#ifdef _MSC_VER
  options.pretty = true;
#else
  options.pretty = isatty(STDOUT_FILENO);
#endif
  options.jet = false;
  options.literals = false;
  options.kkpout = "";
  options.infile = "";

  if (argc < 2) {
    usage(argv);
    return 1;
  }

  for (int i = 1; i < argc; ++i) {
    const char* curarg = argv[i];
    if (!strcmp(curarg, "--raw")) {
      options.pretty = false;
      continue;
    }
    if (!strcmp(curarg, "--jet")) {
      options.jet = true;
      continue;
    }
    if (!strcmp(curarg, "--lits") || !strcmp(curarg, "--literals")) {
      options.literals = true;
      continue;
    }
    if (!strcmp(curarg, "--help")) {
      usage(argv);
      return 0;
    }

    if (!strcmp(curarg, "--kkp")) {
      if (i == argc - 1) {
        std::cerr << argv[0] << ": Need output file argument for --kkp flag!" << std::endl;
        return 1;
      }
      options.kkpout = argv[i+1];
      ++i;
      continue;
    }

    if (!options.infile.empty()) {
      std::cerr << argv[0] << ": Input file already specified! Was parsed as '" << options.infile << "', now also got '" << curarg << "'." << std::endl;
      return 1;
    }
    options.infile = curarg;
  }

  if (options.infile.empty()) {
    std::cerr << argv[0] << ": No input file specified!" << std::endl;
    return 1;
  }

  return -1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x1, %edi
callq 0x2260
cmpl $0x0, %eax
setne %al
andb $0x1, %al
movb %al, 0xd099(%rip)       # 0x101c0
movb $0x0, 0xd093(%rip)      # 0x101c1
movb $0x0, 0xd08d(%rip)      # 0x101c2
leaq 0xd044(%rip), %rdi      # 0x10180
addq $0x20, %rdi
leaq 0x8067(%rip), %rsi      # 0xb1ae
callq 0x21e0
leaq 0xd02d(%rip), %rdi      # 0x10180
leaq 0x8054(%rip), %rsi      # 0xb1ae
callq 0x21e0
cmpl $0x2, -0x8(%rbp)
jge 0x317a
movq -0x10(%rbp), %rdi
callq 0x3c40
movl $0x1, -0x4(%rbp)
jmp 0x33c1
movl $0x1, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x336e
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
leaq 0x7f48(%rip), %rsi      # 0xb0f0
callq 0x2200
cmpl $0x0, %eax
jne 0x31be
movb $0x0, 0xd007(%rip)      # 0x101c0
jmp 0x3360
movq -0x20(%rbp), %rdi
leaq 0x7f2d(%rip), %rsi      # 0xb0f6
callq 0x2200
cmpl $0x0, %eax
jne 0x31df
movb $0x1, 0xcfe7(%rip)      # 0x101c1
jmp 0x3360
movq -0x20(%rbp), %rdi
leaq 0x7f12(%rip), %rsi      # 0xb0fc
callq 0x2200
cmpl $0x0, %eax
je 0x3209
movq -0x20(%rbp), %rdi
leaq 0x7f04(%rip), %rsi      # 0xb103
callq 0x2200
cmpl $0x0, %eax
jne 0x3215
movb $0x1, 0xcfb2(%rip)      # 0x101c2
jmp 0x3360
movq -0x20(%rbp), %rdi
leaq 0x7eee(%rip), %rsi      # 0xb10e
callq 0x2200
cmpl $0x0, %eax
jne 0x323f
movq -0x10(%rbp), %rdi
callq 0x3c40
movl $0x0, -0x4(%rbp)
jmp 0x33c1
movq -0x20(%rbp), %rdi
leaq 0x7ecb(%rip), %rsi      # 0xb115
callq 0x2200
cmpl $0x0, %eax
jne 0x32cd
movl -0x14(%rbp), %eax
movl -0x8(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jne 0x329e
movq -0x10(%rbp), %rax
movq (%rax), %rsi
movq 0xcd81(%rip), %rdi      # 0xfff0
callq 0x2150
movq %rax, %rdi
leaq 0x7e9d(%rip), %rsi      # 0xb11b
callq 0x2150
movq %rax, %rdi
movq 0xcd2b(%rip), %rsi      # 0xffb8
callq 0x2190
movl $0x1, -0x4(%rbp)
jmp 0x33c1
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rsi
leaq 0xceca(%rip), %rdi      # 0x10180
addq $0x20, %rdi
callq 0x21e0
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x3360
leaq 0xceac(%rip), %rdi      # 0x10180
callq 0x2230
testb $0x1, %al
jne 0x3350
movq -0x10(%rbp), %rax
movq (%rax), %rsi
movq 0xcd05(%rip), %rdi      # 0xfff0
callq 0x2150
movq %rax, %rdi
leaq 0x7e4d(%rip), %rsi      # 0xb147
callq 0x2150
movq %rax, %rdi
leaq 0xce77(%rip), %rsi      # 0x10180
callq 0x2130
movq %rax, %rdi
leaq 0x7e5f(%rip), %rsi      # 0xb177
callq 0x2150
movq %rax, %rdi
movq -0x20(%rbp), %rsi
callq 0x2150
movq %rax, %rdi
leaq 0x7e56(%rip), %rsi      # 0xb189
callq 0x2150
movq %rax, %rdi
movq 0xcc76(%rip), %rsi      # 0xffb8
callq 0x2190
movl $0x1, -0x4(%rbp)
jmp 0x33c1
movq -0x20(%rbp), %rsi
leaq 0xce25(%rip), %rdi      # 0x10180
callq 0x21e0
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x3181
leaq 0xce0b(%rip), %rdi      # 0x10180
callq 0x2230
testb $0x1, %al
jne 0x3380
jmp 0x33ba
movq -0x10(%rbp), %rax
movq (%rax), %rsi
movq 0xcc62(%rip), %rdi      # 0xfff0
callq 0x2150
movq %rax, %rdi
leaq 0x7def(%rip), %rsi      # 0xb18c
callq 0x2150
movq %rax, %rdi
movq 0xcc0c(%rip), %rsi      # 0xffb8
callq 0x2190
movl $0x1, -0x4(%rbp)
jmp 0x33c1
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopw (%rax,%rax)