// File: /workspace/github_cpp_makefile_star2_O2/enferex[P]fnplot/main.cc
// Function: main
int main(int argc, char **argv)
{
    int opt;
    FILE *out;
    bool do_callees, do_callers;
    const char *fname, *fn_name, *out_fname;
    CS *cs;
    CSDB *db;
    int depth = 2;

    do_callers = do_callees = false;
    fname = out_fname = fn_name = NULL;

    while ((opt = getopt(argc, argv, "c:d:f:o:hxy")) != -1) {
        switch (opt) {
        case 'c': fname = optarg; break;
        case 'd': depth = atoi(optarg); break;
        case 'f': fn_name = optarg; break;
        case 'o': out_fname = optarg; break;
        case 'x': do_callers = true; break;
        case 'y': do_callees = true; break;
        case 'h': usage(argv[0]); break;
        default: return EXIT_FAILURE;
        }
    }

    if (!fname || !fn_name || depth < 0) {
        fprintf(stderr, "Invalid options, see '-h'\n");
        return EXIT_FAILURE;
    }

    // If the user did not specify callers or callees, do so for them!
    if (!do_callers && !do_callees)
      do_callees = true;

    if (out_fname && !(out = fopen(out_fname, "w"))) {
        fprintf(stderr, "Error opening output file %s: %s\n",
                out_fname, strerror(errno));
        exit(errno);
    }
    else if (!out_fname)
      out = stdout;

    // Load
    try {
        cs = new CS(fname);
    } 
    catch (const char *err) {
        fprintf(stderr, "Error loading cscope database: %s\n", err);
        exit(EXIT_FAILURE);
    }
    db = cs->buildDatabase();

    // Go!
    if (do_callers)
      csPrintCallers(out, db, fn_name, depth);
    if (do_callees)
      csPrintCallees(out, db, fn_name, depth);

    fclose(out);
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, %r13
movl %edi, %ebp
pushq $0x2
popq %rbx
movq $0x0, 0x18(%rsp)
leaq 0x2b6a(%rip), %r14      # 0x501c
movq 0x5aff(%rip), %r15      # 0x7fb8
leaq 0x2b44(%rip), %r12      # 0x5004
movq $0x0, 0x28(%rsp)
movq $0x0, 0x30(%rsp)
movq $0x0, 0x20(%rsp)
movq $0x0, 0x8(%rsp)
movl %ebp, %edi
movq %r13, %rsi
movq %r14, %rdx
callq 0x2080
leal -0x63(%rax), %ecx
cmpl $0x5, %ecx
ja 0x250e
movslq (%r12,%rcx,4), %rax
addq %r12, %rax
jmpq *%rax
movq (%r15), %rdi
callq 0x22c0
movl %eax, %ebx
jmp 0x24e4
cmpl $-0x1, %eax
je 0x2556
cmpl $0x6f, %eax
je 0x2543
cmpl $0x78, %eax
je 0x254d
cmpl $0x79, %eax
jne 0x267e
movb $0x1, %al
movq %rax, 0x8(%rsp)
jmp 0x24e4
movq (%r15), %rax
movq %rax, 0x30(%rsp)
jmp 0x24e4
movq (%r15), %rax
movq %rax, 0x28(%rsp)
jmp 0x24e4
movq (%r15), %rax
movq %rax, 0x20(%rsp)
jmp 0x24e4
movb $0x1, %al
movq %rax, 0x18(%rsp)
jmp 0x24e4
movq 0x28(%rsp), %r15
testq %r15, %r15
movq 0x30(%rsp), %r13
je 0x2662
testq %r13, %r13
je 0x2662
testl %ebx, %ebx
js 0x2662
movq 0x20(%rsp), %r12
testq %r12, %r12
je 0x25d5
leaq 0x2ab8(%rip), %rsi      # 0x5043
movq %r12, %rdi
callq 0x2210
movq %rax, 0x10(%rsp)
testq %rax, %rax
jne 0x25d5
movq 0x5a34(%rip), %rax      # 0x7fd8
movq (%rax), %rbx
callq 0x2030
movq %rax, %r14
movl (%rax), %edi
callq 0x20a0
leaq 0x2a88(%rip), %rsi      # 0x5045
movq %rbx, %rdi
movq %r12, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x2290
movl (%r14), %edi
callq 0x2230
testq %r12, %r12
jne 0x25e9
movq 0x59c7(%rip), %rax      # 0x7fa8
movq (%rax), %rax
movq %rax, 0x10(%rsp)
pushq $0x78
popq %rdi
callq 0x21d0
movq %rax, %r12
movq %r13, %r14
movq %rax, %rdi
movq %r15, %rsi
callq 0x26f8
movq 0x18(%rsp), %r13
movl %r13d, %ebp
orb 0x8(%rsp), %bpl
movq %r12, %rdi
callq 0x2cf8
movq %rax, %r15
testb $0x1, %r13b
movq %r14, %r12
movq 0x10(%rsp), %r14
je 0x2638
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
movl %ebx, %ecx
callq 0x2ef3
notb %bpl
orb 0x8(%rsp), %bpl
testb $0x1, %bpl
je 0x2656
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
movl %ebx, %ecx
callq 0x30b8
movq %r14, %rdi
callq 0x21c0
xorl %eax, %eax
jmp 0x2681
movq 0x596f(%rip), %rax      # 0x7fd8
movq (%rax), %rcx
leaq 0x29b5(%rip), %rdi      # 0x5028
pushq $0x1a
popq %rsi
pushq $0x1
popq %rdx
callq 0x2350
pushq $0x1
popq %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%r13), %rsi
leaq 0x29ef(%rip), %rdi      # 0x508a
xorl %eax, %eax
callq 0x2040
xorl %edi, %edi
callq 0x2230
movq %rdx, %r14
movq %rax, %rbx
pushq $0x78
popq %rsi
movq %r12, %rdi
callq 0x21e0
jmp 0x26c2
movq %rdx, %r14
movq %rax, %rbx
movq %rbx, %rdi
cmpl $0x1, %r14d
jne 0x26f3
callq 0x20c0
movq 0x5901(%rip), %rcx      # 0x7fd8
movq (%rcx), %rdi
leaq 0x2986(%rip), %rsi      # 0x5067
movq %rax, %rdx
xorl %eax, %eax
callq 0x2290
pushq $0x1
popq %rdi
callq 0x2230
callq 0x2320