// File: /workspace/github_c_makefile_star2_O1/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 %r12
pushq %rbx
subq $0x2020, %rsp           # imm = 0x2020
cmpl $0x1, %edi
jle 0x1575
movl %edi, %r14d
cmpl $0x2, %edi
je 0x157c
movq %rsi, %r15
movq 0x8(%rsi), %r12
xorl %eax, %eax
movq %rax, 0x8(%rsp)
movw $0x0, 0x10(%rsp)
leaq 0x20(%rsp), %rcx
movq %rcx, 0x18(%rsp)
movq %rax, (%rsp)
movzbl (%r12), %eax
addl $-0x63, %eax
cmpl $0x14, %eax
ja 0x1676
movl $0xf09, %ecx            # imm = 0xF09
btl %eax, %ecx
jae 0x151e
movq 0x10(%r15), %rdi
xorl %esi, %esi
callq 0x284d
movq %rax, %rbx
testq %rax, %rax
je 0x153f
cmpl $0x0, 0x88(%rbx)
jne 0x153f
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
cmpl $0x0, 0x88(%rbx)
jne 0x1664
movzbl (%r12), %eax
addl $-0x63, %eax
cmpl $0xb, %eax
ja 0x1655
leaq 0x10(%r15), %rcx
leaq 0x5b08(%rip), %rdx      # 0x7010
movslq (%rdx,%rax,4), %rax
addq %rdx, %rax
jmpq *%rax
movq %rbx, %rdi
callq 0x409c
jmp 0x1655
cmpl $0x14, %eax
jne 0x1676
movq 0x10(%r15), %rdi
callq 0x27c8
testl %eax, %eax
je 0x1662
callq 0x1288
jmp 0x1581
leaq 0x8(%rbx), %rax
testq %rbx, %rbx
movq 0x8aab(%rip), %rcx      # 0x9ff8
movq (%rcx), %rdi
leaq 0x5d9f(%rip), %rcx      # 0x72f6
cmovneq %rax, %rcx
leaq 0x5d8c(%rip), %rsi      # 0x72ee
leaq 0x5c91(%rip), %rdx      # 0x71fa
xorl %eax, %eax
callq 0x1160
jmp 0x14da
callq 0x1250
jmp 0x1581
callq 0x12d1
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0x1664
addl $-0x2, %r14d
leaq 0x8(%rsp), %rdi
movq %rsp, %rsi
movl %r14d, %edx
callq 0x22fb
testl %eax, %eax
jne 0x1655
movq (%rsp), %rdx
leaq 0x10bb(%rip), %rcx      # 0x266d
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x4173
jmp 0x1655
cmpl $0x4, %r14d
jl 0x1626
movq 0x18(%r15), %rdi
callq 0x11f0
cltq
jmp 0x162d
addl $-0x2, %r14d
leaq 0x8(%rsp), %rdi
movq %rsp, %rsi
movl %r14d, %edx
callq 0x22fb
testl %eax, %eax
jne 0x1655
movq (%rsp), %rdx
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x24c5
jmp 0x1655
movq 0x89b9(%rip), %rax      # 0x9fc8
movq (%rax), %rsi
movq %rbx, %rdi
callq 0x2506
jmp 0x1655
movq %rbx, %rdi
callq 0x167d
jmp 0x1655
movq 0x128(%rbx), %rax
cmpq $0x71, %rax
movl $0x70, %edx
cmovaeq %rax, %rdx
addq 0x98(%rbx), %rdx
leaq 0x8b90(%rip), %rcx      # 0xa1d8
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x17fe
movq %rbx, %rdi
callq 0x33dc
testq %rax, %rax
jne 0x1664
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x2020, %rsp           # imm = 0x2020
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
callq 0x12ad
jmp 0x1662