// File: /workspace/github_cpp_makefile_star2_O3/luooofan[P]hblzbd_compiler/src/construct_ir_module.cpp
// Function: ConstructModule(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::vector<ir::IR*, std::allocator<ir::IR*>>&)
IRModule* ConstructModule(const std::string& module_name, std::vector<ir::IR*>& gIRList) {
  // Construct BasicBlocks Functions and Module from gIRList

  // 基本块的首指令
  //  由于IR中使用了label 所有跳转语句都跳到某个label
  //  并且每个出现在四元式中的label都有跳转到该label的指令(不一定)
  //  所以首指令为每个label和每个跳转语句(call,ret,goto,jxx)的下一句
  //  (即便不一定为真正的首指令也可以接受)

  // 先遍历一遍IR 把所有func和有label的BB创建完成 创建两个map
  std::unordered_map<std::string, IRBasicBlock*> label2bb;
  std::unordered_map<std::string, IRFunction*> label2func;

  // add library function to label2func
  // not add them to module
  label2func.insert({"getint", new IRFunction("getint", 0)});
  label2func.insert({"getch", new IRFunction("getch", 0)});
  label2func.insert({"getarray", new IRFunction("getarray", 0)});
  label2func.insert({"putint", new IRFunction("putint", 1)});
  label2func.insert({"putch", new IRFunction("putch", 1)});
  label2func.insert({"putarray", new IRFunction("putarray", 1)});
  label2func.insert({"_sysy_starttime", new IRFunction("_sysy_starttime", 1)});
  label2func.insert({"_sysy_stoptime", new IRFunction("_sysy_stoptime", 1)});
  label2func.insert({"memset", new IRFunction("memset", 3)});

  IRModule* module = new IRModule(module_name, gScopes[0]);

  // fill label2bb label2func. every bb has its first ir. every func has it first bb. module has all funs.
  for (int i = 0; i < gIRList.size(); ++i) {
    auto& ir = *gIRList[i];
    if (ir.op_ == IR::OpKind::LABEL) {
      auto& label_name = ir.opn1_.name_;
      IRBasicBlock* bb = new IRBasicBlock();
      bb->ir_list_.push_back(&ir);
      label2bb.insert({label_name, bb});
      if (ir.opn1_.type_ == Opn::Type::Func) {  // is a function begin
        auto& func_item = (*ir::gFuncTable.find(label_name)).second;
        IRFunction* func = new IRFunction(label_name, func_item.shape_list_.size());
        func->bb_list_.push_back(bb);
        bb->func_ = func;
        label2func.insert({label_name, func});
        module->func_list_.push_back(func);
      }
    }
  }

  bool is_leader = false;
  bool is_succ = true;
  IRFunction* curr_func = nullptr;
  IRBasicBlock* pre_bb = nullptr;
  IRBasicBlock* curr_bb = nullptr;
  // for every ir
  for (int i = 0; i < gIRList.size(); ++i) {
    auto& ir = *gIRList[i];
    if (ir.op_ == IR::OpKind::LABEL) {
      is_leader = true;  // 表示这条一定是首指令
    }
    if (is_leader) {  // 一定已经或者将要把该ir放入到基本块中
      pre_bb = curr_bb;
      // 更新curr_bb curr_func
      if (ir.op_ == IR::OpKind::LABEL) {
        curr_bb = label2bb[ir.opn1_.name_];
        if (ir.opn1_.type_ == Opn::Type::Func) {
          curr_func = label2func[ir.opn1_.name_];
          is_leader = false;  // 下一条语句非首指令
          continue;
        }
      } else {
        // new BB
        curr_bb = new IRBasicBlock();
        curr_bb->ir_list_.push_back(&ir);
      }
      curr_func->bb_list_.push_back(curr_bb);
      curr_bb->func_ = curr_func;
      // 维护两个基本块之间的关系
      if (nullptr != pre_bb && is_succ) {
        pre_bb->succ_.push_back(curr_bb);
        curr_bb->pred_.push_back(pre_bb);
      }
    } else {
      curr_bb->ir_list_.push_back(&ir);
    }
    is_succ = true;
    // 维护当前基本块和跳转目标基本块之间的关系 维护is_leader 之后is_leader表示下一条ir是否为首指令
    switch (ir.op_) {
      case IR::OpKind::RET:
        is_leader = true;
        is_succ = false;
        break;
      case IR::OpKind::CALL:  // NOTE: 此时不维护调用双方两个基本块之间的关系 TODO: call语句的下一条语句是首指令吗
        curr_func->call_func_list_.push_back(label2func[ir.opn1_.name_]);
        is_leader = false;
        break;
      case IR::OpKind::GOTO: {
        auto succ_bb = label2bb[ir.opn1_.name_];
        curr_bb->succ_.push_back(succ_bb);
        succ_bb->pred_.push_back(curr_bb);
        is_leader = true;
        is_succ = false;
        break;
      }
      case IR::OpKind::JEQ:
      case IR::OpKind::JNE:
      case IR::OpKind::JLT:
      case IR::OpKind::JLE:
      case IR::OpKind::JGT:
      case IR::OpKind::JGE: {
        auto succ_bb = label2bb[ir.res_.name_];
        curr_bb->succ_.push_back(succ_bb);
        succ_bb->pred_.push_back(curr_bb);
        is_leader = true;
        break;
      }
      default:
        is_leader = false;
        break;
    }
  }

  return module;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
movq %rsi, 0x58(%rsp)
movq %rdi, %r14
leaq 0xe0(%rsp), %rax
movq %rax, -0x30(%rax)
movl $0x1, %ecx
movq %rcx, -0x28(%rax)
xorps %xmm0, %xmm0
movups %xmm0, -0x20(%rax)
movl $0x3f800000, %edx       # imm = 0x3F800000
movl %edx, -0x10(%rax)
movups %xmm0, -0x8(%rax)
leaq 0x98(%rsp), %rax
movq %rax, -0x30(%rax)
movq %rcx, -0x28(%rax)
movups %xmm0, -0x20(%rax)
movl %edx, -0x10(%rax)
movups %xmm0, -0x8(%rax)
movl $0x98, %edi
callq 0x8290
movq %rax, %r15
leaq 0x18(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x5edaa(%rip), %rsi     # 0x6e91c
leaq 0x5eda9(%rip), %rdx     # 0x6e922
leaq 0x8(%rsp), %rdi
callq 0xc772
leaq 0x7e4a6(%rip), %rbx     # 0x8e030
addq $0x10, %rbx
movq %rbx, (%r15)
leaq 0x8(%r15), %rdi
leaq 0x18(%r15), %rax
movq %rax, 0x8(%r15)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
addq %rsi, %rdx
movb $0x1, %bpl
callq 0xc6dc
movl $0x0, 0x28(%r15)
movq %r15, %rax
addq $0x90, %rax
xorps %xmm0, %xmm0
movups %xmm0, 0x30(%r15)
movups %xmm0, 0x40(%r15)
movups %xmm0, 0x50(%r15)
movq %rax, 0x60(%r15)
movq $0x1, 0x68(%r15)
movups %xmm0, 0x70(%r15)
movl $0x3f800000, 0x80(%r15) # imm = 0x3F800000
movups %xmm0, 0x88(%r15)
leaq 0x40(%rsp), %r13
movq %r13, -0x10(%r13)
xorl %ebp, %ebp
leaq 0x5ed11(%rip), %rsi     # 0x6e91c
leaq 0x5ed10(%rip), %rdx     # 0x6e922
leaq 0x30(%rsp), %rdi
callq 0xc772
leaq 0x30(%rsp), %rsi
movq %r15, 0x20(%rsi)
leaq 0x68(%rsp), %rdi
callq 0x10d7a
movq 0x30(%rsp), %rdi
cmpq %r13, %rdi
je 0xfc46
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x82a0
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0xfc5d
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x82a0
movl $0x98, %edi
callq 0x8290
movq %rax, %r15
leaq 0x8(%rsp), %rdi
movq %r12, (%rdi)
leaq 0x5ecaa(%rip), %rsi     # 0x6e923
leaq 0x5eca8(%rip), %rdx     # 0x6e928
callq 0xc772
movq %rbx, (%r15)
leaq 0x8(%r15), %rdi
leaq 0x18(%r15), %rax
movq %rax, 0x8(%r15)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
addq %rsi, %rdx
movb $0x1, %bpl
callq 0xc6dc
movl $0x0, 0x28(%r15)
movq %r15, %rax
addq $0x90, %rax
xorps %xmm0, %xmm0
movups %xmm0, 0x30(%r15)
movups %xmm0, 0x40(%r15)
movups %xmm0, 0x50(%r15)
movq %rax, 0x60(%r15)
movq $0x1, 0x68(%r15)
movups %xmm0, 0x70(%r15)
movl $0x3f800000, 0x80(%r15) # imm = 0x3F800000
movups %xmm0, 0x88(%r15)
leaq 0x30(%rsp), %rdi
movq %r13, (%rdi)
xorl %ebp, %ebp
leaq 0x5ec22(%rip), %rsi     # 0x6e923
leaq 0x5ec20(%rip), %rdx     # 0x6e928
callq 0xc772
leaq 0x30(%rsp), %rsi
movq %r15, 0x20(%rsi)
leaq 0x68(%rsp), %rdi
callq 0x10d7a
movq 0x30(%rsp), %rdi
cmpq %r13, %rdi
je 0xfd37
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x82a0
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0xfd4e
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x82a0
movl $0x98, %edi
callq 0x8290
movq %rax, %r15
leaq 0x8(%rsp), %rdi
movq %r12, (%rdi)
leaq 0x5ebbf(%rip), %rsi     # 0x6e929
leaq 0x5ebc0(%rip), %rdx     # 0x6e931
callq 0xc772
movq %rbx, (%r15)
leaq 0x8(%r15), %rdi
leaq 0x18(%r15), %rax
movq %rax, 0x8(%r15)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
addq %rsi, %rdx
movb $0x1, %bpl
callq 0xc6dc
movl $0x0, 0x28(%r15)
movq %r15, %rax
addq $0x90, %rax
xorps %xmm0, %xmm0
movups %xmm0, 0x30(%r15)
movups %xmm0, 0x40(%r15)
movups %xmm0, 0x50(%r15)
movq %rax, 0x60(%r15)
movq $0x1, 0x68(%r15)
movups %xmm0, 0x70(%r15)
movl $0x3f800000, 0x80(%r15) # imm = 0x3F800000
movups %xmm0, 0x88(%r15)
leaq 0x30(%rsp), %rdi
movq %r13, (%rdi)
xorl %ebp, %ebp
leaq 0x5eb37(%rip), %rsi     # 0x6e929
leaq 0x5eb38(%rip), %rdx     # 0x6e931
callq 0xc772
leaq 0x30(%rsp), %rsi
movq %r15, 0x20(%rsi)
leaq 0x68(%rsp), %rdi
callq 0x10d7a
movq 0x30(%rsp), %rdi
cmpq %r13, %rdi
je 0xfe28
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x82a0
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0xfe3f
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x82a0
movl $0x98, %edi
callq 0x8290
movq %rax, %r15
leaq 0x8(%rsp), %rdi
movq %r12, (%rdi)
leaq 0x5ead7(%rip), %rsi     # 0x6e932
leaq 0x5ead6(%rip), %rdx     # 0x6e938
callq 0xc772
movq %rbx, (%r15)
leaq 0x8(%r15), %rdi
leaq 0x18(%r15), %rax
movq %rax, 0x8(%r15)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
addq %rsi, %rdx
movb $0x1, %bpl
callq 0xc6dc
movl $0x1, 0x28(%r15)
movq %r15, %rax
addq $0x90, %rax
xorps %xmm0, %xmm0
movups %xmm0, 0x30(%r15)
movups %xmm0, 0x40(%r15)
movups %xmm0, 0x50(%r15)
movq %rax, 0x60(%r15)
movq $0x1, 0x68(%r15)
movups %xmm0, 0x70(%r15)
movl $0x3f800000, 0x80(%r15) # imm = 0x3F800000
movups %xmm0, 0x88(%r15)
leaq 0x30(%rsp), %rdi
movq %r13, (%rdi)
xorl %ebp, %ebp
leaq 0x5ea4f(%rip), %rsi     # 0x6e932
leaq 0x5ea4e(%rip), %rdx     # 0x6e938
callq 0xc772
leaq 0x30(%rsp), %rsi
movq %r15, 0x20(%rsi)
leaq 0x68(%rsp), %rdi
callq 0x10d7a
movq 0x30(%rsp), %rdi
cmpq %r13, %rdi
je 0xff19
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x82a0
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0xff30
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x82a0
movl $0x98, %edi
callq 0x8290
movq %rax, %r15
leaq 0x8(%rsp), %rdi
movq %r12, (%rdi)
leaq 0x5e9ed(%rip), %rsi     # 0x6e939
leaq 0x5e9eb(%rip), %rdx     # 0x6e93e
callq 0xc772
movq %rbx, (%r15)
leaq 0x8(%r15), %rdi
leaq 0x18(%r15), %rax
movq %rax, 0x8(%r15)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
addq %rsi, %rdx
movb $0x1, %bpl
callq 0xc6dc
movl $0x1, 0x28(%r15)
movq %r15, %rax
addq $0x90, %rax
xorps %xmm0, %xmm0
movups %xmm0, 0x30(%r15)
movups %xmm0, 0x40(%r15)
movups %xmm0, 0x50(%r15)
movq %rax, 0x60(%r15)
movq $0x1, 0x68(%r15)
movups %xmm0, 0x70(%r15)
movl $0x3f800000, 0x80(%r15) # imm = 0x3F800000
movups %xmm0, 0x88(%r15)
leaq 0x30(%rsp), %rdi
movq %r13, (%rdi)
xorl %ebp, %ebp
leaq 0x5e965(%rip), %rsi     # 0x6e939
leaq 0x5e963(%rip), %rdx     # 0x6e93e
callq 0xc772
leaq 0x30(%rsp), %rsi
movq %r15, 0x20(%rsi)
leaq 0x68(%rsp), %rdi
callq 0x10d7a
movq 0x30(%rsp), %rdi
cmpq %r13, %rdi
je 0x1000a
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x82a0
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x10021
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x82a0
movl $0x98, %edi
callq 0x8290
movq %rax, %r15
leaq 0x8(%rsp), %rdi
movq %r12, (%rdi)
leaq 0x5e902(%rip), %rsi     # 0x6e93f
leaq 0x5e903(%rip), %rdx     # 0x6e947
callq 0xc772
movq %rbx, (%r15)
leaq 0x8(%r15), %rdi
leaq 0x18(%r15), %rax
movq %rax, 0x8(%r15)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
addq %rsi, %rdx
movb $0x1, %bpl
callq 0xc6dc
movl $0x1, 0x28(%r15)
movq %r15, %rax
addq $0x90, %rax
xorps %xmm0, %xmm0
movups %xmm0, 0x30(%r15)
movups %xmm0, 0x40(%r15)
movups %xmm0, 0x50(%r15)
movq %rax, 0x60(%r15)
movq $0x1, 0x68(%r15)
movups %xmm0, 0x70(%r15)
movl $0x3f800000, 0x80(%r15) # imm = 0x3F800000
movups %xmm0, 0x88(%r15)
leaq 0x30(%rsp), %rdi
movq %r13, (%rdi)
xorl %ebp, %ebp
leaq 0x5e87a(%rip), %rsi     # 0x6e93f
leaq 0x5e87b(%rip), %rdx     # 0x6e947
callq 0xc772
leaq 0x30(%rsp), %rsi
movq %r15, 0x20(%rsi)
leaq 0x68(%rsp), %rdi
callq 0x10d7a
movq 0x30(%rsp), %rdi
cmpq %r13, %rdi
je 0x100fb
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x82a0
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x10112
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x82a0
movl $0x98, %edi
callq 0x8290
movq %rax, %r15
leaq 0x8(%rsp), %rdi
movq %r12, (%rdi)
leaq 0x5e81a(%rip), %rsi     # 0x6e948
leaq 0x5e822(%rip), %rdx     # 0x6e957
callq 0xc772
movq %rbx, (%r15)
leaq 0x8(%r15), %rdi
leaq 0x18(%r15), %rax
movq %rax, 0x8(%r15)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
addq %rsi, %rdx
movb $0x1, %bpl
callq 0xc6dc
movl $0x1, 0x28(%r15)
movq %r15, %rax
addq $0x90, %rax
xorps %xmm0, %xmm0
movups %xmm0, 0x30(%r15)
movups %xmm0, 0x40(%r15)
movups %xmm0, 0x50(%r15)
movq %rax, 0x60(%r15)
movq $0x1, 0x68(%r15)
movups %xmm0, 0x70(%r15)
movl $0x3f800000, 0x80(%r15) # imm = 0x3F800000
movups %xmm0, 0x88(%r15)
leaq 0x30(%rsp), %rdi
movq %r13, (%rdi)
xorl %ebp, %ebp
leaq 0x5e792(%rip), %rsi     # 0x6e948
leaq 0x5e79a(%rip), %rdx     # 0x6e957
callq 0xc772
leaq 0x30(%rsp), %rsi
movq %r15, 0x20(%rsi)
leaq 0x68(%rsp), %rdi
callq 0x10d7a
movq 0x30(%rsp), %rdi
cmpq %r13, %rdi
je 0x101ec
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x82a0
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x10203
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x82a0
movl $0x98, %edi
callq 0x8290
movq %rax, %r15
leaq 0x8(%rsp), %rdi
movq %r12, (%rdi)
leaq 0x5e739(%rip), %rsi     # 0x6e958
leaq 0x5e740(%rip), %rdx     # 0x6e966
callq 0xc772
movq %rbx, (%r15)
leaq 0x8(%r15), %rdi
leaq 0x18(%r15), %rax
movq %rax, 0x8(%r15)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
addq %rsi, %rdx
movb $0x1, %bpl
callq 0xc6dc
movl $0x1, 0x28(%r15)
movq %r15, %rax
addq $0x90, %rax
xorps %xmm0, %xmm0
movups %xmm0, 0x30(%r15)
movups %xmm0, 0x40(%r15)
movups %xmm0, 0x50(%r15)
movq %rax, 0x60(%r15)
movq $0x1, 0x68(%r15)
movups %xmm0, 0x70(%r15)
movl $0x3f800000, 0x80(%r15) # imm = 0x3F800000
movups %xmm0, 0x88(%r15)
leaq 0x30(%rsp), %rdi
movq %r13, (%rdi)
xorl %ebp, %ebp
leaq 0x5e6b1(%rip), %rsi     # 0x6e958
leaq 0x5e6b8(%rip), %rdx     # 0x6e966
callq 0xc772
leaq 0x30(%rsp), %rsi
movq %r15, 0x20(%rsi)
leaq 0x68(%rsp), %rdi
callq 0x10d7a
movq 0x30(%rsp), %rdi
cmpq %r13, %rdi
je 0x102dd
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x82a0
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x102f4
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x82a0
movl $0x98, %edi
callq 0x8290
movq %rax, %r15
leaq 0x8(%rsp), %rdi
movq %r12, (%rdi)
leaq 0x5e657(%rip), %rsi     # 0x6e967
leaq 0x5e656(%rip), %rdx     # 0x6e96d
callq 0xc772
movq %rbx, (%r15)
leaq 0x8(%r15), %rdi
leaq 0x18(%r15), %rax
movq %rax, 0x8(%r15)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
addq %rsi, %rdx
movb $0x1, %bpl
callq 0xc6dc
movl $0x3, 0x28(%r15)
movq %r15, %rax
addq $0x90, %rax
xorps %xmm0, %xmm0
movups %xmm0, 0x30(%r15)
movups %xmm0, 0x40(%r15)
movups %xmm0, 0x50(%r15)
movq %rax, 0x60(%r15)
movq $0x1, 0x68(%r15)
movups %xmm0, 0x70(%r15)
movl $0x3f800000, 0x80(%r15) # imm = 0x3F800000
movups %xmm0, 0x88(%r15)
leaq 0x30(%rsp), %rdi
movq %r13, (%rdi)
xorl %ebp, %ebp
leaq 0x5e5cf(%rip), %rsi     # 0x6e967
leaq 0x5e5ce(%rip), %rdx     # 0x6e96d
callq 0xc772
leaq 0x30(%rsp), %rsi
movq %r15, 0x20(%rsi)
leaq 0x68(%rsp), %rdi
callq 0x10d7a
movq 0x30(%rsp), %rdi
cmpq %r13, %rdi
je 0x103ce
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x82a0
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x103e5
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x82a0
movq %rbx, 0xa8(%rsp)
movl $0x48, %edi
callq 0x8290
movq %rax, %r15
leaq 0x7f177(%rip), %rax     # 0x8f578
movq (%rax), %rbx
leaq 0x7d25d(%rip), %rax     # 0x8d668
movq %rax, (%r15)
leaq 0x8(%r15), %rdi
leaq 0x18(%r15), %rax
movq %rax, 0x8(%r15)
movq (%r14), %rsi
movq 0x8(%r14), %rdx
addq %rsi, %rdx
callq 0xc6dc
leaq 0x7dbd8(%rip), %rax     # 0x8e008
addq $0x10, %rax
movq %rax, (%r15)
xorps %xmm0, %xmm0
movups %xmm0, 0x28(%r15)
movq $0x0, 0x38(%r15)
movq %rbx, 0x40(%r15)
movq 0x58(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rcx
cmpq %rax, %rcx
movq %r15, 0x60(%rsp)
je 0x10667
addq $0x28, %r15
movq %r15, 0xa0(%rsp)
xorl %r15d, %r15d
leaq 0x30(%rsp), %r12
movq (%rax,%r15,8), %rbx
cmpl $0x7, (%rbx)
jne 0x10651
movl $0x2a8, %edi            # imm = 0x2A8
callq 0x8290
movq %rax, %r14
movq %rax, %rdi
callq 0x10a6e
movq %r14, 0x8(%rsp)
addq $0x8, %r14
movq %rbx, 0x30(%rsp)
movq %r14, %rdi
movq %r12, %rsi
callq 0x11182
movq %r13, 0x30(%rsp)
movq 0x10(%rbx), %rsi
movq 0x18(%rbx), %rdx
addq %rsi, %rdx
movq %r12, %rdi
callq 0xc6dc
movq 0x8(%rsp), %rax
movq %rax, 0x50(%rsp)
leaq 0xb0(%rsp), %rdi
movq %r12, %rsi
callq 0x112f6
movq 0x30(%rsp), %rdi
cmpq %r13, %rdi
je 0x104fd
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x82a0
cmpl $0x3, 0x8(%rbx)
jne 0x10645
leaq 0x10(%rbx), %rsi
leaq 0x7f07e(%rip), %rdi     # 0x8f590
callq 0x116e2
movq %rax, %r14
movl $0x98, %edi
callq 0x8290
movq %rax, %rbp
movq %r13, %r12
movq 0x30(%r14), %r13
movq 0x38(%r14), %r14
movq 0xa8(%rsp), %rax
movq %rax, (%rbp)
leaq 0x8(%rbp), %rdi
leaq 0x18(%rbp), %rax
movq %rax, 0x8(%rbp)
movq 0x10(%rbx), %rsi
movq 0x18(%rbx), %rdx
addq %rsi, %rdx
callq 0xc6dc
subq %r13, %r14
shrq $0x3, %r14
imull $0xaaaaaaab, %r14d, %eax # imm = 0xAAAAAAAB
movl %eax, 0x28(%rbp)
leaq 0x30(%rbp), %rdi
movq %rbp, %rax
addq $0x90, %rax
xorps %xmm0, %xmm0
movups %xmm0, 0x30(%rbp)
movups %xmm0, 0x40(%rbp)
movups %xmm0, 0x50(%rbp)
movq %rax, 0x60(%rbp)
movq $0x1, 0x68(%rbp)
movups %xmm0, 0x70(%rbp)
movl $0x3f800000, 0x80(%rbp) # imm = 0x3F800000
movups %xmm0, 0x88(%rbp)
movq %rbp, 0x28(%rsp)
xorl %esi, %esi
leaq 0x8(%rsp), %rdx
callq 0x117de
movq %r12, %r13
leaq 0x30(%rsp), %r12
movq 0x8(%rsp), %rax
movq 0x28(%rsp), %rcx
movq %rcx, 0x20(%rax)
movq %r13, 0x30(%rsp)
movq 0x10(%rbx), %rsi
movq 0x18(%rbx), %rdx
addq %rsi, %rdx
movq %r12, %rdi
callq 0xc6dc
movq 0x28(%rsp), %rax
movq %rax, 0x50(%rsp)
leaq 0x68(%rsp), %rdi
movq %r12, %rsi
callq 0x10d7a
movq 0x30(%rsp), %rdi
cmpq %r13, %rdi
je 0x10615
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x82a0
movq 0x60(%rsp), %rcx
movq 0x30(%rcx), %rsi
cmpq 0x38(%rcx), %rsi
je 0x10633
movq 0x28(%rsp), %rax
movq %rax, (%rsi)
addq $0x8, 0x30(%rcx)
jmp 0x10645
movq 0xa0(%rsp), %rdi
leaq 0x28(%rsp), %rdx
callq 0x1191a
movq 0x58(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rcx
incq %r15
movq %rcx, %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq %r15, %rdx
ja 0x10479
xorl %edx, %edx
movq %rdx, 0x30(%rsp)
movq %rdx, 0x8(%rsp)
cmpq %rax, %rcx
je 0x10926
movb $0x1, %bl
xorl %r14d, %r14d
leaq 0x5e26c(%rip), %rbp     # 0x6e8f4
xorl %r15d, %r15d
xorl %r13d, %r13d
movq (%rax,%r14,8), %r12
movl (%r12), %eax
movq 0x8(%rsp), %rdi
testb $0x1, %r13b
jne 0x106be
cmpl $0x7, %eax
je 0x106be
addq $0x8, %rdi
movq %r12, 0x28(%rsp)
leaq 0x28(%rsp), %rsi
callq 0x11182
jmp 0x107c2
movq %rdi, 0x30(%rsp)
cmpl $0x7, %eax
jne 0x10702
leaq 0x10(%r12), %r13
leaq 0xb0(%rsp), %rdi
movq %r13, %rsi
callq 0x11a56
movq (%rax), %rax
movq %rax, 0x8(%rsp)
cmpl $0x3, 0x8(%r12)
jne 0x10732
leaq 0x68(%rsp), %rdi
movq %r13, %rsi
callq 0x11b92
movq (%rax), %r15
jmp 0x108f2
movl $0x2a8, %edi            # imm = 0x2A8
callq 0x8290
movq %rax, %r13
movq %rax, %rdi
callq 0x10a6e
movq %r13, 0x8(%rsp)
addq $0x8, %r13
movq %r12, 0x28(%rsp)
movq %r13, %rdi
leaq 0x28(%rsp), %rsi
callq 0x11182
movq 0x38(%r15), %rsi
cmpq 0x40(%r15), %rsi
je 0x1074b
movq 0x8(%rsp), %rax
movq %rax, (%rsi)
addq $0x8, 0x38(%r15)
jmp 0x1075e
leaq 0x30(%r15), %rdi
leaq 0x8(%rsp), %rdx
callq 0x117de
movq 0x8(%rsp), %rax
movq %r15, 0x20(%rax)
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
setne %cl
andb %bl, %cl
cmpb $0x1, %cl
jne 0x107c2
movq 0x48(%rdi), %rsi
cmpq 0x50(%rdi), %rsi
je 0x10788
movq %rax, (%rsi)
addq $0x8, 0x48(%rdi)
jmp 0x10796
addq $0x40, %rdi
leaq 0x8(%rsp), %rdx
callq 0x117de
movq 0x8(%rsp), %rdi
movq 0x30(%rdi), %rsi
cmpq 0x38(%rdi), %rsi
je 0x107b4
movq 0x30(%rsp), %rax
movq %rax, (%rsi)
addq $0x8, 0x30(%rdi)
jmp 0x107c2
addq $0x28, %rdi
leaq 0x30(%rsp), %rdx
callq 0x117de
movl (%r12), %eax
addl $-0x9, %eax
cmpl $0x9, %eax
ja 0x108f0
movb $0x1, %r13b
movslq (%rbp,%rax,4), %rax
addq %rbp, %rax
jmpq *%rax
addq $0x90, %r12
leaq 0xb0(%rsp), %rdi
movq %r12, %rsi
callq 0x11a56
movq (%rax), %rax
movq %rax, 0x28(%rsp)
movq 0x8(%rsp), %rdi
movq 0x48(%rdi), %rsi
cmpq 0x50(%rdi), %rsi
je 0x10817
movq %rax, (%rsi)
addq $0x8, 0x48(%rdi)
jmp 0x10825
addq $0x40, %rdi
leaq 0x28(%rsp), %rdx
callq 0x117de
movq 0x28(%rsp), %rdi
movq 0x30(%rdi), %rsi
cmpq 0x38(%rdi), %rsi
je 0x10843
movq 0x8(%rsp), %rax
movq %rax, (%rsi)
addq $0x8, 0x30(%rdi)
jmp 0x10851
addq $0x28, %rdi
leaq 0x8(%rsp), %rdx
callq 0x117de
movb $0x1, %r13b
movb $0x1, %bl
jmp 0x10907
addq $0x10, %r12
leaq 0xb0(%rsp), %rdi
movq %r12, %rsi
callq 0x11a56
movq (%rax), %rax
movq %rax, 0x28(%rsp)
movq 0x8(%rsp), %rdi
movq 0x48(%rdi), %rsi
cmpq 0x50(%rdi), %rsi
je 0x108b8
movq %rax, (%rsi)
addq $0x8, 0x48(%rdi)
jmp 0x108c6
addq $0x10, %r12
leaq 0x68(%rsp), %rdi
movq %r12, %rsi
callq 0x11b92
movq 0x50(%r15), %rsi
cmpq 0x58(%r15), %rsi
je 0x108e4
movq (%rax), %rax
movq %rax, (%rsi)
addq $0x8, 0x50(%r15)
jmp 0x108f0
addq $0x40, %rdi
leaq 0x28(%rsp), %rdx
callq 0x117de
movq 0x28(%rsp), %rdi
movq 0x30(%rdi), %rsi
cmpq 0x38(%rdi), %rsi
je 0x108f7
movq 0x8(%rsp), %rax
movq %rax, (%rsi)
addq $0x8, 0x30(%rdi)
jmp 0x10905
leaq 0x48(%r15), %rdi
movq %rax, %rdx
callq 0x1191a
movb $0x1, %bl
xorl %r13d, %r13d
jmp 0x10907
addq $0x28, %rdi
leaq 0x8(%rsp), %rdx
callq 0x117de
xorl %ebx, %ebx
incq %r14
movq 0x58(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %r14, %rcx
ja 0x1068e
leaq 0x68(%rsp), %rdi
callq 0x10c3e
leaq 0xb0(%rsp), %rdi
callq 0x10cdc
movq 0x60(%rsp), %rax
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movl $0x48, %esi
jmp 0x10a07
jmp 0x10a4b
jmp 0x109ae
jmp 0x109cc
jmp 0x10a4b
jmp 0x109ae
jmp 0x109cc
jmp 0x10a4b
jmp 0x109ae
jmp 0x109cc
jmp 0x10a4b
jmp 0x109ae
jmp 0x109cc
jmp 0x10a4b
jmp 0x109ae
jmp 0x109cc
jmp 0x10a4b
jmp 0x109ae
jmp 0x109cc
jmp 0x10a4b
jmp 0x109ae
jmp 0x109cc
jmp 0x10a4b
jmp 0x109ae
jmp 0x109cc
jmp 0x10a4b
movq %rax, %rbx
movq 0x30(%rsp), %rdi
cmpq %r13, %rdi
je 0x109c8
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x82a0
xorl %ebp, %ebp
jmp 0x109e6
movq %rax, %rbx
jmp 0x10a02
jmp 0x10a4b
jmp 0x109e3
jmp 0x109e3
jmp 0x109e3
jmp 0x109e3
jmp 0x109e3
jmp 0x109e3
jmp 0x109e3
jmp 0x109e3
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x109fd
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x82a0
testb %bpl, %bpl
je 0x10a4e
movl $0x98, %esi
movq %r15, %rdi
jmp 0x10a3c
jmp 0x10a4b
jmp 0x10a4b
movq %rax, %rbx
movl $0x98, %esi
movq %rbp, %rdi
jmp 0x10a3c
jmp 0x10a4b
jmp 0x10a27
jmp 0x10a4b
jmp 0x10a4b
jmp 0x10a4b
movq %rax, %rbx
movq 0x30(%rsp), %rdi
cmpq %r13, %rdi
je 0x10a4e
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x82a0
jmp 0x10a4e
jmp 0x10a4b
jmp 0x10a4b
jmp 0x10a4b
jmp 0x10a4b
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0x10c3e
leaq 0xb0(%rsp), %rdi
callq 0x10cdc
movq %rbx, %rdi
callq 0x8540
nop