// File: /workspace/github_c_makefile_star2_O3/taeguk[P]Compiler-Proj-Cminus/src/cgen.c
// Function: localCodeGen
static int localCodeGen(TreeNode *syntaxTree, FILE *codeStream, int currStack, int travSibling)
{
  TreeNode *t;
  for(t = syntaxTree;
      t != NULL;
      t = travSibling ? t->sibling : NULL)
    {
      switch (t->nodeKind)
        {

        case VariableDeclarationK:
        {
          int size = sizeof(int);

          fprintf(codeStream, "\n# Local variable declaration\n");
          fprintf(codeStream, "addiu $sp, $sp, %d\n", -size);
          currStack += size;
          t->attr.varDecl._var->symbolInfo->attr.intInfo.memloc = -currStack;
          break;
        }
        case ArrayDeclarationK:
        {
          int size = regSize * t->attr.varDecl._var->symbolInfo->attr.arrInfo.arrLen;
          fprintf(codeStream, "\n# Local array declaration\n");
          fprintf(codeStream, "addiu $sp, $sp, %d\n", -size);
          t->attr.varDecl._var->symbolInfo->attr.arrInfo.memloc = -currStack-size;
          currStack += size;
          break;
        }

        case CompoundStatementK:
        {
          fprintf(codeStream, "\n# Compound Statement\n");
          int updateStack = currStack;

          updateStack = localCodeGen(t->attr.cmpdStmt.local_decl, codeStream, updateStack, 1);
          if(localCodeGen(t->attr.cmpdStmt.stmt_list, codeStream, updateStack, 1) != updateStack, 1)
            DONT_OCCUR_PRINT;

          // stack cleanup
          if(updateStack < currStack)
            DONT_OCCUR_PRINT;

          fprintf(codeStream, "\n# Local stack cleanup\n");
          fprintf(codeStream, "addiu $sp, $sp, %d\n", updateStack - currStack);

          /*
          if(updateStack > 0) // it does not have return stmt
            {
              fprintf(codeStream, "\n# Local stack cleanup\n");
              fprintf(codeStream, "addiu $sp, $sp, %d\n", updateStack - currStack);
            }
          */
          break;
        }
        case ExpressionStatementK:
        {
          if(localCodeGen(t->attr.exprStmt.expr, codeStream, currStack, 0) != currStack)
            DONT_OCCUR_PRINT;
          break;
        }
        case SelectionStatementK:
        {
          fprintf(codeStream, "\n# Selection Statement\n");
          fprintf(codeStream, "# Selection Statement Expression\n");
          if(localCodeGen(t->attr.selectStmt.expr, codeStream, currStack, 0) != currStack)
            DONT_OCCUR_PRINT;
          int L_exit = labelAlloc(), L_false = labelAlloc();
          fprintf(codeStream, "beqz $v0, L%d\n", L_false);
          fprintf(codeStream, "# Selection Statement If Statement\n");
          if(localCodeGen(t->attr.selectStmt.if_stmt, codeStream, currStack, 1) != currStack)
            DONT_OCCUR_PRINT;
          fprintf(codeStream, "j L%d\n", L_exit);
          fprintf(codeStream, "L%d:\n", L_false);
          fprintf(codeStream, "# Selection Statement Else Statement\n");
          if(localCodeGen(t->attr.selectStmt.else_stmt, codeStream, currStack, 1) != currStack)
            DONT_OCCUR_PRINT;
          fprintf(codeStream, "L%d:\n", L_exit);
          break;
        }
        case IterationStatementK:
        {
          fprintf(codeStream, "\n# Iteration Statement\n");
          int L_cmp = labelAlloc(), L_loop = labelAlloc();
          fprintf(codeStream, "j L%d\n", L_cmp);
          fprintf(codeStream, "L%d:\n", L_loop);
          fprintf(codeStream, "# Iteration Statement Loop Statement\n");
          if(localCodeGen(t->attr.iterStmt.loop_stmt, codeStream, currStack, 1) != currStack)
            DONT_OCCUR_PRINT;
          fprintf(codeStream, "L%d:\n", L_cmp);
          fprintf(codeStream, "# Iteration Statement Expression\n");
          if(localCodeGen(t->attr.iterStmt.expr, codeStream, currStack, 0) != currStack)
            DONT_OCCUR_PRINT;
          fprintf(codeStream, "bnez $v0, L%d\n", L_loop);
          break;
        }
        case ReturnStatementK:
        {
          // TODO: review this
          // ex) have to jr immediatly (but have to clean stack with prev value
          // of registers. no need to load. just roll up the stack.)
          // int f(int i) {
          //   if(i) {
          //     int j;
          //     return 1;
          //   }
          //   return 0;
          // }
          if(t->attr.retStmt.expr != NULL)
            if(localCodeGen(t->attr.retStmt.expr, codeStream, currStack, 0) != currStack)
              DONT_OCCUR_PRINT;

          fprintf(codeStream, "j L%d\n", L_cleanup);

          break;

          /*
          // cleanup
          fprintf(codeStream, "\n# Stack cleanup\n");

          // return to original sp
          fprintf(codeStream, "addiu $sp, $sp, %d\n", currStack - 10 * regSize);

          // load register $fp
          fprintf(codeStream, "lw $fp, %d($sp)\n", 0 * regSize);
          // load registers $s0~$s7
          int i;
          for(i=0; i<8; ++i)
            fprintf(codeStream, "lw $s%d, %d($sp)\n", i, (i+1) * regSize);
          // load register $ra
          fprintf(codeStream, "lw $ra, %d($sp)\n", 9 * regSize);

          // free stack
          fprintf(codeStream, "addiu $sp, $sp, %d\n", 10 * regSize);

          // return
          fprintf(codeStream, "\n# Return to caller\n");
          fprintf(codeStream, "jr $ra\n\n");
          */

          // Optimization: do not need to check other stmts
          //return 0;
        }

        case AssignExpressionK:
        {
          if(localCodeGen(t->attr.assignStmt.expr, codeStream, currStack, 0) != currStack)
            DONT_OCCUR_PRINT;
          if (t->attr.assignStmt._var->nodeKind == VariableK)
            {
              fprintf(codeStream,
                      t->attr.assignStmt._var->symbolInfo->attr.intInfo.globalFlag ?
                      "sw $v0, %d\n" : "sw $v0, %d($fp)\n",
                      t->attr.assignStmt._var->symbolInfo->attr.intInfo.memloc);
            }
          else if (t->attr.assignStmt._var->nodeKind == ArrayK)
            {
              fprintf(codeStream, "move $s1, $v0\n");
              {
                TreeNode* arr = t->attr.assignStmt._var;
                if(localCodeGen(arr->attr.arr.arr_expr, codeStream, currStack, 0) != currStack)
                  DONT_OCCUR_PRINT;
                fprintf(codeStream, "li $s0, %lu\n", sizeof(int));
                fprintf(codeStream, "mul $s0, $v0, $s0\n");
                if(localCodeGen(arr->attr.arr._var, codeStream, currStack, 0) != currStack)
                  DONT_OCCUR_PRINT;
                fprintf(codeStream, "add $v0, $v0, $s0\n");
              }
              /*
              if(localCodeGen(t->attr.assignStmt._var, codeStream, currStack) != currStack)
                DONT_OCCUR_PRINT;*/
              fprintf(codeStream, "sw $s1, 0($v0)\n");
              fprintf(codeStream, "move $v0, $s1\n");
            }
          else
            DONT_OCCUR_PRINT;
          break;
        }
        case ComparisonExpressionK:
        {
          if(localCodeGen(t->attr.cmpExpr.lexpr, codeStream, currStack, 0) != currStack)
            DONT_OCCUR_PRINT;
          fprintf(codeStream, "addiu $sp, $sp, -%lu\n", sizeof(int));
          fprintf(codeStream, "sw $v0, 0($sp)\n");
          currStack += sizeof(int);

          if(localCodeGen(t->attr.cmpExpr.rexpr, codeStream, currStack, 0) != currStack)
            DONT_OCCUR_PRINT;
          fprintf(codeStream, "lw $s0, 0($sp)\n");
          fprintf(codeStream, "addiu $sp, $sp, %lu\n", sizeof(int));
          currStack -= sizeof(int);

          switch(t->attr.cmpExpr.op->attr.TOK)
            {
            case LT: fprintf(codeStream, "slt $v0, $s0, $v0\n"); break;
            case LE: fprintf(codeStream, "sle $v0, $s0, $v0\n"); break;
            case GT: fprintf(codeStream, "sgt $v0, $s0, $v0\n"); break;
            case GE: fprintf(codeStream, "sge $v0, $s0, $v0\n"); break;
            case EQ: fprintf(codeStream, "seq $v0, $s0, $v0\n"); break;
            case NE: fprintf(codeStream, "sne $v0, $s0, $v0\n"); break;
            default: DONT_OCCUR_PRINT;
            }
          break;
        }
        case AdditiveExpressionK:
        {
          if(localCodeGen(t->attr.addExpr.lexpr, codeStream, currStack, 0) != currStack)
            DONT_OCCUR_PRINT;
          fprintf(codeStream, "addiu $sp, $sp, -%lu\n", sizeof(int));
          fprintf(codeStream, "sw $v0, 0($sp)\n");
          currStack += sizeof(int);

          if(localCodeGen(t->attr.addExpr.rexpr, codeStream, currStack, 0) != currStack)
            DONT_OCCUR_PRINT;
          fprintf(codeStream, "lw $s0, 0($sp)\n");
          fprintf(codeStream, "addiu $sp, $sp, %lu\n", sizeof(int));
          currStack -= sizeof(int);

          switch(t->attr.addExpr.op->attr.TOK)
            {
            case PLUS: fprintf(codeStream, "add $v0, $s0, $v0\n"); break;
            case MINUS: fprintf(codeStream, "sub $v0, $s0, $v0\n"); break;
            default: DONT_OCCUR_PRINT;
            }
          break;
          //return currStack; //break;
        }
        case MultiplicativeExpressionK:
        {
          if(localCodeGen(t->attr.multExpr.lexpr, codeStream, currStack, 0) != currStack)
            DONT_OCCUR_PRINT;
          fprintf(codeStream, "addiu $sp, $sp, -%lu\n", sizeof(int));
          fprintf(codeStream, "sw $v0, 0($sp)\n");
          currStack += sizeof(int);

          if(localCodeGen(t->attr.multExpr.rexpr, codeStream, currStack, 0) != currStack)
            DONT_OCCUR_PRINT;
          fprintf(codeStream, "lw $s0, 0($sp)\n");
          fprintf(codeStream, "addiu $sp, $sp, %lu\n", sizeof(int));
          currStack -= sizeof(int);

          switch(t->attr.multExpr.op->attr.TOK)
            {
            case TIMES: fprintf(codeStream, "mul $v0, $s0, $v0\n"); break;
            case OVER: fprintf(codeStream, "div $v0, $s0, $v0\n"); break;
            default: DONT_OCCUR_PRINT;
            }
          break;
        }

        case CallK:
        {
          int accLoc = 0, i;
          TreeNode *expr;
          if (!strcmp(t->attr.call._var->attr.ID, "input"))
            {
              // print "input : "
              fprintf(codeStream, "\n# input\n");
              fprintf(codeStream, "li $v0, 4\n");
              fprintf(codeStream, "la $a0, input_str\n");
              fprintf(codeStream, "syscall\n");
              // read_int
              fprintf(codeStream, "li $v0, 5\n");
              fprintf(codeStream, "syscall\n");
            }
          else if (!strcmp(t->attr.call._var->attr.ID, "output"))
            {
              // print "output : "
              fprintf(codeStream, "\n# output\n");
              fprintf(codeStream, "move $t0, $v0\n");
              fprintf(codeStream, "li $v0, 4\n");
              fprintf(codeStream, "la $a0, output_str\n");
              fprintf(codeStream, "syscall\n");
              fprintf(codeStream, "move $v0, $t0\n");
              // print_int
              if (localCodeGen(t->attr.call.expr_list, codeStream, currStack + accLoc, 1) != (currStack + accLoc))
                DONT_OCCUR_PRINT;
              fprintf(codeStream, "move $a0, $v0\n"); // the argument
              fprintf(codeStream, "li $v0, 1\n");
              fprintf(codeStream, "syscall\n");
              // print newline
              fprintf(codeStream, "li $v0, 4\n");
              fprintf(codeStream, "la $a0, newline\n");
              fprintf(codeStream, "syscall\n");
            }
          else
            {
              for(expr = t->attr.call.expr_list, i = 0;
                  expr != NULL;
                  expr = expr->sibling, i++)
                {
                  int size;
                  switch(t->attr.call._var->symbolInfo->attr.funcInfo.paramTypeList[i])
                    {
                    case IntT: size = sizeof(int); break;
                    case IntArrayT: size = regSize; break;
                    default: DONT_OCCUR_PRINT;
                    }

                  if(localCodeGen(expr, codeStream, currStack + accLoc, 0) != (currStack + accLoc))
                    DONT_OCCUR_PRINT;

                  fprintf(codeStream, "addiu $sp, $sp, %d\n", -size);
                  fprintf(codeStream, "sw $v0, 0($sp)\n");
                  accLoc += size;
                }
              fprintf(codeStream, "jal %s\n", t->attr.call._var->attr.ID);
              fprintf(codeStream, "addiu $sp, $sp, %d\n", accLoc);
            }

          break;
          /* For fixing a bug about iteration of sibling in parameter passing. */
          //return currStack;//break;
        }

        case ArrayK:
        {
          if(localCodeGen(t->attr.arr.arr_expr, codeStream, currStack, 0) != currStack)
            DONT_OCCUR_PRINT;
          fprintf(codeStream, "li $s0, %lu\n", sizeof(int));
          fprintf(codeStream, "mul $s0, $v0, $s0\n");
          if(localCodeGen(t->attr.arr._var, codeStream, currStack, 0) != currStack)
            DONT_OCCUR_PRINT;
          fprintf(codeStream, "add $v0, $v0, $s0\n");
          fprintf(codeStream, "lw $v0, 0($v0)\n");
          
          break;
          /* For fixing a bug about iteration of sibling in parameter passing. */
          //return currStack;//break;
        }
        case VariableK:
        {
          switch(t->symbolInfo->nodeType)
            {
            case IntT:
              fprintf(codeStream,
                      t->symbolInfo->attr.intInfo.globalFlag ? "lw $v0, %d\n" : "lw $v0, %d($fp)\n",
                      t->symbolInfo->attr.intInfo.memloc);
              break;
            case IntArrayT:
              fprintf(codeStream,
                      t->symbolInfo->attr.arrInfo.globalFlag ? "li $v0, %d\n" : "addiu $v0, $fp, %d\n",
                      t->symbolInfo->attr.arrInfo.memloc);
              if (t->symbolInfo->attr.arrInfo.isParam)
                fprintf(codeStream, "lw $v0, 0($v0)\n");
              break;
            default:
              DONT_OCCUR_PRINT;
            }

          break;
          /* For fixing a bug about iteration of sibling in parameter passing. */
          //return currStack;//break;
        }
        case ConstantK:
        {
          fprintf(codeStream, "li $v0, %d\n", t->attr.NUM);
          
          break;
          /* For fixing a bug about iteration of sibling in parameter passing. */
          //return currStack;//break;
        }

        default:
          DONT_OCCUR_PRINT;
        }
    }
  return currStack;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, -0x30(%rbp)
testq %rdi, %rdi
je 0x2e73
movl %ecx, %r8d
movq %rsi, %r15
movq %rdi, %r12
leaq 0x42a8(%rip), %r14      # 0x65b4
leaq 0x4397(%rip), %r13      # 0x66aa
movl %ecx, -0x34(%rbp)
movl 0xc(%r12), %eax
decl %eax
cmpl $0x11, %eax
ja 0x2e5a
movslq (%r14,%rax,4), %rax
addq %r14, %rax
jmpq *%rax
movl $0x1e, %esi
movl $0x1, %edx
leaq 0x447a(%rip), %rdi      # 0x67ba
movq %r15, %rcx
movl %r8d, %ebx
callq 0x11c0
movq %r15, %rdi
movq %r13, %rsi
movl $0xfffffffc, %edx       # imm = 0xFFFFFFFC
xorl %eax, %eax
callq 0x1120
movl %ebx, %r8d
movq -0x30(%rbp), %rcx
movl $0xfffffffc, %eax       # imm = 0xFFFFFFFC
subl %ecx, %eax
addl $0x4, %ecx
movq %rcx, -0x30(%rbp)
jmp 0x2788
movq 0x20(%r12), %rax
movq 0x20(%rax), %rbx
movq %rbx, %rdi
leaq 0x4021(%rip), %rsi      # 0x63ab
callq 0x1110
testl %eax, %eax
je 0x2af6
movq %rbx, %rdi
leaq 0x4041(%rip), %rsi      # 0x63e2
callq 0x1110
testl %eax, %eax
je 0x2cb0
movq 0x28(%r12), %r14
xorl %r13d, %r13d
testq %r14, %r14
je 0x2414
movq -0x30(%rbp), %rbx
leal (%rbx,%r13), %edx
movq %r14, %rdi
movq %r15, %rsi
xorl %ecx, %ecx
callq 0x22de
movq %r15, %rdi
leaq 0x42d0(%rip), %rsi      # 0x66aa
movl $0xfffffffc, %edx       # imm = 0xFFFFFFFC
xorl %eax, %eax
callq 0x1120
movl $0xf, %esi
movl $0x1, %edx
leaq 0x45ca(%rip), %rdi      # 0x69c1
movq %r15, %rcx
callq 0x11c0
addl $0x4, %r13d
movq (%r14), %r14
testq %r14, %r14
jne 0x23bf
movq 0x20(%r12), %rax
movq 0x20(%rax), %rbx
movq %r15, %rdi
leaq 0x473a(%rip), %rsi      # 0x6b58
movq %rbx, %rdx
xorl %eax, %eax
callq 0x1120
movq %r15, %rdi
leaq 0x4278(%rip), %rsi      # 0x66aa
movl %r13d, %edx
xorl %eax, %eax
callq 0x1120
movl -0x34(%rbp), %r8d
leaq 0x416d(%rip), %r14      # 0x65b4
jmp 0x2e5a
movl %r8d, %r13d
movq 0x20(%r12), %rdi
movq %r15, %rsi
movq -0x30(%rbp), %rbx
movl %ebx, %edx
xorl %ecx, %ecx
callq 0x22de
movl $0x4, %edx
movq %r15, %rdi
leaq 0x4538(%rip), %rsi      # 0x69ab
xorl %eax, %eax
callq 0x1120
movl $0xf, %esi
movl $0x1, %edx
leaq 0x4536(%rip), %rdi      # 0x69c1
movq %r15, %rcx
callq 0x11c0
leal 0x4(%rbx), %edx
movq 0x30(%r12), %rdi
movq %r15, %rsi
xorl %ecx, %ecx
callq 0x22de
movl $0xf, %esi
movl $0x1, %edx
leaq 0x451b(%rip), %rdi      # 0x69d1
movq %r15, %rcx
callq 0x11c0
movl $0x4, %edx
movq %r15, %rdi
leaq 0x4514(%rip), %rsi      # 0x69e1
xorl %eax, %eax
callq 0x1120
movq 0x28(%r12), %rax
movl 0x20(%rax), %eax
cmpl $0x10e, %eax            # imm = 0x10E
je 0x2b88
cmpl $0x10d, %eax            # imm = 0x10D
jne 0x2e57
movl $0x12, %esi
movl $0x1, %edx
leaq 0x458b(%rip), %rdi      # 0x6a8e
jmp 0x2e4f
movq 0x28(%r12), %rdi
movq %r15, %rsi
movq -0x30(%rbp), %rbx
movl %ebx, %edx
xorl %ecx, %ecx
movl %r8d, %r13d
callq 0x22de
movl $0x4, %edx
movq %r15, %rdi
leaq 0x442a(%rip), %rsi      # 0x6959
xorl %eax, %eax
callq 0x1120
movl $0x12, %esi
movl $0x1, %edx
leaq 0x441f(%rip), %rdi      # 0x6966
movq %r15, %rcx
callq 0x11c0
movq 0x20(%r12), %rdi
movq %r15, %rsi
movl %ebx, %edx
xorl %ecx, %ecx
callq 0x22de
movl $0x12, %esi
movl $0x1, %edx
leaq 0x4408(%rip), %rdi      # 0x6979
movq %r15, %rcx
callq 0x11c0
movl $0xf, %esi
movl $0x1, %edx
leaq 0x45d6(%rip), %rdi      # 0x6b60
jmp 0x2e4f
movl $0x16, %esi
movl $0x1, %edx
leaq 0x4255(%rip), %rdi      # 0x67f5
movq %r15, %rcx
movl %r8d, %r13d
callq 0x11c0
movq 0x20(%r12), %rdi
movq %r15, %rsi
movq -0x30(%rbp), %r14
movl %r14d, %edx
movl $0x1, %ecx
callq 0x22de
movl %eax, %ebx
movq 0x28(%r12), %rdi
movq %r15, %rsi
movl %eax, %edx
movl $0x1, %ecx
callq 0x22de
movl $0x17, %esi
movl $0x1, %edx
leaq 0x4221(%rip), %rdi      # 0x680c
movq %r15, %rcx
callq 0x11c0
subl %r14d, %ebx
movq %r15, %rdi
leaq 0x40aa(%rip), %rsi      # 0x66aa
movl %ebx, %edx
leaq 0x3fab(%rip), %r14      # 0x65b4
jmp 0x2816
movl $0x17, %esi
movl $0x1, %edx
leaq 0x429f(%rip), %rdi      # 0x68be
movq %r15, %rcx
callq 0x11c0
movl 0x8afe(%rip), %r14d     # 0xb12c
leal 0x1(%r14), %r13d
leal 0x2(%r14), %eax
movl %eax, 0x8af0(%rip)      # 0xb12c
movq %r15, %rdi
leaq 0x424b(%rip), %rsi      # 0x6891
movl %r14d, %edx
xorl %eax, %eax
callq 0x1120
movq %r15, %rdi
leaq 0x40f4(%rip), %rsi      # 0x674e
movl %r13d, %edx
xorl %eax, %eax
callq 0x1120
movl $0x25, %esi
movl $0x1, %edx
leaq 0x4261(%rip), %rdi      # 0x68d6
movq %r15, %rcx
callq 0x11c0
movq 0x28(%r12), %rdi
movq %r15, %rsi
movq -0x30(%rbp), %rbx
movq %rbx, -0x30(%rbp)
movl %ebx, %edx
movl $0x1, %ecx
callq 0x22de
movq %r15, %rdi
leaq 0x40ab(%rip), %rsi      # 0x674e
movl %r14d, %edx
leaq 0x3f07(%rip), %r14      # 0x65b4
xorl %eax, %eax
callq 0x1120
movl $0x21, %esi
movl $0x1, %edx
leaq 0x4237(%rip), %rdi      # 0x68fc
movq %r15, %rcx
callq 0x11c0
movq 0x20(%r12), %rdi
movq %r15, %rsi
movl %ebx, %edx
xorl %ecx, %ecx
callq 0x22de
movq %r15, %rdi
leaq 0x4236(%rip), %rsi      # 0x691e
movl %r13d, %edx
jmp 0x2962
movq 0x18(%r12), %rax
movl (%rax), %ecx
cmpl $0x5, %ecx
je 0x2b9e
cmpl $0x4, %ecx
jne 0x2e5a
cmpl $0x0, 0x10(%rax)
leaq 0x445c(%rip), %rsi      # 0x6b70
leaq 0x4461(%rip), %rcx      # 0x6b7c
cmoveq %rcx, %rsi
movl 0xc(%rax), %edx
movq %r15, %rdi
jmp 0x2831
movq 0x28(%r12), %rax
movq 0x18(%rax), %rax
movl 0x14(%rax), %r14d
leal (,%r14,4), %ebx
movl $0x1b, %esi
movl $0x1, %edx
leaq 0x4089(%rip), %rdi      # 0x67d9
movq %r15, %rcx
callq 0x11c0
negl %ebx
movq %r15, %rdi
movq %r13, %rsi
movl %ebx, %edx
movq -0x30(%rbp), %r13
movl -0x34(%rbp), %ebx
xorl %eax, %eax
callq 0x1120
movl %ebx, %r8d
leal (%r13,%r14,4), %r13d
leaq 0x3e35(%rip), %r14      # 0x65b4
movq %r13, -0x30(%rbp)
movl %r13d, %eax
negl %eax
movq 0x28(%r12), %rcx
movq 0x18(%rcx), %rcx
movl %eax, 0xc(%rcx)
jmp 0x2e5a
movl %r8d, %r13d
movq 0x20(%r12), %rdi
testq %rdi, %rdi
je 0x27b4
movq %r15, %rsi
movq -0x30(%rbp), %rdx
xorl %ecx, %ecx
callq 0x22de
movl 0x896e(%rip), %edx      # 0xb128
movq %r15, %rdi
leaq 0x40cd(%rip), %rsi      # 0x6891
jmp 0x2816
movl %r8d, %r13d
movq 0x20(%r12), %rdi
movq %r15, %rsi
movq -0x30(%rbp), %rdx
xorl %ecx, %ecx
callq 0x22de
movq 0x28(%r12), %rax
movl 0xc(%rax), %ecx
cmpl $0x10, %ecx
je 0x2bd8
cmpl $0xf, %ecx
jne 0x2e57
movq 0x18(%rax), %rax
cmpl $0x0, 0x10(%rax)
leaq 0x4128(%rip), %rsi      # 0x692d
leaq 0x412d(%rip), %rcx      # 0x6939
cmoveq %rcx, %rsi
movl 0xc(%rax), %edx
movq %r15, %rdi
xorl %eax, %eax
callq 0x1120
jmp 0x2e57
movl 0x20(%r12), %edx
movq %r15, %rdi
leaq 0x435c(%rip), %rsi      # 0x6b8d
xorl %eax, %eax
movl %r8d, %ebx
jmp 0x2967
movq 0x20(%r12), %rdi
movq %r15, %rsi
movq -0x30(%rbp), %rdx
movq %rdx, -0x30(%rbp)
xorl %ecx, %ecx
movl %r8d, %ebx
callq 0x22de
jmp 0x296c
movl $0x17, %esi
movl $0x1, %edx
leaq 0x3fb9(%rip), %rdi      # 0x6824
movq %r15, %rcx
callq 0x11c0
movl $0x21, %esi
movl $0x1, %edx
leaq 0x3fb8(%rip), %rdi      # 0x683c
movq %r15, %rcx
callq 0x11c0
movq 0x20(%r12), %rdi
movq %r15, %rsi
movq -0x30(%rbp), %r14
movl %r14d, %edx
xorl %ecx, %ecx
callq 0x22de
movl 0x8884(%rip), %ebx      # 0xb12c
leal 0x1(%rbx), %r13d
leal 0x2(%rbx), %eax
movl %eax, 0x8877(%rip)      # 0xb12c
movq %r15, %rdi
leaq 0x3f9f(%rip), %rsi      # 0x685e
movl %r13d, %edx
xorl %eax, %eax
callq 0x1120
movl $0x23, %esi
movl $0x1, %edx
leaq 0x3f93(%rip), %rdi      # 0x686d
movq %r15, %rcx
callq 0x11c0
movq 0x28(%r12), %rdi
movq %r15, %rsi
movl %r14d, %edx
movl $0x1, %ecx
callq 0x22de
movq %r15, %rdi
leaq 0x3f90(%rip), %rsi      # 0x6891
movl %ebx, %edx
xorl %eax, %eax
callq 0x1120
movq %r15, %rdi
leaq 0x3e3a(%rip), %rsi      # 0x674e
movl %r13d, %edx
movq %r14, %r13
leaq 0x3c93(%rip), %r14      # 0x65b4
xorl %eax, %eax
callq 0x1120
movl $0x25, %esi
movl $0x1, %edx
leaq 0x3f5f(%rip), %rdi      # 0x6898
movq %r15, %rcx
callq 0x11c0
movq 0x30(%r12), %rdi
movq %r15, %rsi
movl %r13d, %edx
movl $0x1, %ecx
callq 0x22de
movq %r15, %rdi
leaq 0x3dee(%rip), %rsi      # 0x674e
movl %ebx, %edx
movl -0x34(%rbp), %ebx
xorl %eax, %eax
callq 0x1120
movl %ebx, %r8d
jmp 0x2e5a
movl %r8d, %r13d
movq 0x20(%r12), %rdi
movq %r15, %rsi
movq -0x30(%rbp), %rbx
movl %ebx, %edx
xorl %ecx, %ecx
callq 0x22de
movl $0x4, %edx
movq %r15, %rdi
leaq 0x4010(%rip), %rsi      # 0x69ab
xorl %eax, %eax
callq 0x1120
movl $0xf, %esi
movl $0x1, %edx
leaq 0x400e(%rip), %rdi      # 0x69c1
movq %r15, %rcx
callq 0x11c0
leal 0x4(%rbx), %edx
movq 0x30(%r12), %rdi
movq %r15, %rsi
xorl %ecx, %ecx
callq 0x22de
movl $0xf, %esi
movl $0x1, %edx
leaq 0x3ff3(%rip), %rdi      # 0x69d1
movq %r15, %rcx
callq 0x11c0
movl $0x4, %edx
movq %r15, %rdi
leaq 0x3fec(%rip), %rsi      # 0x69e1
xorl %eax, %eax
callq 0x1120
movq 0x28(%r12), %rax
movl 0x20(%rax), %eax
cmpl $0x10c, %eax            # imm = 0x10C
je 0x2c9a
cmpl $0x10b, %eax            # imm = 0x10B
jne 0x2e57
movl $0x12, %esi
movl $0x1, %edx
leaq 0x403d(%rip), %rdi      # 0x6a68
jmp 0x2e4f
movl %r8d, %r13d
movq 0x20(%r12), %rdi
movq %r15, %rsi
movq -0x30(%rbp), %rbx
movl %ebx, %edx
xorl %ecx, %ecx
callq 0x22de
movl $0x4, %edx
movq %r15, %rdi
leaq 0x3f54(%rip), %rsi      # 0x69ab
xorl %eax, %eax
callq 0x1120
movl $0xf, %esi
movl $0x1, %edx
leaq 0x3f52(%rip), %rdi      # 0x69c1
movq %r15, %rcx
callq 0x11c0
leal 0x4(%rbx), %edx
movq 0x30(%r12), %rdi
movq %r15, %rsi
xorl %ecx, %ecx
callq 0x22de
movl $0xf, %esi
movl $0x1, %edx
leaq 0x3f37(%rip), %rdi      # 0x69d1
movq %r15, %rcx
callq 0x11c0
movl $0x4, %edx
movq %r15, %rdi
leaq 0x3f30(%rip), %rsi      # 0x69e1
xorl %eax, %eax
callq 0x1120
movq 0x28(%r12), %rax
movl 0x20(%rax), %eax
movl $0xfffffef1, %ecx       # imm = 0xFFFFFEF1
addl %ecx, %eax
cmpl $0x5, %eax
ja 0x2e57
leaq 0x3b25(%rip), %rcx      # 0x65fc
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x12, %esi
movl $0x1, %edx
leaq 0x3f05(%rip), %rdi      # 0x69f6
jmp 0x2e4f
movl $0x9, %esi
movl $0x1, %edx
leaq 0x3fad(%rip), %rdi      # 0x6ab4
movq %r15, %rcx
callq 0x11c0
movl $0xa, %esi
movl $0x1, %edx
leaq 0x3f9e(%rip), %rdi      # 0x6abe
movq %r15, %rcx
callq 0x11c0
movl $0x12, %esi
movl $0x1, %edx
leaq 0x3f90(%rip), %rdi      # 0x6ac9
movq %r15, %rcx
callq 0x11c0
movl $0x8, %esi
movl $0x1, %edx
leaq 0x3f8a(%rip), %rbx      # 0x6adc
movq %rbx, %rdi
movq %r15, %rcx
callq 0x11c0
movl $0xa, %esi
movl $0x1, %edx
leaq 0x3f77(%rip), %rdi      # 0x6ae5
movq %r15, %rcx
callq 0x11c0
movl $0x8, %esi
movl $0x1, %edx
movq %rbx, %rdi
jmp 0x2de4
movl $0x12, %esi
movl $0x1, %edx
leaq 0x3f08(%rip), %rdi      # 0x6aa1
jmp 0x2e4f
movl %r8d, %r13d
cmpl $0x0, 0x10(%rax)
leaq 0x3fe1(%rip), %rsi      # 0x6b8d
leaq 0x3fe6(%rip), %rcx      # 0x6b99
cmoveq %rcx, %rsi
movl 0xc(%rax), %edx
movq %r15, %rdi
xorl %eax, %eax
callq 0x1120
movq 0x18(%r12), %rax
cmpl $0x0, 0x8(%rax)
jne 0x2579
jmp 0x2e57
movl $0xe, %esi
movl $0x1, %edx
leaq 0x3d61(%rip), %rdi      # 0x694a
movq %r15, %rcx
callq 0x11c0
movq -0x30(%rbp), %r14
movq 0x28(%r12), %rbx
movq 0x28(%rbx), %rdi
movq %r15, %rsi
movl %r14d, %edx
xorl %ecx, %ecx
callq 0x22de
movl $0x4, %edx
movq %r15, %rdi
leaq 0x3d3f(%rip), %rsi      # 0x6959
xorl %eax, %eax
callq 0x1120
movl $0x12, %esi
movl $0x1, %edx
leaq 0x3d34(%rip), %rdi      # 0x6966
movq %r15, %rcx
callq 0x11c0
movq 0x20(%rbx), %rdi
movq %r14, %rdx
leaq 0x396c(%rip), %r14      # 0x65b4
movq %r15, %rsi
xorl %ecx, %ecx
callq 0x22de
movl $0x12, %esi
movl $0x1, %edx
leaq 0x3d16(%rip), %rdi      # 0x6979
movq %r15, %rcx
callq 0x11c0
movl $0xf, %esi
movl $0x1, %edx
leaq 0x3d10(%rip), %rdi      # 0x698c
movq %r15, %rcx
callq 0x11c0
movl $0xe, %esi
movl $0x1, %edx
leaq 0x3d07(%rip), %rdi      # 0x699c
jmp 0x2e4f
movl $0x12, %esi
movl $0x1, %edx
leaq 0x3dd0(%rip), %rdi      # 0x6a7b
jmp 0x2e4f
movl $0xa, %esi
movl $0x1, %edx
leaq 0x3e2f(%rip), %rdi      # 0x6af0
movq %r15, %rcx
callq 0x11c0
movl $0xe, %esi
movl $0x1, %edx
leaq 0x3e21(%rip), %rdi      # 0x6afb
movq %r15, %rcx
callq 0x11c0
movl $0xa, %esi
movl $0x1, %edx
leaq 0x3dcb(%rip), %rbx      # 0x6abe
movq %rbx, %rdi
movq %r15, %rcx
callq 0x11c0
movl $0x13, %esi
movl $0x1, %edx
leaq 0x3dfb(%rip), %rdi      # 0x6b0a
movq %r15, %rcx
callq 0x11c0
movl $0x8, %esi
movl $0x1, %edx
leaq 0x3db4(%rip), %r13      # 0x6adc
movq %r13, %rdi
movq %r15, %rcx
callq 0x11c0
movl $0xe, %esi
movl $0x1, %edx
leaq 0x3dda(%rip), %rdi      # 0x6b1e
movq %r15, %rcx
callq 0x11c0
movq 0x28(%r12), %rdi
movq %r15, %rsi
movq -0x30(%rbp), %rdx
movl $0x1, %ecx
callq 0x22de
movl $0xe, %esi
movl $0x1, %edx
leaq 0x3dba(%rip), %rdi      # 0x6b2d
movq %r15, %rcx
callq 0x11c0
movl $0xa, %esi
movl $0x1, %edx
leaq 0x3db0(%rip), %rdi      # 0x6b3c
movq %r15, %rcx
callq 0x11c0
movl $0x8, %esi
movl $0x1, %edx
movq %r13, %rdi
movq %r15, %rcx
callq 0x11c0
movl $0xa, %esi
movl $0x1, %edx
movq %rbx, %rdi
movq %r15, %rcx
callq 0x11c0
movl $0x10, %esi
movl $0x1, %edx
leaq 0x3d78(%rip), %rdi      # 0x6b47
movq %r15, %rcx
callq 0x11c0
movl $0x8, %esi
movl $0x1, %edx
movq %r13, %rdi
movq %r15, %rcx
callq 0x11c0
movl -0x34(%rbp), %r8d
jmp 0x2e5a
movl $0x12, %esi
movl $0x1, %edx
leaq 0x3c3f(%rip), %rdi      # 0x6a42
jmp 0x2e4f
movl $0x12, %esi
movl $0x1, %edx
leaq 0x3c06(%rip), %rdi      # 0x6a1c
jmp 0x2e4f
movl $0x12, %esi
movl $0x1, %edx
leaq 0x3c06(%rip), %rdi      # 0x6a2f
jmp 0x2e4f
movl $0x12, %esi
movl $0x1, %edx
leaq 0x3bcd(%rip), %rdi      # 0x6a09
jmp 0x2e4f
movl $0x12, %esi
movl $0x1, %edx
leaq 0x3c06(%rip), %rdi      # 0x6a55
movq %r15, %rcx
callq 0x11c0
movl %r13d, %r8d
testl %r8d, %r8d
je 0x2e73
movq (%r12), %r12
testq %r12, %r12
leaq 0x383d(%rip), %r13      # 0x66aa
jne 0x2316
movq -0x30(%rbp), %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop