// File: /workspace/github_cpp_makefile_star2_O2/luooofan[P]hblzbd_compiler/src/arm.cpp
// Function: arm::LdrPseudo::EmitCode(std::ostream&)
void LdrPseudo::EmitCode(std::ostream& outfile) {
  // convert ldr-pseudo inst to movw&movt
  // https://community.arm.com/developer/ip-products/processors/b/processors-ip-blog/posts/how-to-load-constants-in-assembly-for-arm-architecture
  if (!this->is_imm_) {
    outfile << "\tmov32 " << CondToString(this->cond_) << ", " << std::string(*(this->rd_)) + ", " << this->literal_
            << std::endl;
  } else if (0 == ((this->imm_ >> 16) & 0xFFFF)) {
    outfile << "\tmovw" << CondToString(this->cond_) << " " << std::string(*(this->rd_)) + ", #"
            << (this->imm_ & 0xFFFF) << std::endl;
  } else {
    outfile << "\tmov32 " << CondToString(this->cond_) << ", " << std::string(*(this->rd_)) + ", " << this->imm_
            << std::endl;
  }
  // outfile << "\tmov32 " << std::string(*(this->rd_)) << ", "
  //         << (this->is_imm_ ? std::to_string(this->imm_) : this->literal_) << std::endl;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x60, %rsp
movq %rsi, %rax
movq %rdi, %rbx
cmpb $0x0, 0x44(%rdi)
je 0x9f3b
cmpl $0xffff, 0x40(%rbx)     # imm = 0xFFFF
ja 0x9fc0
leaq 0x4c2ad(%rip), %rsi     # 0x5616a
movq %rax, %rdi
callq 0x8240
movq %rax, %r14
movl 0x10(%rbx), %esi
leaq 0x40(%rsp), %r15
movq %r15, %rdi
callq 0x8fbd
movq %r14, %rdi
movq %r15, %rsi
callq 0x8230
leaq 0x4c448(%rip), %rsi     # 0x56332
movq %rax, %rdi
callq 0x8240
movq %rax, %r14
movq 0x18(%rbx), %rsi
movq %rsp, %rdi
callq 0xa3c6
leaq 0x4c268(%rip), %rdx     # 0x56170
leaq 0x20(%rsp), %rdi
movq %rsp, %rsi
callq 0xa440
leaq 0x20(%rsp), %rsi
movq %r14, %rdi
callq 0x8230
movzwl 0x40(%rbx), %esi
movq %rax, %rdi
callq 0x84b0
movq %rax, %rdi
callq 0x8170
jmp 0xa03f
leaq 0x4c220(%rip), %rsi     # 0x56162
movq %rax, %rdi
callq 0x8240
movq %rax, %r14
movl 0x10(%rbx), %esi
leaq 0x40(%rsp), %r15
movq %r15, %rdi
callq 0x8fbd
movq %r14, %rdi
movq %r15, %rsi
callq 0x8230
leaq 0x4c1f0(%rip), %rsi     # 0x5615f
movq %rax, %rdi
callq 0x8240
movq %rax, %r14
movq 0x18(%rbx), %rsi
movq %rsp, %rdi
callq 0xa3c6
leaq 0x4c1d2(%rip), %rdx     # 0x5615f
leaq 0x20(%rsp), %rdi
movq %rsp, %rsi
callq 0xa440
leaq 0x20(%rsp), %rsi
movq %r14, %rdi
callq 0x8230
addq $0x20, %rbx
movq %rax, %rdi
movq %rbx, %rsi
callq 0x8230
movq %rax, %rdi
callq 0x8170
jmp 0xa03f
leaq 0x4c19b(%rip), %rsi     # 0x56162
movq %rax, %rdi
callq 0x8240
movq %rax, %r14
movl 0x10(%rbx), %esi
leaq 0x40(%rsp), %r15
movq %r15, %rdi
callq 0x8fbd
movq %r14, %rdi
movq %r15, %rsi
callq 0x8230
leaq 0x4c16b(%rip), %rsi     # 0x5615f
movq %rax, %rdi
callq 0x8240
movq %rax, %r14
movq 0x18(%rbx), %rsi
movq %rsp, %rdi
callq 0xa3c6
leaq 0x4c14d(%rip), %rdx     # 0x5615f
leaq 0x20(%rsp), %rdi
movq %rsp, %rsi
callq 0xa440
leaq 0x20(%rsp), %rsi
movq %r14, %rdi
callq 0x8230
movl 0x40(%rbx), %esi
movq %rax, %rdi
callq 0x84b0
movq %rax, %rdi
callq 0x8170
leaq 0x20(%rsp), %rdi
callq 0x8578
movq %rsp, %rdi
callq 0x8578
leaq 0x40(%rsp), %rdi
callq 0x8578
addq $0x60, %rsp
popq %rbx
popq %r14
popq %r15
retq
jmp 0xa06d
jmp 0xa06d
jmp 0xa07c
jmp 0xa07c
movq %rax, %rbx
jmp 0xa08e
jmp 0xa07c
jmp 0xa07c
jmp 0xa07c
jmp 0xa081
jmp 0xa081
movq %rax, %rbx
jmp 0xa096
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x8578
movq %rsp, %rdi
callq 0x8578
leaq 0x40(%rsp), %rdi
callq 0x8578
movq %rbx, %rdi
callq 0x84d0