// File: /workspace/github_cpp_makefile_star2_O1/luooofan[P]hblzbd_compiler/src/generate_ir.cpp
// Function: ast::WhileStatement::GenerateIR(ir::ContextInfo&, std::vector<ir::IR*, std::allocator<ir::IR*>>&)
void WhileStatement::GenerateIR(ir::ContextInfo &ctx, std::vector<ir::IR *> &gIRList) {
  std::string label_next = ir::NewLabel();
  std::string label_begin = ir::NewLabel();
  // genir(label,begin,-,-)
  gIRList.push_back(new ir::IR(IROpKind::LABEL, LABEL_OPN(label_begin)));
  ctx.true_label_.push("null");
  ctx.false_label_.push(label_next);
  this->cond_.GenerateIR(ctx, gIRList);
  ctx.true_label_.pop();
  ctx.false_label_.pop();

  // maybe useless
  ctx.break_label_.push(label_next);
  ctx.continue_label_.push(label_begin);

  this->bodystmt_.GenerateIR(ctx, gIRList);
  // genir(goto,begin,-,-)
  gIRList.push_back(new ir::IR(IROpKind::GOTO, LABEL_OPN(label_begin)));

  ctx.continue_label_.pop();
  ctx.break_label_.pop();

  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 0x2802c
leaq 0x68(%rsp), %rdi
callq 0x2802c
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 $0x7, %esi
callq 0x25080
leaq 0x28(%rsp), %rsi
movq %r12, (%rsi)
xorl %ebp, %ebp
movq %rbx, %rdi
callq 0x114b8
movq 0x150(%rsp), %rdi
cmpq %r13, %rdi
je 0x1a2e7
movq 0x160(%rsp), %rsi
incq %rsi
callq 0x82a0
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x1a303
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x82a0
leaq 0x38(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0x559a4(%rip), %rsi     # 0x6fcb7
leaq 0x559a1(%rip), %rdx     # 0x6fcbb
leaq 0x28(%rsp), %rdi
callq 0xcaa0
leaq 0x148(%r14), %r12
leaq 0x28(%rsp), %rsi
movq %r12, %rdi
callq 0x2745e
movq 0x28(%rsp), %rdi
cmpq %r13, %rdi
je 0x1a34f
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x82a0
leaq 0x198(%r14), %r13
leaq 0x88(%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
leaq 0xa8(%r14), %r12
leaq 0x88(%rsp), %rsi
movq %r12, %rdi
callq 0x27748
leaq 0xf8(%r14), %r13
leaq 0x68(%rsp), %rsi
movq %r13, %rdi
callq 0x27748
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 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
movq 0x68(%rsp), %rsi
movq 0x70(%rsp), %rdx
addq %rsi, %rdx
leaq 0x8(%rsp), %rdi
callq 0xca10
leaq 0x110(%rsp), %rdi
movl $0x2, -0x8(%rdi)
leaq 0x120(%rsp), %r15
movq %r15, -0x10(%r15)
movq 0x8(%rsp), %rsi
movq 0x10(%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 %r14, %rdi
movl $0xb, %esi
callq 0x25080
leaq 0x28(%rsp), %rsi
movq %r14, (%rsi)
xorl %ebp, %ebp
movq %rbx, %rdi
callq 0x114b8
movq 0x110(%rsp), %rdi
cmpq %r15, %rdi
je 0x1a475
movq 0x120(%rsp), %rsi
incq %rsi
callq 0x82a0
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x1a491
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x82a0
movq %r13, %rdi
callq 0x27896
movq %r12, %rdi
callq 0x27896
movl $0xe0, %edi
callq 0x8290
movq %rax, %r14
leaq 0xb8(%rsp), %r15
movq %r15, -0x10(%r15)
movq 0x88(%rsp), %rsi
movq 0x90(%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 0x28(%rsp), %rsi
movq %r14, (%rsi)
xorl %ebp, %ebp
movq %rbx, %rdi
callq 0x114b8
movq 0xd0(%rsp), %rdi
cmpq %r12, %rdi
je 0x1a568
movq 0xe0(%rsp), %rsi
incq %rsi
callq 0x82a0
movq 0xa8(%rsp), %rdi
cmpq %r15, %rdi
je 0x1a585
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x82a0
leaq 0x78(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1a5a0
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x82a0
leaq 0x98(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1a5c1
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
movb $0x1, %bpl
jmp 0x1a666
jmp 0x1a5f0
jmp 0x1a718
movq %rax, %rbx
movb $0x1, %bpl
jmp 0x1a69d
movq %rax, %rbx
movb $0x1, %bpl
jmp 0x1a6b9
jmp 0x1a718
movq %rax, %rbx
movq 0x28(%rsp), %rdi
cmpq %r13, %rdi
je 0x1a71b
movq 0x38(%rsp), %rsi
incq %rsi
jmp 0x1a711
jmp 0x1a718
movq %rax, %rbx
movb $0x1, %bpl
jmp 0x1a6e8
movq %rax, %rbx
movb $0x1, %bpl
jmp 0x1a704
jmp 0x1a718
movq %rax, %rbx
jmp 0x1a736
movq %rax, %rbx
movq 0xd0(%rsp), %rdi
cmpq %r12, %rdi
je 0x1a666
movq 0xe0(%rsp), %rsi
incq %rsi
callq 0x82a0
movq 0xa8(%rsp), %rdi
cmpq %r15, %rdi
je 0x1a6b9
movq 0xb8(%rsp), %rsi
jmp 0x1a6b1
movq %rax, %rbx
movq 0x110(%rsp), %rdi
cmpq %r15, %rdi
je 0x1a69d
movq 0x120(%rsp), %rsi
incq %rsi
callq 0x82a0
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x1a6b9
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x82a0
testb %bpl, %bpl
je 0x1a71b
movl $0xe0, %esi
movq %r14, %rdi
jmp 0x1a711
movq %rax, %rbx
movq 0x150(%rsp), %rdi
cmpq %r13, %rdi
je 0x1a6e8
movq 0x160(%rsp), %rsi
incq %rsi
callq 0x82a0
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x1a704
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x82a0
testb %bpl, %bpl
je 0x1a71b
movl $0xe0, %esi
movq %r12, %rdi
callq 0x82a0
jmp 0x1a71b
movq %rax, %rbx
leaq 0x78(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1a736
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x82a0
leaq 0x98(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1a757
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x82a0
movq %rbx, %rdi
callq 0x8540
nop