// File: /workspace/github_cpp_makefile_star2_O3/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 0x2e80
movq 0xb176(%rip), %rdi      # 0xdfd8
leaq 0x719b(%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 0x2fca
movq 0x8(%rbx), %rsi
leaq 0x10(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x30b2
leaq 0x30(%rsp), %rdi
leaq 0x160(%rsp), %rsi
leaq 0x10(%rsp), %rdx
callq 0x30f0
leaq 0x20(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2f03
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x21c0
leaq 0x30(%rsp), %rdi
callq 0x3784
leaq 0x30(%rsp), %rdi
callq 0x6dac
leaq 0x30(%rsp), %rdi
callq 0x7602
movb 0x158(%rsp), %al
testb %al, %al
je 0x3015
testb $0x1, %al
je 0x2f64
movq 0xb09d(%rip), %rdi      # 0xdfd8
leaq 0x7107(%rip), %rsi      # 0xa049
movl $0x16, %edx
callq 0x2200
movq 0xb085(%rip), %rdi      # 0xdfd8
callq 0x20e0
movq 0xb079(%rip), %rdi      # 0xdfd8
callq 0x20e0
cmpb $0x1, 0x159(%rsp)
jne 0x2fb6
movq 0xb063(%rip), %rdi      # 0xdfd8
callq 0x20e0
movq %rax, %rbx
leaq 0x70dc(%rip), %rsi      # 0xa060
movl $0xa, %edx
movq %rax, %rdi
callq 0x2200
movq %rbx, %rdi
callq 0x20e0
movq 0xb038(%rip), %rsi      # 0xdfd8
leaq 0x30(%rsp), %rdi
callq 0x7e54
movq 0xb027(%rip), %rdi      # 0xdfd8
callq 0x20e0
leaq 0x160(%rsp), %rdi
callq 0x2070
xorl %edi, %edi
callq 0x2220
movq 0xb007(%rip), %rbx      # 0xdfd8
leaq 0x7052(%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 0xafd5(%rip), %rdi      # 0xdfd8
callq 0x2030
movq %rax, %rdi
callq 0x2130
jmp 0x2e76
movq 0xafbc(%rip), %rdi      # 0xdfd8
callq 0x20e0
movq %rax, %rbx
leaq 0x7015(%rip), %rsi      # 0xa040
movl $0x8, %edx
movq %rax, %rdi
callq 0x2200
movq %rbx, %rdi
callq 0x20e0
movq 0xaf91(%rip), %rsi      # 0xdfd8
leaq 0x30(%rsp), %rdi
callq 0x7bd4
movq 0xaf80(%rip), %rdi      # 0xdfd8
callq 0x20e0
movb 0x158(%rsp), %al
jmp 0x2f30
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x322e
jmp 0x309d
movq %rax, %rbx
leaq 0x20(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x309d
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x21c0
jmp 0x309d
jmp 0x309a
movq %rax, %rbx
leaq 0x160(%rsp), %rdi
callq 0x2080
movq %rbx, %rdi
callq 0x22e0