// File: ATOMIC-LICHESS[P]ATOMKRAFT/position.cpp
// Function: Position::do_move(Move, StateInfo&, CheckInfo const&, bool)
void Position::do_move(Move m, StateInfo& newSt, const CheckInfo& ci, bool moveIsCheck) {

  assert(is_ok());
  assert(move_is_ok(m));
  assert(&newSt != st);

  nodes++;
  Key key = st->key;

  // Copy some fields of old state to our new StateInfo object except the
  // ones which are recalculated from scratch anyway, then switch our state
  // pointer to point to the new, ready to be updated, state.
  struct ReducedStateInfo {
    Key pawnKey, materialKey;
    int castleRights, rule50, gamePly, pliesFromNull;
    Square epSquare;
    Score value;
    Value npMaterial[2];
  };

  memcpy(&newSt, st, sizeof(ReducedStateInfo));

  newSt.previous = st;
  st = &newSt;

  // Save the current key to the history[] array, in order to be able to
  // detect repetition draws.
  history[st->gamePly++] = key;

  // Update side to move
  key ^= zobSideToMove;

  // Increment the 50 moves rule draw counter. Resetting it to zero in the
  // case of non-reversible moves is taken care of later.
  st->rule50++;
  st->pliesFromNull++;

  if (move_is_castle(m))
  {
      st->key = key;
      do_castle_move(m);
      return;
  }

  Color us = side_to_move();
  Color them = opposite_color(us);
  Square from = move_from(m);
  Square to = move_to(m);
  bool ep = move_is_ep(m);
  bool pm = move_is_promotion(m);

  Piece piece = piece_on(from);
  PieceType pt = type_of_piece(piece);
  PieceType capture = ep ? PAWN : type_of_piece_on(to);

  assert(color_of_piece_on(from) == us);
  assert(color_of_piece_on(to) == them || square_is_empty(to));
  assert(!(ep || pm) || piece == make_piece(us, PAWN));
  assert(!pm || relative_rank(us, to) == RANK_8);
  
  if (capture)
      do_capture_move(key, capture, them, to, from, ep);

  // Update hash key
  key ^= zobrist[us][pt][from] ^ zobrist[us][pt][to];

  // Reset en passant square
  if (st->epSquare != SQ_NONE)
  {
      key ^= zobEp[st->epSquare];
      st->epSquare = SQ_NONE;
  }

  // Update castle rights, try to shortcut a common case
  int cm = castleRightsMask[from] & castleRightsMask[to];
  NEW if (capture) cm &= expl_castleRightsMask[to];	// 
  if (cm != ALL_CASTLES && ((cm & st->castleRights) != st->castleRights))
  {
      key ^= zobCastle[st->castleRights];
      OLD st->castleRights &= castleRightsMask[from];
      OLD st->castleRights &= castleRightsMask[to];
      NEW st->castleRights &= cm;
      key ^= zobCastle[st->castleRights];
  }
  
  // TODO: PREFETCH
  // Prefetch TT access as soon as we know key is updated
  prefetch((char*)TT.first_entry(key));

  // Move the piece
  Bitboard move_bb = make_move_bb(from, to);
  do_move_bb(&(byColorBB[us]), move_bb);
  do_move_bb(&(byTypeBB[pt]), move_bb);
  do_move_bb(&(byTypeBB[0]), move_bb); // HACK: byTypeBB[0] == occupied squares

  board[to] = board[from];
  board[from] = PIECE_NONE;

  // Update piece lists, note that index[from] is not updated and
  // becomes stale. This works as long as index[] is accessed just
  // by known occupied squares.
  index[to] = index[from];
  pieceList[us][pt][index[to]] = to;

  // If the moving piece was a pawn do some special extra work
  if (pt == PAWN)
  {
      // Reset rule 50 draw counter
      st->rule50 = 0;

      // Update pawn hash key and prefetch in L1/L2 cache
      OLD st->pawnKey ^= zobrist[us][PAWN][from] ^ zobrist[us][PAWN][to];
      STARTNEW
      if (capture) {
    	  st->pawnKey ^= zobrist[us][PAWN][from];
      } else {
    	  st->pawnKey ^= zobrist[us][PAWN][from] ^ zobrist[us][PAWN][to];
      }
      ENDNEW

      // Set en passant square, only if moved pawn can be captured
      if ((to ^ from) == 16)
      {
          if (attacks_from<PAWN>(from + (us == WHITE ? DELTA_N : DELTA_S), us) & pieces(PAWN, them))
          {
              st->epSquare = Square((int(from) + int(to)) / 2);
              key ^= zobEp[st->epSquare];
          }
      }

      if (pm) // promotion ?
      //NEW if (pm && !capture)	// if capture the following code is unnecessary
      {
    	  NEW assert(!capture); // if capture the following code is unnecessary
    	  
          PieceType promotion = move_promotion_piece(m);

          assert(promotion >= KNIGHT && promotion <= QUEEN);

          // Insert promoted piece instead of pawn
          clear_bit(&(byTypeBB[PAWN]), to);
          set_bit(&(byTypeBB[promotion]), to);
          board[to] = make_piece(us, promotion);

          // Update piece counts
          pieceCount[us][promotion]++;
          pieceCount[us][PAWN]--;

          // Update material key
          st->materialKey ^= zobrist[us][PAWN][pieceCount[us][PAWN]];
          st->materialKey ^= zobrist[us][promotion][pieceCount[us][promotion]-1];

          // Update piece lists, move the last pawn at index[to] position
          // and shrink the list. Add a new promotion piece to the list.
          Square lastPawnSquare = pieceList[us][PAWN][pieceCount[us][PAWN]];
          index[lastPawnSquare] = index[to];
          pieceList[us][PAWN][index[lastPawnSquare]] = lastPawnSquare;
          pieceList[us][PAWN][pieceCount[us][PAWN]] = SQ_NONE;
          index[to] = pieceCount[us][promotion] - 1;
          pieceList[us][promotion][index[to]] = to;

          // Partially revert hash keys update
          key ^= zobrist[us][PAWN][to] ^ zobrist[us][promotion][to];
          st->pawnKey ^= zobrist[us][PAWN][to];

          // Partially revert and update incremental scores
          st->value -= pst(us, PAWN, to);
          st->value += pst(us, promotion, to);

          // Update material
          st->npMaterial[us] += PieceValueMidgame[promotion];
      }
  }

// Assembly:
subq $0x168, %rsp            # imm = 0x168
movb %r8b, %al
movq %rdi, 0x160(%rsp)
movl %esi, 0x15c(%rsp)
movq %rdx, 0x150(%rsp)
movq %rcx, 0x148(%rsp)
andb $0x1, %al
movb %al, 0x147(%rsp)
movq 0x160(%rsp), %rax
movq %rax, 0xd8(%rsp)
movq 0x1930(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x1930(%rax)
movq 0x1938(%rax), %rcx
movq 0x38(%rcx), %rcx
movq %rcx, 0x138(%rsp)
movq 0x150(%rsp), %rdi
movq 0x1938(%rax), %rsi
movl $0x30, %edx
callq 0x63f0
movq 0xd8(%rsp), %rax
movq 0x1938(%rax), %rdx
movq 0x150(%rsp), %rcx
movq %rdx, 0x98(%rcx)
movq 0x150(%rsp), %rcx
movq %rcx, 0x1938(%rax)
movq 0x138(%rsp), %rdx
movq 0x1938(%rax), %rsi
movl 0x18(%rsi), %ecx
movl %ecx, %edi
addl $0x1, %edi
movl %edi, 0x18(%rsi)
movslq %ecx, %rcx
movq %rdx, 0x1098(%rax,%rcx,8)
movq 0x3afed7(%rip), %rcx    # 0x3ea3c0
xorq 0x138(%rsp), %rcx
movq %rcx, 0x138(%rsp)
movq 0x1938(%rax), %rcx
movl 0x14(%rcx), %edx
addl $0x1, %edx
movl %edx, 0x14(%rcx)
movq 0x1938(%rax), %rax
movl 0x1c(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x1c(%rax)
movl 0x15c(%rsp), %edi
callq 0x12970
cmpl $0x0, %eax
je 0x3a556
movq 0xd8(%rsp), %rdi
movq 0x138(%rsp), %rcx
movq 0x1938(%rdi), %rax
movq %rcx, 0x38(%rax)
movl 0x15c(%rsp), %esi
callq 0x3b6b0
jmp 0x3b6a7
movq 0xd8(%rsp), %rdi
callq 0xf5d0
movl %eax, 0x134(%rsp)
movl 0x134(%rsp), %edi
callq 0x122b0
movl %eax, 0x130(%rsp)
movl 0x15c(%rsp), %edi
callq 0xf680
movl %eax, 0x12c(%rsp)
movl 0x15c(%rsp), %edi
callq 0xf690
movl %eax, 0x128(%rsp)
movl 0x15c(%rsp), %edi
callq 0x2e360
cmpl $0x0, %eax
setne %al
andb $0x1, %al
movb %al, 0x127(%rsp)
movl 0x15c(%rsp), %edi
callq 0xfb40
movq 0xd8(%rsp), %rdi
andb $0x1, %al
movb %al, 0x126(%rsp)
movl 0x12c(%rsp), %esi
callq 0xf530
movl %eax, 0x120(%rsp)
movl 0x120(%rsp), %edi
callq 0x12990
movl %eax, 0x11c(%rsp)
testb $0x1, 0x127(%rsp)
je 0x3a619
movl $0x1, %eax
movl %eax, 0xd4(%rsp)
jmp 0x3a634
movq 0xd8(%rsp), %rdi
movl 0x128(%rsp), %esi
callq 0x11f10
movl %eax, 0xd4(%rsp)
movl 0xd4(%rsp), %eax
movl %eax, 0x118(%rsp)
cmpl $0x0, 0x118(%rsp)
je 0x3a68e
movq 0xd8(%rsp), %rdi
movl 0x118(%rsp), %edx
movl 0x130(%rsp), %ecx
movl 0x128(%rsp), %r8d
movl 0x12c(%rsp), %r9d
movb 0x127(%rsp), %al
leaq 0x138(%rsp), %rsi
andb $0x1, %al
movzbl %al, %eax
movl %eax, (%rsp)
callq 0x3be30
movq 0xd8(%rsp), %rax
movl 0x134(%rsp), %ecx
movl %ecx, %edx
leaq 0x3ada9a(%rip), %rcx    # 0x3e8140
shlq $0xc, %rdx
addq %rdx, %rcx
movl 0x11c(%rsp), %edx
shlq $0x9, %rdx
addq %rdx, %rcx
movslq 0x12c(%rsp), %rdx
movq (%rcx,%rdx,8), %rcx
movl 0x134(%rsp), %edx
movl %edx, %esi
leaq 0x3ada69(%rip), %rdx    # 0x3e8140
shlq $0xc, %rsi
addq %rsi, %rdx
movl 0x11c(%rsp), %esi
shlq $0x9, %rsi
addq %rsi, %rdx
movslq 0x128(%rsp), %rsi
xorq (%rdx,%rsi,8), %rcx
xorq 0x138(%rsp), %rcx
movq %rcx, 0x138(%rsp)
movq 0x1938(%rax), %rax
cmpl $0x40, 0x20(%rax)
je 0x3a751
movq 0xd8(%rsp), %rax
movq 0x1938(%rax), %rcx
movslq 0x20(%rcx), %rdx
leaq 0x3afa11(%rip), %rcx    # 0x3ea140
movq (%rcx,%rdx,8), %rcx
xorq 0x138(%rsp), %rcx
movq %rcx, 0x138(%rsp)
movq 0x1938(%rax), %rax
movl $0x40, 0x20(%rax)
movq 0xd8(%rsp), %rcx
movslq 0x12c(%rsp), %rax
movl 0x1778(%rcx,%rax,4), %eax
movslq 0x128(%rsp), %rdx
andl 0x1778(%rcx,%rdx,4), %eax
movl %eax, 0x114(%rsp)
cmpl $0x0, 0x118(%rsp)
je 0x3a7a8
movslq 0x128(%rsp), %rcx
leaq 0x20939(%rip), %rax     # 0x5b0d0
movl (%rax,%rcx,4), %eax
andl 0x114(%rsp), %eax
movl %eax, 0x114(%rsp)
cmpl $0xf, 0x114(%rsp)
je 0x3a843
movq 0xd8(%rsp), %rcx
movl 0x114(%rsp), %eax
movq 0x1938(%rcx), %rdx
andl 0x10(%rdx), %eax
movq 0x1938(%rcx), %rcx
cmpl 0x10(%rcx), %eax
je 0x3a843
movq 0xd8(%rsp), %rax
movq 0x1938(%rax), %rcx
movslq 0x10(%rcx), %rdx
leaq 0x3afb4b(%rip), %rcx    # 0x3ea340
movq (%rcx,%rdx,8), %rcx
xorq 0x138(%rsp), %rcx
movq %rcx, 0x138(%rsp)
movl 0x114(%rsp), %edx
movq 0x1938(%rax), %rcx
andl 0x10(%rcx), %edx
movl %edx, 0x10(%rcx)
movq 0x1938(%rax), %rax
movslq 0x10(%rax), %rcx
leaq 0x3afb11(%rip), %rax    # 0x3ea340
movq (%rax,%rcx,8), %rax
xorq 0x138(%rsp), %rax
movq %rax, 0x138(%rsp)
movq 0x138(%rsp), %rsi
leaq 0x3c103e(%rip), %rdi    # 0x3fb890
callq 0x3e740
movq %rax, %rdi
callq 0x2c330
movl 0x12c(%rsp), %edi
movl 0x128(%rsp), %esi
callq 0x3e630
movq 0xd8(%rsp), %rdi
movq %rax, 0x108(%rsp)
addq $0x140, %rdi            # imm = 0x140
movl 0x134(%rsp), %eax
shlq $0x3, %rax
addq %rax, %rdi
movq 0x108(%rsp), %rsi
callq 0x3e610
movq 0xd8(%rsp), %rdi
addq $0x100, %rdi            # imm = 0x100
movl 0x11c(%rsp), %eax
shlq $0x3, %rax
addq %rax, %rdi
movq 0x108(%rsp), %rsi
callq 0x3e610
movq 0xd8(%rsp), %rdi
addq $0x100, %rdi            # imm = 0x100
movq 0x108(%rsp), %rsi
callq 0x3e610
movq 0xd8(%rsp), %rcx
movslq 0x12c(%rsp), %rax
movl (%rcx,%rax,4), %edx
movslq 0x128(%rsp), %rax
movl %edx, (%rcx,%rax,4)
movslq 0x12c(%rsp), %rax
movl $0x10, (%rcx,%rax,4)
movslq 0x12c(%rsp), %rax
movl 0x590(%rcx,%rax,4), %edx
movslq 0x128(%rsp), %rax
movl %edx, 0x590(%rcx,%rax,4)
movl 0x128(%rsp), %edx
movq %rcx, %rax
addq $0x190, %rax            # imm = 0x190
movl 0x134(%rsp), %esi
shlq $0x9, %rsi
addq %rsi, %rax
movl 0x11c(%rsp), %esi
shlq $0x6, %rsi
addq %rsi, %rax
movslq 0x128(%rsp), %rsi
movslq 0x590(%rcx,%rsi,4), %rcx
movl %edx, (%rax,%rcx,4)
cmpl $0x1, 0x11c(%rsp)
jne 0x3af1b
movq 0xd8(%rsp), %rax
movq 0x1938(%rax), %rax
movl $0x0, 0x14(%rax)
cmpl $0x0, 0x118(%rsp)
je 0x3a9e0
movq 0xd8(%rsp), %rax
movl 0x134(%rsp), %ecx
movl %ecx, %edx
leaq 0x3ad786(%rip), %rcx    # 0x3e8140
shlq $0xc, %rdx
addq %rdx, %rcx
movslq 0x12c(%rsp), %rdx
movq 0x200(%rcx,%rdx,8), %rcx
movq 0x1938(%rax), %rax
xorq (%rax), %rcx
movq %rcx, (%rax)
jmp 0x3aa43
movq 0xd8(%rsp), %rax
movl 0x134(%rsp), %ecx
movl %ecx, %edx
leaq 0x3ad748(%rip), %rcx    # 0x3e8140
shlq $0xc, %rdx
addq %rdx, %rcx
movslq 0x12c(%rsp), %rdx
movq 0x200(%rcx,%rdx,8), %rcx
movl 0x134(%rsp), %edx
movl %edx, %esi
leaq 0x3ad721(%rip), %rdx    # 0x3e8140
shlq $0xc, %rsi
addq %rsi, %rdx
movslq 0x128(%rsp), %rsi
xorq 0x200(%rdx,%rsi,8), %rcx
movq 0x1938(%rax), %rax
xorq (%rax), %rcx
movq %rcx, (%rax)
movl 0x128(%rsp), %eax
xorl 0x12c(%rsp), %eax
cmpl $0x10, %eax
jne 0x3ab1a
movl 0x12c(%rsp), %edi
movl 0x134(%rsp), %ecx
movl $0xfffffff8, %esi       # imm = 0xFFFFFFF8
movl $0x8, %eax
cmpl $0x0, %ecx
cmovel %eax, %esi
callq 0xd780
movq 0xd8(%rsp), %rdi
movl %eax, %esi
movl 0x134(%rsp), %edx
callq 0x1b460
movq 0xd8(%rsp), %rdi
movq %rax, 0xc8(%rsp)
movl 0x130(%rsp), %edx
movl $0x1, %esi
callq 0x16530
movq %rax, %rcx
movq 0xc8(%rsp), %rax
andq %rcx, %rax
cmpq $0x0, %rax
je 0x3ab18
movl 0x12c(%rsp), %eax
addl 0x128(%rsp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %edx
movq 0xd8(%rsp), %rax
movq 0x1938(%rax), %rcx
movl %edx, 0x20(%rcx)
movq 0x1938(%rax), %rax
movslq 0x20(%rax), %rcx
leaq 0x3af63c(%rip), %rax    # 0x3ea140
movq (%rax,%rcx,8), %rax
xorq 0x138(%rsp), %rax
movq %rax, 0x138(%rsp)
jmp 0x3ab1a
testb $0x1, 0x126(%rsp)
je 0x3af19
movl 0x15c(%rsp), %edi
callq 0xf830
movq 0xd8(%rsp), %rdi
movl %eax, 0x104(%rsp)
addq $0x100, %rdi            # imm = 0x100
addq $0x8, %rdi
movl 0x128(%rsp), %esi
callq 0x29eb0
movq 0xd8(%rsp), %rdi
addq $0x100, %rdi            # imm = 0x100
movl 0x104(%rsp), %eax
shlq $0x3, %rax
addq %rax, %rdi
movl 0x128(%rsp), %esi
callq 0xe7c0
movl 0x134(%rsp), %edi
movl 0x104(%rsp), %esi
callq 0x1bce0
movl %eax, %edx
movq 0xd8(%rsp), %rax
movslq 0x128(%rsp), %rcx
movl %edx, (%rax,%rcx,4)
movq %rax, %rcx
addq $0x150, %rcx            # imm = 0x150
movl 0x134(%rsp), %edx
shlq $0x5, %rdx
addq %rdx, %rcx
movl 0x104(%rsp), %edx
movl (%rcx,%rdx,4), %esi
addl $0x1, %esi
movl %esi, (%rcx,%rdx,4)
movq %rax, %rcx
addq $0x150, %rcx            # imm = 0x150
movl 0x134(%rsp), %edx
shlq $0x5, %rdx
addq %rdx, %rcx
movl 0x4(%rcx), %edx
addl $-0x1, %edx
movl %edx, 0x4(%rcx)
movl 0x134(%rsp), %ecx
movl %ecx, %edx
leaq 0x3ad53c(%rip), %rcx    # 0x3e8140
shlq $0xc, %rdx
addq %rdx, %rcx
movq %rax, %rdx
addq $0x150, %rdx            # imm = 0x150
movl 0x134(%rsp), %esi
shlq $0x5, %rsi
addq %rsi, %rdx
movslq 0x4(%rdx), %rdx
movq 0x200(%rcx,%rdx,8), %rdx
movq 0x1938(%rax), %rcx
xorq 0x8(%rcx), %rdx
movq %rdx, 0x8(%rcx)
movl 0x134(%rsp), %ecx
movl %ecx, %edx
leaq 0x3ad4f2(%rip), %rcx    # 0x3e8140
shlq $0xc, %rdx
addq %rdx, %rcx
movl 0x104(%rsp), %edx
shlq $0x9, %rdx
addq %rdx, %rcx
movq %rax, %rdx
addq $0x150, %rdx            # imm = 0x150
movl 0x134(%rsp), %esi
shlq $0x5, %rsi
addq %rsi, %rdx
movl 0x104(%rsp), %esi
movl (%rdx,%rsi,4), %edx
subl $0x1, %edx
movslq %edx, %rdx
movq (%rcx,%rdx,8), %rdx
movq 0x1938(%rax), %rcx
xorq 0x8(%rcx), %rdx
movq %rdx, 0x8(%rcx)
movq %rax, %rcx
addq $0x190, %rcx            # imm = 0x190
movl 0x134(%rsp), %edx
shlq $0x9, %rdx
addq %rdx, %rcx
movq %rax, %rdx
addq $0x150, %rdx            # imm = 0x150
movl 0x134(%rsp), %esi
shlq $0x5, %rsi
addq %rsi, %rdx
movslq 0x4(%rdx), %rdx
movl 0x40(%rcx,%rdx,4), %ecx
movl %ecx, 0x100(%rsp)
movslq 0x128(%rsp), %rcx
movl 0x590(%rax,%rcx,4), %edx
movslq 0x100(%rsp), %rcx
movl %edx, 0x590(%rax,%rcx,4)
movl 0x100(%rsp), %esi
movq %rax, %rcx
addq $0x190, %rcx            # imm = 0x190
movl 0x134(%rsp), %edx
shlq $0x9, %rdx
addq %rdx, %rcx
movslq 0x100(%rsp), %rdx
movslq 0x590(%rax,%rdx,4), %rdx
movl %esi, 0x40(%rcx,%rdx,4)
movq %rax, %rcx
addq $0x190, %rcx            # imm = 0x190
movl 0x134(%rsp), %edx
shlq $0x9, %rdx
addq %rdx, %rcx
movq %rax, %rdx
addq $0x150, %rdx            # imm = 0x150
movl 0x134(%rsp), %esi
shlq $0x5, %rsi
addq %rsi, %rdx
movslq 0x4(%rdx), %rdx
movl $0x40, 0x40(%rcx,%rdx,4)
movq %rax, %rcx
addq $0x150, %rcx            # imm = 0x150
movl 0x134(%rsp), %edx
shlq $0x5, %rdx
addq %rdx, %rcx
movl 0x104(%rsp), %edx
movl (%rcx,%rdx,4), %edx
subl $0x1, %edx
movslq 0x128(%rsp), %rcx
movl %edx, 0x590(%rax,%rcx,4)
movl 0x128(%rsp), %esi
movq %rax, %rcx
addq $0x190, %rcx            # imm = 0x190
movl 0x134(%rsp), %edx
shlq $0x9, %rdx
addq %rdx, %rcx
movl 0x104(%rsp), %edx
shlq $0x6, %rdx
addq %rdx, %rcx
movslq 0x128(%rsp), %rdx
movslq 0x590(%rax,%rdx,4), %rdx
movl %esi, (%rcx,%rdx,4)
movl 0x134(%rsp), %ecx
movl %ecx, %edx
leaq 0x3ad352(%rip), %rcx    # 0x3e8140
shlq $0xc, %rdx
addq %rdx, %rcx
movslq 0x128(%rsp), %rdx
movq 0x200(%rcx,%rdx,8), %rcx
movl 0x134(%rsp), %edx
movl %edx, %esi
leaq 0x3ad32b(%rip), %rdx    # 0x3e8140
shlq $0xc, %rsi
addq %rsi, %rdx
movl 0x104(%rsp), %esi
shlq $0x9, %rsi
addq %rsi, %rdx
movslq 0x128(%rsp), %rsi
xorq (%rdx,%rsi,8), %rcx
xorq 0x138(%rsp), %rcx
movq %rcx, 0x138(%rsp)
movl 0x134(%rsp), %ecx
movl %ecx, %edx
leaq 0x3ad2ea(%rip), %rcx    # 0x3e8140
shlq $0xc, %rdx
addq %rdx, %rcx
movslq 0x128(%rsp), %rdx
movq 0x200(%rcx,%rdx,8), %rcx
movq 0x1938(%rax), %rax
xorq (%rax), %rcx
movq %rcx, (%rax)
movl 0x134(%rsp), %edi
movl 0x128(%rsp), %edx
movl $0x1, %esi
callq 0x3e770
movl %eax, %esi
movq 0xd8(%rsp), %rax
movq 0x1938(%rax), %rdi
addq $0x24, %rdi
callq 0x29ae0
movl 0x134(%rsp), %edi
movl 0x104(%rsp), %esi
movl 0x128(%rsp), %edx
callq 0x3e770
movl %eax, %esi
movq 0xd8(%rsp), %rax
movq 0x1938(%rax), %rdi
addq $0x24, %rdi
callq 0x29810
movq 0xd8(%rsp), %rax
movl 0x104(%rsp), %ecx
movl %ecx, %edx
leaq 0x3b04d8(%rip), %rcx    # 0x3eb3d0
movl (%rcx,%rdx,4), %esi
movq 0x1938(%rax), %rdi
addq $0x28, %rdi
movl 0x134(%rsp), %eax
shlq $0x2, %rax
addq %rax, %rdi
callq 0x29dd0
jmp 0x3af1b
cmpl $0x0, 0x118(%rsp)
je 0x3af50
movq 0xd8(%rsp), %rdi
movl 0x134(%rsp), %edx
movl 0x128(%rsp), %ecx
movl 0x11c(%rsp), %r8d
leaq 0x138(%rsp), %rsi
callq 0x3c2a0
movq 0xd8(%rsp), %rax
movl 0x192c(%rax), %esi
leaq 0x3b5cdb(%rip), %rdi    # 0x3f0c40
callq 0x297c0
movq %rax, %rdi
movq 0xd8(%rsp), %rax
addq $0x18, %rdi
movq 0x1938(%rax), %rax
movq (%rax), %rsi
callq 0x3e7b0
movq 0xd8(%rsp), %rax
movl 0x192c(%rax), %esi
leaq 0x3b5ca3(%rip), %rdi    # 0x3f0c40
callq 0x297c0
movq %rax, %rdi
movq 0xd8(%rsp), %rax
movq 0x1938(%rax), %rax
movq 0x8(%rax), %rsi
callq 0x3e7e0
movl 0x120(%rsp), %edi
movl 0x12c(%rsp), %esi
movl 0x128(%rsp), %edx
callq 0x3e810
movl %eax, %esi
movq 0xd8(%rsp), %rax
movq 0x1938(%rax), %rdi
addq $0x24, %rdi
callq 0x29810
movq 0xd8(%rsp), %rdi
movl 0x118(%rsp), %ecx
movq 0x1938(%rdi), %rax
movl %ecx, 0x30(%rax)
movl 0x11c(%rsp), %ecx
movq 0x1938(%rdi), %rax
movl %ecx, 0x34(%rax)
movq 0x138(%rsp), %rcx
movq 0x1938(%rdi), %rax
movq %rcx, 0x38(%rax)
movq 0x1938(%rdi), %rax
movq $0x0, 0x40(%rax)
movl 0x130(%rsp), %esi
movl $0x6, %edx
callq 0x164c0
cmpl $0x0, %eax
je 0x3b644
testb $0x1, 0x147(%rsp)
je 0x3b642
movq 0xd8(%rsp), %rdi
movl 0x134(%rsp), %esi
callq 0x1b250
movq 0xd8(%rsp), %rdi
movl %eax, 0xfc(%rsp)
movl 0x130(%rsp), %esi
callq 0x1b250
movl %eax, 0xf8(%rsp)
cmpl $0x0, 0x118(%rsp)
jne 0x3b0b3
testb $0x1, 0x126(%rsp)
je 0x3b2cc
movslq 0xfc(%rsp), %rcx
leaq 0x327de(%rip), %rax     # 0x6d8a0
shlq $0x6, %rcx
addq %rcx, %rax
movslq 0xf8(%rsp), %rcx
cmpb $0x0, (%rax,%rcx)
je 0x3b0f3
movq 0xd8(%rsp), %rax
movq 0x1938(%rax), %rax
movq $0x0, 0x40(%rax)
jmp 0x3b2c7
movq 0xd8(%rsp), %rdi
movl 0xf8(%rsp), %esi
movl $0x1, %edx
callq 0x1b460
movq 0xd8(%rsp), %rdi
movq %rax, 0x78(%rsp)
movl $0x1, %esi
xorl %edx, %edx
callq 0x16530
movq 0xd8(%rsp), %rdi
movq %rax, %rcx
movq 0x78(%rsp), %rax
andq %rcx, %rax
movq %rax, 0x88(%rsp)
movl 0xf8(%rsp), %esi
xorl %edx, %edx
callq 0x1b460
movq 0xd8(%rsp), %rdi
movq %rax, 0x80(%rsp)
movl $0x1, %edx
movl %edx, %esi
callq 0x16530
movq 0x80(%rsp), %rcx
movq 0xd8(%rsp), %rdi
movq %rax, %rdx
movq 0x88(%rsp), %rax
andq %rdx, %rcx
orq %rcx, %rax
movq %rax, 0x98(%rsp)
movl 0xf8(%rsp), %esi
callq 0x29aa0
movq 0xd8(%rsp), %rdi
movq %rax, 0x90(%rsp)
movl $0x2, %esi
callq 0x33a70
movq 0x90(%rsp), %rcx
movq 0xd8(%rsp), %rdi
movq %rax, %rdx
movq 0x98(%rsp), %rax
andq %rdx, %rcx
orq %rcx, %rax
movq %rax, 0xa8(%rsp)
movl 0xf8(%rsp), %esi
callq 0x29d40
movq 0xd8(%rsp), %rdi
movq %rax, 0xa0(%rsp)
movl $0x4, %esi
movl $0x5, %edx
callq 0x33a90
movq 0xa0(%rsp), %rcx
movq 0xd8(%rsp), %rdi
movq %rax, %rdx
movq 0xa8(%rsp), %rax
andq %rdx, %rcx
orq %rcx, %rax
movq %rax, 0xb8(%rsp)
movl 0xf8(%rsp), %esi
callq 0x1b550
movq 0xd8(%rsp), %rdi
movq %rax, 0xb0(%rsp)
movl $0x3, %esi
movl $0x5, %edx
callq 0x33a90
movq 0xb0(%rsp), %rcx
movq 0xd8(%rsp), %rdi
movq %rax, %rdx
movq 0xb8(%rsp), %rax
andq %rdx, %rcx
orq %rcx, %rax
movq %rax, 0xf0(%rsp)
movq 0xf0(%rsp), %rax
movq %rax, 0xc0(%rsp)
movl 0x134(%rsp), %esi
callq 0x298c0
movq 0xc0(%rsp), %rcx
movq %rax, %rdx
movq 0xd8(%rsp), %rax
andq %rdx, %rcx
movq 0x1938(%rax), %rax
movq %rcx, 0x40(%rax)
jmp 0x3b640
movb $0x0, 0xef(%rsp)
cmpl $0x6, 0x11c(%rsp)
jne 0x3b4df
movslq 0x12c(%rsp), %rcx
leaq 0x325af(%rip), %rax     # 0x6d8a0
shlq $0x6, %rcx
addq %rcx, %rax
movslq 0xf8(%rsp), %rcx
cmpb $0x0, (%rax,%rcx)
je 0x3b4dd
movslq 0x128(%rsp), %rcx
leaq 0x32587(%rip), %rax     # 0x6d8a0
shlq $0x6, %rcx
addq %rcx, %rax
movslq 0xf8(%rsp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x0, %eax
jne 0x3b4db
movq 0xd8(%rsp), %rdi
movl 0xf8(%rsp), %esi
movl $0x1, %edx
callq 0x1b460
movq 0xd8(%rsp), %rdi
movq %rax, 0x28(%rsp)
movl $0x1, %esi
xorl %edx, %edx
callq 0x16530
movq 0xd8(%rsp), %rdi
movq %rax, %rcx
movq 0x28(%rsp), %rax
andq %rcx, %rax
movq %rax, 0x38(%rsp)
movl 0xf8(%rsp), %esi
xorl %edx, %edx
callq 0x1b460
movq 0xd8(%rsp), %rdi
movq %rax, 0x30(%rsp)
movl $0x1, %edx
movl %edx, %esi
callq 0x16530
movq 0x30(%rsp), %rcx
movq 0xd8(%rsp), %rdi
movq %rax, %rdx
movq 0x38(%rsp), %rax
andq %rdx, %rcx
orq %rcx, %rax
movq %rax, 0x48(%rsp)
movl 0xf8(%rsp), %esi
callq 0x29aa0
movq 0xd8(%rsp), %rdi
movq %rax, 0x40(%rsp)
movl $0x2, %esi
callq 0x33a70
movq 0x40(%rsp), %rcx
movq 0xd8(%rsp), %rdi
movq %rax, %rdx
movq 0x48(%rsp), %rax
andq %rdx, %rcx
orq %rcx, %rax
movq %rax, 0x58(%rsp)
movl 0xf8(%rsp), %esi
callq 0x29d40
movq 0xd8(%rsp), %rdi
movq %rax, 0x50(%rsp)
movl $0x4, %esi
movl $0x5, %edx
callq 0x33a90
movq 0x50(%rsp), %rcx
movq 0xd8(%rsp), %rdi
movq %rax, %rdx
movq 0x58(%rsp), %rax
andq %rdx, %rcx
orq %rcx, %rax
movq %rax, 0x68(%rsp)
movl 0xf8(%rsp), %esi
callq 0x1b550
movq 0xd8(%rsp), %rdi
movq %rax, 0x60(%rsp)
movl $0x3, %esi
movl $0x5, %edx
callq 0x33a90
movq 0x60(%rsp), %rcx
movq 0xd8(%rsp), %rdi
movq %rax, %rdx
movq 0x68(%rsp), %rax
andq %rdx, %rcx
orq %rcx, %rax
movq %rax, 0xe0(%rsp)
movq 0xe0(%rsp), %rax
movq %rax, 0x70(%rsp)
movl 0x134(%rsp), %esi
callq 0x298c0
movq 0x70(%rsp), %rcx
movq %rax, %rdx
movq 0xd8(%rsp), %rax
andq %rdx, %rcx
movq 0x1938(%rax), %rax
movq %rcx, 0x40(%rax)
movb $0x1, 0xef(%rsp)
jmp 0x3b4dd
jmp 0x3b4df
testb $0x1, 0xef(%rsp)
jne 0x3b63e
movq 0x148(%rsp), %rax
movl 0x11c(%rsp), %ecx
movq 0x8(%rax,%rcx,8), %rdi
movl 0x128(%rsp), %esi
callq 0xd760
cmpq $0x0, %rax
je 0x3b539
movq 0xd8(%rsp), %rax
movslq 0x128(%rsp), %rdx
leaq 0x10cd86(%rip), %rcx    # 0x1482b0
movq (%rcx,%rdx,8), %rcx
movq 0x1938(%rax), %rax
movq %rcx, 0x40(%rax)
movq 0x148(%rsp), %rax
cmpq $0x0, (%rax)
je 0x3b63c
movq 0x148(%rsp), %rax
movq (%rax), %rdi
movl 0x12c(%rsp), %esi
callq 0xd760
cmpq $0x0, %rax
je 0x3b63c
cmpl $0x4, 0x11c(%rsp)
je 0x3b5d3
movq 0xd8(%rsp), %rdi
movq 0x148(%rsp), %rax
movl 0x48(%rax), %esi
callq 0x29d40
movq 0xd8(%rsp), %rdi
movq %rax, 0x20(%rsp)
movl 0x134(%rsp), %ecx
movl $0x4, %esi
movl $0x5, %edx
callq 0x29b80
movq 0x20(%rsp), %rcx
movq %rax, %rdx
movq 0xd8(%rsp), %rax
andq %rdx, %rcx
movq 0x1938(%rax), %rax
orq 0x40(%rax), %rcx
movq %rcx, 0x40(%rax)
cmpl $0x3, 0x11c(%rsp)
je 0x3b63a
movq 0xd8(%rsp), %rdi
movq 0x148(%rsp), %rax
movl 0x48(%rax), %esi
callq 0x1b550
movq 0xd8(%rsp), %rdi
movq %rax, 0x18(%rsp)
movl 0x134(%rsp), %ecx
movl $0x3, %esi
movl $0x5, %edx
callq 0x29b80
movq 0x18(%rsp), %rcx
movq %rax, %rdx
movq 0xd8(%rsp), %rax
andq %rdx, %rcx
movq 0x1938(%rax), %rax
orq 0x40(%rax), %rcx
movq %rcx, 0x40(%rax)
jmp 0x3b63c
jmp 0x3b63e
jmp 0x3b640
jmp 0x3b642
jmp 0x3b644
movq 0xd8(%rsp), %rax
movl 0x1090(%rax), %edi
callq 0x122b0
movl %eax, %ecx
movq 0xd8(%rsp), %rax
movl %ecx, 0x1090(%rax)
cmpl $0x0, 0x1090(%rax)
jne 0x3b67c
movl 0x3afe1a(%rip), %eax    # 0x3eb490
movl %eax, 0x14(%rsp)
jmp 0x3b68b
movl 0x3afe0e(%rip), %edi    # 0x3eb490
callq 0x29f10
movl %eax, 0x14(%rsp)
movq 0xd8(%rsp), %rax
movl 0x14(%rsp), %esi
movq 0x1938(%rax), %rdi
addq $0x24, %rdi
callq 0x29810
addq $0x168, %rsp            # imm = 0x168
retq
nop