// File: luooofan[P]hblzbd_compiler/src/ssa_struct.cpp
// Function: SSAFunction::EmitCode(std::ostream&)
void SSAFunction::EmitCode(std::ostream& out) {
  out << func_name_ << ":" << std::endl;
  out << "; Function Begin:" << std::endl;
  out << "  ; called by func: ";
  for (auto called_func_use : value_->GetUses()) {
    // called_func_use->Get()->Print();
    auto inst = dynamic_cast<SSAInstruction*>(called_func_use->GetUser());
    MyAssert(nullptr != inst);
    out << inst->GetParent()->GetFunction()->GetFuncName() << " ";
  }
  out << std::endl;
  out << "  ; call func: ";
  for (auto call_func : call_func_list_) {
    out << call_func->GetFuncName() << " ";
  }
  out << std::endl;
  out << "  ; used global var: ";
  for (auto glob_var : used_glob_var_list_) {
    out << glob_var->GetName() << " ";
  }
  out << std::endl;
  for (auto bb : bb_list_) {
    bb->EmitCode(out);
    out << std::endl;
  }
  out << "; Function End." << std::endl;
}

// Assembly:
subq $0xc8, %rsp
movq %rdi, 0xc0(%rsp)
movq %rsi, 0xb8(%rsp)
movq 0xc0(%rsp), %rsi
movq %rsi, 0x28(%rsp)
movq 0xb8(%rsp), %rdi
callq 0x8310
movq %rax, %rdi
leaq 0x996df(%rip), %rsi     # 0xfb3ea
callq 0x8330
movq %rax, %rdi
movq 0xea266(%rip), %rsi     # 0x14bf80
callq 0x8380
movq 0xb8(%rsp), %rdi
leaq 0x9b936(%rip), %rsi     # 0xfd664
callq 0x8330
movq %rax, %rdi
movq 0xea243(%rip), %rsi     # 0x14bf80
callq 0x8380
movq 0xb8(%rsp), %rdi
leaq 0x9b925(%rip), %rsi     # 0xfd676
callq 0x8330
movq 0x28(%rsp), %rax
movq 0x28(%rax), %rdi
callq 0x5e2d0
movq %rax, 0xb0(%rsp)
movq 0xb0(%rsp), %rdi
callq 0x5e160
movq %rax, 0xa8(%rsp)
movq 0xb0(%rsp), %rdi
callq 0x5e1b0
movq %rax, 0xa0(%rsp)
leaq 0xa8(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
callq 0x5e190
testb $0x1, %al
jne 0x61db4
jmp 0x61ed8
leaq 0xa8(%rsp), %rdi
callq 0x5e1e0
movq (%rax), %rax
movq %rax, 0x98(%rsp)
movq 0x98(%rsp), %rdi
callq 0x60410
movq %rax, 0x20(%rsp)
cmpq $0x0, %rax
je 0x61e07
movq 0x20(%rsp), %rdi
leaq 0xe9820(%rip), %rsi     # 0x14b610
leaq 0xe9621(%rip), %rdx     # 0x14b418
xorl %eax, %eax
movl %eax, %ecx
callq 0x8410
movq %rax, 0x18(%rsp)
jmp 0x61e10
xorl %eax, %eax
movq %rax, 0x18(%rsp)
jmp 0x61e10
movq 0x18(%rsp), %rax
movq %rax, 0x90(%rsp)
xorl %eax, %eax
cmpq 0x90(%rsp), %rax
jne 0x61e80
movq 0xea1b8(%rip), %rdi     # 0x14bfe8
leaq 0x982c1(%rip), %rsi     # 0xfa0f8
callq 0x8330
movq %rax, %rdi
leaq 0x9b80b(%rip), %rsi     # 0xfd651
callq 0x8330
movq %rax, %rdi
leaq 0x99595(%rip), %rsi     # 0xfb3ea
callq 0x8330
movq %rax, %rdi
movl $0xa7, %esi
callq 0x8650
movq %rax, %rdi
movq 0xea10f(%rip), %rsi     # 0x14bf80
callq 0x8380
movl $0xff, %edi
callq 0x8460
movq 0xb8(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x90(%rsp), %rdi
callq 0x5e2b0
movq %rax, %rdi
callq 0x5e2c0
movq %rax, %rdi
callq 0x62ad0
movq 0x10(%rsp), %rdi
movq %rax, %rsi
callq 0x8310
movq %rax, %rdi
leaq 0x98494(%rip), %rsi     # 0xfa355
callq 0x8330
leaq 0xa8(%rsp), %rdi
callq 0x5e280
jmp 0x61d96
movq 0xb8(%rsp), %rdi
movq 0xea099(%rip), %rsi     # 0x14bf80
callq 0x8380
movq 0xb8(%rsp), %rdi
leaq 0x9b790(%rip), %rsi     # 0xfd68b
callq 0x8330
movq 0x28(%rsp), %rax
addq $0x48, %rax
movq %rax, 0x88(%rsp)
movq 0x88(%rsp), %rdi
callq 0x62a30
movq %rax, 0x80(%rsp)
movq 0x88(%rsp), %rdi
callq 0x62a60
movq %rax, 0x78(%rsp)
leaq 0x80(%rsp), %rdi
leaq 0x78(%rsp), %rsi
callq 0x62a90
testb $0x1, %al
jne 0x61f50
jmp 0x61fa7
leaq 0x80(%rsp), %rdi
callq 0x62ab0
movq (%rax), %rax
movq %rax, 0x70(%rsp)
movq 0xb8(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x70(%rsp), %rdi
callq 0x62ad0
movq 0x8(%rsp), %rdi
movq %rax, %rsi
callq 0x8310
movq %rax, %rdi
leaq 0x983c2(%rip), %rsi     # 0xfa355
callq 0x8330
leaq 0x80(%rsp), %rdi
callq 0x62ae0
jmp 0x61f38
movq 0xb8(%rsp), %rdi
movq 0xe9fca(%rip), %rsi     # 0x14bf80
callq 0x8380
movq 0xb8(%rsp), %rdi
leaq 0x9b6d1(%rip), %rsi     # 0xfd69b
callq 0x8330
movq 0x28(%rsp), %rax
addq $0x80, %rax
movq %rax, 0x68(%rsp)
movq 0x68(%rsp), %rdi
callq 0x62b10
movq %rax, 0x60(%rsp)
movq 0x68(%rsp), %rdi
callq 0x62b40
movq %rax, 0x58(%rsp)
leaq 0x60(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0x62b70
testb $0x1, %al
jne 0x62012
jmp 0x62061
leaq 0x60(%rsp), %rdi
callq 0x62b90
movq (%rax), %rax
movq %rax, 0x50(%rsp)
movq 0xb8(%rsp), %rax
movq %rax, (%rsp)
movq 0x50(%rsp), %rdi
callq 0x5e770
movq (%rsp), %rdi
movq %rax, %rsi
callq 0x8310
movq %rax, %rdi
leaq 0x98305(%rip), %rsi     # 0xfa355
callq 0x8330
leaq 0x60(%rsp), %rdi
callq 0x62bb0
jmp 0x61ffd
movq 0xb8(%rsp), %rdi
movq 0xe9f10(%rip), %rsi     # 0x14bf80
callq 0x8380
movq 0x28(%rsp), %rax
addq $0x30, %rax
movq %rax, 0x48(%rsp)
movq 0x48(%rsp), %rdi
callq 0x62720
movq %rax, 0x40(%rsp)
movq 0x48(%rsp), %rdi
callq 0x62750
movq %rax, 0x38(%rsp)
leaq 0x40(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0x62780
testb $0x1, %al
jne 0x620b6
jmp 0x620fa
leaq 0x40(%rsp), %rdi
callq 0x627a0
movq (%rax), %rax
movq %rax, 0x30(%rsp)
movq 0x30(%rsp), %rdi
movq 0xb8(%rsp), %rsi
callq 0x62130
movq 0xb8(%rsp), %rdi
movq 0xe9e97(%rip), %rsi     # 0x14bf80
callq 0x8380
leaq 0x40(%rsp), %rdi
callq 0x627f0
jmp 0x620a1
movq 0xb8(%rsp), %rdi
leaq 0x9b5a8(%rip), %rsi     # 0xfd6b1
callq 0x8330
movq %rax, %rdi
movq 0xe9e68(%rip), %rsi     # 0x14bf80
callq 0x8380
addq $0xc8, %rsp
retq
nopw %cs:(%rax,%rax)