// File: /workspace/github_cpp_makefile_star2_O1/saumya-prakash[P]AssemblerEmulator/asm.cpp
// Function: main
int main(int argc, char **argv)
{
    if(argc==1)
    {
        cout<<"Fatal Error: No input file specified."<<endl;
        exit(EXIT_FAILURE);
    }

    ifstream src;

    src.open(argv[1], ofstream::in);

    if(!src)
    {
        cout<<"Error in opening file"<<endl;
        exit(EXIT_FAILURE);
    }

    Assembler a1(src, argv[1]);

    a1.assemble();
    a1.generate_listing_file();
    a1.generate_log_file();

    if(a1.get_assembly_status()==false)
    {   
        cout<<endl<<"Errors: "<<endl;
        a1.print_errors(cout);
        cout<<endl;
    }

    if(a1.get_assembly_status()==true)
    {
        cout<<"Assembled successfully"<<endl;
        cout<<endl;
    }


    if(a1.get_warning_status()==true)
    {
        cout<<endl<<"Warnings: "<<endl;
        a1.print_warnings(cout);
        cout<<endl;
    }


    src.close();
    

    exit(EXIT_SUCCESS);
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x368, %rsp            # imm = 0x368
cmpl $0x1, %edi
jne 0x2ea0
movq 0xb156(%rip), %rdi      # 0xdfd8
leaq 0x717b(%rip), %rsi      # 0xa004
callq 0x21a0
movq %rax, %rdi
callq 0x20e0
movl $0x1, %edi
callq 0x2220
movq %rsi, %rbx
leaq 0x160(%rsp), %r14
movq %r14, %rdi
callq 0x21f0
movq 0x8(%rbx), %rsi
movq %r14, %rdi
movl $0x8, %edx
callq 0x2110
movq 0x160(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x180(%rsp,%rax)
jne 0x2fef
movq 0x8(%rbx), %rsi
leaq 0x10(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x30d0
leaq 0x30(%rsp), %rdi
leaq 0x160(%rsp), %rsi
leaq 0x10(%rsp), %rdx
callq 0x310e
leaq 0x20(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2f23
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x21c0
leaq 0x30(%rsp), %rdi
callq 0x3792
leaq 0x30(%rsp), %rdi
callq 0x6e26
leaq 0x30(%rsp), %rdi
callq 0x7680
cmpb $0x0, 0x158(%rsp)
je 0x303a
cmpb $0x1, 0x158(%rsp)
jne 0x2f89
movq 0xb078(%rip), %rdi      # 0xdfd8
leaq 0x70e2(%rip), %rsi      # 0xa049
movl $0x16, %edx
callq 0x2200
movq 0xb060(%rip), %rdi      # 0xdfd8
callq 0x20e0
movq 0xb054(%rip), %rdi      # 0xdfd8
callq 0x20e0
cmpb $0x1, 0x159(%rsp)
jne 0x2fdb
movq 0xb03e(%rip), %rdi      # 0xdfd8
callq 0x20e0
movq %rax, %rbx
leaq 0x70b7(%rip), %rsi      # 0xa060
movl $0xa, %edx
movq %rax, %rdi
callq 0x2200
movq %rbx, %rdi
callq 0x20e0
movq 0xb013(%rip), %rsi      # 0xdfd8
leaq 0x30(%rsp), %rdi
callq 0x7ed2
movq 0xb002(%rip), %rdi      # 0xdfd8
callq 0x20e0
leaq 0x160(%rsp), %rdi
callq 0x2070
xorl %edi, %edi
callq 0x2220
movq 0xafe2(%rip), %rbx      # 0xdfd8
leaq 0x702d(%rip), %rsi      # 0xa02a
movl $0x15, %edx
movq %rbx, %rdi
callq 0x2200
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x2190
movsbl %al, %esi
movq 0xafb0(%rip), %rdi      # 0xdfd8
callq 0x2030
movq %rax, %rdi
callq 0x2130
jmp 0x2e96
movq 0xaf97(%rip), %rdi      # 0xdfd8
callq 0x20e0
movq %rax, %rbx
leaq 0x6ff0(%rip), %rsi      # 0xa040
movl $0x8, %edx
movq %rax, %rdi
callq 0x2200
movq %rbx, %rdi
callq 0x20e0
movq 0xaf6c(%rip), %rsi      # 0xdfd8
leaq 0x30(%rsp), %rdi
callq 0x7c52
movq 0xaf5b(%rip), %rdi      # 0xdfd8
callq 0x20e0
jmp 0x2f4f
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x324c
jmp 0x30bb
movq %rax, %rbx
leaq 0x20(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x30bb
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x21c0
jmp 0x30bb
jmp 0x30b8
movq %rax, %rbx
leaq 0x160(%rsp), %rdi
callq 0x2080
movq %rbx, %rdi
callq 0x22e0