// File: luooofan[P]hblzbd_compiler/src/generate_ir.cpp
// Function: ast::FunctionDefine::GenerateIR(ir::ContextInfo&, std::vector<ir::IR*, std::allocator<ir::IR*>>&)
void FunctionDefine::GenerateIR(ir::ContextInfo &ctx, std::vector<ir::IR *> &gIRList) {
#ifdef GENIR_TIME_CONTROL
  clock_t begin, end;
  double cost;
  begin = clock();
#endif
  // NOTE: 函数无法嵌套定义
  if (ctx.scope_id_ != 0) {
    ir::SemanticError(this->line_no_, "function nest define.");
    return;
  }
  const auto &func_iter = ir::gFuncTable.find(this->name_.name_);
  if (func_iter == ir::gFuncTable.end()) {
    ctx.current_func_name_ = this->name_.name_;
    ctx.scope_id_ = ir::gScopes.size();
    gIRList.push_back(new ir::IR(IROpKind::LABEL, FUNC_OPN(this->name_.name_)));
    // 父作用域id一定为0 函数初始栈偏移为0
    ir::gScopes.push_back({ctx.scope_id_, 0});
    auto tmp = new ir::FuncTableItem(return_type_, ctx.scope_id_);
    ctx.has_aug_scope = true;
    for (int i = 0; i < args_.arg_list_.size(); ++i) {
      // for (const auto &arg : args_.arg_list_) {
      const auto &arg = args_.arg_list_[i];
      auto &scope = ir::gScopes[ctx.scope_id_];
      auto &symbol_table = scope.symbol_table_;
      if (Identifier *ident = dynamic_cast<Identifier *>(&arg->name_)) {
        const auto &var_iter = symbol_table.find(ident->name_);
        if (var_iter == symbol_table.end()) {
          auto &&symbol_item = ir::SymbolTableItem(false, false);
          symbol_table.insert({ident->name_, symbol_item});
          // ADD DECLARE
          gIRList.push_back(new ir::IR{IROpKind::DECLARE, ir::Opn(OpnType::Var, ident->name_, ctx.scope_id_),
                                       ir::Opn(OpnType::Imm, i)});
        } else {
          ir::SemanticError(this->line_no_, ident->name_ + ": variable redefined");
        }
        tmp->shape_list_.push_back(std::vector<int>());
      } else if (ArrayIdentifier *arrident = dynamic_cast<ArrayIdentifier *>(&arg->name_)) {
        const auto &var_iter = symbol_table.find(arrident->name_.name_);
        if (var_iter == symbol_table.end()) {
          auto tmp1 = new ir::SymbolTableItem(true, false);
          // NOTE: 参数中的数组视为一个基址指针
          // ADD DECLARE
          gIRList.push_back(
              new ir::IR{IROpKind::DECLARE,
                         ir::Opn(OpnType::Array, arrident->name_.name_, ctx.scope_id_, new ir::Opn(OpnType::Imm, 0)),
                         ir::Opn(OpnType::Imm, i)});

          // 计算shape和width shape:-1 2 3  width:? 24 12 4
          tmp1->shape_.push_back(-1);  //第一维因为文法规定必须留空，这里记-1
          for (const auto &shape : arrident->shape_list_) {
            shape->Evaluate(ctx, gIRList);
            tmp1->shape_.push_back(ctx.opn_.imm_num_);
          }
          tmp1->width_.resize(tmp1->shape_.size() + 1);
          tmp1->width_[tmp1->width_.size() - 1] = ir::kIntWidth;
          for (int i = tmp1->width_.size() - 2; i > 0; i--) tmp1->width_[i] = tmp1->width_[i + 1] * tmp1->shape_[i];
          tmp1->width_[0] = -1;  // useless
          symbol_table.insert({arrident->name_.name_, *tmp1});
          tmp->shape_list_.push_back(tmp1->shape_);
          delete tmp1;
        } else {
          ir::SemanticError(this->line_no_, arrident->name_.name_ + ": variable redefined");
        }
      }
      // std::cout<<"haha"<<ctx.shape_.size()<<'\n';
      // tmp->shape_list_.push_back(ctx.shape_);
    }
    ir::gFuncTable.insert({name_.name_, *tmp});
    delete tmp;

    ctx.has_return = false;
    this->body_.GenerateIR(ctx, gIRList);

    if (return_type_ == INT && ctx.has_return == false) {
      ir::SemanticError(this->line_no_,
                        this->name_.name_ + ": function's return type is INT,but does not return anything");
    }
    // 保证函数执行流最后会有一条ret语句 方便汇编生成
    if (return_type_ == VOID /*&& ctx.has_return == false*/) {
      gIRList.push_back(new ir::IR(IROpKind::RET));
    }

    // Set current_scope_id
    ctx.scope_id_ = 0;
  } else {
    ir::SemanticError(this->line_no_, this->name_.name_ + ": function redefined");
  }
#ifdef GENIR_TIME_CONTROL
  end = clock();
  cost = (double)(end - begin) / CLOCKS_PER_SEC;
  std::cout << "GenIrFunction cost: " << cost << "s" << std::endl;
  if (cost > 3) exit(233);
#endif
}

// Assembly:
subq $0x6f8, %rsp            # imm = 0x6F8
movq %rdi, 0x6f0(%rsp)
movq %rsi, 0x6e8(%rsp)
movq %rdx, 0x6e0(%rsp)
movq 0x6f0(%rsp), %rax
movq %rax, 0x190(%rsp)
movq 0x6e8(%rsp), %rax
cmpl $0x0, (%rax)
je 0x27ae3
movq 0x190(%rsp), %rax
movl 0x8(%rax), %eax
movl %eax, 0x184(%rsp)
leaq 0x6bf(%rsp), %rdi
movq %rdi, 0x188(%rsp)
callq 0x8680
movq 0x188(%rsp), %rdx
leaq 0xd3149(%rip), %rsi     # 0xfab9f
leaq 0x6c0(%rsp), %rdi
callq 0xc570
jmp 0x27a65
movl 0x184(%rsp), %edi
leaq 0x6c0(%rsp), %rsi
callq 0x47ce0
jmp 0x27a7b
leaq 0x6c0(%rsp), %rdi
callq 0x8728
leaq 0x6bf(%rsp), %rdi
callq 0x83c0
jmp 0x28cd5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x6b0(%rsp)
movl %eax, 0x6ac(%rsp)
jmp 0x27ad1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x6b0(%rsp)
movl %eax, 0x6ac(%rsp)
leaq 0x6c0(%rsp), %rdi
callq 0x8728
leaq 0x6bf(%rsp), %rdi
callq 0x83c0
jmp 0x28cdd
movq 0x190(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x10(%rax), %rsi
leaq 0x124b46(%rip), %rdi    # 0x14c640
callq 0x18680
movq %rax, 0x698(%rsp)
leaq 0x698(%rsp), %rax
movq %rax, 0x6a0(%rsp)
movq 0x6a0(%rsp), %rax
movq %rax, 0x178(%rsp)
leaq 0x124b12(%rip), %rdi    # 0x14c640
callq 0x36170
movq 0x178(%rsp), %rdi
movq %rax, 0x690(%rsp)
leaq 0x690(%rsp), %rsi
callq 0x36150
testb $0x1, %al
jne 0x27b59
jmp 0x28c63
movq 0x190(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x10(%rax), %rsi
movq 0x6e8(%rsp), %rdi
addq $0x1e8, %rdi            # imm = 0x1E8
callq 0x8050
leaq 0x124aa4(%rip), %rdi    # 0x14c628
callq 0x37290
movl %eax, %ecx
movq 0x6e8(%rsp), %rax
movl %ecx, (%rax)
movq 0x6e0(%rsp), %rax
movq %rax, 0x168(%rsp)
movl $0xe0, %edi
callq 0x8340
movq %rax, %rcx
movq 0x190(%rsp), %rax
movq %rcx, 0x170(%rsp)
movb $0x1, 0x627(%rsp)
movq 0x10(%rax), %rax
movq 0x10(%rax), %rsi
leaq 0x628(%rsp), %rdi
callq 0x81a0
jmp 0x27be1
leaq 0x648(%rsp), %rdi
movl $0x3, %esi
leaq 0x628(%rsp), %rdx
callq 0x36d70
jmp 0x27bfd
movq 0x170(%rsp), %rdi
movl $0x7, %esi
leaq 0x648(%rsp), %rdx
callq 0x36c00
jmp 0x27c19
movq 0x168(%rsp), %rdi
movq 0x170(%rsp), %rax
movb $0x0, 0x627(%rsp)
movq %rax, 0x688(%rsp)
leaq 0x688(%rsp), %rsi
callq 0x185b0
jmp 0x27c48
leaq 0x648(%rsp), %rdi
callq 0x1f210
leaq 0x628(%rsp), %rdi
callq 0x8728
movq 0x6e8(%rsp), %rax
movl (%rax), %esi
leaq 0x5e0(%rsp), %rdi
movq %rdi, 0x160(%rsp)
xorl %edx, %edx
callq 0x360d0
movq 0x160(%rsp), %rsi
leaq 0x124996(%rip), %rdi    # 0x14c628
callq 0x360a0
jmp 0x27c99
leaq 0x5e0(%rsp), %rdi
callq 0x36110
movl $0x20, %edi
callq 0x8340
movq %rax, %rdi
movq 0x190(%rsp), %rax
movq %rdi, %rcx
movq %rcx, 0x158(%rsp)
movl 0xc(%rax), %esi
movq 0x6e8(%rsp), %rax
movl (%rax), %edx
callq 0x35980
jmp 0x27cda
movq 0x158(%rsp), %rax
movq %rax, 0x5d8(%rsp)
movq 0x6e8(%rsp), %rax
movb $0x1, 0x208(%rax)
movl $0x0, 0x5d4(%rsp)
movq 0x190(%rsp), %rax
movslq 0x5d4(%rsp), %rcx
movq %rcx, 0x150(%rsp)
movq 0x18(%rax), %rdi
addq $0x10, %rdi
callq 0x372b0
movq %rax, %rcx
movq 0x150(%rsp), %rax
cmpq %rcx, %rax
jae 0x28a3d
movq 0x190(%rsp), %rax
movq 0x18(%rax), %rdi
addq $0x10, %rdi
movslq 0x5d4(%rsp), %rsi
callq 0x372d0
movq %rax, 0x5c8(%rsp)
movq 0x6e8(%rsp), %rax
movslq (%rax), %rsi
leaq 0x1248b4(%rip), %rdi    # 0x14c628
callq 0x183c0
movq %rax, 0x5c0(%rsp)
movq 0x5c0(%rsp), %rax
movq %rax, 0x5b8(%rsp)
movq 0x5c8(%rsp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movq %rax, 0x148(%rsp)
cmpq $0x0, %rax
je 0x27eac
movq 0x148(%rsp), %rdi
leaq 0x123037(%rip), %rsi    # 0x14adf8
leaq 0x122d30(%rip), %rdx    # 0x14aaf8
xorl %eax, %eax
movl %eax, %ecx
callq 0x8410
movq %rax, 0x140(%rsp)
jmp 0x27eb8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x6b0(%rsp)
movl %eax, 0x6ac(%rsp)
jmp 0x27e38
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x6b0(%rsp)
movl %eax, 0x6ac(%rsp)
jmp 0x27e2b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x6b0(%rsp)
movl %eax, 0x6ac(%rsp)
leaq 0x648(%rsp), %rdi
callq 0x1f210
leaq 0x628(%rsp), %rdi
callq 0x8728
testb $0x1, 0x627(%rsp)
jne 0x27e44
jmp 0x27e56
movq 0x170(%rsp), %rdi
movl $0xe0, %esi
callq 0x8350
jmp 0x28cdd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x6b0(%rsp)
movl %eax, 0x6ac(%rsp)
leaq 0x5e0(%rsp), %rdi
callq 0x36110
jmp 0x28cdd
movq 0x158(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x6b0(%rsp)
movl %eax, 0x6ac(%rsp)
movl $0x20, %esi
callq 0x8350
jmp 0x28cdd
xorl %eax, %eax
movq %rax, 0x140(%rsp)
jmp 0x27eb8
movq 0x140(%rsp), %rax
movq %rax, 0x5b0(%rsp)
cmpq $0x0, 0x5b0(%rsp)
je 0x2830b
movq 0x5b8(%rsp), %rdi
movq 0x5b0(%rsp), %rax
movq 0x10(%rax), %rsi
callq 0x1f270
movq %rax, 0x5a0(%rsp)
leaq 0x5a0(%rsp), %rax
movq %rax, 0x5a8(%rsp)
movq 0x5a8(%rsp), %rax
movq %rax, 0x138(%rsp)
movq 0x5b8(%rsp), %rdi
callq 0x109d0
movq 0x138(%rsp), %rdi
movq %rax, 0x598(%rsp)
leaq 0x598(%rsp), %rsi
callq 0x36e80
testb $0x1, %al
jne 0x27f4b
jmp 0x281f7
leaq 0x540(%rsp), %rdi
movq %rdi, 0x128(%rsp)
xorl %edx, %edx
movl %edx, %esi
callq 0x366c0
movq 0x128(%rsp), %rax
movq %rax, 0x590(%rsp)
movq 0x5b8(%rsp), %rax
movq %rax, 0x130(%rsp)
movq 0x5b0(%rsp), %rax
movq 0x10(%rax), %rsi
movq 0x590(%rsp), %rdx
leaq 0x4d0(%rsp), %rdi
callq 0x36ed0
jmp 0x27fa7
movq 0x130(%rsp), %rdi
leaq 0x4d0(%rsp), %rsi
callq 0x36670
movb %dl, 0x11f(%rsp)
movq %rax, 0x120(%rsp)
jmp 0x27fcd
movb 0x11f(%rsp), %al
movq 0x120(%rsp), %rcx
movq %rcx, 0x4c0(%rsp)
movb %al, 0x4c8(%rsp)
leaq 0x4d0(%rsp), %rdi
callq 0x36810
movq 0x6e0(%rsp), %rax
movq %rax, 0x108(%rsp)
movl $0xe0, %edi
callq 0x8340
movq %rax, 0x110(%rsp)
jmp 0x2801c
movb $0x1, 0x417(%rsp)
movq 0x5b0(%rsp), %rax
movq 0x10(%rax), %rsi
leaq 0x458(%rsp), %rdi
callq 0x81a0
jmp 0x2803f
movq 0x6e8(%rsp), %rax
movl (%rax), %ecx
leaq 0x478(%rsp), %rdi
xorl %esi, %esi
leaq 0x458(%rsp), %rdx
callq 0x36480
jmp 0x28062
movl 0x5d4(%rsp), %edx
leaq 0x418(%rsp), %rdi
movl $0x1, %esi
callq 0x1f160
jmp 0x2807d
movq 0x110(%rsp), %rdi
movl $0x17, %esi
leaq 0x478(%rsp), %rdx
leaq 0x418(%rsp), %rcx
callq 0x36880
jmp 0x280a1
movq 0x108(%rsp), %rdi
movq 0x110(%rsp), %rax
movb $0x0, 0x417(%rsp)
movq %rax, 0x4b8(%rsp)
leaq 0x4b8(%rsp), %rsi
callq 0x185b0
jmp 0x280d0
leaq 0x418(%rsp), %rdi
callq 0x1f210
leaq 0x478(%rsp), %rdi
callq 0x1f210
leaq 0x458(%rsp), %rdi
callq 0x8728
leaq 0x540(%rsp), %rdi
callq 0x36840
jmp 0x2827c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x6b0(%rsp)
movl %eax, 0x6ac(%rsp)
jmp 0x281e5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x6b0(%rsp)
movl %eax, 0x6ac(%rsp)
leaq 0x4d0(%rsp), %rdi
callq 0x36810
jmp 0x281e5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x6b0(%rsp)
movl %eax, 0x6ac(%rsp)
jmp 0x281c5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x6b0(%rsp)
movl %eax, 0x6ac(%rsp)
jmp 0x281b8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x6b0(%rsp)
movl %eax, 0x6ac(%rsp)
jmp 0x281ab
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x6b0(%rsp)
movl %eax, 0x6ac(%rsp)
leaq 0x418(%rsp), %rdi
callq 0x1f210
leaq 0x478(%rsp), %rdi
callq 0x1f210
leaq 0x458(%rsp), %rdi
callq 0x8728
testb $0x1, 0x417(%rsp)
jne 0x281d1
jmp 0x281e3
movq 0x110(%rsp), %rdi
movl $0xe0, %esi
callq 0x8350
jmp 0x281e5
leaq 0x540(%rsp), %rdi
callq 0x36840
jmp 0x28cdd
movq 0x190(%rsp), %rax
movl 0x8(%rax), %eax
movl %eax, 0xfc(%rsp)
movq 0x5b0(%rsp), %rax
movq 0x10(%rax), %rsi
leaq 0xd296e(%rip), %rdx     # 0xfab8a
leaq 0x3f0(%rsp), %rdi
movq %rdi, 0x100(%rsp)
callq 0xc720
movl 0xfc(%rsp), %edi
movq 0x100(%rsp), %rsi
callq 0x47ce0
jmp 0x28247
leaq 0x3f0(%rsp), %rdi
callq 0x8728
jmp 0x2827c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x6b0(%rsp)
movl %eax, 0x6ac(%rsp)
leaq 0x3f0(%rsp), %rdi
callq 0x8728
jmp 0x28cdd
movq 0x5d8(%rsp), %rax
addq $0x8, %rax
movq %rax, 0xe8(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x3d0(%rsp)
movq $0x0, 0x3e0(%rsp)
leaq 0x3d0(%rsp), %rdi
movq %rdi, 0xf0(%rsp)
callq 0x35d90
movq 0xe8(%rsp), %rdi
movq 0xf0(%rsp), %rsi
callq 0x35b90
jmp 0x282d3
leaq 0x3d0(%rsp), %rdi
callq 0x35c60
jmp 0x28a25
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x6b0(%rsp)
movl %eax, 0x6ac(%rsp)
leaq 0x3d0(%rsp), %rdi
callq 0x35c60
jmp 0x28cdd
movq 0x5c8(%rsp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movq %rax, 0xe0(%rsp)
cmpq $0x0, %rax
je 0x28351
movq 0xe0(%rsp), %rdi
leaq 0x122ac1(%rip), %rsi    # 0x14adf8
leaq 0x1227d2(%rip), %rdx    # 0x14ab10
xorl %eax, %eax
movl %eax, %ecx
callq 0x8410
movq %rax, 0xd8(%rsp)
jmp 0x2835d
xorl %eax, %eax
movq %rax, 0xd8(%rsp)
jmp 0x2835d
movq 0xd8(%rsp), %rax
movq %rax, 0x3c8(%rsp)
cmpq $0x0, 0x3c8(%rsp)
je 0x28a23
movq 0x5b8(%rsp), %rdi
movq 0x3c8(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x10(%rax), %rsi
callq 0x1f270
movq %rax, 0x3b8(%rsp)
leaq 0x3b8(%rsp), %rax
movq %rax, 0x3c0(%rsp)
movq 0x3c0(%rsp), %rax
movq %rax, 0xd0(%rsp)
movq 0x5b8(%rsp), %rdi
callq 0x109d0
movq 0xd0(%rsp), %rdi
movq %rax, 0x3b0(%rsp)
leaq 0x3b0(%rsp), %rsi
callq 0x36e80
testb $0x1, %al
jne 0x283f4
jmp 0x289a4
movl $0x50, %edi
callq 0x8340
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0xc8(%rsp)
movl $0x1, %esi
xorl %edx, %edx
callq 0x366c0
jmp 0x2841a
movq 0xc8(%rsp), %rax
movq %rax, 0x3a8(%rsp)
movq 0x6e0(%rsp), %rax
movq %rax, 0xb8(%rsp)
movl $0xe0, %edi
callq 0x8340
movq %rax, 0xc0(%rsp)
movb $0x1, 0x2ff(%rsp)
movq 0x3c8(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x10(%rax), %rsi
leaq 0x340(%rsp), %rdi
callq 0x81a0
jmp 0x28473
movq 0x6e8(%rsp), %rax
movl (%rax), %eax
movl %eax, 0xac(%rsp)
movl $0x40, %edi
callq 0x8340
movq %rax, 0xb0(%rsp)
jmp 0x28498
movq 0xb0(%rsp), %rdi
movl $0x1, %esi
xorl %edx, %edx
callq 0x1f160
jmp 0x284ae
movq 0xb0(%rsp), %r8
movl 0xac(%rsp), %ecx
leaq 0x360(%rsp), %rdi
movl $0x5, %esi
leaq 0x340(%rsp), %rdx
callq 0x36610
jmp 0x284d9
movl 0x5d4(%rsp), %edx
leaq 0x300(%rsp), %rdi
movl $0x1, %esi
callq 0x1f160
jmp 0x284f4
movq 0xc0(%rsp), %rdi
movl $0x17, %esi
leaq 0x360(%rsp), %rdx
leaq 0x300(%rsp), %rcx
callq 0x36880
jmp 0x28518
movq 0xb8(%rsp), %rdi
movq 0xc0(%rsp), %rax
movb $0x0, 0x2ff(%rsp)
movq %rax, 0x3a0(%rsp)
leaq 0x3a0(%rsp), %rsi
callq 0x185b0
jmp 0x28547
leaq 0x300(%rsp), %rdi
callq 0x1f210
leaq 0x360(%rsp), %rdi
callq 0x1f210
leaq 0x340(%rsp), %rdi
callq 0x8728
movq 0x3a8(%rsp), %rdi
addq $0x8, %rdi
movl $0xffffffff, 0x2f8(%rsp) # imm = 0xFFFFFFFF
leaq 0x2f8(%rsp), %rsi
callq 0x36ea0
movq 0x3c8(%rsp), %rax
addq $0x18, %rax
movq %rax, 0x2f0(%rsp)
movq 0x2f0(%rsp), %rdi
callq 0x14bc0
movq %rax, 0x2e8(%rsp)
movq 0x2f0(%rsp), %rdi
callq 0x14bf0
movq %rax, 0x2e0(%rsp)
leaq 0x2e8(%rsp), %rdi
leaq 0x2e0(%rsp), %rsi
callq 0x14c20
testb $0x1, %al
jne 0x285ee
jmp 0x28752
leaq 0x2e8(%rsp), %rdi
callq 0x14c60
movq %rax, 0x2d8(%rsp)
movq 0x2d8(%rsp), %rdi
callq 0x14c70
movq %rax, %rdi
movq 0x6e8(%rsp), %rsi
movq 0x6e0(%rsp), %rdx
movq (%rdi), %rax
callq *0x18(%rax)
movq 0x3a8(%rsp), %rdi
addq $0x8, %rdi
movq 0x6e8(%rsp), %rsi
addq $0x8, %rsi
addq $0x4, %rsi
callq 0x1f2a0
leaq 0x2e8(%rsp), %rdi
callq 0x14c80
jmp 0x285d0
movq 0xc8(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x6b0(%rsp)
movl %eax, 0x6ac(%rsp)
movl $0x50, %esi
callq 0x8350
jmp 0x28cdd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x6b0(%rsp)
movl %eax, 0x6ac(%rsp)
jmp 0x2872f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x6b0(%rsp)
movl %eax, 0x6ac(%rsp)
jmp 0x28722
movq 0xb0(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x6b0(%rsp)
movl %eax, 0x6ac(%rsp)
movl $0x40, %esi
callq 0x8350
jmp 0x28722
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x6b0(%rsp)
movl %eax, 0x6ac(%rsp)
jmp 0x28715
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x6b0(%rsp)
movl %eax, 0x6ac(%rsp)
leaq 0x300(%rsp), %rdi
callq 0x1f210
leaq 0x360(%rsp), %rdi
callq 0x1f210
leaq 0x340(%rsp), %rdi
callq 0x8728
testb $0x1, 0x2ff(%rsp)
jne 0x2873b
jmp 0x2874d
movq 0xc0(%rsp), %rdi
movl $0xe0, %esi
callq 0x8350
jmp 0x28cdd
movq 0x3a8(%rsp), %rax
addq $0x20, %rax
movq %rax, 0x98(%rsp)
movq 0x3a8(%rsp), %rdi
addq $0x8, %rdi
callq 0x10a40
movq 0x98(%rsp), %rdi
movq %rax, %rsi
addq $0x1, %rsi
callq 0x36fa0
leaq 0xd29f6(%rip), %rax     # 0xfb188
movl (%rax), %eax
movl %eax, 0xa8(%rsp)
movq 0x3a8(%rsp), %rax
addq $0x20, %rax
movq %rax, 0xa0(%rsp)
movq 0x3a8(%rsp), %rdi
addq $0x20, %rdi
callq 0x10a40
movq 0xa0(%rsp), %rdi
movq %rax, %rsi
subq $0x1, %rsi
callq 0x10a60
movl 0xa8(%rsp), %ecx
movl %ecx, (%rax)
movq 0x3a8(%rsp), %rdi
addq $0x20, %rdi
callq 0x10a40
subq $0x2, %rax
movl %eax, 0x2d4(%rsp)
cmpl $0x0, 0x2d4(%rsp)
jle 0x28893
movq 0x3a8(%rsp), %rdi
addq $0x20, %rdi
movl 0x2d4(%rsp), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0x10a60
movl (%rax), %eax
movl %eax, 0x90(%rsp)
movq 0x3a8(%rsp), %rdi
addq $0x8, %rdi
movslq 0x2d4(%rsp), %rsi
callq 0x10a60
movq %rax, %rcx
movl 0x90(%rsp), %eax
imull (%rcx), %eax
movl %eax, 0x94(%rsp)
movq 0x3a8(%rsp), %rdi
addq $0x20, %rdi
movslq 0x2d4(%rsp), %rsi
callq 0x10a60
movl 0x94(%rsp), %ecx
movl %ecx, (%rax)
movl 0x2d4(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x2d4(%rsp)
jmp 0x287f9
movq 0x3a8(%rsp), %rdi
addq $0x20, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x10a60
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
movq 0x5b8(%rsp), %rax
movq %rax, 0x70(%rsp)
movq 0x3c8(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x10(%rax), %rsi
movq 0x3a8(%rsp), %rdx
leaq 0x260(%rsp), %rdi
movq %rdi, 0x78(%rsp)
callq 0x36ed0
movq 0x70(%rsp), %rdi
movq 0x78(%rsp), %rsi
callq 0x36670
movb %dl, 0x87(%rsp)
movq %rax, 0x88(%rsp)
jmp 0x28905
movb 0x87(%rsp), %al
movq 0x88(%rsp), %rcx
movq %rcx, 0x250(%rsp)
movb %al, 0x258(%rsp)
leaq 0x260(%rsp), %rdi
callq 0x36810
movq 0x5d8(%rsp), %rdi
addq $0x8, %rdi
movq 0x3a8(%rsp), %rsi
addq $0x8, %rsi
callq 0x372f0
movq 0x3a8(%rsp), %rax
movq %rax, 0x68(%rsp)
cmpq $0x0, %rax
je 0x28979
movq 0x68(%rsp), %rdi
callq 0x36840
movq 0x68(%rsp), %rdi
movl $0x50, %esi
callq 0x8350
jmp 0x28a21
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x6b0(%rsp)
movl %eax, 0x6ac(%rsp)
leaq 0x260(%rsp), %rdi
callq 0x36810
jmp 0x28cdd
movq 0x190(%rsp), %rax
movl 0x8(%rax), %eax
movl %eax, 0x5c(%rsp)
movq 0x3c8(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x10(%rax), %rsi
leaq 0xd21c0(%rip), %rdx     # 0xfab8a
leaq 0x230(%rsp), %rdi
movq %rdi, 0x60(%rsp)
callq 0xc720
movl 0x5c(%rsp), %edi
movq 0x60(%rsp), %rsi
callq 0x47ce0
jmp 0x289ec
leaq 0x230(%rsp), %rdi
callq 0x8728
jmp 0x28a21
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x6b0(%rsp)
movl %eax, 0x6ac(%rsp)
leaq 0x230(%rsp), %rdi
callq 0x8728
jmp 0x28cdd
jmp 0x28a23
jmp 0x28a25
jmp 0x28a27
movl 0x5d4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x5d4(%rsp)
jmp 0x27d04
movq 0x190(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x10(%rax), %rsi
movq 0x5d8(%rsp), %rdx
leaq 0x1f0(%rsp), %rdi
movq %rdi, 0x40(%rsp)
callq 0x37360
movq 0x40(%rsp), %rsi
leaq 0x123bcd(%rip), %rdi    # 0x14c640
callq 0x35930
movb %dl, 0x4f(%rsp)
movq %rax, 0x50(%rsp)
jmp 0x28a83
movb 0x4f(%rsp), %al
movq 0x50(%rsp), %rcx
movq %rcx, 0x1e0(%rsp)
movb %al, 0x1e8(%rsp)
leaq 0x1f0(%rsp), %rdi
callq 0x35a80
movq 0x5d8(%rsp), %rax
movq %rax, 0x38(%rsp)
cmpq $0x0, %rax
je 0x28ad4
movq 0x38(%rsp), %rdi
callq 0x35ab0
movq 0x38(%rsp), %rdi
movl $0x20, %esi
callq 0x8350
movq 0x190(%rsp), %rax
movq 0x6e8(%rsp), %rcx
movb $0x0, 0x48(%rcx)
movq 0x20(%rax), %rdi
movq 0x6e8(%rsp), %rsi
movq 0x6e0(%rsp), %rdx
movq (%rdi), %rax
callq *0x10(%rax)
movq 0x190(%rsp), %rax
cmpl $0x121, 0xc(%rax)       # imm = 0x121
jne 0x28bcb
movq 0x6e8(%rsp), %rax
movb 0x48(%rax), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x28bcb
movq 0x190(%rsp), %rax
movl 0x8(%rax), %ecx
movl %ecx, 0x2c(%rsp)
movq 0x10(%rax), %rax
movq 0x10(%rax), %rsi
leaq 0xd2067(%rip), %rdx     # 0xfabb5
leaq 0x1c0(%rsp), %rdi
movq %rdi, 0x30(%rsp)
callq 0xc720
movl 0x2c(%rsp), %edi
movq 0x30(%rsp), %rsi
callq 0x47ce0
jmp 0x28b70
leaq 0x1c0(%rsp), %rdi
callq 0x8728
jmp 0x28bcb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x6b0(%rsp)
movl %eax, 0x6ac(%rsp)
leaq 0x1f0(%rsp), %rdi
callq 0x35a80
jmp 0x28cdd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x6b0(%rsp)
movl %eax, 0x6ac(%rsp)
leaq 0x1c0(%rsp), %rdi
callq 0x8728
jmp 0x28cdd
movq 0x190(%rsp), %rax
cmpl $0x122, 0xc(%rax)       # imm = 0x122
jne 0x28c53
movq 0x6e0(%rsp), %rax
movq %rax, 0x18(%rsp)
movl $0xe0, %edi
callq 0x8340
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0x20(%rsp)
movl $0xa, %esi
callq 0x373d0
jmp 0x28c0a
movq 0x18(%rsp), %rdi
movq 0x20(%rsp), %rax
movq %rax, 0x1b8(%rsp)
leaq 0x1b8(%rsp), %rsi
callq 0x185b0
jmp 0x28c53
movq 0x20(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x6b0(%rsp)
movl %eax, 0x6ac(%rsp)
movl $0xe0, %esi
callq 0x8350
jmp 0x28cdd
movq 0x6e8(%rsp), %rax
movl $0x0, (%rax)
jmp 0x28cd5
movq 0x190(%rsp), %rax
movl 0x8(%rax), %ecx
movl %ecx, 0xc(%rsp)
movq 0x10(%rax), %rax
movq 0x10(%rax), %rsi
leaq 0xd1f71(%rip), %rdx     # 0xfabf2
leaq 0x198(%rsp), %rdi
movq %rdi, 0x10(%rsp)
callq 0xc720
movl 0xc(%rsp), %edi
movq 0x10(%rsp), %rsi
callq 0x47ce0
jmp 0x28ca3
leaq 0x198(%rsp), %rdi
callq 0x8728
jmp 0x28cd5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x6b0(%rsp)
movl %eax, 0x6ac(%rsp)
leaq 0x198(%rsp), %rdi
callq 0x8728
jmp 0x28cdd
addq $0x6f8, %rsp            # imm = 0x6F8
retq
movq 0x6b0(%rsp), %rdi
callq 0x8670
nopw (%rax,%rax)