// File: enferex[P]fnplot/cs.cc
// Function: CS::buildDatabase[abi:cxx11]()
CSDB *CS::buildDatabase()
{
    int i = 0, sidx = 0;
    const char spin[] = "-\\|/";
    auto db = new CSDB;

    cout << "Building internal database: ";
    for (auto f: this->_files) {
        for (auto fndef_pr: *f->getFunctions()) {
            // Collect all calls this function (fndef) makes
            std::vector<const CSFuncCall *> callees;
            auto fndef = static_cast<const CSFuncDef *>(fndef_pr.second);
            fndef->getCallees(callees);

            // Add the funtion_def : calleess map entry
            auto pr = std::make_pair(fndef->getName(), callees);
            db->insert(pr);
            if ((++i % 1000) == 0)
              cout << '\b' << spin[sidx++ % 4] << std::flush;
        }
    }

    cout << '\b' << " Done " << endl;
    return db;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x150, %rsp            # imm = 0x150
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x120(%rbp)
movl $0x0, -0xc(%rbp)
movl $0x0, -0x10(%rbp)
movl 0x72c0(%rip), %eax      # 0xa28e
movl %eax, -0x15(%rbp)
movb 0x72bb(%rip), %al       # 0xa292
movb %al, -0x11(%rbp)
movl $0x38, %edi
callq 0x2230
movq %rax, %rdi
movq %rdi, -0x128(%rbp)
callq 0x3ef0
movq -0x128(%rbp), %rax
movq %rax, -0x20(%rbp)
movq 0xcfc3(%rip), %rdi      # 0xffc8
leaq 0x7287(%rip), %rsi      # 0xa293
callq 0x2210
movq -0x120(%rbp), %rax
addq $0x60, %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
callq 0x3f10
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rdi
callq 0x3f40
movq %rax, -0x38(%rbp)
leaq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x3f70
testb $0x1, %al
jne 0x3050
jmp 0x328a
leaq -0x30(%rbp), %rdi
callq 0x3fb0
movq (%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rdi
callq 0x3fd0
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rdi
callq 0x3ff0
movq %rax, -0x50(%rbp)
movq -0x48(%rbp), %rdi
callq 0x4020
movq %rax, -0x58(%rbp)
leaq -0x50(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x4050
testb $0x1, %al
jne 0x309d
jmp 0x327a
leaq -0x50(%rbp), %rdi
callq 0x4080
movq %rax, %rsi
leaq -0x80(%rbp), %rdi
callq 0x40b0
leaq -0x98(%rbp), %rdi
movq %rdi, -0x130(%rbp)
callq 0x40f0
movq -0x130(%rbp), %rsi
movq -0x60(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rdi
callq 0x4110
jmp 0x30e5
movq -0xa0(%rbp), %rsi
movq (%rsi), %rax
movq (%rax), %rax
leaq -0x108(%rbp), %rdi
callq *%rax
jmp 0x30fd
leaq -0xe8(%rbp), %rdi
leaq -0x108(%rbp), %rsi
leaq -0x98(%rbp), %rdx
callq 0x41c0
jmp 0x3119
leaq -0x108(%rbp), %rdi
callq 0x2180
movq -0x20(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
callq 0x4200
movb %dl, -0x139(%rbp)
movq %rax, -0x138(%rbp)
jmp 0x3144
movb -0x139(%rbp), %al
movq -0x138(%rbp), %rcx
movq %rcx, -0x118(%rbp)
movb %al, -0x110(%rbp)
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
movl $0x3e8, %ecx            # imm = 0x3E8
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0x3234
movq 0xce49(%rip), %rdi      # 0xffc8
movl $0x8, %esi
callq 0x22b0
movq %rax, -0x148(%rbp)
jmp 0x3192
movq -0x148(%rbp), %rdi
movl -0x10(%rbp), %eax
movl %eax, %ecx
incl %ecx
movl %ecx, -0x10(%rbp)
movl %eax, %edx
addl $0x3, %edx
testl %eax, %eax
movl %eax, %ecx
cmovsl %edx, %ecx
andl $-0x4, %ecx
subl %ecx, %eax
cltq
movsbl -0x15(%rbp,%rax), %esi
callq 0x22b0
movq %rax, -0x150(%rbp)
jmp 0x31c9
movq -0x150(%rbp), %rdi
movq 0xcdf9(%rip), %rsi      # 0xffd0
callq 0x2250
jmp 0x31de
jmp 0x3234
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa8(%rbp)
movl %eax, -0xac(%rbp)
jmp 0x3263
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa8(%rbp)
movl %eax, -0xac(%rbp)
leaq -0x108(%rbp), %rdi
callq 0x2180
jmp 0x3263
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa8(%rbp)
movl %eax, -0xac(%rbp)
leaq -0xe8(%rbp), %rdi
callq 0x4240
jmp 0x3263
leaq -0xe8(%rbp), %rdi
callq 0x4240
leaq -0x98(%rbp), %rdi
callq 0x4270
leaq -0x80(%rbp), %rdi
callq 0x42d0
leaq -0x50(%rbp), %rdi
callq 0x42f0
jmp 0x3087
leaq -0x98(%rbp), %rdi
callq 0x4270
leaq -0x80(%rbp), %rdi
callq 0x42d0
jmp 0x32c6
jmp 0x327c
leaq -0x30(%rbp), %rdi
callq 0x4320
jmp 0x303a
movq 0xcd37(%rip), %rdi      # 0xffc8
movl $0x8, %esi
callq 0x22b0
movq %rax, %rdi
leaq 0x700b(%rip), %rsi      # 0xa2b0
callq 0x2210
movq %rax, %rdi
movq 0xccf4(%rip), %rsi      # 0xffa8
callq 0x2250
movq -0x20(%rbp), %rax
addq $0x150, %rsp            # imm = 0x150
popq %rbp
retq
movq -0xa8(%rbp), %rdi
callq 0x23e0
nopw %cs:(%rax,%rax)