// File: /workspace/github_cpp_makefile_star2_O1/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 0xbffe(%rip), %rbx      # 0x13270
leaq 0x623b(%rip), %rsi      # 0xd4b4
movq %rbx, %rdi
movl $0x10, %edx
callq 0x3050
leaq 0x622d(%rip), %rsi      # 0xd4ba
movl $0x8, %edx
movq %rbx, %rdi
callq 0x3260
leaq 0x6222(%rip), %rsi      # 0xd4c3
movl $0x6, %edx
movq %rbx, %rdi
callq 0x3260
leaq 0x626a(%rip), %rsi      # 0xd51f
movl $0x2, %edx
movq %rbx, %rdi
callq 0x3260
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x61f8(%rip), %rsi      # 0xd4ca
leaq 0x61f6(%rip), %rdx      # 0xd4cf
leaq 0x8(%rsp), %rdi
callq 0x7948
leaq 0x8(%rsp), %rdi
callq 0x4785
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x7309
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3200
leaq 0xc218(%rip), %rax      # 0x13528
movq (%rax), %rbx
testq %rbx, %rbx
je 0x7326
movq %rbx, %rdi
callq 0x4233
movq 0x20(%rbx), %rbx
jmp 0x7313
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movq $0x0, 0x40(%rsp)
movq 0xbf1a(%rip), %rbx      # 0x13258
leaq 0xbf03(%rip), %rax      # 0x13248
cmpq %rax, %rbx
je 0x7534
leaq 0xbf1b(%rip), %r15      # 0x13270
leaq 0x617c(%rip), %r13      # 0xd4d8
leaq 0x5de1(%rip), %r12      # 0xd144
movq 0x20(%rbx), %rax
movl (%rax), %eax
cmpq $0x6, %rax
ja 0x7378
movslq (%r12,%rax,4), %rax
addq %r12, %rax
jmpq *%rax
xorl %ebp, %ebp
jmp 0x743e
movl $0x8, %ebp
jmp 0x743e
movl $0x4, %ebp
jmp 0x743e
leaq 0x28(%rbx), %rsi
movl $0x4, %ecx
leaq 0x8(%rsp), %r14
movq %r14, %rdi
xorl %edx, %edx
callq 0x3220
movq %r14, %rdi
leaq 0x5f41(%rip), %rsi      # 0xd2f6
callq 0x30a0
movl %eax, %ebp
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x73d8
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3200
testl %ebp, %ebp
jne 0x74b0
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 0x78b8
leaq 0x30(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x7d32
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x74b0
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x3200
jmp 0x74b0
movl $0x1, %ebp
movl $0x7, %edx
movq %r15, %rdi
leaq 0x6083(%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 0x6075(%rip), %rsi      # 0xd520
callq 0x3260
movq 0x20(%rbx), %rax
movq 0x8(%rax), %rsi
movq 0x10(%rax), %rdx
movq 0xbb2d(%rip), %rdi      # 0x12ff0
callq 0x3260
movq %rax, %rbp
movl $0x1, %edx
movq %rax, %rdi
leaq 0x61d6(%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 0xbd1d(%rip), %rax      # 0x13248
cmpq %rax, %rbx
jne 0x7363
movq 0x38(%rsp), %rax
cmpq 0x30(%rsp), %rax
je 0x7558
leaq 0xbd29(%rip), %rdi      # 0x13270
leaq 0x5f8c(%rip), %rsi      # 0xd4da
movl $0x12, %edx
callq 0x3260
movq 0x30(%rsp), %r13
movq 0x38(%rsp), %rbp
cmpq %rbp, %r13
je 0x75e0
leaq 0xbd02(%rip), %rbx      # 0x13270
leaq 0x5e53(%rip), %r14      # 0xd3c8
leaq 0x5f71(%rip), %r15      # 0xd4ed
leaq 0x5f9c(%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 0x7583
leaq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
movq %rax, (%rdi)
leaq 0x5ed6(%rip), %rsi      # 0xd4ca
leaq 0x5ed4(%rip), %rdx      # 0xd4cf
callq 0x7948
leaq 0x8(%rsp), %rdi
callq 0x4785
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x7626
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3200
leaq 0xbefb(%rip), %rax      # 0x13528
movq (%rax), %rdi
callq 0x47e9
leaq 0xbc34(%rip), %rdi      # 0x13270
leaq 0x5eb5(%rip), %rsi      # 0xd4f8
movl $0x29, %edx
callq 0x3260
leaq 0xbc1c(%rip), %rdi      # 0x13270
leaq 0x5ec7(%rip), %rsi      # 0xd522
movl $0x27, %edx
callq 0x3260
leaq 0x30(%rsp), %rdi
callq 0x776c
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 0x76ed
movq 0x20(%rsp), %rsi
jmp 0x76b0
jmp 0x76ea
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x76ed
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3200
jmp 0x76ed
jmp 0x76ea
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x76f7
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3200
jmp 0x76f7
movq %rax, %rbx
jmp 0x76f7
jmp 0x76ea
jmp 0x76ea
jmp 0x76ea
jmp 0x76ea
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x776c
movq %rbx, %rdi
callq 0x33d0
nop