// File: /workspace/github_cpp_makefile_star2_O1/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 0xca10
movl %ebp, %edi
movq %r12, %rsi
movq %r15, %rdx
callq 0x27e6f
movl %eax, %ebp
movq 0x78(%rsp), %rdi
cmpq %r13, %rdi
je 0x13c9a
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x82a0
cmpq $0x0, 0x10(%rsp)
jne 0x13cfd
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 0xca10
leaq 0x5bd0f(%rip), %rsi     # 0x6f9e0
movq %r12, %rdi
callq 0x8590
leaq 0x18(%rsp), %rsi
movl %r15d, %edi
callq 0x2b12a
movq 0x18(%rsp), %rdi
cmpq %r13, %rdi
je 0x13cfd
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x82a0
cmpb $0x0, 0xf(%rsp)
jne 0x13d18
movq 0x10(%rsp), %rax
cmpb $0x1, 0x1(%rax)
jne 0x13d18
cmpb $0x0, (%rax)
je 0x13dd6
movq 0x10(%rsp), %rsi
addq $0x8, %rsi
leaq 0x50(%rbx), %rdi
callq 0x24b84
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 0xca10
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 0xca10
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 0x28312
movq 0x20(%rsp), %rdi
cmpq %r12, %rdi
je 0x13dad
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x82a0
movq 0x58(%rsp), %rdi
cmpq %r15, %rdi
je 0x13dc4
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(%rax), %rax
movl (%rax), %edx
leaq 0x18(%rsp), %r14
movq %r14, %rdi
movl $0x1, %esi
callq 0x12ade
leaq 0x8(%rbx), %rdi
movq %r14, %rsi
callq 0x28312
leaq 0x30(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x13e15
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x82a0
movq 0x50(%rbx), %rax
cmpq %rax, 0x58(%rbx)
je 0x13dc4
movq %rax, 0x58(%rbx)
jmp 0x13dc4
movq %rax, %rbx
leaq 0x30(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x13ea0
movq 0x30(%rsp), %rsi
jmp 0x13e98
jmp 0x13e3f
movq %rax, %rbx
movq 0x18(%rsp), %rdi
cmpq %r13, %rdi
je 0x13ea0
movq 0x28(%rsp), %rsi
jmp 0x13e98
movq %rax, %rbx
movq 0x20(%rsp), %rdi
cmpq %r12, %rdi
je 0x13e72
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x82a0
jmp 0x13e72
movq %rax, %rbx
movq 0x58(%rsp), %rdi
cmpq %r15, %rdi
je 0x13ea0
movq 0x68(%rsp), %rsi
jmp 0x13e98
movq %rax, %rbx
movq 0x78(%rsp), %rdi
cmpq %r13, %rdi
je 0x13ea0
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x82a0
movq %rbx, %rdi
callq 0x8540