// File: luooofan[P]hblzbd_compiler/src/evaluate.cpp
// Function: ast::BinaryExpression::Evaluate(ir::ContextInfo&, std::vector<ir::IR*, std::allocator<ir::IR*>>&)
void BinaryExpression::Evaluate(ir::ContextInfo& ctx, std::vector<ir::IR*>& gIRList) {
  int l, r, res;

  // lhs_.Evaluate(ctx, gIRList);
  lhs_->Evaluate(ctx, gIRList);
  l = ctx.opn_.imm_num_;
  rhs_.Evaluate(ctx, gIRList);
  r = ctx.opn_.imm_num_;

  switch (op_) {
    case 258:
      res = l + r;
      break;
    case 259:
      res = l - r;
      break;
    case 261:
      res = l * r;
      break;
    case 262:
      res = l / r;
      break;
    case 263:
      res = l % r;
      break;
    case 270:
      res = l && r;
      break;
    case 271:
      res = l || r;
      break;
    default:
      // printf("mystery operator code: %d", op_);
      MyAssert(0);
      break;
  }

  ctx.opn_ = ir::Opn(ir::Opn::Type::Imm, res);
}

// Assembly:
subq $0x98, %rsp
movq %rdi, 0x90(%rsp)
movq %rsi, 0x88(%rsp)
movq %rdx, 0x80(%rsp)
movq 0x90(%rsp), %rdi
movq %rdi, 0x10(%rsp)
addq $0x10, %rdi
callq 0x14c70
movq %rax, %rdi
movq 0x88(%rsp), %rsi
movq 0x80(%rsp), %rdx
movq (%rdi), %rax
movq 0x18(%rax), %rax
callq *%rax
movq 0x10(%rsp), %rax
movq 0x88(%rsp), %rcx
movl 0xc(%rcx), %ecx
movl %ecx, 0x7c(%rsp)
movq 0x20(%rax), %rdi
movq 0x88(%rsp), %rsi
movq 0x80(%rsp), %rdx
movq (%rdi), %rax
movq 0x18(%rax), %rax
callq *%rax
movq 0x10(%rsp), %rax
movq 0x88(%rsp), %rcx
movl 0xc(%rcx), %ecx
movl %ecx, 0x78(%rsp)
movl 0xc(%rax), %eax
addl $0xfffffefe, %eax       # imm = 0xFFFFFEFE
movl %eax, %ecx
movq %rcx, 0x18(%rsp)
subl $0xd, %eax
ja 0x1e92b
movq 0x18(%rsp), %rax
leaq 0xdc0ba(%rip), %rcx     # 0xfa934
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl 0x7c(%rsp), %eax
addl 0x78(%rsp), %eax
movl %eax, 0x74(%rsp)
jmp 0x1e982
movl 0x7c(%rsp), %eax
subl 0x78(%rsp), %eax
movl %eax, 0x74(%rsp)
jmp 0x1e982
movl 0x7c(%rsp), %eax
imull 0x78(%rsp), %eax
movl %eax, 0x74(%rsp)
jmp 0x1e982
movl 0x7c(%rsp), %eax
cltd
idivl 0x78(%rsp)
movl %eax, 0x74(%rsp)
jmp 0x1e982
movl 0x7c(%rsp), %eax
cltd
idivl 0x78(%rsp)
movl %edx, 0x74(%rsp)
jmp 0x1e982
xorl %eax, %eax
cmpl $0x0, 0x7c(%rsp)
movb %al, 0xf(%rsp)
je 0x1e8f4
cmpl $0x0, 0x78(%rsp)
setne %al
movb %al, 0xf(%rsp)
movb 0xf(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x74(%rsp)
jmp 0x1e982
movb $0x1, %al
cmpl $0x0, 0x7c(%rsp)
movb %al, 0xe(%rsp)
jne 0x1e91c
cmpl $0x0, 0x78(%rsp)
setne %al
movb %al, 0xe(%rsp)
movb 0xe(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x74(%rsp)
jmp 0x1e982
movq 0x12d6b6(%rip), %rdi    # 0x14bfe8
leaq 0xdb7bf(%rip), %rsi     # 0xfa0f8
callq 0x8330
movq %rax, %rdi
leaq 0xdc099(%rip), %rsi     # 0xfa9e1
callq 0x8330
movq %rax, %rdi
leaq 0xdca93(%rip), %rsi     # 0xfb3ea
callq 0x8330
movq %rax, %rdi
movl $0x57, %esi
callq 0x8650
movq %rax, %rdi
movq 0x12d60d(%rip), %rsi    # 0x14bf80
callq 0x8380
movl $0xff, %edi
callq 0x8460
movl 0x74(%rsp), %edx
leaq 0x30(%rsp), %rdi
movq %rdi, (%rsp)
movl $0x1, %esi
callq 0x1f160
movq (%rsp), %rsi
movq 0x88(%rsp), %rdi
addq $0x8, %rdi
callq 0x433c0
jmp 0x1e9b0
leaq 0x30(%rsp), %rdi
callq 0x1f210
addq $0x98, %rsp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x28(%rsp)
movl %eax, 0x24(%rsp)
leaq 0x30(%rsp), %rdi
callq 0x1f210
movq 0x28(%rsp), %rdi
callq 0x8670
nopw %cs:(%rax,%rax)