// File: /workspace/github_cpp_makefile_star2_O1/salihbektas[P]Simple-CPU-emulator/main.cpp
// Function: main
int main(int argc, char* argv[])
{
    int option;

    //Console argumans check
    if(argc != 3){
        cerr<< "Wrong Usage" << endl
            << "Example Usage: "<<argv[0]<<" <file_name.txt> <option>" << endl;
        return 1;
    }
    //Option check
    if (argv[2][0] != '0' && argv[2][0] != '1' && argv[2][0] != '2'){
        cerr << "Wrong option" << endl
             << "Option must be 0, 1 or 2" << endl;
        return 1;
    }

    if (argv[2][0] == '0')
        option = 0;
    else if (argv[2][0] == '1')
        option = 1;
    else if (argv[2][0] == '2')
        option = 2;

    CPU myCPU;
    CPUProgramDyn myProg(argv[1]);
    Memory myMemory;

    Computer myComputer(myCPU, myProg, myMemory, option);
    myComputer.execute();

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x370, %rsp            # imm = 0x370
movq %rsi, %rbx
cmpl $0x3, %edi
jne 0x24dc
movq 0x10(%rbx), %rax
movb (%rax), %al
leal -0x30(%rax), %ecx
cmpb $0x3, %cl
jae 0x255c
xorl %ecx, %ecx
cmpb $0x31, %al
sete %cl
cmpb $0x32, %al
movl $0x2, %r14d
cmovnel %ecx, %r14d
leaq -0x4c(%rbp), %rdi
callq 0x2788
movq 0x8(%rbx), %rsi
leaq -0xb0(%rbp), %rdi
callq 0x710a
leaq -0x298(%rbp), %rdi
callq 0x266c
movups -0x4c(%rbp), %xmm0
movups -0x40(%rbp), %xmm1
movaps %xmm0, -0x30(%rbp)
movups %xmm1, -0x24(%rbp)
leaq -0x80(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x7024
leaq 0x20(%rsp), %rdi
leaq -0x298(%rbp), %rsi
movl $0x19, %ecx
rep  movsq (%rsi), %es:(%rdi)
movups -0x24(%rbp), %xmm0
movups %xmm0, 0xc(%rsp)
movaps -0x30(%rbp), %xmm0
movups %xmm0, (%rsp)
leaq -0x1d0(%rbp), %rdi
leaq -0x80(%rbp), %rsi
movl %r14d, %edx
callq 0x81b4
leaq -0x80(%rbp), %rdi
callq 0x7300
leaq -0x1d0(%rbp), %rdi
callq 0x8398
leaq -0x1b0(%rbp), %rdi
callq 0x7300
leaq -0xb0(%rbp), %rdi
callq 0x7300
xorl %eax, %eax
jmp 0x262b
movq 0x9b0d(%rip), %r14      # 0xbff0
leaq 0x6b1a(%rip), %rsi      # 0x9004
movl $0xb, %edx
movq %r14, %rdi
callq 0x2130
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2120
movsbl %al, %esi
movq %r14, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20c0
movq %rax, %r14
leaq 0x6ae8(%rip), %rsi      # 0x9010
movl $0xf, %edx
movq %rax, %rdi
callq 0x2130
movq (%rbx), %rbx
testq %rbx, %rbx
je 0x25d1
movq %rbx, %rdi
callq 0x2080
movq %r14, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x2130
jmp 0x25eb
movq 0x9a8d(%rip), %rbx      # 0xbff0
leaq 0x6ad0(%rip), %rsi      # 0x903a
movl $0xc, %edx
movq %rbx, %rdi
callq 0x2130
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2120
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20c0
movq %rax, %rbx
leaq 0x6a9f(%rip), %rsi      # 0x9047
movl $0x18, %edx
movq %rax, %rdi
callq 0x2130
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2120
movsbl %al, %esi
movq %rbx, %rdi
jmp 0x2619
movq (%r14), %rax
movq -0x18(%rax), %rax
movq %r14, %rdi
addq %rax, %rdi
movl 0x20(%r14,%rax), %esi
orl $0x1, %esi
callq 0x21a0
leaq 0x6a2e(%rip), %rsi      # 0x9020
movl $0x19, %edx
movq %r14, %rdi
callq 0x2130
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2120
movsbl %al, %esi
movq %r14, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20c0
movl $0x1, %eax
addq $0x370, %rsp            # imm = 0x370
popq %rbx
popq %r14
popq %rbp
retq
movq %rax, %rbx
leaq -0x1b0(%rbp), %rdi
jmp 0x264a
movq %rax, %rbx
leaq -0x80(%rbp), %rdi
callq 0x7300
jmp 0x2656
jmp 0x2653
movq %rax, %rbx
leaq -0xb0(%rbp), %rdi
callq 0x7300
movq %rbx, %rdi
callq 0x21c0
nop