// File: /workspace/github_c_makefile_star2_O0/vsee[P]openCLFeatureExtract/oclFeatureExt.cpp
// Function: main
int main(int argc, char* argv[]) {
    InputParser input(argc, argv);
    
    if(input.cmdOptionExists("-h")) {
        outs() << usage;
        exit(0);
    }
    if(input.cmdOptionExists("-v")) {
        verbose = true;
    }
    const string &fileName = input.getCmdOption("-f");
    if (fileName.empty()){
        outs() << usage;
        exit(1);
    }
    const string &outFile = input.getCmdOption("-o");
    if (outFile.empty()){
        outs() << usage;
        exit(1);
    }
    
    FeatureStats stats;

    ErrorOr<unique_ptr<MemoryBuffer>> fileBuffer = MemoryBuffer::getFile(fileName);
    if (error_code ec = fileBuffer.getError())
		errs() << "ERROR loading bitcode file: " << fileName << " -- " << ec.message() << "\n";
	else
		outs() << "Bitcode file loaded: " << fileName << "\n";  
    
    
    LLVMContext context;
    MemoryBufferRef memRef = (*fileBuffer)->getMemBufferRef();
    Expected<unique_ptr<Module>> bcModule = parseBitcodeFile(memRef, context);
    if (!bcModule)
            errs() << "ERROR parsing bitcode file" << bcModule.takeError() << "\n";
    else
            outs() << "Bitcode parsed successfully!"<< "\n";
    
       
    for (Module::const_iterator curFref = (*bcModule)->getFunctionList().begin(),
         endFref = (*bcModule)->getFunctionList().end();
         curFref != endFref; curFref++) {
        stats.funcount++;

        for (Function::const_iterator curBref = curFref->begin(), endBref = curFref->end();
         curBref != endBref; curBref++) {
            stats.bbcount++;
            for (BasicBlock::const_iterator curIref = curBref->begin(), endIref = curBref->end();
                 curIref != endIref; curIref++) {
                if(verbose) outs() << "Found an instruction: " << *curIref << "\n";        
                evalInstruction(*curIref, stats);               
            }
            
        }
    }
    
    outs() << stats << "\n\n";
    writeToCSV(outFile, stats);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x430, %rsp            # imm = 0x430
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rdx
leaq -0x28(%rbp), %rdi
leaq -0x8(%rbp), %rsi
callq 0x5c20
leaq -0x49(%rbp), %rdi
movq %rdi, -0x260(%rbp)
callq 0x31c0
movq -0x260(%rbp), %rdx
leaq 0x79d0(%rip), %rsi      # 0xc0e8
leaq -0x48(%rbp), %rdi
callq 0x5ab0
jmp 0x4723
leaq -0x28(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x5d10
movb %al, -0x261(%rbp)
jmp 0x4738
leaq -0x48(%rbp), %rdi
callq 0x3438
leaq -0x49(%rbp), %rdi
callq 0x3030
movb -0x261(%rbp), %al
testb $0x1, %al
jne 0x4756
jmp 0x47c2
callq 0x32c0
movq %rax, -0x270(%rbp)
jmp 0x4764
movq -0x270(%rbp), %rdi
leaq 0xebb6(%rip), %rsi      # 0x13328
callq 0x5d80
jmp 0x4779
xorl %edi, %edi
callq 0x3360
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x47a3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x3438
leaq -0x49(%rbp), %rdi
callq 0x3030
jmp 0x5202
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x5202
leaq -0x81(%rbp), %rdi
movq %rdi, -0x278(%rbp)
callq 0x31c0
movq -0x278(%rbp), %rdx
leaq 0x7908(%rip), %rsi      # 0xc0eb
leaq -0x80(%rbp), %rdi
callq 0x5ab0
jmp 0x47ee
leaq -0x28(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x5d10
movb %al, -0x279(%rbp)
jmp 0x4803
leaq -0x80(%rbp), %rdi
callq 0x3438
leaq -0x81(%rbp), %rdi
callq 0x3030
movb -0x279(%rbp), %al
testb $0x1, %al
jne 0x4824
jmp 0x4861
movb $0x1, 0xeb1d(%rip)      # 0x13348
jmp 0x4861
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x4850
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x3438
leaq -0x81(%rbp), %rdi
callq 0x3030
jmp 0x5202
leaq -0xb1(%rbp), %rdi
movq %rdi, -0x288(%rbp)
callq 0x31c0
movq -0x288(%rbp), %rdx
leaq 0x786c(%rip), %rsi      # 0xc0ee
leaq -0xb0(%rbp), %rdi
callq 0x5ab0
jmp 0x4890
leaq -0x28(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x5dd0
movq %rax, -0x290(%rbp)
jmp 0x48a9
leaq -0xb0(%rbp), %rdi
callq 0x3438
leaq -0xb1(%rbp), %rdi
callq 0x3030
movq -0x290(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rdi
callq 0x30c0
testb $0x1, %al
jne 0x48e1
jmp 0x4945
callq 0x32c0
movq %rax, -0x298(%rbp)
jmp 0x48ef
movq -0x298(%rbp), %rdi
leaq 0xea2b(%rip), %rsi      # 0x13328
callq 0x5d80
jmp 0x4904
movl $0x1, %edi
callq 0x3360
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x4934
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x3438
leaq -0xb1(%rbp), %rdi
callq 0x3030
jmp 0x5202
leaq -0xe1(%rbp), %rdi
movq %rdi, -0x2a0(%rbp)
callq 0x31c0
movq -0x2a0(%rbp), %rdx
leaq 0x778b(%rip), %rsi      # 0xc0f1
leaq -0xe0(%rbp), %rdi
callq 0x5ab0
jmp 0x4974
leaq -0x28(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x5dd0
movq %rax, -0x2a8(%rbp)
jmp 0x498d
leaq -0xe0(%rbp), %rdi
callq 0x3438
leaq -0xe1(%rbp), %rdi
callq 0x3030
movq -0x2a8(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq -0xc0(%rbp), %rdi
callq 0x30c0
testb $0x1, %al
jne 0x49c5
jmp 0x4a29
callq 0x32c0
movq %rax, -0x2b0(%rbp)
jmp 0x49d3
movq -0x2b0(%rbp), %rdi
leaq 0xe947(%rip), %rsi      # 0x13328
callq 0x5d80
jmp 0x49e8
movl $0x1, %edi
callq 0x3360
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x4a18
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0x3438
leaq -0xe1(%rbp), %rdi
callq 0x3030
jmp 0x5202
leaq -0x114(%rbp), %rdi
callq 0x5f50
movq -0x90(%rbp), %rsi
leaq -0x158(%rbp), %rdi
callq 0x5fc0
jmp 0x4a4a
leaq -0x130(%rbp), %rdi
leaq -0x158(%rbp), %rsi
movl $0x1, %ecx
xorl %r8d, %r8d
movl %r8d, %edx
callq 0x3230
jmp 0x4a6a
leaq -0x130(%rbp), %rdi
callq 0x6030
movq %rdx, -0x2c0(%rbp)
movl %eax, -0x2b4(%rbp)
jmp 0x4a85
movq -0x2c0(%rbp), %rax
movl -0x2b4(%rbp), %ecx
movl %ecx, -0x168(%rbp)
movq %rax, -0x160(%rbp)
leaq -0x168(%rbp), %rdi
callq 0x6080
testb $0x1, %al
jne 0x4ab4
jmp 0x4b9b
callq 0x3370
movq %rax, -0x2c8(%rbp)
jmp 0x4ac2
movq -0x2c8(%rbp), %rdi
leaq 0x7624(%rip), %rsi      # 0xc0f4
callq 0x60a0
movq %rax, -0x2d0(%rbp)
jmp 0x4ade
movq -0x2d0(%rbp), %rdi
movq -0x90(%rbp), %rsi
callq 0x5d80
movq %rax, -0x2d8(%rbp)
jmp 0x4afa
movq -0x2d8(%rbp), %rdi
leaq 0x7609(%rip), %rsi      # 0xc111
callq 0x60a0
movq %rax, -0x2e0(%rbp)
jmp 0x4b16
leaq -0x188(%rbp), %rdi
leaq -0x168(%rbp), %rsi
callq 0x60e0
jmp 0x4b2b
movq -0x2e0(%rbp), %rdi
leaq -0x188(%rbp), %rsi
callq 0x5d80
movq %rax, -0x2e8(%rbp)
jmp 0x4b47
movq -0x2e8(%rbp), %rdi
leaq 0x7627(%rip), %rsi      # 0xc17c
callq 0x60a0
jmp 0x4b5c
leaq -0x188(%rbp), %rdi
callq 0x3438
jmp 0x4bf8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x51f6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x188(%rbp), %rdi
callq 0x3438
jmp 0x51f6
callq 0x32c0
movq %rax, -0x2f0(%rbp)
jmp 0x4ba9
movq -0x2f0(%rbp), %rdi
leaq 0x755f(%rip), %rsi      # 0xc116
callq 0x60a0
movq %rax, -0x2f8(%rbp)
jmp 0x4bc5
movq -0x2f8(%rbp), %rdi
movq -0x90(%rbp), %rsi
callq 0x5d80
movq %rax, -0x300(%rbp)
jmp 0x4be1
movq -0x300(%rbp), %rdi
leaq 0x758d(%rip), %rsi      # 0xc17c
callq 0x60a0
jmp 0x4bf6
jmp 0x4bf8
leaq -0x190(%rbp), %rdi
callq 0x3210
jmp 0x4c06
leaq -0x130(%rbp), %rdi
callq 0x6130
movq %rax, -0x308(%rbp)
jmp 0x4c1b
movq -0x308(%rbp), %rdi
callq 0x6150
movq %rax, %rsi
leaq -0x1b0(%rbp), %rdi
callq 0x32a0
jmp 0x4c38
movups -0x1b0(%rbp), %xmm0
movups -0x1a0(%rbp), %xmm1
movaps %xmm1, -0x1d0(%rbp)
movaps %xmm0, -0x1e0(%rbp)
xorl %eax, %eax
movl %eax, %ecx
leaq -0x1f0(%rbp), %rdi
leaq -0x1f1(%rbp), %rsi
movq %rcx, %rdx
callq 0x5220
jmp 0x4c70
movq -0x1f0(%rbp), %rdx
movq -0x1e8(%rbp), %rcx
movaps -0x1e0(%rbp), %xmm0
movaps -0x1d0(%rbp), %xmm1
movq %rsp, %rax
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
leaq -0x1c0(%rbp), %rdi
leaq -0x190(%rbp), %rsi
callq 0x3310
jmp 0x4cab
leaq -0x1c0(%rbp), %rdi
callq 0x6170
movb %al, -0x309(%rbp)
jmp 0x4cbf
movb -0x309(%rbp), %al
testb $0x1, %al
jne 0x4d8f
jmp 0x4ccf
callq 0x3370
movq %rax, -0x318(%rbp)
jmp 0x4cdd
movq -0x318(%rbp), %rdi
leaq 0x7441(%rip), %rsi      # 0xc12c
callq 0x60a0
movq %rax, -0x320(%rbp)
jmp 0x4cf9
leaq -0x200(%rbp), %rdi
leaq -0x1c0(%rbp), %rsi
callq 0x61e0
jmp 0x4d0e
movq -0x320(%rbp), %rdi
leaq -0x200(%rbp), %rsi
callq 0x6190
movq %rax, -0x328(%rbp)
jmp 0x4d2a
movq -0x328(%rbp), %rdi
leaq 0x7444(%rip), %rsi      # 0xc17c
callq 0x60a0
jmp 0x4d3f
leaq -0x200(%rbp), %rdi
callq 0x62e0
jmp 0x4dd0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x51ea
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x51de
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x200(%rbp), %rdi
callq 0x62e0
jmp 0x51de
callq 0x32c0
movq %rax, -0x330(%rbp)
jmp 0x4d9d
movq -0x330(%rbp), %rdi
leaq 0x739c(%rip), %rsi      # 0xc147
callq 0x60a0
movq %rax, -0x338(%rbp)
jmp 0x4db9
movq -0x338(%rbp), %rdi
leaq 0x73b5(%rip), %rsi      # 0xc17c
callq 0x60a0
jmp 0x4dce
jmp 0x4dd0
leaq -0x1c0(%rbp), %rdi
callq 0x6330
movq %rax, -0x340(%rbp)
jmp 0x4de5
movq -0x340(%rbp), %rdi
callq 0x6360
movq %rax, %rdi
callq 0x6380
movq %rax, -0x348(%rbp)
jmp 0x4e02
movq -0x348(%rbp), %rdi
callq 0x63a0
movq %rax, -0x350(%rbp)
jmp 0x4e17
movq -0x350(%rbp), %rax
movq %rax, -0x210(%rbp)
xorl %eax, %eax
movl %eax, %edx
leaq -0x208(%rbp), %rdi
leaq -0x210(%rbp), %rsi
callq 0x63e0
jmp 0x4e3e
leaq -0x1c0(%rbp), %rdi
callq 0x6330
movq %rax, -0x358(%rbp)
jmp 0x4e53
movq -0x358(%rbp), %rdi
callq 0x6360
movq %rax, %rdi
callq 0x6380
movq %rax, -0x360(%rbp)
jmp 0x4e70
movq -0x360(%rbp), %rdi
callq 0x6400
movq %rax, -0x368(%rbp)
jmp 0x4e85
movq -0x368(%rbp), %rax
movq %rax, -0x220(%rbp)
xorl %eax, %eax
movl %eax, %edx
leaq -0x218(%rbp), %rdi
leaq -0x220(%rbp), %rsi
callq 0x63e0
jmp 0x4eac
jmp 0x4eae
leaq -0x208(%rbp), %rdi
leaq -0x218(%rbp), %rsi
callq 0x6430
movb %al, -0x369(%rbp)
jmp 0x4ec9
movb -0x369(%rbp), %al
testb $0x1, %al
jne 0x4ed8
jmp 0x5151
movl -0x110(%rbp), %eax
incl %eax
movl %eax, -0x110(%rbp)
leaq -0x208(%rbp), %rdi
callq 0x6460
movq %rax, -0x378(%rbp)
jmp 0x4efb
movq -0x378(%rbp), %rdi
callq 0x6480
movq %rax, -0x380(%rbp)
jmp 0x4f10
movq -0x380(%rbp), %rax
movq %rax, -0x228(%rbp)
leaq -0x208(%rbp), %rdi
callq 0x6460
movq %rax, -0x388(%rbp)
jmp 0x4f33
movq -0x388(%rbp), %rdi
callq 0x64b0
movq %rax, -0x390(%rbp)
jmp 0x4f48
movq -0x390(%rbp), %rax
movq %rax, -0x230(%rbp)
leaq -0x228(%rbp), %rdi
leaq -0x230(%rbp), %rsi
callq 0x64e0
movb %al, -0x391(%rbp)
jmp 0x4f71
movb -0x391(%rbp), %al
testb $0x1, %al
jne 0x4f80
jmp 0x5125
movl -0x114(%rbp), %eax
incl %eax
movl %eax, -0x114(%rbp)
leaq -0x228(%rbp), %rdi
callq 0x6510
movq %rax, -0x3a0(%rbp)
jmp 0x4fa3
movq -0x3a0(%rbp), %rdi
callq 0x6530
movq %rax, -0x3a8(%rbp)
jmp 0x4fb8
movq -0x3a8(%rbp), %rax
movq %rax, -0x238(%rbp)
leaq -0x228(%rbp), %rdi
callq 0x6510
movq %rax, -0x3b0(%rbp)
jmp 0x4fdb
movq -0x3b0(%rbp), %rdi
callq 0x6560
movq %rax, -0x3b8(%rbp)
jmp 0x4ff0
movq -0x3b8(%rbp), %rax
movq %rax, -0x240(%rbp)
leaq -0x238(%rbp), %rdi
leaq -0x240(%rbp), %rsi
callq 0x6590
movb %al, -0x3b9(%rbp)
jmp 0x5019
movb -0x3b9(%rbp), %al
testb $0x1, %al
jne 0x5028
jmp 0x50f9
testb $0x1, 0xe319(%rip)      # 0x13348
je 0x50a3
callq 0x32c0
movq %rax, -0x3c8(%rbp)
jmp 0x503f
movq -0x3c8(%rbp), %rdi
leaq 0x7117(%rip), %rsi      # 0xc164
callq 0x60a0
movq %rax, -0x3d0(%rbp)
jmp 0x505b
leaq -0x238(%rbp), %rdi
callq 0x65f0
movq %rax, -0x3d8(%rbp)
jmp 0x5070
movq -0x3d8(%rbp), %rsi
movq -0x3d0(%rbp), %rdi
callq 0x65c0
movq %rax, -0x3e0(%rbp)
jmp 0x508c
movq -0x3e0(%rbp), %rdi
leaq 0x70e2(%rip), %rsi      # 0xc17c
callq 0x60a0
jmp 0x50a1
jmp 0x50a3
leaq -0x238(%rbp), %rdi
callq 0x65f0
movq %rax, -0x3e8(%rbp)
jmp 0x50b8
movq -0x3e8(%rbp), %rdi
leaq -0x114(%rbp), %rsi
callq 0x5250
jmp 0x50cd
jmp 0x50cf
leaq -0x238(%rbp), %rdi
xorl %esi, %esi
callq 0x6650
movq %rax, -0x3f0(%rbp)
jmp 0x50e6
movq -0x3f0(%rbp), %rax
movq %rax, -0x248(%rbp)
jmp 0x4ffe
jmp 0x50fb
leaq -0x228(%rbp), %rdi
xorl %esi, %esi
callq 0x6680
movq %rax, -0x3f8(%rbp)
jmp 0x5112
movq -0x3f8(%rbp), %rax
movq %rax, -0x250(%rbp)
jmp 0x4f56
jmp 0x5127
leaq -0x208(%rbp), %rdi
xorl %esi, %esi
callq 0x66b0
movq %rax, -0x400(%rbp)
jmp 0x513e
movq -0x400(%rbp), %rax
movq %rax, -0x258(%rbp)
jmp 0x4eae
callq 0x32c0
movq %rax, -0x408(%rbp)
jmp 0x515f
movq -0x408(%rbp), %rdi
leaq -0x114(%rbp), %rsi
callq 0x66e0
movq %rax, -0x410(%rbp)
jmp 0x517b
movq -0x410(%rbp), %rdi
leaq 0x6ff2(%rip), %rsi      # 0xc17b
callq 0x60a0
jmp 0x5190
movq -0xc0(%rbp), %rdi
leaq -0x114(%rbp), %rsi
callq 0x55c0
jmp 0x51a5
leaq -0x1c0(%rbp), %rdi
callq 0x6970
leaq -0x190(%rbp), %rdi
callq 0x3380
leaq -0x130(%rbp), %rdi
callq 0x69e0
leaq -0x28(%rbp), %rdi
callq 0x6a30
movl -0x4(%rbp), %eax
addq $0x430, %rsp            # imm = 0x430
popq %rbp
retq
leaq -0x1c0(%rbp), %rdi
callq 0x6970
leaq -0x190(%rbp), %rdi
callq 0x3380
leaq -0x130(%rbp), %rdi
callq 0x69e0
leaq -0x28(%rbp), %rdi
callq 0x6a30
movq -0x58(%rbp), %rdi
callq 0x3130
nopw %cs:(%rax,%rax)