// File: /workspace/github_c_makefile_star2_O2/barabo[P]advanced-shell-history/src/ash_query.cpp
// Function: main
int main(int argc, char ** argv) {
  // Load the config from the environment.
  Config & config = Config::instance();

  if (argc == 1) {  // No flags.
    if (config.sets("DEFAULT_QUERY")) {
      return execute(config.get_string("DEFAULT_QUERY"));
    }
    if (!config.sets("HIDE_USAGE_FOR_NO_ARGS")) {
      Flag::parse(&argc, &argv, true);  // Sets the prog name in help output.
      Flag::show_help(cerr);
    }
    return 1;
  }

  // Parse the flags, removing from argv and argc.
  Flag::parse(&argc, &argv, true);

  // Abort if unrecognized flags were used on the command line.
  if (argc != 0 && !config.sets("IGNORE_UNKNOWN_FLAGS")) {
    cerr << "unrecognized flag: " << argv[0] << endl;
    Flag::show_help(cerr);
    return 1;
  }

  // Display version, if that's all that was wanted.
  if (FLAGS_version) {
    cout << ASH_VERSION << endl;
    return 0;
  }

  // Display available query names, if requested.
  if (FLAGS_list_queries) {
    display(cout, Queries::get_desc(), "Query");
    return 0;
  }

  // Initialize the available formatters.
  CsvFormatter::init();
  NullFormatter::init();
  SpacedFormatter::init();
  GroupedFormatter::init();

  // Diaplay the available format names.
  if (FLAGS_list_formats) {
    display(cout, Formatter::get_desc(), "Format");
    return 0;
  }

  // Print the requested query (both generic and actual, if different).
  if (FLAGS_print_query != "") {
    string sql = Queries::get_sql(FLAGS_print_query);
    string raw = Queries::get_raw_sql(FLAGS_print_query);
    if (raw == "") {
      cout << "Query not found: " << FLAGS_print_query << "\nAvailable:\n";
      display(cout, Queries::get_desc(), "Query");
      return 1;
    }
    cout << "Query: " << FLAGS_print_query << endl;
    if (raw != sql) {
      cout << "Template Form:\n" << raw << "\nActual SQL:\n";
    }
    cout << sql << endl;
    return 0;
  }

  // Make sure the requested query exists.
  string sql = Queries::get_sql(FLAGS_query);
  if (sql == "") {
    cout << "Query not found: " << FLAGS_query << "\nAvailable:\n";
    display(cout, Queries::get_desc(), "Query");
    return 1;
  }

  // Execute the requested query.
  return execute(sql);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0xa8, %rsp
movl %edi, %ebx
movl %edi, 0x2c(%rsp)
movq %rsi, 0x80(%rsp)
callq 0x5d6d2
movq %rax, %r14
cmpl $0x1, %ebx
jne 0x5bfd3
leaq 0x13779(%rip), %rsi     # 0x6f6a5
leaq 0x30(%rsp), %rdi
leaq 0x8(%rsp), %rdx
callq 0x8150
leaq 0x30(%rsp), %rsi
movq %r14, %rdi
xorl %edx, %edx
callq 0x5d5c8
movl %eax, %ebx
leaq 0x30(%rsp), %rdi
callq 0x84b0
testb %bl, %bl
je 0x5c056
leaq 0x13740(%rip), %rsi     # 0x6f6a5
leaq 0x8(%rsp), %rdi
leaq 0x88(%rsp), %rdx
callq 0x8150
leaq 0x143c7(%rip), %rsi     # 0x70345
leaq 0x60(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x8150
leaq 0x30(%rsp), %rdi
leaq 0x8(%rsp), %rdx
leaq 0x60(%rsp), %rcx
movq %r14, %rsi
callq 0x5d692
leaq 0x30(%rsp), %rdi
callq 0x5bad9
movl %eax, %ebx
leaq 0x30(%rsp), %rdi
callq 0x84b0
leaq 0x60(%rsp), %rdi
callq 0x84b0
leaq 0x8(%rsp), %rdi
callq 0x84b0
jmp 0x5c19f
leaq 0x2c(%rsp), %r15
leaq 0x80(%rsp), %rsi
pushq $0x1
popq %rbx
movq %r15, %rdi
movl %ebx, %edx
callq 0x5f9a6
cmpl $0x0, (%r15)
je 0x5c02d
leaq 0x136d0(%rip), %rsi     # 0x6f6ca
leaq 0x30(%rsp), %rdi
leaq 0x8(%rsp), %rdx
callq 0x8150
leaq 0x30(%rsp), %rsi
movq %r14, %rdi
xorl %edx, %edx
callq 0x5d5c8
movl %eax, %ebp
leaq 0x30(%rsp), %rdi
callq 0x84b0
testb %bpl, %bpl
je 0x5c0e2
cmpb $0x1, 0x2d314(%rip)     # 0x89348
jne 0x5c097
movq 0x2af7b(%rip), %rdi     # 0x86fb8
leaq 0x136af(%rip), %rsi     # 0x6f6f3
callq 0x83a0
movq %rax, %rdi
callq 0x81a0
jmp 0x5c19d
leaq 0x13656(%rip), %rsi     # 0x6f6b3
leaq 0x30(%rsp), %rdi
leaq 0x8(%rsp), %rdx
callq 0x8150
leaq 0x30(%rsp), %rsi
movq %r14, %rdi
xorl %edx, %edx
callq 0x5d5c8
movl %eax, %ebx
leaq 0x30(%rsp), %rdi
callq 0x84b0
testb %bl, %bl
je 0x5c118
pushq $0x1
popq %rbx
jmp 0x5c19f
cmpb $0x1, 0x2d272(%rip)     # 0x89310
jne 0x5c13d
leaq 0x30(%rsp), %rdi
callq 0x63bd0
leaq 0x13644(%rip), %rsi     # 0x6f6f9
leaq 0x8(%rsp), %rdi
leaq 0x60(%rsp), %rdx
callq 0x8150
leaq 0x30(%rsp), %rsi
leaq 0x8(%rsp), %rdx
callq 0x5b98c
leaq 0x8(%rsp), %rdi
callq 0x84b0
jmp 0x5c193
movq 0x2af07(%rip), %r14     # 0x86ff0
leaq 0x135ef(%rip), %rsi     # 0x6f6df
movq %r14, %rdi
callq 0x83a0
movq 0x80(%rsp), %rcx
movq (%rcx), %rsi
movq %rax, %rdi
callq 0x83a0
movq %rax, %rdi
callq 0x81a0
movq %r14, %rdi
jmp 0x5c136
leaq 0x2c(%rsp), %rdi
leaq 0x80(%rsp), %rsi
pushq $0x1
popq %rbx
movl %ebx, %edx
callq 0x5f9a6
movq 0x2aeba(%rip), %rdi     # 0x86ff0
callq 0x5f8ec
jmp 0x5c19f
callq 0x6156e
callq 0x616c6
callq 0x610a2
callq 0x61802
cmpb $0x1, 0x2d148(%rip)     # 0x892a0
jne 0x5c1af
leaq 0x30(%rsp), %rdi
callq 0x60f34
leaq 0x13533(%rip), %rsi     # 0x6f69e
leaq 0x8(%rsp), %rdi
leaq 0x60(%rsp), %rdx
callq 0x8150
leaq 0x30(%rsp), %rsi
leaq 0x8(%rsp), %rdx
callq 0x5b98c
leaq 0x8(%rsp), %rdi
callq 0x84b0
leaq 0x30(%rsp), %rdi
callq 0x5c56c
xorl %ebx, %ebx
movl %ebx, %eax
addq $0xa8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2d01a(%rip), %rdi     # 0x891d0
leaq 0x14188(%rip), %rsi     # 0x70345
callq 0x5c558
testb %al, %al
je 0x5c289
leaq 0x2cfff(%rip), %rbx     # 0x891d0
leaq 0x8(%rsp), %rdi
movq %rbx, %rsi
callq 0x63e5e
leaq 0x60(%rsp), %rdi
movq %rbx, %rsi
callq 0x63e08
leaq 0x14153(%rip), %rsi     # 0x70345
leaq 0x60(%rsp), %rdi
callq 0x5c510
testb %al, %al
je 0x5c340
movq 0x2adad(%rip), %rdi     # 0x86fb8
leaq 0x134ed(%rip), %rsi     # 0x6f6ff
callq 0x83a0
leaq 0x2cfb2(%rip), %rsi     # 0x891d0
movq %rax, %rdi
callq 0x8320
leaq 0x134e4(%rip), %rsi     # 0x6f711
movq %rax, %rdi
callq 0x83a0
leaq 0x30(%rsp), %rdi
callq 0x63bd0
leaq 0x134b3(%rip), %rsi     # 0x6f6f9
leaq 0x88(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x8150
leaq 0x30(%rsp), %rsi
leaq 0x88(%rsp), %rdx
callq 0x5b98c
leaq 0x88(%rsp), %rdi
callq 0x84b0
leaq 0x30(%rsp), %rdi
callq 0x5c56c
pushq $0x1
popq %rbx
jmp 0x5c3c7
leaq 0x2cf90(%rip), %rsi     # 0x89220
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0x63e5e
leaq 0x140a1(%rip), %rsi     # 0x70345
movq %rbx, %rdi
callq 0x5c510
testb %al, %al
je 0x5c32f
movq 0x2ad01(%rip), %rdi     # 0x86fb8
leaq 0x13441(%rip), %rsi     # 0x6f6ff
callq 0x83a0
leaq 0x2cf56(%rip), %rsi     # 0x89220
movq %rax, %rdi
callq 0x8320
leaq 0x13438(%rip), %rsi     # 0x6f711
movq %rax, %rdi
callq 0x83a0
leaq 0x30(%rsp), %rdi
callq 0x63bd0
leaq 0x13407(%rip), %rsi     # 0x6f6f9
leaq 0x60(%rsp), %rdi
leaq 0x88(%rsp), %rdx
callq 0x8150
leaq 0x30(%rsp), %rsi
leaq 0x60(%rsp), %rdx
callq 0x5b98c
leaq 0x60(%rsp), %rdi
callq 0x84b0
leaq 0x30(%rsp), %rdi
callq 0x5c56c
pushq $0x1
popq %rbx
jmp 0x5c3d1
leaq 0x8(%rsp), %rdi
callq 0x5bad9
movl %eax, %ebx
jmp 0x5c3d1
movq 0x2ac71(%rip), %rdi     # 0x86fb8
leaq 0x133d0(%rip), %rsi     # 0x6f71e
callq 0x83a0
leaq 0x2ce76(%rip), %rsi     # 0x891d0
movq %rax, %rdi
callq 0x8320
movq %rax, %rdi
callq 0x81a0
leaq 0x60(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x5c562
testb %al, %al
je 0x5c3ac
movq 0x2ac34(%rip), %rdi     # 0x86fb8
leaq 0x1339b(%rip), %rsi     # 0x6f726
callq 0x83a0
leaq 0x60(%rsp), %rsi
movq %rax, %rdi
callq 0x8320
leaq 0x13392(%rip), %rsi     # 0x6f736
movq %rax, %rdi
callq 0x83a0
movq 0x2ac05(%rip), %rdi     # 0x86fb8
leaq 0x8(%rsp), %rsi
callq 0x8320
xorl %ebx, %ebx
movq %rax, %rdi
callq 0x81a0
leaq 0x60(%rsp), %rdi
callq 0x84b0
leaq 0x8(%rsp), %rdi
callq 0x84b0
jmp 0x5c19f
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
callq 0x84b0
jmp 0x5c406
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0x84b0
jmp 0x5c417
jmp 0x5c46a
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x5c56c
jmp 0x5c46d
jmp 0x5c437
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x5c56c
jmp 0x5c43a
movq %rax, %rbx
jmp 0x5c477
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x84b0
jmp 0x5c44c
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x84b0
jmp 0x5c4f5
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x5c56c
jmp 0x5c4f5
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x84b0
jmp 0x5c486
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0x84b0
leaq 0x8(%rsp), %rdi
callq 0x84b0
jmp 0x5c4f5
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x5c56c
jmp 0x5c4f5
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x84b0
jmp 0x5c4c9
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x84b0
jmp 0x5c4f5
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x84b0
jmp 0x5c4f5
jmp 0x5c4f2
movq %rax, %rbx
jmp 0x5c4d3
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0x84b0
leaq 0x8(%rsp), %rdi
callq 0x84b0
jmp 0x5c4f5
jmp 0x5c4f2
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x84b0
jmp 0x5c4f5
jmp 0x5c4f2
movq %rax, %rbx
movq %rbx, %rdi
callq 0x86f0
movq %rax, %rdi
callq 0x5c505