// File: /workspace/github_cpp_makefile_star2_O3/SunriseFox[P]very-simple-c-compiler/./src/asm.cpp
// Function: generateASM()
void generateASM() {
    of.open("out.S");

    of << "\t.file\t\"" << "temp.c" << "\"\n";

    putLine(".text");

    TreeNode* temp = root;

    while (temp) {
        storeVar(temp);
        temp = temp -> sibling;
    }

    vector<pair<Symbol*, string>> constStr;

    for (const auto& i : varDeclare) {
        if (i.first->type != Symbol::VALUE_STRING) {
            int size = symbolSize(i.first);
            of << "\t.comm\t" << i.second << "," << size << "," << size << "\n";
        } else if (i.second.substr(0, 4) == ".str") {
            constStr.push_back(i);
        }
        cerr << i.first->value << " " << i.second << endl;
    }

    if(constStr.size() != 0) {
        of << "\t.section\t.rodata\n";
    }

    for (const auto& i : constStr) {
        of << i.second << ":\n";
        of << "\t.string\t\"" << i.first->value << "\"\n";
    }

    putLine(".text");

    handleCodeBlock(root);

    of << "\t.ident\t\"Vampire very-simple-c-compiler\"\n";
    of << "\t.section\t.note.GNU-stack,\"\",@progbits\n";
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
leaq 0xc00f(%rip), %rbx      # 0x13270
leaq 0x624c(%rip), %rsi      # 0xd4b4
movq %rbx, %rdi
movl $0x10, %edx
callq 0x3050
leaq 0x623e(%rip), %rsi      # 0xd4ba
movl $0x8, %edx
movq %rbx, %rdi
callq 0x3260
leaq 0x6233(%rip), %rsi      # 0xd4c3
movl $0x6, %edx
movq %rbx, %rdi
callq 0x3260
leaq 0x627b(%rip), %rsi      # 0xd51f
movl $0x2, %edx
movq %rbx, %rdi
callq 0x3260
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x6209(%rip), %rsi      # 0xd4ca
leaq 0x6207(%rip), %rdx      # 0xd4cf
leaq 0x8(%rsp), %rdi
callq 0x7944
leaq 0x8(%rsp), %rdi
callq 0x4745
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x72f8
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3200
leaq 0xc229(%rip), %rax      # 0x13528
movq (%rax), %rbx
testq %rbx, %rbx
je 0x7315
movq %rbx, %rdi
callq 0x4200
movq 0x20(%rbx), %rbx
jmp 0x7302
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movq $0x0, 0x40(%rsp)
movq 0xbf2b(%rip), %rbx      # 0x13258
leaq 0xbf14(%rip), %rax      # 0x13248
cmpq %rax, %rbx
je 0x75d3
leaq 0xbf2c(%rip), %r15      # 0x13270
leaq 0x618d(%rip), %r13      # 0xd4d8
leaq 0x5df2(%rip), %r12      # 0xd144
movq 0x20(%rbx), %rax
movl (%rax), %eax
cmpq $0x6, %rax
ja 0x7367
movslq (%r12,%rax,4), %rax
addq %r12, %rax
jmpq *%rax
xorl %ebp, %ebp
jmp 0x742d
movl $0x8, %ebp
jmp 0x742d
movl $0x4, %ebp
jmp 0x742d
leaq 0x28(%rbx), %rsi
movl $0x4, %ecx
leaq 0x8(%rsp), %r14
movq %r14, %rdi
xorl %edx, %edx
callq 0x3220
movq %r14, %rdi
leaq 0x5f52(%rip), %rsi      # 0xd2f6
callq 0x30a0
movl %eax, %ebp
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x73c7
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3200
testl %ebp, %ebp
jne 0x749f
movq 0x20(%rbx), %rax
movq %rax, 0x8(%rsp)
leaq 0x20(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x28(%rbx), %rsi
movq 0x30(%rbx), %rdx
addq %rsi, %rdx
leaq 0x10(%rsp), %rdi
callq 0x78ae
leaq 0x30(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x7d34
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x749f
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x3200
jmp 0x749f
movl $0x1, %ebp
movl $0x7, %edx
movq %r15, %rdi
leaq 0x6094(%rip), %rsi      # 0xd4d0
callq 0x3260
movq 0x28(%rbx), %rsi
movq 0x30(%rbx), %rdx
movq %r15, %rdi
callq 0x3260
movq %rax, %r14
movl $0x1, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x3260
movq %r14, %rdi
movl %ebp, %esi
callq 0x33a0
movq %rax, %r14
movl $0x1, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x3260
movq %r14, %rdi
movl %ebp, %esi
callq 0x33a0
movl $0x1, %edx
movq %rax, %rdi
leaq 0x6086(%rip), %rsi      # 0xd520
callq 0x3260
movq 0x20(%rbx), %rax
movq 0x8(%rax), %rsi
movq 0x10(%rax), %rdx
movq 0xbb3e(%rip), %rdi      # 0x12ff0
callq 0x3260
movq %rax, %rbp
movl $0x1, %edx
movq %rax, %rdi
leaq 0x61e7(%rip), %rsi      # 0xd6b0
callq 0x3260
movq 0x28(%rbx), %rsi
movq 0x30(%rbx), %rdx
movq %rbp, %rdi
callq 0x3260
movq %rax, %rbp
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbp, %rdi
movl $0xa, %esi
callq 0x31d0
movsbl %al, %esi
movq %rbp, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3150
movq %rbx, %rdi
callq 0x3160
movq %rax, %rbx
leaq 0xbd2e(%rip), %rax      # 0x13248
cmpq %rax, %rbx
jne 0x7352
movq 0x38(%rsp), %rax
cmpq 0x30(%rsp), %rax
je 0x75d3
leaq 0xbd36(%rip), %rdi      # 0x13270
leaq 0x5f99(%rip), %rsi      # 0xd4da
movl $0x12, %edx
callq 0x3260
movq 0x30(%rsp), %r13
movq 0x38(%rsp), %rbp
cmpq %rbp, %r13
je 0x75d3
leaq 0xbd0f(%rip), %rbx      # 0x13270
leaq 0x5e60(%rip), %r14      # 0xd3c8
leaq 0x5f7e(%rip), %r15      # 0xd4ed
leaq 0x5fa9(%rip), %r12      # 0xd51f
movq 0x8(%r13), %rsi
movq 0x10(%r13), %rdx
movq %rbx, %rdi
callq 0x3260
movl $0x2, %edx
movq %rax, %rdi
movq %r14, %rsi
callq 0x3260
movl $0xa, %edx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x3260
movq (%r13), %rax
movq 0x8(%rax), %rsi
movq 0x10(%rax), %rdx
movq %rbx, %rdi
callq 0x3260
movl $0x2, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x3260
addq $0x28, %r13
cmpq %rbp, %r13
jne 0x7576
leaq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
movq %rax, (%rdi)
leaq 0x5ee3(%rip), %rsi      # 0xd4ca
leaq 0x5ee1(%rip), %rdx      # 0xd4cf
callq 0x7944
leaq 0x8(%rsp), %rdi
callq 0x4745
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x7619
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3200
leaq 0xbf08(%rip), %rax      # 0x13528
movq (%rax), %rdi
callq 0x47a9
leaq 0xbc41(%rip), %rdi      # 0x13270
leaq 0x5ec2(%rip), %rsi      # 0xd4f8
movl $0x29, %edx
callq 0x3260
leaq 0xbc29(%rip), %rdi      # 0x13270
leaq 0x5ed4(%rip), %rsi      # 0xd522
movl $0x27, %edx
callq 0x3260
leaq 0x30(%rsp), %rdi
callq 0x775e
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x76e0
movq 0x20(%rsp), %rsi
jmp 0x76a3
jmp 0x76dd
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x76e0
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3200
jmp 0x76e0
jmp 0x76dd
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x76ea
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3200
jmp 0x76ea
movq %rax, %rbx
jmp 0x76ea
jmp 0x76dd
jmp 0x76dd
jmp 0x76dd
jmp 0x76dd
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x775e
movq %rbx, %rdi
callq 0x33d0