// File: SunriseFox[P]very-simple-c-compiler/./src/asm.cpp
// Function: storeVar(TreeNode*)
void storeVar(TreeNode* node) {
    if (node == nullptr) return;

    Symbol* ownSymbol = nullptr;

    if (node->nodeType == TreeNode::NODE_DECLARATION) {
        ownSymbol = static_cast<DeclarationNode*>(node)->symbol;
        cerr << "get dec " << ownSymbol << " " << ownSymbol->value << endl;
        varDeclare[ownSymbol] = string("temp") + to_string(tempVarCount++);
    } else if (node->nodeType == TreeNode::NODE_EXPRESSION) {
        ownSymbol = static_cast<ExprNode*>(node)->symbol;
        cerr << "get exp " << ownSymbol << " " << ownSymbol->value << endl;
        if (ownSymbol->symbolType == Symbol::SYMBOL_CONSTANT
                && ownSymbol->type == Symbol::VALUE_STRING) {
            varDeclare[ownSymbol] = string(".str") + to_string(tempVarCount++);
        }
    }

    auto children = node -> child;
    while (children) {
        storeVar(children);
        children = children -> sibling;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x120, %rsp            # imm = 0x120
movq %rdi, -0x8(%rbp)
cmpq $0x0, -0x8(%rbp)
jne 0x4eab
jmp 0x521c
movq $0x0, -0x10(%rbp)
movq -0x8(%rbp), %rax
cmpl $0x2, 0x10(%rax)
jne 0x502e
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x10(%rbp)
movq 0x1c11c(%rip), %rdi     # 0x20ff0
leaq 0x123c8(%rip), %rsi     # 0x172a3
callq 0x3240
movq %rax, %rdi
movq -0x10(%rbp), %rsi
callq 0x31e0
movq %rax, %rdi
leaq 0x1278a(%rip), %rsi     # 0x17680
callq 0x3240
movq %rax, %rdi
movq -0x10(%rbp), %rsi
addq $0x8, %rsi
callq 0x3230
movq %rax, %rdi
movq 0x1c093(%rip), %rsi     # 0x20fa8
callq 0x3290
leaq -0x51(%rbp), %rdi
movq %rdi, -0x100(%rbp)
callq 0x3490
movq -0x100(%rbp), %rdx
leaq 0x12374(%rip), %rsi     # 0x172ac
leaq -0x50(%rbp), %rdi
callq 0x8910
jmp 0x4f43
movl 0x1c5bb(%rip), %esi     # 0x21504
movl %esi, %eax
incl %eax
movl %eax, 0x1c5b1(%rip)     # 0x21504
leaq -0x88(%rbp), %rdi
callq 0x8bc0
jmp 0x4f61
leaq -0x30(%rbp), %rdi
leaq -0x50(%rbp), %rsi
leaq -0x88(%rbp), %rdx
callq 0x8af0
jmp 0x4f77
leaq 0x1c342(%rip), %rdi     # 0x212c0
leaq -0x10(%rbp), %rsi
callq 0x89c0
movq %rax, -0x108(%rbp)
jmp 0x4f90
movq -0x108(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x3340
leaq -0x30(%rbp), %rdi
callq 0x3180
leaq -0x88(%rbp), %rdi
callq 0x3180
leaq -0x50(%rbp), %rdi
callq 0x3180
leaq -0x51(%rbp), %rdi
callq 0x32c0
jmp 0x51e3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x5020
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x5017
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x500b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x3180
leaq -0x88(%rbp), %rdi
callq 0x3180
leaq -0x50(%rbp), %rdi
callq 0x3180
leaq -0x51(%rbp), %rdi
callq 0x32c0
jmp 0x5225
movq -0x8(%rbp), %rax
cmpl $0x3, 0x10(%rax)
jne 0x51e1
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x10(%rbp)
movq 0x1bfa1(%rip), %rdi     # 0x20ff0
leaq 0x1225b(%rip), %rsi     # 0x172b1
callq 0x3240
movq %rax, %rdi
movq -0x10(%rbp), %rsi
callq 0x31e0
movq %rax, %rdi
leaq 0x1260f(%rip), %rsi     # 0x17680
callq 0x3240
movq %rax, %rdi
movq -0x10(%rbp), %rsi
addq $0x8, %rsi
callq 0x3230
movq %rax, %rdi
movq 0x1bf18(%rip), %rsi     # 0x20fa8
callq 0x3290
movq -0x10(%rbp), %rax
cmpl $0x0, 0x28(%rax)
jne 0x51df
movq -0x10(%rbp), %rax
cmpl $0x4, (%rax)
jne 0x51df
leaq -0xc9(%rbp), %rdi
movq %rdi, -0x110(%rbp)
callq 0x3490
movq -0x110(%rbp), %rdx
leaq 0x121e9(%rip), %rsi     # 0x172ba
leaq -0xc8(%rbp), %rdi
callq 0x8910
jmp 0x50df
movl 0x1c41f(%rip), %esi     # 0x21504
movl %esi, %eax
incl %eax
movl %eax, 0x1c415(%rip)     # 0x21504
leaq -0xf0(%rbp), %rdi
callq 0x8bc0
jmp 0x50fd
leaq -0xa8(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
leaq -0xf0(%rbp), %rdx
callq 0x8af0
jmp 0x5119
leaq 0x1c1a0(%rip), %rdi     # 0x212c0
leaq -0x10(%rbp), %rsi
callq 0x89c0
movq %rax, -0x118(%rbp)
jmp 0x5132
movq -0x118(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x3340
leaq -0xa8(%rbp), %rdi
callq 0x3180
leaq -0xf0(%rbp), %rdi
callq 0x3180
leaq -0xc8(%rbp), %rdi
callq 0x3180
leaq -0xc9(%rbp), %rdi
callq 0x32c0
jmp 0x51df
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x51d1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x51c5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x51b9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x3180
leaq -0xf0(%rbp), %rdi
callq 0x3180
leaq -0xc8(%rbp), %rdi
callq 0x3180
leaq -0xc9(%rbp), %rdi
callq 0x32c0
jmp 0x5225
jmp 0x51e1
jmp 0x51e3
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0xf8(%rbp)
cmpq $0x0, -0xf8(%rbp)
je 0x521c
movq -0xf8(%rbp), %rdi
callq 0x4e90
movq -0xf8(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0xf8(%rbp)
jmp 0x51f2
addq $0x120, %rsp            # imm = 0x120
popq %rbp
retq
movq -0x60(%rbp), %rdi
callq 0x3480
nop