// File: /workspace/github_cpp_makefile_star2_O3/luooofan[P]hblzbd_compiler/src/generate_ir.cpp
// Function: ast::Identifier::GenerateIR(ir::ContextInfo&, std::vector<ir::IR*, std::allocator<ir::IR*>>&)
void Identifier::GenerateIR(ir::ContextInfo &ctx, std::vector<ir::IR *> &gIRList) {
  bool is_assigned = ctx.is_assigned_;
  ctx.is_assigned_ = false;
  ir::SymbolTableItem *s = nullptr;
  int scope_id = ir::FindSymbol(ctx.scope_id_, name_, s);
  if (!s) {
    ir::SemanticError(line_no_, name_ + ": undefined variable");
  }

  // NOTE: 常量直接替换为立即数 作用域为当前作用域
  if (!is_assigned && s->is_const_ && !s->is_array_) {
    ctx.opn_ = ir::Opn(OpnType::Imm, s->initval_[0]);
    ctx.shape_.clear();
  } else {
    ctx.shape_ = s->shape_;
    ctx.opn_ = ir::Opn(OpnType::Var, name_, scope_id);
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rsi, %rbx
movq %rdi, %r14
movb 0x209(%rsi), %al
movb %al, 0xf(%rsp)
movb $0x0, 0x209(%rsi)
leaq 0x10(%rsp), %r15
movq $0x0, (%r15)
movl (%rsi), %ebp
movq 0x10(%rdi), %rax
leaq 0x88(%rsp), %r13
movq %r13, -0x10(%r13)
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq 0x78(%rsp), %r12
movq %r12, %rdi
callq 0xc6dc
movl %ebp, %edi
movq %r12, %rsi
movq %r15, %rdx
callq 0x28507
movl %eax, %ebp
movq 0x78(%rsp), %rdi
cmpq %r13, %rdi
je 0x13962
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x82a0
movq 0x10(%rsp), %rsi
testq %rsi, %rsi
jne 0x139cc
movl 0x8(%r14), %r15d
movq 0x10(%r14), %rax
leaq 0x28(%rsp), %r13
movq %r13, -0x10(%r13)
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq 0x18(%rsp), %r12
movq %r12, %rdi
callq 0xc6dc
leaq 0x5b045(%rip), %rsi     # 0x6e9e0
movq %r12, %rdi
callq 0x8590
leaq 0x18(%rsp), %rsi
movl %r15d, %edi
callq 0x2b6aa
movq 0x18(%rsp), %rdi
cmpq %r13, %rdi
je 0x139c7
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x82a0
movq 0x10(%rsp), %rsi
cmpb $0x0, 0xf(%rsp)
jne 0x139e2
cmpb $0x1, 0x1(%rsi)
jne 0x139e2
cmpb $0x0, (%rsi)
je 0x13a9b
addq $0x8, %rsi
leaq 0x50(%rbx), %rdi
callq 0x25242
movq 0x10(%r14), %rax
leaq 0x68(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq 0x58(%rsp), %r14
movq %r14, %rdi
callq 0xc6dc
leaq 0x20(%rsp), %rdi
movl $0x0, -0x8(%rdi)
leaq 0x30(%rsp), %r12
movq %r12, -0x10(%r12)
movq (%r14), %rsi
movq 0x8(%r14), %rdx
addq %rsi, %rdx
callq 0xc6dc
leaq 0x18(%rsp), %rsi
movl %ebp, 0x28(%rsi)
movq $0x0, 0x30(%rsi)
movl $0xffffffff, 0x38(%rsi) # imm = 0xFFFFFFFF
addq $0x8, %rbx
movq %rbx, %rdi
callq 0x289a2
movq 0x20(%rsp), %rdi
cmpq %r12, %rdi
je 0x13a72
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x82a0
movq 0x58(%rsp), %rdi
cmpq %r15, %rdi
je 0x13a89
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x82a0
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x38(%rsi), %rax
movl (%rax), %edx
leaq 0x18(%rsp), %r14
movq %r14, %rdi
movl $0x1, %esi
callq 0x1279c
leaq 0x8(%rbx), %rdi
movq %r14, %rsi
callq 0x289a2
leaq 0x30(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x13ada
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x82a0
movq 0x50(%rbx), %rax
cmpq %rax, 0x58(%rbx)
je 0x13a89
movq %rax, 0x58(%rbx)
jmp 0x13a89
movq %rax, %rbx
leaq 0x30(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x13b65
movq 0x30(%rsp), %rsi
jmp 0x13b5d
jmp 0x13b04
movq %rax, %rbx
movq 0x18(%rsp), %rdi
cmpq %r13, %rdi
je 0x13b65
movq 0x28(%rsp), %rsi
jmp 0x13b5d
movq %rax, %rbx
movq 0x20(%rsp), %rdi
cmpq %r12, %rdi
je 0x13b37
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x82a0
jmp 0x13b37
movq %rax, %rbx
movq 0x58(%rsp), %rdi
cmpq %r15, %rdi
je 0x13b65
movq 0x68(%rsp), %rsi
jmp 0x13b5d
movq %rax, %rbx
movq 0x78(%rsp), %rdi
cmpq %r13, %rdi
je 0x13b65
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x82a0
movq %rbx, %rdi
callq 0x8540
nop