// File: rfotino[P]consolite-compiler/src/syntax.cpp
// Function: FunctionToken::output(Parser*)
void FunctionToken::output(Parser *parser) {
  // Check if this is a builtin function, in which case we should
  // do nothing.
  if (isBuiltin(_name)) {
    return;
  }
  // Create an end label for the function, so if we return we can jump
  // to it without having to unwind the stack each time.
  std::string endLabel = parser->getUnusedLabel(_name + "_end");
  // Create a label for the function so that we can CALL it.
  parser->writeln(_name + ":");
  // Assign registers or stack positions to parameters. Parameters can
  // be stored in registers "A" through "D", and if there are more than
  // 4 parameters they will be stored on the stack before the return
  // address. The return address is stored at FP, so the first
  // overflow parameter will be stored at -2, the next at -4, etc.
  std::string reg = "A";
  int offset = -ADDRESS_SIZE;
  int numOverflowParams = 0;
  for (auto param : _parameters) {
    if (reg[0] <= 'D') {
      param->setReg(reg);
      reg[0]++;
    } else {
      param->setOffset(offset);
      offset -= DATA_SIZE;
      numOverflowParams++;
    }
  }
  // Assign registers or stack positions to local variables. Local
  // variables can be stored in registers "E" through "K", and if there
  // are more local variables than can fit in registers we store them
  // as frame pointer offsets. The offset starts at 0 and increases from
  // there.
  reg = "E";
  offset = 0;
  int extraParamOffset = 0;
  for (auto local : _localVars) {
    if (reg[0] <= 'K' && local->canBeReg()) {
      local->setReg(reg);
      // This is a callee-saved register, push it onto the stack and
      // make a note that we need to pop it later.
      parser->writeInst("PUSH " + reg);
      _savedRegisters.push(reg);
      extraParamOffset -= DATA_SIZE;
      // Increment the register
      reg[0]++;
    } else {
      local->setOffset(offset);
      offset += DATA_SIZE;
    }
    // If this is an array, reserve space for the array's data.
    if (local->type().isArray()) {
      // The data offset is at the current stack offset + DATA_SIZE.
      // We must add DATA_SIZE because the stack pointer points at an
      // address that's in use, and we want the next unused address.
      local->setDataOffset(offset + DATA_SIZE);
      offset += local->type().arraySize() * DATA_SIZE;
    }
  }
  // Save the previous value of the frame pointer.
  parser->writeInst("PUSH FP");
  _savedRegisters.push("FP");
  extraParamOffset -= DATA_SIZE;
  // Set the frame pointer to the stack's current location.
  parser->writeInst("MOV FP SP");
  // Store parameters on the stack if they are currently stored in
  // registers but are flagged as needing their own address. Also fix
  // offset for parameters on the stack based on the number of saved
  // registers.
  for (auto param : _parameters) {
    if (param->isReg() && !param->canBeReg()) {
      parser->writeInst("PUSH " + param->getReg());
      param->setOffset(offset);
      offset += DATA_SIZE;
    } else if (!param->isReg()) {
      param->setOffset(param->getOffset() + extraParamOffset);
    }
  }
  // Reserve space for the local variable storage on the stack.
  if (0 < offset) {
    parser->writeInst("MOVI L " + toHexStr(offset));
    parser->writeInst("ADD SP L");
  }

  // Outputs initial values of local variables.
  for (auto local : _localVars) {
    local->output(parser);
  }

  // Assign assembly-level labels to all label declarations.
  for (auto label : _labels) {
    std::string asmLabel = parser->getUnusedLabel(_name + "_" + label->name());
    label->setAsmLabel(asmLabel);
  }

  // Output assembly code for the rest of the statement types.
  for (auto statement : _statements) {
    statement->output(parser, shared_from_this(), endLabel);
  }

  // Unwind the stack, popping the saved registers, then return.
  // We have a label here so that when we have return statements
  // they can jump here without having to unwind the stack in
  // multiple places.
  parser->writeln(endLabel + ":");
  parser->writeInst("MOV SP FP");
  while (!_savedRegisters.empty()) {
    parser->writeInst("POP " + _savedRegisters.top());
    _savedRegisters.pop();
  }
  // If there are overflow parameters, pop them off the stack in
  // addition to jumping to the return address.
  if (0 < numOverflowParams) {
    parser->writeInst("RET " + toHexStr(numOverflowParams * DATA_SIZE, 2));
  } else {
    parser->writeInst("RET");
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x720, %rsp            # imm = 0x720
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x598(%rbp)
addq $0x58, %rdi
callq 0x6ce20
testb $0x1, %al
jne 0x295ed
jmp 0x295f2
jmp 0x2ab4e
movq -0x598(%rbp), %rsi
movq -0x10(%rbp), %rax
movq %rax, -0x5a8(%rbp)
addq $0x58, %rsi
leaq 0x4695c(%rip), %rdx     # 0x6ff6b
leaq -0x50(%rbp), %rdi
movq %rdi, -0x5a0(%rbp)
callq 0xdd40
movq -0x5a8(%rbp), %rsi
movq -0x5a0(%rbp), %rdx
leaq -0x30(%rbp), %rdi
callq 0xc3c0
jmp 0x29638
leaq -0x50(%rbp), %rdi
callq 0x8848
movq -0x598(%rbp), %rsi
movq -0x10(%rbp), %rax
movq %rax, -0x5b0(%rbp)
addq $0x58, %rsi
leaq 0x47fea(%rip), %rdx     # 0x71648
leaq -0x80(%rbp), %rdi
callq 0xdd40
jmp 0x29669
movq -0x5b0(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0xcc30
jmp 0x2967b
leaq -0x80(%rbp), %rdi
callq 0x8848
leaq -0xa1(%rbp), %rdi
movq %rdi, -0x5b8(%rbp)
callq 0x8760
movq -0x5b8(%rbp), %rdx
leaq 0x46246(%rip), %rsi     # 0x6f8eb
leaq -0xa0(%rbp), %rdi
callq 0xced0
jmp 0x296b3
leaq -0xa1(%rbp), %rdi
callq 0x8460
movq -0x598(%rbp), %rax
movl $0xfffffffe, -0xa8(%rbp) # imm = 0xFFFFFFFE
movl $0x0, -0xac(%rbp)
addq $0x78, %rax
movq %rax, -0xb8(%rbp)
movq -0xb8(%rbp), %rdi
callq 0x34430
movq %rax, -0xc0(%rbp)
movq -0xb8(%rbp), %rdi
callq 0x34460
movq %rax, -0xc8(%rbp)
leaq -0xc0(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x34490
testb $0x1, %al
jne 0x29727
jmp 0x29895
leaq -0xc0(%rbp), %rdi
callq 0x344d0
movq %rax, %rsi
leaq -0xd8(%rbp), %rdi
callq 0xee60
xorl %eax, %eax
movl %eax, %esi
leaq -0xa0(%rbp), %rdi
callq 0x8820
movq %rax, -0x5c0(%rbp)
jmp 0x2975b
movq -0x5c0(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x44, %eax
jg 0x2983a
leaq -0xd8(%rbp), %rdi
callq 0x34080
movq %rax, %rdi
addq $0x10, %rdi
leaq -0xa0(%rbp), %rsi
callq 0x344f0
jmp 0x2978f
xorl %eax, %eax
movl %eax, %esi
leaq -0xa0(%rbp), %rdi
callq 0x8820
movq %rax, -0x5c8(%rbp)
jmp 0x297a8
movq -0x5c8(%rbp), %rax
movb (%rax), %cl
addb $0x1, %cl
movb %cl, (%rax)
jmp 0x29878
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x8848
jmp 0x2ab6c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x2ab63
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x8848
jmp 0x2ab63
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0xa1(%rbp), %rdi
callq 0x8460
jmp 0x2ab63
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0xd400
jmp 0x2ab57
leaq -0xd8(%rbp), %rdi
callq 0x34080
movq %rax, %rdi
addq $0x10, %rdi
movl -0xa8(%rbp), %esi
callq 0x34520
jmp 0x2985a
movl -0xa8(%rbp), %eax
subl $0x2, %eax
movl %eax, -0xa8(%rbp)
movl -0xac(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xac(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0xd400
leaq -0xc0(%rbp), %rdi
callq 0x34540
jmp 0x2970b
leaq 0x46053(%rip), %rsi     # 0x6f8ef
leaq -0xa0(%rbp), %rdi
callq 0x8580
jmp 0x298aa
movq -0x598(%rbp), %rax
movl $0x0, -0xa8(%rbp)
movl $0x0, -0xdc(%rbp)
addq $0x90, %rax
movq %rax, -0xe8(%rbp)
movq -0xe8(%rbp), %rdi
callq 0x34560
movq %rax, -0xf0(%rbp)
movq -0xe8(%rbp), %rdi
callq 0x34590
movq %rax, -0xf8(%rbp)
leaq -0xf0(%rbp), %rdi
leaq -0xf8(%rbp), %rsi
callq 0x345c0
testb $0x1, %al
jne 0x29914
jmp 0x29be7
leaq -0xf0(%rbp), %rdi
callq 0x34600
movq %rax, %rsi
leaq -0x108(%rbp), %rdi
callq 0x34620
xorl %eax, %eax
movl %eax, %esi
leaq -0xa0(%rbp), %rdi
callq 0x8820
movq %rax, -0x5d0(%rbp)
jmp 0x29948
movq -0x5d0(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x4b, %eax
jg 0x29a86
leaq -0x108(%rbp), %rdi
callq 0x34650
movq %rax, %rdi
addq $0x10, %rdi
callq 0x34670
movb %al, -0x5d1(%rbp)
jmp 0x2997b
movb -0x5d1(%rbp), %al
testb $0x1, %al
jne 0x2998a
jmp 0x29a86
leaq -0x108(%rbp), %rdi
callq 0x34650
movq %rax, %rdi
addq $0x10, %rdi
leaq -0xa0(%rbp), %rsi
callq 0x344f0
jmp 0x299ab
movq -0x10(%rbp), %rax
movq %rax, -0x5e0(%rbp)
leaq 0x45786(%rip), %rsi     # 0x6f143
leaq -0x128(%rbp), %rdi
leaq -0xa0(%rbp), %rdx
callq 0xdc30
jmp 0x299d2
movq -0x5e0(%rbp), %rdi
leaq -0x128(%rbp), %rsi
callq 0xc600
jmp 0x299e7
leaq -0x128(%rbp), %rdi
callq 0x8848
movq -0x598(%rbp), %rdi
addq $0xf0, %rdi
leaq -0xa0(%rbp), %rsi
callq 0x33490
jmp 0x29a0f
movl -0xdc(%rbp), %eax
addl $-0x2, %eax
movl %eax, -0xdc(%rbp)
xorl %eax, %eax
movl %eax, %esi
leaq -0xa0(%rbp), %rdi
callq 0x8820
movq %rax, -0x5e8(%rbp)
jmp 0x29a37
movq -0x5e8(%rbp), %rax
movb (%rax), %cl
addb $0x1, %cl
movb %cl, (%rax)
jmp 0x29ab5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x2ab57
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x29bd6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x128(%rbp), %rdi
callq 0x8848
jmp 0x29bd6
leaq -0x108(%rbp), %rdi
callq 0x34650
movq %rax, %rdi
addq $0x10, %rdi
movl -0xa8(%rbp), %esi
callq 0x34520
jmp 0x29aa6
movl -0xa8(%rbp), %eax
addl $0x2, %eax
movl %eax, -0xa8(%rbp)
leaq -0x108(%rbp), %rdi
callq 0x34650
movq %rax, %rsi
addq $0x10, %rsi
leaq -0x160(%rbp), %rdi
callq 0x34690
jmp 0x29ad6
leaq -0x160(%rbp), %rdi
callq 0x33e20
movb %al, -0x5e9(%rbp)
jmp 0x29aea
leaq -0x160(%rbp), %rdi
callq 0xd440
movb -0x5e9(%rbp), %al
testb $0x1, %al
jne 0x29b05
jmp 0x29bb9
leaq -0x108(%rbp), %rdi
callq 0x34650
movq %rax, %rdi
movl -0xa8(%rbp), %eax
addl $0x2, %eax
movzwl %ax, %esi
callq 0x346c0
jmp 0x29b27
leaq -0x108(%rbp), %rdi
callq 0x34650
movq %rax, %rsi
addq $0x10, %rsi
leaq -0x198(%rbp), %rdi
callq 0x34690
jmp 0x29b48
leaq -0x198(%rbp), %rdi
callq 0x33ea0
movq %rax, -0x5f8(%rbp)
jmp 0x29b5d
movq -0x5f8(%rbp), %rcx
shlq %rcx
movslq -0xa8(%rbp), %rax
addq %rcx, %rax
movl %eax, -0xa8(%rbp)
leaq -0x198(%rbp), %rdi
callq 0xd440
jmp 0x29bb9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x160(%rbp), %rdi
callq 0xd440
jmp 0x29bd6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x198(%rbp), %rdi
callq 0xd440
jmp 0x29bd6
leaq -0x108(%rbp), %rdi
callq 0x10dc0
leaq -0xf0(%rbp), %rdi
callq 0x346e0
jmp 0x298f8
leaq -0x108(%rbp), %rdi
callq 0x10dc0
jmp 0x2ab57
movq -0x10(%rbp), %rax
movq %rax, -0x608(%rbp)
leaq -0x1b9(%rbp), %rdi
movq %rdi, -0x600(%rbp)
callq 0x8760
movq -0x600(%rbp), %rdx
leaq 0x461ff(%rip), %rsi     # 0x6fe12
leaq -0x1b8(%rbp), %rdi
callq 0xced0
jmp 0x29c21
movq -0x608(%rbp), %rdi
leaq -0x1b8(%rbp), %rsi
callq 0xc600
jmp 0x29c36
leaq -0x1b8(%rbp), %rdi
callq 0x8848
leaq -0x1b9(%rbp), %rdi
callq 0x8460
movq -0x598(%rbp), %rax
addq $0xf0, %rax
movq %rax, -0x618(%rbp)
leaq -0x1e1(%rbp), %rdi
movq %rdi, -0x610(%rbp)
callq 0x8760
movq -0x610(%rbp), %rdx
leaq 0x46194(%rip), %rsi     # 0x6fe17
leaq -0x1e0(%rbp), %rdi
callq 0xced0
jmp 0x29c91
movq -0x618(%rbp), %rdi
leaq -0x1e0(%rbp), %rsi
callq 0x32940
jmp 0x29ca6
leaq -0x1e0(%rbp), %rdi
callq 0x8848
leaq -0x1e1(%rbp), %rdi
callq 0x8460
movl -0xdc(%rbp), %eax
addl $-0x2, %eax
movl %eax, -0xdc(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x628(%rbp)
leaq -0x209(%rbp), %rdi
movq %rdi, -0x620(%rbp)
callq 0x8760
movq -0x620(%rbp), %rdx
leaq 0x46121(%rip), %rsi     # 0x6fe1a
leaq -0x208(%rbp), %rdi
callq 0xced0
jmp 0x29d07
movq -0x628(%rbp), %rdi
leaq -0x208(%rbp), %rsi
callq 0xc600
jmp 0x29d1c
leaq -0x208(%rbp), %rdi
callq 0x8848
leaq -0x209(%rbp), %rdi
callq 0x8460
movq -0x598(%rbp), %rax
addq $0x78, %rax
movq %rax, -0x218(%rbp)
movq -0x218(%rbp), %rdi
callq 0x34430
movq %rax, -0x220(%rbp)
movq -0x218(%rbp), %rdi
callq 0x34460
movq %rax, -0x228(%rbp)
leaq -0x220(%rbp), %rdi
leaq -0x228(%rbp), %rsi
callq 0x34490
testb $0x1, %al
jne 0x29d88
jmp 0x2a057
leaq -0x220(%rbp), %rdi
callq 0x344d0
movq %rax, %rsi
leaq -0x238(%rbp), %rdi
movq %rdi, -0x638(%rbp)
callq 0xee60
movq -0x638(%rbp), %rdi
callq 0x34080
movq %rax, %rdi
addq $0x10, %rdi
callq 0x33980
movb %al, -0x629(%rbp)
jmp 0x29dca
movb -0x629(%rbp), %al
testb $0x1, %al
jne 0x29dd9
jmp 0x29f9f
leaq -0x238(%rbp), %rdi
callq 0x34080
movq %rax, %rdi
addq $0x10, %rdi
callq 0x34670
movb %al, -0x639(%rbp)
jmp 0x29df9
movb -0x639(%rbp), %al
testb $0x1, %al
jne 0x29f9f
jmp 0x29e09
movq -0x10(%rbp), %rax
movq %rax, -0x648(%rbp)
leaq -0x238(%rbp), %rdi
callq 0x34080
movq %rax, %rsi
addq $0x10, %rsi
leaq -0x278(%rbp), %rdi
callq 0x339a0
jmp 0x29e35
leaq 0x45307(%rip), %rsi     # 0x6f143
leaq -0x258(%rbp), %rdi
leaq -0x278(%rbp), %rdx
callq 0x325f0
jmp 0x29e51
movq -0x648(%rbp), %rdi
leaq -0x258(%rbp), %rsi
callq 0xc600
jmp 0x29e66
leaq -0x258(%rbp), %rdi
callq 0x8848
leaq -0x278(%rbp), %rdi
callq 0x8848
leaq -0x238(%rbp), %rdi
callq 0x34080
movq %rax, %rdi
addq $0x10, %rdi
movl -0xa8(%rbp), %esi
callq 0x34520
jmp 0x29e9e
movl -0xa8(%rbp), %eax
addl $0x2, %eax
movl %eax, -0xa8(%rbp)
jmp 0x2a029
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x29ed8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x1b8(%rbp), %rdi
callq 0x8848
leaq -0x1b9(%rbp), %rdi
callq 0x8460
jmp 0x2ab57
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x29f0f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x1e0(%rbp), %rdi
callq 0x8848
leaq -0x1e1(%rbp), %rdi
callq 0x8460
jmp 0x2ab57
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x29f46
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x208(%rbp), %rdi
callq 0x8848
leaq -0x209(%rbp), %rdi
callq 0x8460
jmp 0x2ab57
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x2a046
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x29f8e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x258(%rbp), %rdi
callq 0x8848
leaq -0x278(%rbp), %rdi
callq 0x8848
jmp 0x2a046
leaq -0x238(%rbp), %rdi
callq 0x34080
movq %rax, %rdi
addq $0x10, %rdi
callq 0x33980
movb %al, -0x649(%rbp)
jmp 0x29fbf
movb -0x649(%rbp), %al
testb $0x1, %al
jne 0x2a027
jmp 0x29fcb
leaq -0x238(%rbp), %rdi
movq %rdi, -0x660(%rbp)
callq 0x34080
movq -0x660(%rbp), %rdi
addq $0x10, %rax
movq %rax, -0x658(%rbp)
callq 0x34080
movq %rax, %rdi
addq $0x10, %rdi
callq 0x339d0
movl %eax, -0x650(%rbp)
jmp 0x2a009
movq -0x658(%rbp), %rdi
movl -0x650(%rbp), %esi
movl -0xdc(%rbp), %eax
addl %eax, %esi
callq 0x34520
jmp 0x2a025
jmp 0x2a027
jmp 0x2a029
leaq -0x238(%rbp), %rdi
callq 0xd400
leaq -0x220(%rbp), %rdi
callq 0x34540
jmp 0x29d6c
leaq -0x238(%rbp), %rdi
callq 0xd400
jmp 0x2ab57
xorl %eax, %eax
cmpl -0xa8(%rbp), %eax
jge 0x2a1aa
movq -0x10(%rbp), %rax
movq %rax, -0x668(%rbp)
movzwl -0xa8(%rbp), %esi
leaq -0x2b8(%rbp), %rdi
movl $0x4, %edx
callq 0x6c950
jmp 0x2a08a
leaq 0x4581a(%rip), %rsi     # 0x6f8ab
leaq -0x298(%rbp), %rdi
leaq -0x2b8(%rbp), %rdx
callq 0x325f0
jmp 0x2a0a6
movq -0x668(%rbp), %rdi
leaq -0x298(%rbp), %rsi
callq 0xc600
jmp 0x2a0bb
leaq -0x298(%rbp), %rdi
callq 0x8848
leaq -0x2b8(%rbp), %rdi
callq 0x8848
movq -0x10(%rbp), %rax
movq %rax, -0x678(%rbp)
leaq -0x2d9(%rbp), %rdi
movq %rdi, -0x670(%rbp)
callq 0x8760
movq -0x670(%rbp), %rdx
leaq 0x45d25(%rip), %rsi     # 0x6fe24
leaq -0x2d8(%rbp), %rdi
callq 0xced0
jmp 0x2a10d
movq -0x678(%rbp), %rdi
leaq -0x2d8(%rbp), %rsi
callq 0xc600
jmp 0x2a122
leaq -0x2d8(%rbp), %rdi
callq 0x8848
leaq -0x2d9(%rbp), %rdi
callq 0x8460
jmp 0x2a1aa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x2a162
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x298(%rbp), %rdi
callq 0x8848
leaq -0x2b8(%rbp), %rdi
callq 0x8848
jmp 0x2ab57
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x2a199
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x2d8(%rbp), %rdi
callq 0x8848
leaq -0x2d9(%rbp), %rdi
callq 0x8460
jmp 0x2ab57
movq -0x598(%rbp), %rax
addq $0x90, %rax
movq %rax, -0x2e8(%rbp)
movq -0x2e8(%rbp), %rdi
callq 0x34560
movq %rax, -0x2f0(%rbp)
movq -0x2e8(%rbp), %rdi
callq 0x34590
movq %rax, -0x2f8(%rbp)
leaq -0x2f0(%rbp), %rdi
leaq -0x2f8(%rbp), %rsi
callq 0x345c0
testb $0x1, %al
jne 0x2a200
jmp 0x2a41e
leaq -0x2f0(%rbp), %rdi
callq 0x34600
movq %rax, %rsi
leaq -0x308(%rbp), %rdi
movq %rdi, -0x698(%rbp)
callq 0x34620
movq -0x698(%rbp), %rdi
callq 0x34650
movq %rax, -0x690(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x688(%rbp)
xorl %eax, %eax
movl %eax, %esi
leaq -0x318(%rbp), %rdi
callq 0x34700
leaq -0x339(%rbp), %rdi
movq %rdi, -0x680(%rbp)
callq 0x8760
movq -0x680(%rbp), %rdx
leaq 0x45eee(%rip), %rsi     # 0x7015f
leaq -0x338(%rbp), %rdi
callq 0xced0
jmp 0x2a27f
leaq -0x361(%rbp), %rdi
movq %rdi, -0x6a0(%rbp)
callq 0x8760
movq -0x6a0(%rbp), %rdx
leaq 0x45ebf(%rip), %rsi     # 0x7015f
leaq -0x360(%rbp), %rdi
callq 0xced0
jmp 0x2a2ae
leaq -0x389(%rbp), %rdi
movq %rdi, -0x6a8(%rbp)
callq 0x8760
movq -0x6a8(%rbp), %rdx
leaq 0x45e90(%rip), %rsi     # 0x7015f
leaq -0x388(%rbp), %rdi
callq 0xced0
jmp 0x2a2dd
movq -0x688(%rbp), %rsi
movq -0x690(%rbp), %rdi
movq (%rdi), %rax
movq 0x8(%rax), %rax
leaq -0x318(%rbp), %rdx
leaq -0x338(%rbp), %rcx
leaq -0x360(%rbp), %r8
leaq -0x388(%rbp), %r9
callq *%rax
jmp 0x2a312
leaq -0x388(%rbp), %rdi
callq 0x8848
leaq -0x389(%rbp), %rdi
callq 0x8460
leaq -0x360(%rbp), %rdi
callq 0x8848
leaq -0x361(%rbp), %rdi
callq 0x8460
leaq -0x338(%rbp), %rdi
callq 0x8848
leaq -0x339(%rbp), %rdi
callq 0x8460
leaq -0x318(%rbp), %rdi
callq 0x94c0
leaq -0x308(%rbp), %rdi
callq 0x10dc0
leaq -0x2f0(%rbp), %rdi
callq 0x346e0
jmp 0x2a1e4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x2a3f5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x2a3dd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x2a3c5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x388(%rbp), %rdi
callq 0x8848
leaq -0x389(%rbp), %rdi
callq 0x8460
leaq -0x360(%rbp), %rdi
callq 0x8848
leaq -0x361(%rbp), %rdi
callq 0x8460
leaq -0x338(%rbp), %rdi
callq 0x8848
leaq -0x339(%rbp), %rdi
callq 0x8460
leaq -0x318(%rbp), %rdi
callq 0x94c0
leaq -0x308(%rbp), %rdi
callq 0x10dc0
jmp 0x2ab57
movq -0x598(%rbp), %rax
addq $0xa8, %rax
movq %rax, -0x398(%rbp)
movq -0x398(%rbp), %rdi
callq 0x34720
movq %rax, -0x3a0(%rbp)
movq -0x398(%rbp), %rdi
callq 0x34750
movq %rax, -0x3a8(%rbp)
leaq -0x3a0(%rbp), %rdi
leaq -0x3a8(%rbp), %rsi
callq 0x34780
testb $0x1, %al
jne 0x2a474
jmp 0x2a5fe
leaq -0x3a0(%rbp), %rdi
callq 0x347c0
movq %rax, %rsi
leaq -0x3b8(%rbp), %rdi
callq 0x347e0
movq -0x598(%rbp), %rsi
movq -0x10(%rbp), %rax
movq %rax, -0x6b0(%rbp)
addq $0x58, %rsi
leaq 0x45981(%rip), %rdx     # 0x6fe2d
leaq -0x418(%rbp), %rdi
callq 0xdd40
jmp 0x2a4ba
leaq -0x3b8(%rbp), %rdi
callq 0x34810
movq %rax, %rsi
leaq -0x438(%rbp), %rdi
callq 0x34830
jmp 0x2a4d7
leaq -0x3f8(%rbp), %rdi
leaq -0x418(%rbp), %rsi
leaq -0x438(%rbp), %rdx
callq 0x33bb0
jmp 0x2a4f3
movq -0x6b0(%rbp), %rsi
leaq -0x3d8(%rbp), %rdi
leaq -0x3f8(%rbp), %rdx
callq 0xc3c0
jmp 0x2a50f
leaq -0x3f8(%rbp), %rdi
callq 0x8848
leaq -0x438(%rbp), %rdi
callq 0x8848
leaq -0x418(%rbp), %rdi
callq 0x8848
leaq -0x3b8(%rbp), %rdi
callq 0x34810
movq %rax, %rdi
leaq -0x3d8(%rbp), %rsi
callq 0x34860
jmp 0x2a550
leaq -0x3d8(%rbp), %rdi
callq 0x8848
leaq -0x3b8(%rbp), %rdi
callq 0x10150
leaq -0x3a0(%rbp), %rdi
callq 0x34890
jmp 0x2a458
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x2a5ed
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x2a5c7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x2a5bb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x3f8(%rbp), %rdi
callq 0x8848
leaq -0x438(%rbp), %rdi
callq 0x8848
leaq -0x418(%rbp), %rdi
callq 0x8848
jmp 0x2a5ed
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x3d8(%rbp), %rdi
callq 0x8848
leaq -0x3b8(%rbp), %rdi
callq 0x10150
jmp 0x2ab57
movq -0x598(%rbp), %rax
addq $0xd8, %rax
movq %rax, -0x440(%rbp)
movq -0x440(%rbp), %rdi
callq 0x348b0
movq %rax, -0x448(%rbp)
movq -0x440(%rbp), %rdi
callq 0x348e0
movq %rax, -0x450(%rbp)
leaq -0x448(%rbp), %rdi
leaq -0x450(%rbp), %rsi
callq 0x34910
testb $0x1, %al
jne 0x2a654
jmp 0x2a819
leaq -0x448(%rbp), %rdi
callq 0x34950
movq %rax, %rsi
leaq -0x460(%rbp), %rdi
movq %rdi, -0x6c8(%rbp)
callq 0x34970
movq -0x6c8(%rbp), %rdi
callq 0x341f0
movq -0x598(%rbp), %rsi
movq %rax, -0x6c0(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x6b8(%rbp)
addq $0x10, %rsi
leaq -0x470(%rbp), %rdi
callq 0x34110
jmp 0x2a6ad
leaq -0x491(%rbp), %rdi
movq %rdi, -0x6d0(%rbp)
callq 0x8760
movq -0x6d0(%rbp), %rdx
leaq 0x45a91(%rip), %rsi     # 0x7015f
leaq -0x490(%rbp), %rdi
callq 0xced0
jmp 0x2a6dc
leaq -0x4b9(%rbp), %rdi
movq %rdi, -0x6d8(%rbp)
callq 0x8760
movq -0x6d8(%rbp), %rdx
leaq 0x45a62(%rip), %rsi     # 0x7015f
leaq -0x4b8(%rbp), %rdi
callq 0xced0
jmp 0x2a70b
movq -0x6b8(%rbp), %rsi
movq -0x6c0(%rbp), %rdi
movq (%rdi), %rax
movq 0x8(%rax), %rax
leaq -0x470(%rbp), %rdx
leaq -0x30(%rbp), %rcx
leaq -0x490(%rbp), %r8
leaq -0x4b8(%rbp), %r9
callq *%rax
jmp 0x2a73d
leaq -0x4b8(%rbp), %rdi
callq 0x8848
leaq -0x4b9(%rbp), %rdi
callq 0x8460
leaq -0x490(%rbp), %rdi
callq 0x8848
leaq -0x491(%rbp), %rdi
callq 0x8460
leaq -0x470(%rbp), %rdi
callq 0x94c0
leaq -0x460(%rbp), %rdi
callq 0xfcd0
leaq -0x448(%rbp), %rdi
callq 0x349a0
jmp 0x2a638
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x2a808
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x2a7f0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x2a7d8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x4b8(%rbp), %rdi
callq 0x8848
leaq -0x4b9(%rbp), %rdi
callq 0x8460
leaq -0x490(%rbp), %rdi
callq 0x8848
leaq -0x491(%rbp), %rdi
callq 0x8460
leaq -0x470(%rbp), %rdi
callq 0x94c0
leaq -0x460(%rbp), %rdi
callq 0xfcd0
jmp 0x2ab57
movq -0x10(%rbp), %rax
movq %rax, -0x6e0(%rbp)
leaq 0x46e1d(%rip), %rdx     # 0x71648
leaq -0x4e0(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0xdd40
jmp 0x2a83d
movq -0x6e0(%rbp), %rdi
leaq -0x4e0(%rbp), %rsi
callq 0xcc30
jmp 0x2a852
leaq -0x4e0(%rbp), %rdi
callq 0x8848
movq -0x10(%rbp), %rax
movq %rax, -0x6f0(%rbp)
leaq -0x501(%rbp), %rdi
movq %rdi, -0x6e8(%rbp)
callq 0x8760
movq -0x6e8(%rbp), %rdx
leaq 0x455a5(%rip), %rsi     # 0x6fe2f
leaq -0x500(%rbp), %rdi
callq 0xced0
jmp 0x2a898
movq -0x6f0(%rbp), %rdi
leaq -0x500(%rbp), %rsi
callq 0xc600
jmp 0x2a8ad
leaq -0x500(%rbp), %rdi
callq 0x8848
leaq -0x501(%rbp), %rdi
callq 0x8460
movq -0x598(%rbp), %rdi
addq $0xf0, %rdi
callq 0x32a20
movb %al, -0x6f1(%rbp)
jmp 0x2a8e0
movb -0x6f1(%rbp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x2a8f1
jmp 0x2a9e0
movq -0x598(%rbp), %rdi
movq -0x10(%rbp), %rax
movq %rax, -0x708(%rbp)
addq $0xf0, %rdi
callq 0x32a40
movq %rax, -0x700(%rbp)
jmp 0x2a918
movq -0x700(%rbp), %rdx
leaq 0x44802(%rip), %rsi     # 0x6f128
leaq -0x528(%rbp), %rdi
callq 0xdc30
jmp 0x2a934
movq -0x708(%rbp), %rdi
leaq -0x528(%rbp), %rsi
callq 0xc600
jmp 0x2a949
leaq -0x528(%rbp), %rdi
callq 0x8848
movq -0x598(%rbp), %rdi
addq $0xf0, %rdi
callq 0x32c00
jmp 0x2a96a
jmp 0x2a8c5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x4e0(%rbp), %rdi
callq 0x8848
jmp 0x2ab57
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x2a9b2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x500(%rbp), %rdi
callq 0x8848
leaq -0x501(%rbp), %rdi
callq 0x8460
jmp 0x2ab57
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x528(%rbp), %rdi
callq 0x8848
jmp 0x2ab57
xorl %eax, %eax
cmpl -0xac(%rbp), %eax
jge 0x2aa9c
movq -0x10(%rbp), %rax
movq %rax, -0x710(%rbp)
movl -0xac(%rbp), %eax
addl %eax, %eax
movzwl %ax, %esi
leaq -0x568(%rbp), %rdi
movl $0x2, %edx
callq 0x6c950
jmp 0x2aa17
leaq 0x4541b(%rip), %rsi     # 0x6fe39
leaq -0x548(%rbp), %rdi
leaq -0x568(%rbp), %rdx
callq 0x325f0
jmp 0x2aa33
movq -0x710(%rbp), %rdi
leaq -0x548(%rbp), %rsi
callq 0xc600
jmp 0x2aa48
leaq -0x548(%rbp), %rdi
callq 0x8848
leaq -0x568(%rbp), %rdi
callq 0x8848
jmp 0x2ab39
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x2aa8b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x548(%rbp), %rdi
callq 0x8848
leaq -0x568(%rbp), %rdi
callq 0x8848
jmp 0x2ab57
movq -0x10(%rbp), %rax
movq %rax, -0x720(%rbp)
leaq -0x589(%rbp), %rdi
movq %rdi, -0x718(%rbp)
callq 0x8760
movq -0x718(%rbp), %rdx
leaq 0x45376(%rip), %rsi     # 0x6fe3e
leaq -0x588(%rbp), %rdi
callq 0xced0
jmp 0x2aad6
movq -0x720(%rbp), %rdi
leaq -0x588(%rbp), %rsi
callq 0xc600
jmp 0x2aaeb
leaq -0x588(%rbp), %rdi
callq 0x8848
leaq -0x589(%rbp), %rdi
callq 0x8460
jmp 0x2ab39
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x2ab2b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x588(%rbp), %rdi
callq 0x8848
leaq -0x589(%rbp), %rdi
callq 0x8460
jmp 0x2ab57
leaq -0xa0(%rbp), %rdi
callq 0x8848
leaq -0x30(%rbp), %rdi
callq 0x8848
addq $0x720, %rsp            # imm = 0x720
popq %rbp
retq
leaq -0xa0(%rbp), %rdi
callq 0x8848
leaq -0x30(%rbp), %rdi
callq 0x8848
movq -0x58(%rbp), %rdi
callq 0x8750
nopw %cs:(%rax,%rax)