// File: /workspace/github_cpp_makefile_star2_O3/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 0x88(%rsp), %rdi
callq 0x286bd
cmpq $0x0, 0x20(%r15)
je 0x19cdb
leaq 0x8(%rsp), %rdi
callq 0x286bd
leaq 0xb8(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0x55248(%rip), %rsi     # 0x6ecb7
leaq 0x55245(%rip), %rdx     # 0x6ecbb
leaq 0xa8(%rsp), %rdi
callq 0xc772
leaq 0x148(%r14), %r12
leaq 0xa8(%rsp), %rsi
movq %r12, %rdi
callq 0x27af0
movq 0xa8(%rsp), %rdi
cmpq %r13, %rdi
je 0x19ab7
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x82a0
leaq 0x198(%r14), %r13
leaq 0x8(%rsp), %rsi
movq %r13, %rdi
callq 0x27de0
movq 0x10(%r15), %rdi
movq (%rdi), %rax
movq %r14, %rsi
movq %rbx, %rdx
callq *0x10(%rax)
movq %r12, %rdi
callq 0x27f2e
movq %r13, %rdi
callq 0x27f2e
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 0x88(%rsp), %rsi
movq 0x90(%rsp), %rdx
addq %rsi, %rdx
leaq 0x48(%rsp), %rdi
callq 0xc6dc
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 0xc6dc
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 0x2574c
leaq 0xa8(%rsp), %rsi
movq %r12, (%rsi)
xorl %ebp, %ebp
movq %rbx, %rdi
callq 0x11182
movq 0x150(%rsp), %rdi
cmpq %r13, %rdi
je 0x19bb8
movq 0x160(%rsp), %rsi
incq %rsi
callq 0x82a0
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x19bd4
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 0xc6dc
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 0xc6dc
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 0x2574c
leaq 0xa8(%rsp), %rsi
movq %r12, (%rsi)
xorl %ebp, %ebp
movq %rbx, %rdi
callq 0x11182
movq 0x110(%rsp), %rdi
cmpq %r13, %rdi
je 0x19c8b
movq 0x120(%rsp), %rsi
incq %rsi
callq 0x82a0
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x19ca7
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 0x19d6e
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x82a0
jmp 0x19d6e
leaq 0x18(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0x54fcc(%rip), %rsi     # 0x6ecb7
leaq 0x54fc9(%rip), %rdx     # 0x6ecbb
leaq 0x8(%rsp), %rdi
callq 0xc772
leaq 0x148(%r14), %r12
leaq 0x8(%rsp), %rsi
movq %r12, %rdi
callq 0x27af0
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
je 0x19d27
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x82a0
leaq 0x198(%r14), %r13
leaq 0x88(%rsp), %rsi
movq %r13, %rdi
callq 0x27de0
movq 0x10(%r15), %rdi
movq (%rdi), %rax
movq %r14, %rsi
movq %rbx, %rdx
callq *0x10(%rax)
movq %r12, %rdi
callq 0x27f2e
movq %r13, %rdi
callq 0x27f2e
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 0x78(%rsp), %r15
movq %r15, -0x10(%r15)
movq 0x88(%rsp), %rsi
movq 0x90(%rsp), %rdx
addq %rsi, %rdx
leaq 0x68(%rsp), %rdi
callq 0xc6dc
leaq 0xd0(%rsp), %rdi
movl $0x2, -0x8(%rdi)
leaq 0xe0(%rsp), %r12
movq %r12, -0x10(%r12)
movq 0x68(%rsp), %rsi
movq 0x70(%rsp), %rdx
addq %rsi, %rdx
callq 0xc6dc
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 0x2574c
leaq 0x8(%rsp), %rsi
movq %r14, (%rsi)
xorl %ebp, %ebp
movq %rbx, %rdi
callq 0x11182
movq 0xd0(%rsp), %rdi
cmpq %r12, %rdi
je 0x19e29
movq 0xe0(%rsp), %rsi
incq %rsi
callq 0x82a0
movq 0x68(%rsp), %rdi
cmpq %r15, %rdi
je 0x19e40
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x82a0
leaq 0x98(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x19e61
movq 0x98(%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 0x1a024
jmp 0x1a031
jmp 0x19f3f
movq %rax, %rbx
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x19fbe
movq 0x38(%rsp), %rsi
jmp 0x19ecd
jmp 0x19eda
jmp 0x1a013
movq %rax, %rbx
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x19fbe
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x82a0
jmp 0x19fbe
movq %rax, %rbx
jmp 0x19fbe
jmp 0x1a013
movq %rax, %rbx
movq 0xa8(%rsp), %rdi
cmpq %r13, %rdi
je 0x1a016
movq 0xb8(%rsp), %rsi
incq %rsi
jmp 0x19fc6
jmp 0x1a013
jmp 0x19f3f
movq %rax, %rbx
movq 0x68(%rsp), %rdi
cmpq %r15, %rdi
je 0x1a009
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x82a0
jmp 0x1a009
movq %rax, %rbx
jmp 0x1a009
jmp 0x19f3f
movq %rax, %rbx
jmp 0x1a031
movq %rax, %rbx
movq 0x110(%rsp), %rdi
cmpq %r13, %rdi
je 0x19f67
movq 0x120(%rsp), %rsi
incq %rsi
callq 0x82a0
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x19fb9
movq 0x38(%rsp), %rsi
jmp 0x19fb1
movq %rax, %rbx
movq 0x150(%rsp), %rdi
cmpq %r13, %rdi
je 0x19f9d
movq 0x160(%rsp), %rsi
incq %rsi
callq 0x82a0
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x19fb9
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x82a0
testb %bpl, %bpl
je 0x1a016
movl $0xe0, %esi
movq %r12, %rdi
callq 0x82a0
jmp 0x1a016
movq %rax, %rbx
movq 0xd0(%rsp), %rdi
cmpq %r12, %rdi
je 0x19fed
movq 0xe0(%rsp), %rsi
incq %rsi
callq 0x82a0
movq 0x68(%rsp), %rdi
cmpq %r15, %rdi
je 0x1a004
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x82a0
testb %bpl, %bpl
je 0x1a031
movl $0xe0, %esi
movq %r14, %rdi
jmp 0x1a02c
movq %rax, %rbx
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1a031
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x82a0
leaq 0x98(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1a052
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x82a0
movq %rbx, %rdi
callq 0x8540