// File: /workspace/github_cpp_makefile_star2_O1/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 0x4045
leaq 0x40(%rsp), %rdi
callq 0x4045
movq 0x18(%rbx), %rsi
leaq 0x20(%rsp), %rdi
callq 0x5226
leaq 0x10(%rsp), %r15
movq %r15, -0x10(%r15)
movq $0x0, -0x8(%r15)
movb $0x0, (%r15)
leaq 0x20(%rsp), %rdi
callq 0x3b85
cmpl $-0x1, %eax
je 0x6f54
movq %rsp, %rdi
leaq 0x20(%rsp), %rsi
callq 0x3130
jmp 0x7003
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 0x6f99
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x3200
leaq 0xc2d0(%rip), %rdi      # 0x13270
leaq 0x636e(%rip), %rsi      # 0xd315
movl $0x6, %edx
callq 0x3260
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdx
leaq 0xc2ae(%rip), %rdi      # 0x13270
callq 0x3260
movq %rax, %r14
leaq 0x6402(%rip), %rsi      # 0xd3d3
movl $0x2, %edx
movq %rax, %rdi
callq 0x3260
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
movq %r14, %rdi
callq 0x3260
leaq 0x652a(%rip), %rsi      # 0xd520
movl $0x1, %edx
movq %rax, %rdi
callq 0x3260
leaq 0xc266(%rip), %rdi      # 0x13270
leaq 0x6382(%rip), %rsi      # 0xd393
movl $0x7, %edx
callq 0x3260
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
leaq 0xc245(%rip), %rdi      # 0x13270
callq 0x3260
movq %rax, %r14
leaq 0x6399(%rip), %rsi      # 0xd3d3
movl $0x2, %edx
movq %rax, %rdi
callq 0x3260
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
movq %r14, %rdi
callq 0x3260
leaq 0x64c1(%rip), %rsi      # 0xd520
movl $0x1, %edx
movq %rax, %rdi
callq 0x3260
leaq 0xc1fd(%rip), %rdi      # 0x13270
leaq 0x6338(%rip), %rsi      # 0xd3b2
movl $0x4, %edx
callq 0x3260
movq 0x60(%rsp), %rsi
movq 0x68(%rsp), %rdx
leaq 0xc1db(%rip), %rdi      # 0x13270
callq 0x3260
leaq 0x647f(%rip), %rsi      # 0xd520
movl $0x1, %edx
movq %rax, %rdi
callq 0x3260
movq 0x18(%rbx), %rax
movq 0x20(%rax), %rdi
callq 0x4812
leaq 0xc1ae(%rip), %rdi      # 0x13270
leaq 0x62f9(%rip), %rsi      # 0xd3c2
movl $0x5, %edx
callq 0x3260
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rdx
leaq 0xc18c(%rip), %rdi      # 0x13270
callq 0x3260
leaq 0x6430(%rip), %rsi      # 0xd520
movl $0x1, %edx
movq %rax, %rdi
callq 0x3260
movq 0x60(%rsp), %rsi
movq 0x68(%rsp), %rdx
leaq 0xc162(%rip), %rdi      # 0x13270
callq 0x3260
leaq 0x62ae(%rip), %rsi      # 0xd3c8
movl $0x2, %edx
movq %rax, %rdi
callq 0x3260
movq 0x18(%rbx), %rax
movq 0x20(%rax), %rax
testq %rax, %rax
je 0x713a
movq 0x20(%rax), %rdi
jmp 0x713c
xorl %edi, %edi
callq 0x4812
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rdx
leaq 0xc11e(%rip), %rdi      # 0x13270
callq 0x3260
leaq 0x626a(%rip), %rsi      # 0xd3c8
movl $0x2, %edx
movq %rax, %rdi
callq 0x3260
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x7181
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3200
leaq 0x30(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x719c
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x3200
leaq 0x50(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x71b7
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x3200
leaq 0x70(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x71d2
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x3200
addq $0xa0, %rsp
popq %rbx
popq %r14
popq %r15
retq
jmp 0x71eb
movq %rax, %rbx
jmp 0x721f
movq %rax, %rbx
jmp 0x723a
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x7204
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3200
leaq 0x30(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x721f
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x3200
leaq 0x50(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x723a
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x3200
leaq 0x70(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x7255
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x3200
movq %rbx, %rdi
callq 0x33d0