// File: /workspace/github_cpp_makefile_star2_O2/SunriseFox[P]very-simple-c-compiler/./src/asm.cpp
// Function: handleIf(StatementNode*)
void handleIf(StatementNode* node) {
    string LElse = getNextLabel();
    string LEnd = getNextLabel();
    string op = handleExprNode(node->child);

    string reg;

    if (getRegNum(op) == -1) { // 不是寄存器
        reg = getTmpReg(4);
        of << "\tmovl\t" << op << ", " << reg << "\n";
    } else {
        reg = op;
    }

    of << "\ttestl\t" << reg << ", " << reg << "\n";
    of << "\tje\t" << LElse << "\n";
    generateCode(node->child->sibling);
    of << "\tjmp\t" << LEnd << "\n";

    of << LElse << ":\n";
    generateCode(node->child->sibling ? node->child->sibling->sibling : nullptr);
    of << LEnd << ":\n";
}

// Assembly:
pushq %r14
pushq %rbx
subq $0xa8, %rsp
movq %rdi, %rbx
leaq 0x68(%rsp), %rdi
callq 0x3e5e
leaq 0x48(%rsp), %rdi
callq 0x3e5e
movq 0x18(%rbx), %rsi
leaq 0x28(%rsp), %rdi
callq 0x488e
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x28(%rsp), %rdi
callq 0x3ab1
cmpl $-0x1, %eax
je 0x5c25
leaq 0x8(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x3130
jmp 0x5c9d
leaq 0x88(%rsp), %rdi
pushq $0x4
popq %rsi
callq 0x3a35
leaq 0x8(%rsp), %rdi
leaq 0x88(%rsp), %r14
movq %r14, %rsi
callq 0x3280
movq %r14, %rdi
callq 0x30f0
leaq 0xc60f(%rip), %rdi      # 0x12268
leaq 0x56a5(%rip), %rsi      # 0xb305
callq 0x31d0
leaq 0x28(%rsp), %rsi
movq %rax, %rdi
callq 0x31c0
leaq 0x574a(%rip), %rsi      # 0xb3c3
movq %rax, %rdi
callq 0x31d0
leaq 0x8(%rsp), %rsi
movq %rax, %rdi
callq 0x31c0
leaq 0x587b(%rip), %rsi      # 0xb510
movq %rax, %rdi
callq 0x31d0
leaq 0xc5c4(%rip), %rdi      # 0x12268
leaq 0x56d8(%rip), %rsi      # 0xb383
callq 0x31d0
leaq 0x8(%rsp), %rsi
movq %rax, %rdi
callq 0x31c0
leaq 0x56ff(%rip), %rsi      # 0xb3c3
movq %rax, %rdi
callq 0x31d0
leaq 0x8(%rsp), %rsi
movq %rax, %rdi
callq 0x31c0
leaq 0x5830(%rip), %rsi      # 0xb510
movq %rax, %rdi
callq 0x31d0
leaq 0xc579(%rip), %rdi      # 0x12268
leaq 0x56ac(%rip), %rsi      # 0xb3a2
callq 0x31d0
leaq 0x68(%rsp), %rsi
movq %rax, %rdi
callq 0x31c0
leaq 0x5801(%rip), %rsi      # 0xb510
movq %rax, %rdi
callq 0x31d0
movq 0x18(%rbx), %rax
movq 0x20(%rax), %rdi
callq 0x4170
leaq 0xc53d(%rip), %rdi      # 0x12268
leaq 0x5680(%rip), %rsi      # 0xb3b2
callq 0x31d0
leaq 0x48(%rsp), %rsi
movq %rax, %rdi
callq 0x31c0
leaq 0x57c5(%rip), %rsi      # 0xb510
movq %rax, %rdi
callq 0x31d0
leaq 0xc50e(%rip), %rdi      # 0x12268
leaq 0x68(%rsp), %rsi
callq 0x31c0
leaq 0x564d(%rip), %rsi      # 0xb3b8
movq %rax, %rdi
callq 0x31d0
movq 0x18(%rbx), %rax
movq 0x20(%rax), %rax
testq %rax, %rax
je 0x5d86
movq 0x20(%rax), %rdi
jmp 0x5d88
xorl %edi, %edi
callq 0x4170
leaq 0xc4d4(%rip), %rdi      # 0x12268
leaq 0x48(%rsp), %rsi
callq 0x31c0
leaq 0x5613(%rip), %rsi      # 0xb3b8
movq %rax, %rdi
callq 0x31d0
leaq 0x8(%rsp), %rdi
callq 0x30f0
leaq 0x28(%rsp), %rdi
callq 0x30f0
leaq 0x48(%rsp), %rdi
callq 0x30f0
leaq 0x68(%rsp), %rdi
callq 0x30f0
addq $0xa8, %rsp
popq %rbx
popq %r14
retq
jmp 0x5dec
movq %rax, %rbx
jmp 0x5e03
movq %rax, %rbx
jmp 0x5e0d
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x30f0
leaq 0x28(%rsp), %rdi
callq 0x30f0
leaq 0x48(%rsp), %rdi
callq 0x30f0
leaq 0x68(%rsp), %rdi
callq 0x30f0
movq %rbx, %rdi
callq 0x3390