// File: /workspace/github_cpp_makefile_star2_O1/luooofan[P]hblzbd_compiler/src/generate_ir.cpp
// Function: ast::IfElseStatement::GenerateIR(ir::ContextInfo&, std::vector<ir::IR*, std::allocator<ir::IR*>>&)
void IfElseStatement::GenerateIR(ir::ContextInfo &ctx, std::vector<ir::IR *> &gIRList) {
  std::string label_next = ir::NewLabel();
  if (nullptr == this->elsestmt_) {
    // if then
    ctx.true_label_.push("null");
    ctx.false_label_.push(label_next);
    this->cond_.GenerateIR(ctx, gIRList);
    ctx.true_label_.pop();
    ctx.false_label_.pop();
    this->thenstmt_.GenerateIR(ctx, gIRList);
  } else {
    // if then else
    std::string label_else = ir::NewLabel();
    ctx.true_label_.push("null");
    ctx.false_label_.push(label_else);
    this->cond_.GenerateIR(ctx, gIRList);
    ctx.true_label_.pop();
    ctx.false_label_.pop();
    this->thenstmt_.GenerateIR(ctx, gIRList);
    // genir(goto,next,-,-)
    gIRList.push_back(new ir::IR(IROpKind::GOTO, LABEL_OPN(label_next)));
    // genir(label,else,-,-)
    gIRList.push_back(new ir::IR(IROpKind::LABEL, LABEL_OPN(label_else)));
    this->elsestmt_->GenerateIR(ctx, gIRList);
  }
  gIRList.push_back(new ir::IR(IROpKind::LABEL, LABEL_OPN(label_next)));
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x188, %rsp            # imm = 0x188
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
leaq 0x68(%rsp), %rdi
callq 0x2802c
cmpq $0x0, 0x20(%r15)
je 0x19ec4
leaq 0x8(%rsp), %rdi
callq 0x2802c
leaq 0x98(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0x56059(%rip), %rsi     # 0x6fcb7
leaq 0x56056(%rip), %rdx     # 0x6fcbb
leaq 0x88(%rsp), %rdi
callq 0xcaa0
leaq 0x148(%r14), %r12
leaq 0x88(%rsp), %rsi
movq %r12, %rdi
callq 0x2745e
movq 0x88(%rsp), %rdi
cmpq %r13, %rdi
je 0x19ca6
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x82a0
leaq 0x198(%r14), %r13
leaq 0x8(%rsp), %rsi
movq %r13, %rdi
callq 0x27748
movq 0x10(%r15), %rdi
movq (%rdi), %rax
movq %r14, %rsi
movq %rbx, %rdx
callq *0x10(%rax)
movq %r12, %rdi
callq 0x27896
movq %r13, %rdi
callq 0x27896
movq 0x18(%r15), %rdi
movq (%rdi), %rax
movq %r14, %rsi
movq %rbx, %rdx
callq *0x10(%rax)
movl $0xe0, %edi
callq 0x8290
movq %rax, %r12
leaq 0x58(%rsp), %rax
movq %rax, -0x10(%rax)
movq 0x68(%rsp), %rsi
movq 0x70(%rsp), %rdx
addq %rsi, %rdx
leaq 0x48(%rsp), %rdi
callq 0xca10
leaq 0x150(%rsp), %rdi
movl $0x2, -0x8(%rdi)
leaq 0x160(%rsp), %r13
movq %r13, -0x10(%r13)
movq 0x48(%rsp), %rsi
movq 0x50(%rsp), %rdx
addq %rsi, %rdx
callq 0xca10
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
leaq 0x148(%rsp), %rdx
movl %eax, 0x28(%rdx)
movq $0x0, 0x30(%rdx)
movl %eax, 0x38(%rdx)
movb $0x1, %bpl
movq %r12, %rdi
movl $0xb, %esi
callq 0x25080
leaq 0x88(%rsp), %rsi
movq %r12, (%rsi)
xorl %ebp, %ebp
movq %rbx, %rdi
callq 0x114b8
movq 0x150(%rsp), %rdi
cmpq %r13, %rdi
je 0x19da1
movq 0x160(%rsp), %rsi
incq %rsi
callq 0x82a0
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x19dbd
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x82a0
movl $0xe0, %edi
callq 0x8290
movq %rax, %r12
leaq 0x38(%rsp), %rax
movq %rax, -0x10(%rax)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
addq %rsi, %rdx
leaq 0x28(%rsp), %rdi
callq 0xca10
leaq 0x110(%rsp), %rdi
movl $0x2, -0x8(%rdi)
leaq 0x120(%rsp), %r13
movq %r13, -0x10(%r13)
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
addq %rsi, %rdx
callq 0xca10
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
leaq 0x108(%rsp), %rdx
movl %eax, 0x28(%rdx)
movq $0x0, 0x30(%rdx)
movl %eax, 0x38(%rdx)
movb $0x1, %bpl
movq %r12, %rdi
movl $0x7, %esi
callq 0x25080
leaq 0x88(%rsp), %rsi
movq %r12, (%rsi)
xorl %ebp, %ebp
movq %rbx, %rdi
callq 0x114b8
movq 0x110(%rsp), %rdi
cmpq %r13, %rdi
je 0x19e74
movq 0x120(%rsp), %rsi
incq %rsi
callq 0x82a0
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x19e90
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x82a0
movq 0x20(%r15), %rdi
movq (%rdi), %rax
movq %r14, %rsi
movq %rbx, %rdx
callq *0x10(%rax)
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x19f54
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x82a0
jmp 0x19f54
leaq 0x18(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0x55de3(%rip), %rsi     # 0x6fcb7
leaq 0x55de0(%rip), %rdx     # 0x6fcbb
leaq 0x8(%rsp), %rdi
callq 0xcaa0
leaq 0x148(%r14), %r12
leaq 0x8(%rsp), %rsi
movq %r12, %rdi
callq 0x2745e
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
je 0x19f10
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x82a0
leaq 0x198(%r14), %r13
leaq 0x68(%rsp), %rsi
movq %r13, %rdi
callq 0x27748
movq 0x10(%r15), %rdi
movq (%rdi), %rax
movq %r14, %rsi
movq %rbx, %rdx
callq *0x10(%rax)
movq %r12, %rdi
callq 0x27896
movq %r13, %rdi
callq 0x27896
movq 0x18(%r15), %rdi
movq (%rdi), %rax
movq %r14, %rsi
movq %rbx, %rdx
callq *0x10(%rax)
movl $0xe0, %edi
callq 0x8290
movq %rax, %r14
leaq 0xb8(%rsp), %r15
movq %r15, -0x10(%r15)
movq 0x68(%rsp), %rsi
movq 0x70(%rsp), %rdx
addq %rsi, %rdx
leaq 0xa8(%rsp), %rdi
callq 0xca10
leaq 0xd0(%rsp), %rdi
movl $0x2, -0x8(%rdi)
leaq 0xe0(%rsp), %r12
movq %r12, -0x10(%r12)
movq 0xa8(%rsp), %rsi
movq 0xb0(%rsp), %rdx
addq %rsi, %rdx
callq 0xca10
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
leaq 0xc8(%rsp), %rdx
movl %eax, 0x28(%rdx)
movq $0x0, 0x30(%rdx)
movl %eax, 0x38(%rdx)
movb $0x1, %bpl
movq %r14, %rdi
movl $0x7, %esi
callq 0x25080
leaq 0x8(%rsp), %rsi
movq %r14, (%rsi)
xorl %ebp, %ebp
movq %rbx, %rdi
callq 0x114b8
movq 0xd0(%rsp), %rdi
cmpq %r12, %rdi
je 0x1a015
movq 0xe0(%rsp), %rsi
incq %rsi
callq 0x82a0
movq 0xa8(%rsp), %rdi
cmpq %r15, %rdi
je 0x1a032
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x82a0
leaq 0x78(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1a04d
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x82a0
addq $0x188, %rsp            # imm = 0x188
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
jne 0x1a1d2
jmp 0x1a1df
jmp 0x1a0e7
movq %rax, %rbx
movb $0x1, %bpl
jmp 0x1a10f
jmp 0x1a094
jmp 0x1a1c1
movq %rax, %rbx
movb $0x1, %bpl
jmp 0x1a145
movq %rax, %rbx
movb $0x1, %bpl
jmp 0x1a161
jmp 0x1a1c1
movq %rax, %rbx
movq 0x88(%rsp), %rdi
cmpq %r13, %rdi
je 0x1a1c4
movq 0x98(%rsp), %rsi
incq %rsi
jmp 0x1a16e
jmp 0x1a1c1
jmp 0x1a0e7
movq %rax, %rbx
movb $0x1, %bpl
jmp 0x1a195
movq %rax, %rbx
movb $0x1, %bpl
jmp 0x1a1b2
jmp 0x1a0e7
movq %rax, %rbx
jmp 0x1a1df
movq %rax, %rbx
movq 0x110(%rsp), %rdi
cmpq %r13, %rdi
je 0x1a10f
movq 0x120(%rsp), %rsi
incq %rsi
callq 0x82a0
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x1a161
movq 0x38(%rsp), %rsi
jmp 0x1a159
movq %rax, %rbx
movq 0x150(%rsp), %rdi
cmpq %r13, %rdi
je 0x1a145
movq 0x160(%rsp), %rsi
incq %rsi
callq 0x82a0
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x1a161
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x82a0
testb %bpl, %bpl
je 0x1a1c4
movl $0xe0, %esi
movq %r12, %rdi
callq 0x82a0
jmp 0x1a1c4
movq %rax, %rbx
movq 0xd0(%rsp), %rdi
cmpq %r12, %rdi
je 0x1a195
movq 0xe0(%rsp), %rsi
incq %rsi
callq 0x82a0
movq 0xa8(%rsp), %rdi
cmpq %r15, %rdi
je 0x1a1b2
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x82a0
testb %bpl, %bpl
je 0x1a1df
movl $0xe0, %esi
movq %r14, %rdi
jmp 0x1a1da
movq %rax, %rbx
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1a1df
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x82a0
leaq 0x78(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1a1fa
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x82a0
movq %rbx, %rdi
callq 0x8540