// File: /workspace/github_c_makefile_star2_O3/jflatow[P]jfdb/src/jfdb.c
// Function: main
int main(int argc, char **argv) {
  if (pif_error(argc < 2, "No command specified"))
    return usage(-1);
  if (pif_error(argc < 3, "No DB path specified"))
    return usage(-1);

  char *cmd = argv[1];
  char *keyData[JFT_KEY_LIMIT];
  JFDB *db;
  JFT_Stem prefix = (JFT_Stem) {.data = (uint8_t *)keyData};
  JFT_Symbol *stop = NULL;
  JFT_Offset offset;
  switch (cmd[0]) {
    case 'm':
    case 'n':
    case 'k':
    case 'f':
    case 'l':
    case 'c':
      db = JFDB_open(argv[2], 0);
      if (JFDB_pif_error(db, "Failed to open"))
        return -1;
      switch (cmd[0]) {
        case 'm':
          print_meta(db);
          break;
        case 'n':
          offset = argc > 3 ? atoi(argv[3]) : db->tip.cp.offset;
          offset = MAX(offset, sizeof(JFDB_Header));
          print_info(db, &prefix, db->kmap.map + offset, &null);
          break;
        case 'k':
          if (!prefix_opts(&prefix, &stop, argc - 2, argv + 2))
            print_keys(db, &prefix, stop);
          break;
        case 'f':
          if (!prefix_opts(&prefix, &stop, argc - 2, argv + 2))
            print_find(db, &prefix, stop);
          break;
        case 'l':
          load_input(db, stdin);
          break;
        case 'c':
          JFDB_crush(db);
          break;
      }
      if (JFDB_close(db))
        return -1;
      break;
    case 'w':
      if (pif_error(JFDB_wipe(argv[2]), "Failed to wipe"))
        return -1;
      break;
    default:
      usage(1);
      break;
  }
  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x2028, %rsp           # imm = 0x2028
cmpl $0x1, %edi
jle 0x1621
movl %edi, %ebp
cmpl $0x2, %edi
je 0x1628
movq %rsi, %r14
movq 0x8(%rsi), %r15
xorl %eax, %eax
movq %rax, 0x8(%rsp)
movw $0x0, 0x10(%rsp)
leaq 0x20(%rsp), %rcx
movq %rcx, 0x18(%rsp)
movq %rax, (%rsp)
movzbl (%r15), %eax
addl $-0x63, %eax
cmpl $0x14, %eax
ja 0x1688
movl $0xf09, %ecx            # imm = 0xF09
btl %eax, %ecx
jae 0x150f
movq 0x10(%r14), %rdi
xorl %esi, %esi
callq 0x2845
movq %rax, %rbx
testq %rax, %rax
je 0x15dd
cmpl $0x0, 0x88(%rbx)
jne 0x15dd
movzbl (%r15), %eax
addl $-0x63, %eax
cmpl $0xb, %eax
ja 0x1663
leaq 0x10(%r14), %rcx
leaq 0x5b17(%rip), %rdx      # 0x7010
movslq (%rdx,%rax,4), %rax
addq %rdx, %rax
jmpq *%rax
movq %rbx, %rdi
callq 0x4053
jmp 0x1663
cmpl $0x14, %eax
jne 0x1688
movq 0x10(%r14), %rdi
callq 0x27c0
testl %eax, %eax
je 0x1678
callq 0x1288
jmp 0x162d
addl $-0x2, %ebp
leaq 0x8(%rsp), %rdi
movq %rsp, %rsi
movl %ebp, %edx
callq 0x22f5
testl %eax, %eax
jne 0x1663
movq (%rsp), %rdx
leaq 0x110f(%rip), %rcx      # 0x2667
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x412a
jmp 0x1663
cmpl $0x4, %ebp
jb 0x1634
movq 0x18(%r14), %rdi
callq 0x11f0
cltq
jmp 0x163b
addl $-0x2, %ebp
leaq 0x8(%rsp), %rdi
movq %rsp, %rsi
movl %ebp, %edx
callq 0x22f5
testl %eax, %eax
jne 0x1663
movq (%rsp), %rdx
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x24bf
jmp 0x1663
movq 0x8a08(%rip), %rax      # 0x9fc8
movq (%rax), %rsi
movq %rbx, %rdi
callq 0x2500
jmp 0x1663
movq %rbx, %rdi
callq 0x168f
jmp 0x1663
leaq 0x8(%rbx), %rax
testq %rbx, %rbx
movq 0x8a0d(%rip), %rcx      # 0x9ff8
movq (%rcx), %rdi
leaq 0x5d01(%rip), %rcx      # 0x72f6
cmovneq %rax, %rcx
leaq 0x5cee(%rip), %rsi      # 0x72ee
leaq 0x5bf3(%rip), %rdx      # 0x71fa
xorl %eax, %eax
callq 0x1160
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl $0x0, 0x88(%rbx)
jne 0x167a
jmp 0x14de
callq 0x1250
jmp 0x162d
callq 0x12d1
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x167a
movq 0x128(%rbx), %rax
cmpq $0x71, %rax
movl $0x70, %edx
cmovaeq %rax, %rdx
addq 0x98(%rbx), %rdx
leaq 0x8b82(%rip), %rcx      # 0xa1d8
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x1810
movq %rbx, %rdi
callq 0x33a0
movq %rax, %rcx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testq %rcx, %rcx
jne 0x167a
xorl %eax, %eax
addq $0x2028, %rsp           # imm = 0x2028
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
callq 0x12ad
jmp 0x1678