// File: 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
movq %rsp, %rbp
subq $0x190, %rsp            # imm = 0x190
leaq 0x18f9e(%rip), %rdi     # 0x212f0
movq %rdi, -0x120(%rbp)
leaq 0xf118(%rip), %rsi      # 0x17478
movl $0x10, %edx
callq 0x3060
movq -0x120(%rbp), %rdi
leaq 0xf106(%rip), %rsi      # 0x1747e
callq 0x3240
movq %rax, %rdi
leaq 0xf100(%rip), %rsi      # 0x17487
callq 0x3240
movq %rax, %rdi
leaq 0xf14d(%rip), %rsi      # 0x174e3
callq 0x3240
leaq -0x21(%rbp), %rdi
movq %rdi, -0x118(%rbp)
callq 0x3490
movq -0x118(%rbp), %rdx
leaq 0xf0d5(%rip), %rsi      # 0x1748e
leaq -0x20(%rbp), %rdi
callq 0x8910
jmp 0x83c4
leaq -0x20(%rbp), %rdi
callq 0x5230
jmp 0x83cf
leaq -0x20(%rbp), %rdi
callq 0x3180
leaq -0x21(%rbp), %rdi
callq 0x32c0
leaq 0x191c0(%rip), %rax     # 0x215a8
movq (%rax), %rax
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0x843e
movq -0x40(%rbp), %rdi
callq 0x4e90
movq -0x40(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x40(%rbp)
jmp 0x83ef
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x8430
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x3180
leaq -0x21(%rbp), %rdi
callq 0x32c0
jmp 0x88ba
leaq -0x58(%rbp), %rdi
callq 0x8e90
leaq 0x18e72(%rip), %rax     # 0x212c0
movq %rax, -0x60(%rbp)
leaq 0x18e67(%rip), %rdi     # 0x212c0
callq 0x8eb0
movq %rax, -0x68(%rbp)
leaq 0x18e57(%rip), %rdi     # 0x212c0
callq 0x8ee0
movq %rax, -0x70(%rbp)
leaq -0x68(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x8f10
testb $0x1, %al
jne 0x8488
jmp 0x86bb
leaq -0x68(%rbp), %rdi
callq 0x8f40
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rax
movq (%rax), %rax
cmpl $0x4, (%rax)
je 0x857d
movq -0x78(%rbp), %rdi
callq 0x5270
movl %eax, -0x7c(%rbp)
leaq 0x18e38(%rip), %rdi     # 0x212f0
leaq 0xefd5(%rip), %rsi      # 0x17494
callq 0x3240
movq %rax, -0x128(%rbp)
jmp 0x84cd
movq -0x128(%rbp), %rdi
movq -0x78(%rbp), %rsi
addq $0x8, %rsi
callq 0x3230
movq %rax, -0x130(%rbp)
jmp 0x84ea
movq -0x130(%rbp), %rdi
leaq 0xefa4(%rip), %rsi      # 0x1749c
callq 0x3240
movq %rax, -0x138(%rbp)
jmp 0x8506
movq -0x138(%rbp), %rdi
movl -0x7c(%rbp), %esi
callq 0x3460
movq %rax, -0x140(%rbp)
jmp 0x851e
movq -0x140(%rbp), %rdi
leaq 0xef70(%rip), %rsi      # 0x1749c
callq 0x3240
movq %rax, -0x148(%rbp)
jmp 0x853a
movq -0x148(%rbp), %rdi
movl -0x7c(%rbp), %esi
callq 0x3460
movq %rax, -0x150(%rbp)
jmp 0x8552
movq -0x150(%rbp), %rdi
leaq 0xef84(%rip), %rsi      # 0x174e4
callq 0x3240
jmp 0x8567
jmp 0x863d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x88b1
movq -0x78(%rbp), %rsi
addq $0x8, %rsi
xorl %eax, %eax
movl %eax, %edx
leaq -0xa0(%rbp), %rdi
movl $0x4, %ecx
callq 0x3270
jmp 0x859c
leaq 0xed17(%rip), %rsi      # 0x172ba
leaq -0xa0(%rbp), %rdi
callq 0x8db0
movb %al, -0x151(%rbp)
jmp 0x85b7
leaq -0xa0(%rbp), %rdi
callq 0x3180
movb -0x151(%rbp), %al
testb $0x1, %al
jne 0x85cf
jmp 0x863b
movq -0x78(%rbp), %rsi
leaq -0xc8(%rbp), %rdi
callq 0x8f90
jmp 0x85e1
leaq -0x58(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x8f60
jmp 0x85f3
leaq -0xc8(%rbp), %rdi
callq 0x8fd0
jmp 0x863b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x3180
jmp 0x88b1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0x8fd0
jmp 0x88b1
jmp 0x863d
movq -0x78(%rbp), %rax
movq (%rax), %rsi
addq $0x8, %rsi
movq 0x189a1(%rip), %rdi     # 0x20ff0
callq 0x3230
movq %rax, -0x160(%rbp)
jmp 0x865d
movq -0x160(%rbp), %rdi
leaq 0xf015(%rip), %rsi      # 0x17680
callq 0x3240
movq %rax, -0x168(%rbp)
jmp 0x8679
movq -0x168(%rbp), %rdi
movq -0x78(%rbp), %rsi
addq $0x8, %rsi
callq 0x3230
movq %rax, -0x170(%rbp)
jmp 0x8696
movq -0x170(%rbp), %rdi
movq 0x18904(%rip), %rsi     # 0x20fa8
callq 0x3290
jmp 0x86ab
jmp 0x86ad
leaq -0x68(%rbp), %rdi
callq 0x8ff0
jmp 0x8472
leaq -0x58(%rbp), %rdi
callq 0x9020
cmpq $0x0, %rax
je 0x86e1
leaq 0x18c1f(%rip), %rdi     # 0x212f0
leaq 0xedc6(%rip), %rsi      # 0x1749e
callq 0x3240
jmp 0x86df
jmp 0x86e1
leaq -0x58(%rbp), %rax
movq %rax, -0xd0(%rbp)
movq -0xd0(%rbp), %rdi
callq 0x9050
movq %rax, -0xd8(%rbp)
movq -0xd0(%rbp), %rdi
callq 0x9080
movq %rax, -0xe0(%rbp)
leaq -0xd8(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x90b0
testb $0x1, %al
jne 0x872e
jmp 0x87dd
leaq -0xd8(%rbp), %rdi
callq 0x90f0
movq %rax, -0xe8(%rbp)
movq -0xe8(%rbp), %rsi
addq $0x8, %rsi
leaq 0x18b9d(%rip), %rdi     # 0x212f0
callq 0x3230
movq %rax, -0x178(%rbp)
jmp 0x8761
movq -0x178(%rbp), %rdi
leaq 0xec1d(%rip), %rsi      # 0x1738c
callq 0x3240
jmp 0x8776
leaq 0x18b73(%rip), %rdi     # 0x212f0
leaq 0xed2d(%rip), %rsi      # 0x174b1
callq 0x3240
movq %rax, -0x180(%rbp)
jmp 0x8792
movq -0x180(%rbp), %rdi
movq -0xe8(%rbp), %rax
movq (%rax), %rsi
addq $0x8, %rsi
callq 0x3230
movq %rax, -0x188(%rbp)
jmp 0x87b5
movq -0x188(%rbp), %rdi
leaq 0xed20(%rip), %rsi      # 0x174e3
callq 0x3240
jmp 0x87ca
jmp 0x87cc
leaq -0xd8(%rbp), %rdi
callq 0x9110
jmp 0x8712
leaq -0x109(%rbp), %rdi
movq %rdi, -0x190(%rbp)
callq 0x3490
movq -0x190(%rbp), %rdx
leaq 0xec90(%rip), %rsi      # 0x1748e
leaq -0x108(%rbp), %rdi
callq 0x8910
jmp 0x880c
leaq -0x108(%rbp), %rdi
callq 0x5230
jmp 0x881a
leaq -0x108(%rbp), %rdi
callq 0x3180
leaq -0x109(%rbp), %rdi
callq 0x32c0
leaq 0x18d6f(%rip), %rax     # 0x215a8
movq (%rax), %rdi
callq 0x52f0
jmp 0x8843
leaq 0x18aa6(%rip), %rdi     # 0x212f0
leaq 0xec6b(%rip), %rsi      # 0x174bc
callq 0x3240
jmp 0x8858
leaq 0x18a91(%rip), %rdi     # 0x212f0
leaq 0xec80(%rip), %rsi      # 0x174e6
callq 0x3240
jmp 0x886d
leaq -0x58(%rbp), %rdi
callq 0x9130
addq $0x190, %rsp            # imm = 0x190
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x88a5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x108(%rbp), %rdi
callq 0x3180
leaq -0x109(%rbp), %rdi
callq 0x32c0
leaq -0x58(%rbp), %rdi
callq 0x9130
movq -0x30(%rbp), %rdi
callq 0x3480
nopw %cs:(%rax,%rax)
nopl (%rax)