// File: /workspace/github_cpp_makefile_star2_O3/luooofan[P]hblzbd_compiler/src/generate_ir.cpp
// Function: ast::AssignStatement::GenerateIR(ir::ContextInfo&, std::vector<ir::IR*, std::allocator<ir::IR*>>&)
void AssignStatement::GenerateIR(ir::ContextInfo &ctx, std::vector<ir::IR *> &gIRList) {
  // 给函数调用赋值过不了语法分析
  this->rhs_.GenerateIR(ctx, gIRList);
  CHECK_OPN_INT("rhs exp");
  ir::Opn rhs_opn = ctx.opn_;

  ctx.is_assigned_ = true;
  this->lhs_.GenerateIR(ctx, gIRList);
  ctx.is_assigned_ = false;
  CHECK_OPN_INT("leftvalue");

  ir::Opn &lhs_opn = ctx.opn_;
  ir::SymbolTableItem *symbol = nullptr;
  ir::FindSymbol(ctx.scope_id_, lhs_opn.name_, symbol);

  // const check
  if (nullptr != symbol && symbol->is_const_) {
    ir::SemanticError(this->line_no_, lhs_opn.name_ + ": constant can't be assigned");
    return;
  }

  // genir(assign,opn1,-,res)
  gIRList.push_back(new ir::IR(IROpKind::ASSIGN, rhs_opn, lhs_opn));
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x148, %rsp            # imm = 0x148
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
movq 0x18(%rdi), %rdi
movq (%rdi), %rax
callq *0x10(%rax)
movq 0x50(%r14), %rax
cmpq 0x58(%r14), %rax
je 0x19531
cmpl $0x4, 0x8(%r14)
jne 0x19531
movl 0x8(%r15), %ebp
leaq 0x38(%rsp), %r13
movq %r13, -0x10(%r13)
movq 0x10(%r14), %rsi
movq 0x18(%r14), %rdx
addq %rsi, %rdx
leaq 0x28(%rsp), %r12
movq %r12, %rdi
callq 0xc6dc
leaq 0x55ee1(%rip), %rsi     # 0x6f2f0
movq %r12, %rdi
callq 0x8590
leaq 0x559fb(%rip), %rsi     # 0x6ee19
leaq 0x28(%rsp), %rdi
callq 0x8590
leaq 0x18(%rsp), %rsi
movq %rsi, -0x10(%rsi)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x19452
movq %rsi, %r12
movq %rdx, 0x8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x18(%rsp)
jmp 0x1945b
movups (%rcx), %xmm0
movq %rsi, %r12
movups %xmm0, (%rsi)
movq 0x8(%rax), %rdx
leaq 0x8(%rsp), %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x55707(%rip), %rsi     # 0x6eb85
callq 0x8590
leaq 0x98(%rsp), %r13
movq %r13, -0x10(%r13)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x194b3
movq %rdx, 0x88(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x98(%rsp)
jmp 0x194bb
movups (%rcx), %xmm0
movups %xmm0, (%r13)
movq 0x8(%rax), %rdx
leaq 0x88(%rsp), %rsi
movq %rdx, 0x8(%rsi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movl %ebp, %edi
callq 0x2b6aa
movq 0x88(%rsp), %rdi
cmpq %r13, %rdi
je 0x194fe
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x82a0
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
leaq 0x38(%rsp), %r12
je 0x1951a
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x82a0
movq 0x28(%rsp), %rdi
cmpq %r12, %rdi
je 0x19531
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x82a0
leaq 0x8(%r14), %r12
leaq 0x88(%rsp), %rdi
movq %r12, %rsi
callq 0x28816
movb $0x1, 0x209(%r14)
movq 0x10(%r15), %rdi
movq (%rdi), %rax
movq %r14, %rsi
movq %rbx, %rdx
callq *0x10(%rax)
movb $0x0, 0x209(%r14)
movq 0x50(%r14), %rax
cmpq 0x58(%r14), %rax
je 0x196b8
cmpl $0x4, 0x8(%r14)
jne 0x196b8
movl 0x8(%r15), %ebp
leaq 0x58(%rsp), %r13
movq %r13, -0x10(%r13)
movq 0x10(%r14), %rsi
movq 0x18(%r14), %rdx
addq %rsi, %rdx
leaq 0x48(%rsp), %rdi
callq 0xc6dc
leaq 0x55d49(%rip), %rsi     # 0x6f2f0
leaq 0x48(%rsp), %rdi
callq 0x8590
leaq 0x556d8(%rip), %rsi     # 0x6ec90
leaq 0x48(%rsp), %rdi
callq 0x8590
leaq 0x38(%rsp), %rsi
movq %rsi, -0x10(%rsi)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x195e9
movq %rdx, 0x28(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x38(%rsp)
jmp 0x195ef
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
movq 0x8(%rax), %rdx
leaq 0x28(%rsp), %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x55573(%rip), %rsi     # 0x6eb85
callq 0x8590
leaq 0x18(%rsp), %r13
movq %r13, -0x10(%r13)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x1963e
movq %rdx, 0x8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x18(%rsp)
jmp 0x19646
movups (%rcx), %xmm0
movups %xmm0, (%r13)
movq 0x8(%rax), %rdx
leaq 0x8(%rsp), %rsi
movq %rdx, 0x8(%rsi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movl %ebp, %edi
callq 0x2b6aa
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
je 0x19680
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x82a0
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
leaq 0x58(%rsp), %r13
je 0x196a1
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x82a0
movq 0x48(%rsp), %rdi
cmpq %r13, %rdi
je 0x196b8
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x82a0
movq $0x0, 0x28(%rsp)
movl (%r14), %ebp
leaq 0x78(%rsp), %r13
movq %r13, -0x10(%r13)
movq 0x10(%r14), %rsi
movq 0x18(%r14), %rdx
addq %rsi, %rdx
leaq 0x68(%rsp), %rdi
callq 0xc6dc
leaq 0x68(%rsp), %rsi
leaq 0x28(%rsp), %rdx
movl %ebp, %edi
callq 0x28507
movq 0x68(%rsp), %rdi
cmpq %r13, %rdi
je 0x1970a
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x82a0
movq 0x28(%rsp), %rax
testq %rax, %rax
je 0x19771
cmpb $0x1, 0x1(%rax)
jne 0x19771
movl 0x8(%r15), %ebx
leaq 0x18(%rsp), %r15
movq %r15, -0x10(%r15)
movq 0x10(%r14), %rsi
movq 0x18(%r14), %rdx
addq %rsi, %rdx
leaq 0x8(%rsp), %rdi
callq 0xc6dc
leaq 0x55557(%rip), %rsi     # 0x6ec9a
leaq 0x8(%rsp), %rdi
callq 0x8590
leaq 0x8(%rsp), %rsi
movl %ebx, %edi
callq 0x2b6aa
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x19817
movq 0x18(%rsp), %rsi
jmp 0x1980f
movl $0xe0, %edi
callq 0x8290
movq %rax, %r14
leaq 0xc8(%rsp), %rdi
leaq 0x88(%rsp), %rsi
callq 0x28816
leaq 0x108(%rsp), %rdi
movq %r12, %rsi
callq 0x28816
movb $0x1, %bpl
leaq 0xc8(%rsp), %rdx
leaq 0x108(%rsp), %rcx
movq %r14, %rdi
movl $0xc, %esi
callq 0x25560
leaq 0x8(%rsp), %rsi
movq %r14, (%rsi)
xorl %ebp, %ebp
movq %rbx, %rdi
callq 0x11182
leaq 0x120(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x197f6
movq 0x120(%rsp), %rsi
incq %rsi
callq 0x82a0
leaq 0xe0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x19817
movq 0xe0(%rsp), %rsi
incq %rsi
callq 0x82a0
leaq 0xa0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x19838
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x82a0
addq $0x148, %rsp            # imm = 0x148
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1984c
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x199f6
movq 0x18(%rsp), %rsi
jmp 0x19993
jmp 0x1999a
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
je 0x1988b
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x82a0
jmp 0x1988b
movq %rax, %rbx
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x198ac
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x82a0
jmp 0x198ac
movq %rax, %rbx
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
jne 0x198d1
jmp 0x199f6
movq %rax, %rbx
movq 0x48(%rsp), %rdi
cmpq %r13, %rdi
je 0x199f6
movq 0x58(%rsp), %rsi
jmp 0x19993
jmp 0x1999a
movq %rax, %rbx
movq 0x88(%rsp), %rdi
cmpq %r13, %rdi
je 0x19905
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x82a0
jmp 0x19905
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x19921
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x82a0
jmp 0x19921
movq %rax, %rbx
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
jne 0x19946
jmp 0x19a17
movq %rax, %rbx
movq 0x28(%rsp), %rdi
cmpq %r13, %rdi
je 0x19a17
movq 0x38(%rsp), %rsi
jmp 0x19a0f
movq %rax, %rbx
leaq 0xe0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x199e9
movq 0xe0(%rsp), %rsi
incq %rsi
callq 0x82a0
jmp 0x199e9
movq %rax, %rbx
jmp 0x199e9
jmp 0x1999a
movq %rax, %rbx
movq 0x68(%rsp), %rdi
cmpq %r13, %rdi
je 0x199f6
movq 0x78(%rsp), %rsi
incq %rsi
jmp 0x199f1
jmp 0x1999a
movq %rax, %rbx
jmp 0x199f6
movq %rax, %rbx
leaq 0x120(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x199c3
movq 0x120(%rsp), %rsi
incq %rsi
callq 0x82a0
leaq 0xe0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x199e4
movq 0xe0(%rsp), %rsi
incq %rsi
callq 0x82a0
testb %bpl, %bpl
je 0x199f6
movl $0xe0, %esi
movq %r14, %rdi
callq 0x82a0
leaq 0xa0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x19a17
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x82a0
movq %rbx, %rdi
callq 0x8540
nop