// File: /workspace/github_cpp_makefile_star2_O3/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 %r15
pushq %r14
pushq %rbx
subq $0xa0, %rsp
movq %rdi, %rbx
leaq 0x60(%rsp), %rdi
callq 0x4014
leaq 0x40(%rsp), %rdi
callq 0x4014
movq 0x18(%rbx), %rsi
leaq 0x20(%rsp), %rdi
callq 0x5235
leaq 0x10(%rsp), %r15
movq %r15, -0x10(%r15)
movq $0x0, -0x8(%r15)
movb $0x0, (%r15)
leaq 0x20(%rsp), %rdi
callq 0x3b54
cmpl $-0x1, %eax
je 0x6f43
movq %rsp, %rdi
leaq 0x20(%rsp), %rsi
callq 0x3130
jmp 0x6ff2
leaq 0x80(%rsp), %rdi
movl $0x4, %esi
callq 0x3ad5
movq %rsp, %rdi
leaq 0x80(%rsp), %r14
movq %r14, %rsi
callq 0x32b0
movq (%r14), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0x6f88
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x3200
leaq 0xc2e1(%rip), %rdi      # 0x13270
leaq 0x637f(%rip), %rsi      # 0xd315
movl $0x6, %edx
callq 0x3260
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdx
leaq 0xc2bf(%rip), %rdi      # 0x13270
callq 0x3260
movq %rax, %r14
leaq 0x6413(%rip), %rsi      # 0xd3d3
movl $0x2, %edx
movq %rax, %rdi
callq 0x3260
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
movq %r14, %rdi
callq 0x3260
leaq 0x653b(%rip), %rsi      # 0xd520
movl $0x1, %edx
movq %rax, %rdi
callq 0x3260
leaq 0xc277(%rip), %rdi      # 0x13270
leaq 0x6393(%rip), %rsi      # 0xd393
movl $0x7, %edx
callq 0x3260
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
leaq 0xc256(%rip), %rdi      # 0x13270
callq 0x3260
movq %rax, %r14
leaq 0x63aa(%rip), %rsi      # 0xd3d3
movl $0x2, %edx
movq %rax, %rdi
callq 0x3260
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
movq %r14, %rdi
callq 0x3260
leaq 0x64d2(%rip), %rsi      # 0xd520
movl $0x1, %edx
movq %rax, %rdi
callq 0x3260
leaq 0xc20e(%rip), %rdi      # 0x13270
leaq 0x6349(%rip), %rsi      # 0xd3b2
movl $0x4, %edx
callq 0x3260
movq 0x60(%rsp), %rsi
movq 0x68(%rsp), %rdx
leaq 0xc1ec(%rip), %rdi      # 0x13270
callq 0x3260
leaq 0x6490(%rip), %rsi      # 0xd520
movl $0x1, %edx
movq %rax, %rdi
callq 0x3260
movq 0x18(%rbx), %rax
movq 0x20(%rax), %rdi
callq 0x47d2
leaq 0xc1bf(%rip), %rdi      # 0x13270
leaq 0x630a(%rip), %rsi      # 0xd3c2
movl $0x5, %edx
callq 0x3260
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rdx
leaq 0xc19d(%rip), %rdi      # 0x13270
callq 0x3260
leaq 0x6441(%rip), %rsi      # 0xd520
movl $0x1, %edx
movq %rax, %rdi
callq 0x3260
movq 0x60(%rsp), %rsi
movq 0x68(%rsp), %rdx
leaq 0xc173(%rip), %rdi      # 0x13270
callq 0x3260
leaq 0x62bf(%rip), %rsi      # 0xd3c8
movl $0x2, %edx
movq %rax, %rdi
callq 0x3260
movq 0x18(%rbx), %rax
movq 0x20(%rax), %rax
testq %rax, %rax
je 0x7129
movq 0x20(%rax), %rdi
jmp 0x712b
xorl %edi, %edi
callq 0x47d2
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rdx
leaq 0xc12f(%rip), %rdi      # 0x13270
callq 0x3260
leaq 0x627b(%rip), %rsi      # 0xd3c8
movl $0x2, %edx
movq %rax, %rdi
callq 0x3260
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x7170
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3200
leaq 0x30(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x718b
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x3200
leaq 0x50(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x71a6
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x3200
leaq 0x70(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x71c1
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x3200
addq $0xa0, %rsp
popq %rbx
popq %r14
popq %r15
retq
jmp 0x71da
movq %rax, %rbx
jmp 0x720e
movq %rax, %rbx
jmp 0x7229
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x71f3
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3200
leaq 0x30(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x720e
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x3200
leaq 0x50(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x7229
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x3200
leaq 0x70(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x7244
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x3200
movq %rbx, %rdi
callq 0x33d0