// File: /workspace/github_cpp_makefile_star2_O2/EDDRSoftware[P]libdefsEval/main.cpp
// Function: evaluate(boost::program_options::variables_map const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>*)
void evaluate(const variables_map &vm, const string &libdefs, std::vector<string> *pLibDefFiles)
{
    bool showAssigns    = vm.count("assigns");
    bool showComments   = vm.count("comments");
    bool showEmptyLines = vm.count("emptylines");
    path fp;

    try {
        if(parse(libdefs, current_path(), &fp)) {
            ifstream libdefsFile(fp.string().c_str());

            if(libdefsFile.is_open()) {
                int lineNum = 0;

                while(libdefsFile.good()) {
                    lineNum++;
                    string line;
                    getline(libdefsFile, line);

                    if(line.length()==0) {
                        if(showEmptyLines) {
                            cout << "EMPTY LINE: " << fp.string() << ":" <<
                                 lineNum << endl;
                        }

                        continue;
                    }

                    string action;
                    stringstream stream(line);
                    stream >> action;

                    if(action[0]=='#') {
                        if(showComments) {
                            cout << "COMMENT: " << line << endl;
                        }

                        continue;
                    }

                    if(action=="DEFINE") {
                        string var1, var2;
                        stream >> var1;
                        // var2 requires reading until EOL;
                        readUntilEOL(&stream, &var2);

                        if(var1[0]=='#' || var2[0]=='#') {
                            cerr << "INVALID LINE: " << fp.string() << ":" <<
                                 lineNum << " => " << line << endl;
                            continue;
                        }

                        if(var1.length()>0 && var2.length()>0) {
                            evaluateDefine(vm, var1, var2, fp, line, lineNum);
                        }
                    } else if(action=="INCLUDE") {
                        string var1;
                        // var1 requires reading until EOL
                        readUntilEOL(&stream, &var1);

                        if(var1[0]=='#') {
                            cerr << "INVALID LINE: " << fp.string() << ":" <<
                                 lineNum << " => " << line << endl;
                            continue;
                        }

                        if(var1.length()>0) {
                            evaluateInclude(vm, var1, fp, line, lineNum, pLibDefFiles);
                        }
                    } else if(action=="ASSIGN") {
                        if(showAssigns) {
                            cout << "ASSIGN: " << fp.string() << ":" << lineNum << " \"" << line << "\"" <<
                                 endl;
                        }
                    } else {
                        cerr << "INVALID LINE: " << fp.string() << ":" <<
                             lineNum << " => " << line << endl;
                    }
                }
            } else {
                cerr << "ERROR: Library path " << libdefs <<
                     " does not exist." << endl;
            }
        }
    } catch(...) {
        cerr << "ERROR: Library path " << fp << " does not exist." << endl;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x458, %rsp            # imm = 0x458
movq %rdx, %r15
movq %rsi, %rbx
movq %rdi, %r12
leaq 0x3de0(%rip), %rsi      # 0x9146
leaq -0x2f8(%rbp), %rdi
leaq -0x480(%rbp), %rdx
callq 0x6052
leaq 0x10(%r12), %r14
leaq -0x2f8(%rbp), %rsi
movq %r14, %rdi
callq 0x602e
movq %rax, %r13
leaq -0x2f8(%rbp), %rdi
callq 0x4150
leaq 0x3dab(%rip), %rsi      # 0x914e
leaq -0x2f8(%rbp), %rdi
leaq -0x480(%rbp), %rdx
callq 0x6052
leaq -0x2f8(%rbp), %rsi
movq %r14, %rdi
callq 0x602e
movq %rax, -0xa8(%rbp)
leaq -0x2f8(%rbp), %rdi
callq 0x4150
leaq 0x3d78(%rip), %rsi      # 0x9157
leaq -0x2f8(%rbp), %rdi
leaq -0x480(%rbp), %rdx
callq 0x6052
leaq -0x2f8(%rbp), %rsi
movq %r14, %rdi
callq 0x602e
movq %rax, -0xb0(%rbp)
leaq -0x2f8(%rbp), %rdi
callq 0x4150
leaq -0x58(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq -0x2f8(%rbp), %rdi
callq 0x613f
leaq -0x470(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq -0x2f8(%rbp), %rsi
leaq -0x68(%rbp), %rdx
leaq -0x480(%rbp), %rcx
movq %rbx, %rdi
xorl %r8d, %r8d
callq 0x4887
movl %eax, %r14d
leaq -0x480(%rbp), %rdi
callq 0x4150
leaq -0x2f8(%rbp), %rdi
callq 0x4150
testb %r14b, %r14b
je 0x5913
movq -0x68(%rbp), %rsi
leaq -0x2f8(%rbp), %rdi
pushq $0x8
popq %rdx
callq 0x44e0
leaq -0x280(%rbp), %rdi
callq 0x4080
testb %al, %al
je 0x58d2
movq %r13, -0xa0(%rbp)
movq %r12, -0x70(%rbp)
movq %r15, -0x98(%rbp)
pushq $0x1
popq %rbx
leaq -0x2f8(%rbp), %r15
leaq -0xf0(%rbp), %r14
leaq -0x480(%rbp), %r12
leaq -0xd0(%rbp), %r13
movq -0x2f8(%rbp), %rax
movq -0x18(%rax), %rax
cmpl $0x0, -0x2d8(%rbp,%rax)
jne 0x5907
leaq -0xe0(%rbp), %rax
movq %rax, -0xf0(%rbp)
andq $0x0, -0xe8(%rbp)
movb $0x0, -0xe0(%rbp)
movq %r15, %rdi
movq %r14, %rsi
callq 0x4050
cmpq $0x0, -0xe8(%rbp)
je 0x55a6
leaq -0xc0(%rbp), %rax
movq %rax, -0xd0(%rbp)
andq $0x0, -0xc8(%rbp)
movb $0x0, -0xc0(%rbp)
movq %r12, %rdi
movq %r14, %rsi
pushq $0x18
popq %rdx
callq 0x4450
movq %r12, %rdi
movq %r13, %rsi
callq 0x4380
movq -0xd0(%rbp), %rax
cmpb $0x23, (%rax)
jne 0x55f9
movq 0x8a54(%rip), %rdi      # 0xdfc8
leaq 0x3bf4(%rip), %rsi      # 0x916f
cmpq $0x0, -0xa8(%rbp)
je 0x56db
callq 0x42d0
movq %rax, %rdi
movq %r14, %rsi
callq 0x42a0
movq %rax, %rdi
callq 0x4170
jmp 0x56db
cmpq $0x0, -0xb0(%rbp)
je 0x56eb
movq 0x8a0d(%rip), %rdi      # 0xdfc8
leaq 0x3ba0(%rip), %rsi      # 0x9162
callq 0x42d0
movq %rax, %rdi
leaq -0x68(%rbp), %rsi
callq 0x42a0
movq %rax, %rdi
leaq 0x3a74(%rip), %rsi      # 0x9051
callq 0x42d0
movq %rax, %rdi
movl %ebx, %esi
callq 0x4490
movq %rax, %rdi
callq 0x4170
jmp 0x56eb
movq %r13, %rdi
leaq 0x3b76(%rip), %rsi      # 0x9179
callq 0x6159
testb %al, %al
je 0x56fa
leaq -0x38(%rbp), %rax
movq %rax, -0x48(%rbp)
andq $0x0, -0x40(%rbp)
xorl %ecx, %ecx
movb %cl, -0x38(%rbp)
leaq -0x80(%rbp), %rax
movq %rax, -0x90(%rbp)
andq $0x0, -0x88(%rbp)
movb %cl, -0x80(%rbp)
movq %r12, %rdi
leaq -0x48(%rbp), %rsi
callq 0x4380
movq %r12, %rdi
leaq -0x90(%rbp), %rsi
callq 0x4a96
movq -0x48(%rbp), %rax
cmpb $0x23, (%rax)
je 0x566c
movq -0x90(%rbp), %rax
cmpb $0x23, (%rax)
jne 0x5896
movq 0x897d(%rip), %rdi      # 0xdff0
leaq 0x39d9(%rip), %rsi      # 0x9053
callq 0x42d0
movq %rax, %rdi
leaq -0x68(%rbp), %rsi
callq 0x42a0
movq %rax, %rdi
leaq 0x39bc(%rip), %rsi      # 0x9051
callq 0x42d0
movq %rax, %rdi
movl %ebx, %esi
callq 0x4490
movq %rax, %rdi
leaq 0x3a4f(%rip), %rsi      # 0x90fd
callq 0x42d0
movq %rax, %rdi
movq %r14, %rsi
callq 0x42a0
movq %rax, %rdi
callq 0x4170
leaq -0x90(%rbp), %rdi
callq 0x4150
leaq -0x48(%rbp), %rdi
callq 0x4150
movq %r12, %rdi
callq 0x4230
movq %r13, %rdi
callq 0x4150
movq %r14, %rdi
callq 0x4150
incl %ebx
jmp 0x54dc
movq %r13, %rdi
leaq 0x3a7c(%rip), %rsi      # 0x9180
callq 0x6159
testb %al, %al
je 0x579a
leaq -0x38(%rbp), %rax
movq %rax, -0x48(%rbp)
andq $0x0, -0x40(%rbp)
movb $0x0, -0x38(%rbp)
movq %r12, %rdi
leaq -0x48(%rbp), %rsi
callq 0x4a96
movq -0x48(%rbp), %rax
cmpb $0x23, (%rax)
jne 0x5868
movq 0x88ae(%rip), %rdi      # 0xdff0
leaq 0x390a(%rip), %rsi      # 0x9053
callq 0x42d0
movq %rax, %rdi
leaq -0x68(%rbp), %rsi
callq 0x42a0
movq %rax, %rdi
leaq 0x38ed(%rip), %rsi      # 0x9051
callq 0x42d0
movq %rax, %rdi
movl %ebx, %esi
callq 0x4490
movq %rax, %rdi
leaq 0x3980(%rip), %rsi      # 0x90fd
callq 0x42d0
movq %rax, %rdi
movq %r14, %rsi
callq 0x42a0
movq %rax, %rdi
callq 0x4170
jmp 0x56d2
movq %r13, %rdi
leaq 0x39e4(%rip), %rsi      # 0x9188
callq 0x6159
testb %al, %al
je 0x5821
cmpq $0x0, -0xa0(%rbp)
je 0x56db
movq 0x8806(%rip), %rdi      # 0xdfc8
leaq 0x39c6(%rip), %rsi      # 0x918f
callq 0x42d0
movq %rax, %rdi
leaq -0x68(%rbp), %rsi
callq 0x42a0
movq %rax, %rdi
leaq 0x386d(%rip), %rsi      # 0x9051
callq 0x42d0
movq %rax, %rdi
movl %ebx, %esi
callq 0x4490
movq %rax, %rdi
leaq 0x388b(%rip), %rsi      # 0x9088
callq 0x42d0
movq %rax, %rdi
movq %r14, %rsi
callq 0x42a0
movq %rax, %rdi
leaq 0x3872(%rip), %rsi      # 0x9089
callq 0x42d0
jmp 0x5599
movq 0x87c8(%rip), %rdi      # 0xdff0
leaq 0x3824(%rip), %rsi      # 0x9053
callq 0x42d0
movq %rax, %rdi
leaq -0x68(%rbp), %rsi
callq 0x42a0
movq %rax, %rdi
leaq 0x3807(%rip), %rsi      # 0x9051
callq 0x42d0
movq %rax, %rdi
movl %ebx, %esi
callq 0x4490
movq %rax, %rdi
leaq 0x389a(%rip), %rsi      # 0x90fd
jmp 0x5589
cmpq $0x0, -0x40(%rbp)
je 0x56d2
movq -0x70(%rbp), %rdi
leaq -0x48(%rbp), %rsi
leaq -0x68(%rbp), %rdx
movq %r14, %rcx
movl %ebx, %r8d
movq -0x98(%rbp), %r9
callq 0x51ae
jmp 0x56d2
cmpq $0x0, -0x40(%rbp)
je 0x56c6
cmpq $0x0, -0x88(%rbp)
je 0x56c6
movq -0x70(%rbp), %rdi
leaq -0x48(%rbp), %rsi
leaq -0x90(%rbp), %rdx
leaq -0x68(%rbp), %rcx
movq %r14, %r8
movl %ebx, %r9d
callq 0x4b1a
jmp 0x56c6
movq 0x8717(%rip), %rdi      # 0xdff0
leaq 0x38b8(%rip), %rsi      # 0x9198
callq 0x42d0
movq %rax, %rdi
movq %rbx, %rsi
callq 0x42a0
leaq 0x38b6(%rip), %rsi      # 0x91ad
movq %rax, %rdi
callq 0x42d0
movq %rax, %rdi
callq 0x4170
leaq -0x2f8(%rbp), %rdi
callq 0x40a0
leaq -0x68(%rbp), %rdi
callq 0x4150
addq $0x458, %rsp            # imm = 0x458
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x5958
movq %rax, %rbx
jmp 0x59d4
movq %rax, %rbx
leaq -0x480(%rbp), %rdi
callq 0x4150
leaq -0x2f8(%rbp), %rdi
callq 0x4150
jmp 0x59e0
movq %rax, %rbx
jmp 0x59e0
jmp 0x5968
jmp 0x5979
jmp 0x5968
jmp 0x5979
movq %rax, %rbx
leaq -0x2f8(%rbp), %rdi
callq 0x4150
jmp 0x597c
movq %rax, %rbx
movq %rbx, %rdi
callq 0x44c0
movq %rax, %rbx
jmp 0x599d
movq %rax, %rbx
jmp 0x59b7
movq %rax, %rbx
leaq -0x90(%rbp), %rdi
callq 0x4150
leaq -0x48(%rbp), %rdi
callq 0x4150
jmp 0x59ab
movq %rax, %rbx
leaq -0x480(%rbp), %rdi
callq 0x4230
leaq -0xd0(%rbp), %rdi
callq 0x4150
jmp 0x59c8
movq %rax, %rbx
leaq -0xf0(%rbp), %rdi
callq 0x4150
leaq -0x2f8(%rbp), %rdi
callq 0x40a0
movq %rbx, %rdi
callq 0x4110
movq 0x8601(%rip), %rdi      # 0xdff0
leaq 0x37a2(%rip), %rsi      # 0x9198
callq 0x42d0
leaq -0x68(%rbp), %rsi
movq %rax, %rdi
callq 0x5fac
leaq 0x379f(%rip), %rsi      # 0x91ad
movq %rax, %rdi
callq 0x42d0
movq %rax, %rdi
callq 0x4170
callq 0x4460
jmp 0x5913
movq %rax, %rbx
jmp 0x5a35
movq %rax, %rbx
callq 0x4460
leaq -0x68(%rbp), %rdi
jmp 0x5972
movq %rax, %rdi
callq 0x5ee8