// File: saumya-prakash[P]AssemblerEmulator/Assembler.cpp
// Function: Assembler::generate_log_file() const
void Assembler::generate_log_file() const
{
    string::size_type ind = filename.find_first_of('.');

    string log_name = string(filename.begin(), filename.begin()+ind);

    ofstream lg(log_name+".log", ofstream::out);

    if(!errors.empty())
    {
        lg<<"Errors -"<<endl;

        for(map<unsigned, class Error>::const_iterator et=errors.begin(); et!=errors.end(); ++et)
        {
            lg<<"Line "<<et->first<<": "<<et->second.message<<endl;
        }

        lg<<endl;
    }

    if(!warnings.empty())
    {
        lg<<"Warnings -"<<endl;

        for(map<unsigned, class Warning>::const_iterator wt=warnings.begin(); wt!=warnings.end(); ++wt)
        {
            lg<<"Line "<<wt->first<<": "<<wt->second.message<<endl;
        }

        lg<<endl;
    }

    lg.close();

}

// Assembly:
subq $0x308, %rsp            # imm = 0x308
movq %rdi, 0x300(%rsp)
movq 0x300(%rsp), %rdi
movq %rdi, 0x50(%rsp)
addq $0xa8, %rdi
movq %rdi, 0x58(%rsp)
xorl %eax, %eax
movl %eax, %edx
movl $0x2e, %esi
callq 0x3190
movq 0x58(%rsp), %rdi
movq %rax, 0x2f8(%rsp)
callq 0x3260
movq 0x58(%rsp), %rdi
movq %rax, 0x2d0(%rsp)
callq 0x3260
movq %rax, 0x2c0(%rsp)
movq 0x2f8(%rsp), %rsi
leaq 0x2c0(%rsp), %rdi
callq 0xcd70
movq %rax, 0x2c8(%rsp)
leaq 0x2bf(%rsp), %rdi
movq %rdi, 0x60(%rsp)
callq 0x34a0
movq 0x60(%rsp), %rcx
movq 0x2d0(%rsp), %rsi
movq 0x2c8(%rsp), %rdx
leaq 0x2d8(%rsp), %rdi
callq 0xcdb0
jmp 0xadf5
leaq 0x2bf(%rsp), %rdi
callq 0x32f0
leaq 0x93fe(%rip), %rdx      # 0x14207
leaq 0x88(%rsp), %rdi
leaq 0x2d8(%rsp), %rsi
callq 0xc750
jmp 0xae20
leaq 0xa8(%rsp), %rdi
leaq 0x88(%rsp), %rsi
movl $0x10, %edx
callq 0x34e0
jmp 0xae3c
leaq 0x88(%rsp), %rdi
callq 0x3180
movq 0x50(%rsp), %rdi
addq $0xc8, %rdi
callq 0xc350
testb $0x1, %al
jne 0xb01c
leaq 0x93a3(%rip), %rsi      # 0x1420c
leaq 0xa8(%rsp), %rdi
callq 0x3270
movq %rax, 0x48(%rsp)
jmp 0xae7d
movq 0x48(%rsp), %rdi
movq 0x1113f(%rip), %rsi     # 0x1bfc8
callq 0x32d0
jmp 0xae90
movq 0x50(%rsp), %rdi
addq $0xc8, %rdi
callq 0xcfa0
movq %rax, 0x80(%rsp)
movq 0x50(%rsp), %rdi
addq $0xc8, %rdi
callq 0xcff0
movq %rax, 0x78(%rsp)
leaq 0x80(%rsp), %rdi
leaq 0x78(%rsp), %rsi
callq 0xcfd0
testb $0x1, %al
jne 0xaeda
jmp 0xb004
leaq 0x9334(%rip), %rsi      # 0x14215
leaq 0xa8(%rsp), %rdi
callq 0x3270
movq %rax, 0x40(%rsp)
jmp 0xaef5
leaq 0x80(%rsp), %rdi
callq 0xd020
movq 0x40(%rsp), %rdi
movl (%rax), %esi
callq 0x33d0
movq %rax, 0x38(%rsp)
jmp 0xaf15
movq 0x38(%rsp), %rdi
leaq 0x9147(%rip), %rsi      # 0x14068
callq 0x3270
movq %rax, 0x30(%rsp)
jmp 0xaf2d
leaq 0x80(%rsp), %rdi
callq 0xd020
movq 0x30(%rsp), %rdi
movq %rax, %rsi
addq $0x8, %rsi
callq 0x3240
movq %rax, 0x28(%rsp)
jmp 0xaf52
movq 0x28(%rsp), %rdi
movq 0x1106a(%rip), %rsi     # 0x1bfc8
callq 0x32d0
jmp 0xaf65
jmp 0xaf67
leaq 0x80(%rsp), %rdi
callq 0xd040
jmp 0xaea9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2b0(%rsp)
movl %eax, 0x2ac(%rsp)
leaq 0x2bf(%rsp), %rdi
callq 0x32f0
jmp 0xb191
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2b0(%rsp)
movl %eax, 0x2ac(%rsp)
jmp 0xb184
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2b0(%rsp)
movl %eax, 0x2ac(%rsp)
leaq 0x88(%rsp), %rdi
callq 0x3180
jmp 0xb184
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2b0(%rsp)
movl %eax, 0x2ac(%rsp)
leaq 0xa8(%rsp), %rdi
callq 0x3410
jmp 0xb184
movq 0x10fbd(%rip), %rsi     # 0x1bfc8
leaq 0xa8(%rsp), %rdi
callq 0x32d0
jmp 0xb01a
jmp 0xb01c
movq 0x50(%rsp), %rdi
addq $0xf8, %rdi
callq 0xc370
testb $0x1, %al
jne 0xb153
leaq 0x91df(%rip), %rsi      # 0x1421b
leaq 0xa8(%rsp), %rdi
callq 0x3270
movq %rax, 0x20(%rsp)
jmp 0xb050
movq 0x20(%rsp), %rdi
movq 0x10f6c(%rip), %rsi     # 0x1bfc8
callq 0x32d0
jmp 0xb063
movq 0x50(%rsp), %rdi
addq $0xf8, %rdi
callq 0xd070
movq %rax, 0x70(%rsp)
movq 0x50(%rsp), %rdi
addq $0xf8, %rdi
callq 0xd0c0
movq %rax, 0x68(%rsp)
leaq 0x70(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0xd0a0
testb $0x1, %al
jne 0xb0a7
jmp 0xb13b
leaq 0x9167(%rip), %rsi      # 0x14215
leaq 0xa8(%rsp), %rdi
callq 0x3270
movq %rax, 0x18(%rsp)
jmp 0xb0c2
leaq 0x70(%rsp), %rdi
callq 0xd0f0
movq 0x18(%rsp), %rdi
movl (%rax), %esi
callq 0x33d0
movq %rax, 0x10(%rsp)
jmp 0xb0df
movq 0x10(%rsp), %rdi
leaq 0x8f7d(%rip), %rsi      # 0x14068
callq 0x3270
movq %rax, 0x8(%rsp)
jmp 0xb0f7
leaq 0x70(%rsp), %rdi
callq 0xd0f0
movq 0x8(%rsp), %rdi
movq %rax, %rsi
addq $0x8, %rsi
callq 0x3240
movq %rax, (%rsp)
jmp 0xb118
movq (%rsp), %rdi
movq 0x10ea5(%rip), %rsi     # 0x1bfc8
callq 0x32d0
jmp 0xb12a
jmp 0xb12c
leaq 0x70(%rsp), %rdi
callq 0xd110
jmp 0xb079
movq 0x10e86(%rip), %rsi     # 0x1bfc8
leaq 0xa8(%rsp), %rdi
callq 0x32d0
jmp 0xb151
jmp 0xb153
leaq 0xa8(%rsp), %rdi
callq 0x33f0
jmp 0xb162
leaq 0xa8(%rsp), %rdi
callq 0x3410
leaq 0x2d8(%rsp), %rdi
callq 0x3180
addq $0x308, %rsp            # imm = 0x308
retq
leaq 0x2d8(%rsp), %rdi
callq 0x3180
movq 0x2b0(%rsp), %rdi
callq 0x3490
nop