// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x2070, %rsp           # imm = 0x2070
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpl $0x2, -0x8(%rbp)
setl %al
andb $0x1, %al
movzbl %al, %edi
leaq 0x8ed4(%rip), %rsi      # 0xa210
callq 0x1640
cmpl $0x0, %eax
je 0x1358
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x1680
movl %eax, -0x4(%rbp)
jmp 0x162f
cmpl $0x3, -0x8(%rbp)
setl %al
andb $0x1, %al
movzbl %al, %edi
leaq 0x8eba(%rip), %rsi      # 0xa225
callq 0x1640
cmpl $0x0, %eax
je 0x1387
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x1680
movl %eax, -0x4(%rbp)
jmp 0x162f
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x18(%rbp)
movq $0x0, -0x2040(%rbp)
movw $0x0, -0x2038(%rbp)
leaq -0x2020(%rbp), %rax
movq %rax, -0x2030(%rbp)
movq $0x0, -0x2048(%rbp)
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
movl %eax, -0x2054(%rbp)
subl $0x63, %eax
je 0x1405
jmp 0x13d4
movl -0x2054(%rbp), %eax
subl $0x66, %eax
je 0x1405
jmp 0x13e1
movl -0x2054(%rbp), %eax
addl $-0x6b, %eax
subl $0x4, %eax
jb 0x1405
jmp 0x13f1
movl -0x2054(%rbp), %eax
subl $0x77, %eax
je 0x15f3
jmp 0x161e
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
xorl %esi, %esi
callq 0x2f50
movq %rax, -0x2028(%rbp)
movq -0x2028(%rbp), %rdi
leaq 0x8e11(%rip), %rsi      # 0xa23a
callq 0x16d0
cmpl $0x0, %eax
je 0x143f
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x162f
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
addl $-0x63, %eax
movl %eax, %ecx
movq %rcx, -0x2060(%rbp)
subl $0xb, %eax
ja 0x15d6
movq -0x2060(%rbp), %rax
leaq 0x8ba7(%rip), %rcx      # 0xa010
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x2028(%rbp), %rdi
callq 0x1740
jmp 0x15d6
cmpl $0x3, -0x8(%rbp)
jle 0x14a1
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x11d0
cltq
movq %rax, -0x2068(%rbp)
jmp 0x14b6
movq -0x2028(%rbp), %rax
movq 0x128(%rax), %rax
movq %rax, -0x2068(%rbp)
movq -0x2068(%rbp), %rax
movq %rax, -0x2050(%rbp)
cmpq $0x70, -0x2050(%rbp)
jbe 0x14de
movq -0x2050(%rbp), %rax
movq %rax, -0x2070(%rbp)
jmp 0x14ec
movl $0x70, %eax
movq %rax, -0x2070(%rbp)
jmp 0x14ec
movq -0x2070(%rbp), %rax
movq %rax, -0x2050(%rbp)
movq -0x2028(%rbp), %rdi
movq -0x2028(%rbp), %rax
movq 0x98(%rax), %rdx
addq -0x2050(%rbp), %rdx
leaq -0x2040(%rbp), %rsi
leaq 0xcca4(%rip), %rcx      # 0xe1c8
callq 0x18f0
jmp 0x15d6
movl -0x8(%rbp), %edx
subl $0x2, %edx
movq -0x10(%rbp), %rcx
addq $0x10, %rcx
leaq -0x2040(%rbp), %rdi
leaq -0x2048(%rbp), %rsi
callq 0x1ab0
cmpl $0x0, %eax
jne 0x156e
movq -0x2028(%rbp), %rdi
movq -0x2048(%rbp), %rdx
leaq -0x2040(%rbp), %rsi
callq 0x1c40
jmp 0x15d6
movl -0x8(%rbp), %edx
subl $0x2, %edx
movq -0x10(%rbp), %rcx
addq $0x10, %rcx
leaq -0x2040(%rbp), %rdi
leaq -0x2048(%rbp), %rsi
callq 0x1ab0
cmpl $0x0, %eax
jne 0x15b0
movq -0x2028(%rbp), %rdi
movq -0x2048(%rbp), %rdx
leaq -0x2040(%rbp), %rsi
callq 0x1c80
jmp 0x15d6
movq -0x2028(%rbp), %rdi
movq 0xca08(%rip), %rax      # 0xdfc8
movq (%rax), %rsi
callq 0x1cd0
jmp 0x15d6
movq -0x2028(%rbp), %rdi
callq 0x4fd0
movq -0x2028(%rbp), %rdi
callq 0x3c00
cmpq $0x0, %rax
je 0x15f1
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x162f
jmp 0x1628
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x2e90
movl %eax, %edi
leaq 0x8c40(%rip), %rsi      # 0xa249
callq 0x1640
cmpl $0x0, %eax
je 0x161c
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x162f
jmp 0x1628
movl $0x1, %edi
callq 0x1680
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x2070, %rsp           # imm = 0x2070
popq %rbp
retq
nopl (%rax,%rax)