// File: /workspace/github_c_makefile_star2_O2/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 %r13
pushq %r12
pushq %rbx
subq $0x2078, %rsp           # imm = 0x2078
movq %rsi, %r15
movl %edi, %ebp
xorl %edi, %edi
cmpl $0x2, %ebp
setl %dil
leaq 0x4dfe(%rip), %rsi      # 0x6160
callq 0x1857
cmpl $0x1, %ebp
jle 0x1386
xorl %edi, %edi
cmpl $0x2, %ebp
sete %dil
leaq 0x4df9(%rip), %rsi      # 0x6175
callq 0x1857
cmpl $0x2, %ebp
jne 0x13a4
pushq $-0x1
popq %rbx
movl %ebx, %edi
callq 0x187f
movl %ebx, %eax
addq $0x2078, %rsp           # imm = 0x2078
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x8(%r15), %r12
andq $0x0, 0x18(%rsp)
andw $0x0, 0x20(%rsp)
leaq 0x70(%rsp), %rax
andq $0x0, 0x10(%rsp)
movq %rax, 0x28(%rsp)
movzbl (%r12), %eax
addl $-0x63, %eax
cmpl $0x14, %eax
ja 0x1464
pushq $-0x1
popq %rbx
movl $0xf09, %ecx            # imm = 0xF09
btl %eax, %ecx
jae 0x1439
movq 0x10(%r15), %rdi
xorl %esi, %esi
callq 0x2259
movq %rax, %r14
testq %rax, %rax
je 0x17ce
cmpl $0x0, 0x88(%r14)
jne 0x17ce
movzbl (%r12), %eax
addl $-0x63, %eax
cmpl $0xb, %eax
ja 0x183f
leaq 0x10(%r15), %rcx
leaq 0x4bed(%rip), %rdx      # 0x6010
movslq (%rdx,%rax,4), %rax
addq %rdx, %rax
jmpq *%rax
movq %r14, %rdi
callq 0x362a
jmp 0x183f
cmpl $0x14, %eax
jne 0x1464
movq 0x10(%r15), %rdi
callq 0x21d4
movl %eax, %ebp
leaq 0x4d49(%rip), %rsi      # 0x6199
movl %eax, %edi
callq 0x1857
testl %ebp, %ebp
jne 0x1390
jmp 0x1850
pushq $0x1
popq %rdi
callq 0x187f
jmp 0x1850
addl $-0x2, %ebp
leaq 0x18(%rsp), %rdi
leaq 0x10(%rsp), %rsi
movl %ebp, %edx
callq 0x1e06
testl %eax, %eax
jne 0x183f
movq 0x10(%rsp), %rdx
leaq 0xce9(%rip), %rcx       # 0x2182
leaq 0x18(%rsp), %rsi
movq %r14, %rdi
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x3721
jmp 0x183f
cmpl $0x4, %ebp
jb 0x1812
movq 0x18(%r15), %rdi
callq 0x11f0
cltq
jmp 0x1819
addl $-0x2, %ebp
leaq 0x18(%rsp), %rdi
leaq 0x10(%rsp), %rsi
movl %ebp, %edx
callq 0x1e06
testl %eax, %eax
jne 0x183f
movq 0x10(%rsp), %r15
leaq 0x38(%rsp), %rsi
leaq 0x18(%rsp), %rdx
movq %r14, %rdi
callq 0x36b2
testq %rax, %rax
je 0x183f
movq 0x40(%rsp), %rdx
leaq 0x18(%rsp), %rsi
movq %r14, %rdi
movq %r15, %rcx
jmp 0x183a
movq 0x7aa6(%rip), %rax      # 0x8fc8
movq (%rax), %r15
pushq $0x30
popq %rdi
callq 0x1180
movq %rax, %r13
movl $0x100000, %edi         # imm = 0x100000
callq 0x1180
movq %rax, %rdx
andq $0x0, (%r13)
andw $0x0, 0x8(%r13)
movq %rax, 0x10(%r13)
pushq $0x2
popq %rax
movl %eax, 0x4(%rsp)
xorl %r12d, %r12d
xorl %ebp, %ebp
movq %rdx, 0x8(%rsp)
leaq (%rdx,%r12), %rax
movq %rax, 0x30(%rsp)
movb $0x1, %bl
movq %r15, %rdi
callq 0x1230
cmpl $-0x1, %eax
je 0x163c
movslq %ebp, %rcx
testb $0x1, %bl
je 0x15d3
xorl %ebx, %ebx
cmpl $0x5c, %eax
je 0x1568
cmpl $0xa, %eax
je 0x15ee
cmpl $0x9, %eax
jne 0x15d3
incl %ebp
movl 0x4(%rsp), %eax
cmpl %eax, %ebp
jl 0x15b3
addl %eax, %eax
movl %eax, 0x4(%rsp)
cltq
imulq $0x18, %rax, %rsi
movq %r13, %rdi
callq 0x1190
movq %rax, %r13
movslq %ebp, %rax
imulq $0x18, %rax, %rax
andq $0x0, (%r13,%rax)
andw $0x0, 0x8(%r13,%rax)
movq 0x30(%rsp), %rcx
movq %rcx, 0x10(%r13,%rax)
jmp 0x1566
movq 0x8(%rsp), %rdx
movb %al, (%rdx,%r12)
incq %r12
imulq $0x18, %rcx, %rax
incw 0x8(%r13,%rax)
jmp 0x155d
testl %ebp, %ebp
je 0x161a
leaq 0x18(%r13), %rdx
leaq 0x30(%r13), %rcx
leal -0x1(%rbp), %r8d
cmpl $0x2, %ebp
movl $0x0, %eax
cmovll %eax, %r8d
movq %r14, %rdi
movq %r13, %rsi
xorl %r9d, %r9d
callq 0x32bc
jmp 0x1627
movq %r14, %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0x3259
andw $0x0, 0x8(%r13)
xorl %r12d, %r12d
xorl %ebp, %ebp
movq 0x8(%rsp), %rdx
jmp 0x155d
movq %r13, %rdi
callq 0x1030
movq 0x8(%rsp), %rdi
callq 0x1030
jmp 0x17c9
leaq 0x4f14(%rip), %r15      # 0x656e
movq %r15, %rdi
callq 0x1080
movl 0xc0(%r14), %esi
movl 0xc4(%r14), %edx
leaq 0x4c20(%rip), %rdi      # 0x6297
xorl %eax, %eax
callq 0x10f0
movq 0x120(%r14), %rsi
movb 0xc8(%r14), %cl
pushq $0x1
popq %rdx
shlq %cl, %rdx
leaq 0x4c0c(%rip), %rdi      # 0x62a5
xorl %eax, %eax
callq 0x10f0
movq %r15, %rdi
callq 0x1080
leaq 0x4eb2(%rip), %rdi      # 0x6561
callq 0x1080
pushq $0x1a
popq %rbx
leaq 0x4bfa(%rip), %r15      # 0x62b8
cmpq $0x22, %rbx
je 0x16dc
movl (%r14,%rbx,8), %edx
movl 0x4(%r14,%rbx,8), %esi
movq %r15, %rdi
xorl %eax, %eax
callq 0x10f0
incq %rbx
jmp 0x16be
movq 0xa0(%r14), %rsi
movq 0x110(%r14), %rdx
leaq 0x4bd4(%rip), %rdi      # 0x62c5
xorl %eax, %eax
callq 0x10f0
movq 0xb8(%r14), %rsi
movq 0x118(%r14), %rdx
leaq 0x4bce(%rip), %rdi      # 0x62db
xorl %eax, %eax
callq 0x10f0
leaq 0x4e53(%rip), %rdi      # 0x656e
callq 0x1080
leaq 0x4e40(%rip), %rdi      # 0x6567
callq 0x1080
movq 0x128(%r14), %r13
leaq 0x4bc6(%rip), %r15      # 0x6300
leaq 0x4db6(%rip), %rbp      # 0x64f7
testq %r13, %r13
je 0x17bd
movq %r14, %rdi
movq %r13, %rsi
callq 0x3228
movq %rax, %r12
leaq 0x4b96(%rip), %rdi      # 0x62f1
movq %r13, %rsi
xorl %eax, %eax
callq 0x10f0
movb $0x1, %al
movq %r12, %r13
testb $0x1, %al
je 0x17a2
movb $0x3f, %bl
testb %bl, %bl
js 0x179a
testb $0x7, %bl
movq %rbp, %rdi
cmoveq %r15, %rdi
movq (%r13), %rax
movzbl %bl, %ecx
xorl %esi, %esi
btq %rcx, %rax
setb %sil
xorl %eax, %eax
callq 0x10f0
decb %bl
jmp 0x1770
addq $0x8, %r13
xorl %eax, %eax
jmp 0x176a
pushq $0xa
popq %rdi
callq 0x1040
movq (%r12), %r13
movabsq $0xffffffffff, %rax     # imm = 0xFFFFFFFFFF
andq %rax, %r13
jmp 0x1741
leaq 0x4daa(%rip), %rdi      # 0x656e
callq 0x1080
pushq $-0x1
popq %rbx
jmp 0x183f
leaq 0x8(%r14), %rax
testq %r14, %r14
movq 0x781c(%rip), %rcx      # 0x8ff8
movq (%rcx), %rdi
leaq 0x4aa0(%rip), %rcx      # 0x6286
cmovneq %rax, %rcx
leaq 0x4a8d(%rip), %rsi      # 0x627e
leaq 0x4992(%rip), %rdx      # 0x618a
xorl %eax, %eax
callq 0x1160
cmpl $0x0, 0x88(%r14)
jne 0x1390
jmp 0x1407
movq 0x128(%r14), %rax
cmpq $0x71, %rax
pushq $0x70
popq %rdx
cmovaeq %rax, %rdx
addq 0x98(%r14), %rdx
leaq 0x79a6(%rip), %rcx      # 0x91d8
leaq 0x18(%rsp), %rsi
movq %r14, %rdi
callq 0x18b1
movq %r14, %rdi
callq 0x2b14
testq %rax, %rax
jne 0x1390
xorl %ebx, %ebx
jmp 0x1390