// File: /workspace/github_c_makefile_star2_O0/PARKINHYO[P]BlackjackGame/fifo/fifo_server.c
// Function: play_game_one
void* play_game_one(void *data)
{
  int gnSemID2;      /* Semapore Indicator */
  int id = (intptr_t)data;
  int shmId = (intptr_t)data + 60100;
  int semId = (intptr_t)data+1 +60100;
  char buffer[BUFFER_SIZE];
  int nwritten;
  int player_sum, dealer_sum;
  int *player_hand_values = players_hand_values[id], *dealer_hand_values = dealers_hand_values[id];
  int *player_hand_suits = players_hand_suits[id], *dealer_hand_suits = dealers_hand_suits[id];
  int i;

  /* Semapore */
  key_t keySem;       /* Semapore Key */
  union semun sem_union;
  struct sembuf mysem_open  = {0, -1, SEM_UNDO}; // 세마포어 얻기
  struct sembuf mysem_close = {0, 1, SEM_UNDO};  // 세마포어 돌려주기

  /* Semapore 키값을 생성한다. */
  keySem = (key_t)semId;

  /* 공유 Semapore 세그먼트를 연다 - 필요하면 만든다. */
  if((gnSemID2 = semget( keySem, 1, IPC_CREAT | IPC_EXCL | 0666 )) == -1)
  {
   // printf("[SERVER]Semapore segment exist - opening as client\n");
    /* 세그먼트가 이미 존재한다면 - try as a client */
    if( (gnSemID2 = semget( keySem, 0, 0 )) == -1 )
    {
      perror("semget");
      exit(1);
    }
  }
  else
  {
   // printf("[SERVER]Creating new semapore segment\n");
  }

  /* Semapore 초기화 */
  sem_union.val = 1;
  semctl( gnSemID2, 0, SETVAL, sem_union );

  /*첫 카드 뽑기*/
  nplayers[id] = 0;
	ndealers[id] = 0;
  /*딜러들의 카드덱은 공유 - mutex로 raceCondition 제어*/
  pthread_mutex_lock(&card_mutex);
	{
		for (i = 0; i < 2; ++i)
		{
			player_hand_values[nplayers[id]] = card_values[ncard];
			player_hand_suits[nplayers[id]] = card_suits[ncard];
			++ncard;
			++nplayers[id];
		}

		dealer_hand_values[ndealers[id]] = card_values[ncard];
		dealer_hand_suits[ndealers[id]] = card_suits[ncard];
		++ncard;
		++ndealers[id];
	}
	pthread_mutex_unlock(&card_mutex);

  buffer[0] = value_codes[player_hand_values[0]];
	buffer[1] = suit_codes[player_hand_suits[0]];
	buffer[2] = value_codes[player_hand_values[1]];
	buffer[3] = suit_codes[player_hand_suits[1]];
	buffer[4] = value_codes[dealer_hand_values[0]];
	buffer[5] = suit_codes[dealer_hand_suits[0]];
	buffer[6] = 0;

  /******* 임계영역 *******/
  if( semop(gnSemID2, &mysem_open, 1) == -1 )
	{
		perror("semop");
		exit(1);
	}

  //client[id-1]로 카드 줌 )
	write(client[id - 1], buffer, BUFFER_SIZE);

	printf("[SERVER] send to player[%d]: first cardset\n",id);

  semop(gnSemID2, &mysem_close, 1);
  /******* 임계영역 *******/

  /* 첫 카드를 주고서*/
  printf("\n");
  printf("[SERVER] Player[%d] Hand: ",id );
  display_state(player_hand_values, player_hand_suits, nplayers[id]);
  printf("[SERVER] Dealer Hand with player[%d]: ",id);
  display_state(dealer_hand_values, dealer_hand_suits, ndealers[id]);

  //HIT STAND 받을 파이프 open
  clientRead[id - 1] = open(filename2, O_RDWR);

  while (TRUE) {
	  sleep(1);
	  //HIT / STAND 받음
	  read(clientRead[id - 1], buffer, BUFFER_SIZE);
	  printf("[SERVER] I received from player[%d]: %s\n", id, buffer);

	  //HIT일때
	  if (strcmp(buffer, HIT) == 0)
	  {
		  pthread_mutex_lock(&card_mutex);
		  {
			  player_hand_values[nplayers[id]] = card_values[ncard];
			  player_hand_suits[nplayers[id]] = card_suits[ncard];

			  buffer[0] = value_codes[player_hand_values[nplayers[id]]];
			  buffer[1] = suit_codes[player_hand_suits[nplayers[id]]];
			  buffer[2] = 0;

			  ++ncard;
			  ++nplayers[id];
		  }
		  pthread_mutex_unlock(&card_mutex);

		  //새로운 카드 클라이언트로 보냄
		  write(client[id - 1], buffer, BUFFER_SIZE);
		  printf("[SERVER] I send to player[%d]: %s\n", id, buffer);

		  check2[0] = 1;
		  buffer[0] = '\0';
		  semop(gnSemID2, &mysem_close, 1);

		  /* 플레이어 결과가 21이 넘을 경우*/
		  if (calc_sum(player_hand_values, nplayers[id]) > 21)
		  {
			  printf("[SERVER] Player[%d] busted. Dealer wins.\n", id);
			  return NULL;
		  }
		  /* 플레이어 결과가 21일 경우 이기기 때문에 break */
		  else if (calc_sum(player_hand_values, nplayers[id]) == 21)
			  break;
	  } //여기까지 HIT 처리

	  //STAND 일때 - break
	  else if (strcmp(buffer, STAND) == 0) {
		  check2[0] = 1;
		  semop(gnSemID2, &mysem_close, 1);
		  break;
	  }
  }
  i=0;
  while (calc_sum(dealer_hand_values, ndealers[id]) < 17)
  {
    dealer_hand_values[ndealers[id]] = card_values[ncard];
    dealer_hand_suits[ndealers[id]] = card_suits[ncard];
    buffer[i++] = value_codes[dealer_hand_values[ndealers[id]]];
    buffer[i++] = suit_codes[dealer_hand_suits[ndealers[id]]];
    ++ncard;
    ++ndealers[id];
  }
  buffer[i] = 0;

  printf("\n");
  printf("[SERVER] Player[%d] Hand: ",id);
  display_state(player_hand_values, player_hand_suits, nplayers[id]);
  printf("[SERVER] Dealer Hand with Player[%d]: ",id);
  display_state(dealer_hand_values, dealer_hand_suits, ndealers[id]);

  if( semop(gnSemID2, &mysem_open, 1) == -1 )
  {
          perror("semop");
          exit(1);
  }
  //카드 보냄
  write(client[id - 1], buffer, BUFFER_SIZE);


  player_sum = calc_sum(player_hand_values, nplayers[id]);
  dealer_sum = calc_sum(dealer_hand_values, ndealers[id]);

  //결과
  if (dealer_sum > 21)
    printf("\n[SERVER] Dealer busted! Player[%d] wins!\n", id);
  else if (player_sum == dealer_sum)
    printf("\n[SERVER] Player[%d] and dealer have the SAME score. It's a push!\n", id);
  else if (player_sum < dealer_sum)
    printf("\n[SERVER] Dealer has a higher score than player[%d]. Dealer wins!\n", id);
  else
    printf("\n[SERVER] Player[%d] has a higher score. Player wins!\n", id);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movl %eax, -0x18(%rbp)
movq -0x10(%rbp), %rax
addq $0xeac4, %rax           # imm = 0xEAC4
movl %eax, -0x1c(%rbp)
movq -0x10(%rbp), %rax
addq $0x1, %rax
addq $0xeac4, %rax           # imm = 0xEAC4
movl %eax, -0x20(%rbp)
movslq -0x18(%rbp), %rcx
leaq 0x3b31(%rip), %rax      # 0x53e0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x58(%rbp)
movslq -0x18(%rbp), %rcx
leaq 0x3cab(%rip), %rax      # 0x5570
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x60(%rbp)
movslq -0x18(%rbp), %rcx
leaq 0x3e25(%rip), %rax      # 0x5700
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x68(%rbp)
movslq -0x18(%rbp), %rcx
leaq 0x3f9f(%rip), %rax      # 0x5890
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x70(%rbp)
movl 0x1a7c(%rip), %eax      # 0x337e
movl %eax, -0x86(%rbp)
movw 0x1a73(%rip), %ax       # 0x3382
movw %ax, -0x82(%rbp)
movl 0x1a68(%rip), %eax      # 0x3384
movl %eax, -0x8c(%rbp)
movw 0x1a5f(%rip), %ax       # 0x3388
movw %ax, -0x88(%rbp)
movl -0x20(%rbp), %eax
movl %eax, -0x78(%rbp)
movl -0x78(%rbp), %edi
movl $0x1, %esi
movl $0x7b6, %edx            # imm = 0x7B6
callq 0x1030
movl %eax, -0x14(%rbp)
cmpl $-0x1, %eax
jne 0x197c
movl -0x78(%rbp), %edi
xorl %edx, %edx
movl %edx, %esi
callq 0x1030
movl %eax, -0x14(%rbp)
cmpl $-0x1, %eax
jne 0x197a
leaq 0x16fe(%rip), %rdi      # 0x3069
callq 0x1120
movl $0x1, %edi
callq 0x1160
jmp 0x197e
jmp 0x197e
movl $0x1, -0x80(%rbp)
movl -0x14(%rbp), %edi
movq -0x80(%rbp), %rcx
xorl %esi, %esi
movl $0x10, %edx
movb $0x0, %al
callq 0x1130
movslq -0x18(%rbp), %rcx
leaq 0x407b(%rip), %rax      # 0x5a20
movl $0x0, (%rax,%rcx,4)
movslq -0x18(%rbp), %rcx
leaq 0x4089(%rip), %rax      # 0x5a40
movl $0x0, (%rax,%rcx,4)
leaq 0x4093(%rip), %rdi      # 0x5a58
callq 0x1190
movl $0x0, -0x74(%rbp)
cmpl $0x2, -0x74(%rbp)
jge 0x1a61
movslq 0x39ee(%rip), %rcx      # 0x53d0
leaq 0x3847(%rip), %rax      # 0x5230
movl (%rax,%rcx,4), %edx
movq -0x58(%rbp), %rax
movslq -0x18(%rbp), %rsi
leaq 0x4025(%rip), %rcx      # 0x5a20
movslq (%rcx,%rsi,4), %rcx
movl %edx, (%rax,%rcx,4)
movslq 0x39c7(%rip), %rcx      # 0x53d0
leaq 0x38f0(%rip), %rax      # 0x5300
movl (%rax,%rcx,4), %edx
movq -0x68(%rbp), %rax
movslq -0x18(%rbp), %rsi
leaq 0x3ffe(%rip), %rcx      # 0x5a20
movslq (%rcx,%rsi,4), %rcx
movl %edx, (%rax,%rcx,4)
movl 0x39a1(%rip), %eax      # 0x53d0
addl $0x1, %eax
movl %eax, 0x3998(%rip)      # 0x53d0
movslq -0x18(%rbp), %rcx
leaq 0x3fdd(%rip), %rax      # 0x5a20
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
leaq 0x3fd0(%rip), %rax      # 0x5a20
movl %edx, (%rax,%rcx,4)
movl -0x74(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x74(%rbp)
jmp 0x19d1
movslq 0x3968(%rip), %rcx      # 0x53d0
leaq 0x37c1(%rip), %rax      # 0x5230
movl (%rax,%rcx,4), %edx
movq -0x60(%rbp), %rax
movslq -0x18(%rbp), %rsi
leaq 0x3fbf(%rip), %rcx      # 0x5a40
movslq (%rcx,%rsi,4), %rcx
movl %edx, (%rax,%rcx,4)
movslq 0x3941(%rip), %rcx      # 0x53d0
leaq 0x386a(%rip), %rax      # 0x5300
movl (%rax,%rcx,4), %edx
movq -0x70(%rbp), %rax
movslq -0x18(%rbp), %rsi
leaq 0x3f98(%rip), %rcx      # 0x5a40
movslq (%rcx,%rsi,4), %rcx
movl %edx, (%rax,%rcx,4)
movl 0x391b(%rip), %eax      # 0x53d0
addl $0x1, %eax
movl %eax, 0x3912(%rip)      # 0x53d0
movslq -0x18(%rbp), %rcx
leaq 0x3f77(%rip), %rax      # 0x5a40
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
leaq 0x3f6a(%rip), %rax      # 0x5a40
movl %edx, (%rax,%rcx,4)
leaq 0x3f78(%rip), %rdi      # 0x5a58
callq 0x10e0
movq -0x58(%rbp), %rax
movslq (%rax), %rcx
leaq 0x1871(%rip), %rax      # 0x3364
movb (%rax,%rcx), %al
movb %al, -0x40(%rbp)
movq -0x68(%rbp), %rax
movslq (%rax), %rcx
leaq 0x1859(%rip), %rax      # 0x3360
movb (%rax,%rcx), %al
movb %al, -0x3f(%rbp)
movq -0x58(%rbp), %rax
movslq 0x4(%rax), %rcx
leaq 0x1848(%rip), %rax      # 0x3364
movb (%rax,%rcx), %al
movb %al, -0x3e(%rbp)
movq -0x68(%rbp), %rax
movslq 0x4(%rax), %rcx
leaq 0x182f(%rip), %rax      # 0x3360
movb (%rax,%rcx), %al
movb %al, -0x3d(%rbp)
movq -0x60(%rbp), %rax
movslq (%rax), %rcx
leaq 0x181f(%rip), %rax      # 0x3364
movb (%rax,%rcx), %al
movb %al, -0x3c(%rbp)
movq -0x70(%rbp), %rax
movslq (%rax), %rcx
leaq 0x1807(%rip), %rax      # 0x3360
movb (%rax,%rcx), %al
movb %al, -0x3b(%rbp)
movb $0x0, -0x3a(%rbp)
movl -0x14(%rbp), %edi
leaq -0x86(%rbp), %rsi
movl $0x1, %edx
callq 0x1140
cmpl $-0x1, %eax
jne 0x1b92
leaq 0x1574(%rip), %rdi      # 0x30f7
callq 0x1120
movl $0x1, %edi
callq 0x1160
movl -0x18(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rcx
leaq 0x367e(%rip), %rax      # 0x5220
movl (%rax,%rcx,4), %edi
leaq -0x40(%rbp), %rsi
movl $0x20, %edx
callq 0x1040
movl -0x18(%rbp), %esi
leaq 0x15a5(%rip), %rdi      # 0x3162
movb $0x0, %al
callq 0x1050
movl -0x14(%rbp), %edi
leaq -0x8c(%rbp), %rsi
movl $0x1, %edx
callq 0x1140
leaq 0x14bf(%rip), %rdi      # 0x309e
movb $0x0, %al
callq 0x1050
movl -0x18(%rbp), %esi
leaq 0x159e(%rip), %rdi      # 0x318e
movb $0x0, %al
callq 0x1050
movq -0x58(%rbp), %rdi
movq -0x68(%rbp), %rsi
movslq -0x18(%rbp), %rcx
leaq 0x3e16(%rip), %rax      # 0x5a20
movl (%rax,%rcx,4), %edx
callq 0x1450
movl -0x18(%rbp), %esi
leaq 0x158d(%rip), %rdi      # 0x31a9
movb $0x0, %al
callq 0x1050
movq -0x60(%rbp), %rdi
movq -0x70(%rbp), %rsi
movslq -0x18(%rbp), %rcx
leaq 0x3e0a(%rip), %rax      # 0x5a40
movl (%rax,%rcx,4), %edx
callq 0x1450
leaq 0x35bb(%rip), %rdi      # 0x5200
movl $0x2, %esi
movb $0x0, %al
callq 0x1110
movl %eax, %edx
movl -0x18(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rcx
leaq 0x3e1d(%rip), %rax      # 0x5a80
movl %edx, (%rax,%rcx,4)
movl $0x1, %edi
callq 0x1180
movl -0x18(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rcx
leaq 0x3e00(%rip), %rax      # 0x5a80
movl (%rax,%rcx,4), %edi
leaq -0x40(%rbp), %rsi
movl $0x20, %edx
callq 0x1070
movl -0x18(%rbp), %esi
leaq -0x40(%rbp), %rdx
leaq 0x1531(%rip), %rdi      # 0x31d0
movb $0x0, %al
callq 0x1050
leaq -0x40(%rbp), %rdi
leaq 0x1548(%rip), %rsi      # 0x31f9
callq 0x1090
cmpl $0x0, %eax
jne 0x1e4f
leaq 0x3d92(%rip), %rdi      # 0x5a58
callq 0x1190
movslq 0x36fe(%rip), %rcx      # 0x53d0
leaq 0x3557(%rip), %rax      # 0x5230
movl (%rax,%rcx,4), %edx
movq -0x58(%rbp), %rax
movslq -0x18(%rbp), %rsi
leaq 0x3d35(%rip), %rcx      # 0x5a20
movslq (%rcx,%rsi,4), %rcx
movl %edx, (%rax,%rcx,4)
movslq 0x36d7(%rip), %rcx      # 0x53d0
leaq 0x3600(%rip), %rax      # 0x5300
movl (%rax,%rcx,4), %edx
movq -0x68(%rbp), %rax
movslq -0x18(%rbp), %rsi
leaq 0x3d0e(%rip), %rcx      # 0x5a20
movslq (%rcx,%rsi,4), %rcx
movl %edx, (%rax,%rcx,4)
movq -0x58(%rbp), %rax
movslq -0x18(%rbp), %rdx
leaq 0x3cf8(%rip), %rcx      # 0x5a20
movslq (%rcx,%rdx,4), %rcx
movslq (%rax,%rcx,4), %rcx
leaq 0x162d(%rip), %rax      # 0x3364
movb (%rax,%rcx), %al
movb %al, -0x40(%rbp)
movq -0x68(%rbp), %rax
movslq -0x18(%rbp), %rdx
leaq 0x3cd4(%rip), %rcx      # 0x5a20
movslq (%rcx,%rdx,4), %rcx
movslq (%rax,%rcx,4), %rcx
leaq 0x1605(%rip), %rax      # 0x3360
movb (%rax,%rcx), %al
movb %al, -0x3f(%rbp)
movb $0x0, -0x3e(%rbp)
movl 0x3665(%rip), %eax      # 0x53d0
addl $0x1, %eax
movl %eax, 0x365c(%rip)      # 0x53d0
movslq -0x18(%rbp), %rcx
leaq 0x3ca1(%rip), %rax      # 0x5a20
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
leaq 0x3c94(%rip), %rax      # 0x5a20
movl %edx, (%rax,%rcx,4)
leaq 0x3cc2(%rip), %rdi      # 0x5a58
callq 0x10e0
movl -0x18(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rcx
leaq 0x3475(%rip), %rax      # 0x5220
movl (%rax,%rcx,4), %edi
leaq -0x40(%rbp), %rsi
movl $0x20, %edx
callq 0x1040
movl -0x18(%rbp), %esi
leaq -0x40(%rbp), %rdx
leaq 0x1433(%rip), %rdi      # 0x31fd
movb $0x0, %al
callq 0x1050
movl $0x1, 0x3cb1(%rip)      # 0x5a8c
movb $0x0, -0x40(%rbp)
movl -0x14(%rbp), %edi
leaq -0x8c(%rbp), %rsi
movl $0x1, %edx
callq 0x1140
movq -0x58(%rbp), %rdi
movslq -0x18(%rbp), %rcx
leaq 0x3c1e(%rip), %rax      # 0x5a20
movl (%rax,%rcx,4), %esi
callq 0x13b0
cmpl $0x15, %eax
jle 0x1e2d
movl -0x18(%rbp), %esi
leaq 0x1407(%rip), %rdi      # 0x3220
movb $0x0, %al
callq 0x1050
movq $0x0, -0x8(%rbp)
jmp 0x20ea
movq -0x58(%rbp), %rdi
movslq -0x18(%rbp), %rcx
leaq 0x3be4(%rip), %rax      # 0x5a20
movl (%rax,%rcx,4), %esi
callq 0x13b0
cmpl $0x15, %eax
jne 0x1e4b
jmp 0x1e8b
jmp 0x1e4d
jmp 0x1e86
leaq -0x40(%rbp), %rdi
leaq 0x13f0(%rip), %rsi      # 0x324a
callq 0x1090
cmpl $0x0, %eax
jne 0x1e84
movl $0x1, 0x3c1e(%rip)      # 0x5a8c
movl -0x14(%rbp), %edi
leaq -0x8c(%rbp), %rsi
movl $0x1, %edx
callq 0x1140
jmp 0x1e8b
jmp 0x1e86
jmp 0x1c66
movl $0x0, -0x74(%rbp)
movq -0x60(%rbp), %rdi
movslq -0x18(%rbp), %rcx
leaq 0x3b9f(%rip), %rax      # 0x5a40
movl (%rax,%rcx,4), %esi
callq 0x13b0
cmpl $0x11, %eax
jge 0x1f93
movslq 0x3517(%rip), %rcx      # 0x53d0
leaq 0x3370(%rip), %rax      # 0x5230
movl (%rax,%rcx,4), %edx
movq -0x60(%rbp), %rax
movslq -0x18(%rbp), %rsi
leaq 0x3b6e(%rip), %rcx      # 0x5a40
movslq (%rcx,%rsi,4), %rcx
movl %edx, (%rax,%rcx,4)
movslq 0x34f0(%rip), %rcx      # 0x53d0
leaq 0x3419(%rip), %rax      # 0x5300
movl (%rax,%rcx,4), %edx
movq -0x70(%rbp), %rax
movslq -0x18(%rbp), %rsi
leaq 0x3b47(%rip), %rcx      # 0x5a40
movslq (%rcx,%rsi,4), %rcx
movl %edx, (%rax,%rcx,4)
movq -0x60(%rbp), %rax
movslq -0x18(%rbp), %rdx
leaq 0x3b31(%rip), %rcx      # 0x5a40
movslq (%rcx,%rdx,4), %rcx
movslq (%rax,%rcx,4), %rcx
leaq 0x1446(%rip), %rax      # 0x3364
movb (%rax,%rcx), %cl
movl -0x74(%rbp), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, -0x74(%rbp)
cltq
movb %cl, -0x40(%rbp,%rax)
movq -0x70(%rbp), %rax
movslq -0x18(%rbp), %rdx
leaq 0x3aff(%rip), %rcx      # 0x5a40
movslq (%rcx,%rdx,4), %rcx
movslq (%rax,%rcx,4), %rcx
leaq 0x1410(%rip), %rax      # 0x3360
movb (%rax,%rcx), %cl
movl -0x74(%rbp), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, -0x74(%rbp)
cltq
movb %cl, -0x40(%rbp,%rax)
movl 0x3466(%rip), %eax      # 0x53d0
addl $0x1, %eax
movl %eax, 0x345d(%rip)      # 0x53d0
movslq -0x18(%rbp), %rcx
leaq 0x3ac2(%rip), %rax      # 0x5a40
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
leaq 0x3ab5(%rip), %rax      # 0x5a40
movl %edx, (%rax,%rcx,4)
jmp 0x1e92
movslq -0x74(%rbp), %rax
movb $0x0, -0x40(%rbp,%rax)
leaq 0x10fb(%rip), %rdi      # 0x309e
movb $0x0, %al
callq 0x1050
movl -0x18(%rbp), %esi
leaq 0x11da(%rip), %rdi      # 0x318e
movb $0x0, %al
callq 0x1050
movq -0x58(%rbp), %rdi
movq -0x68(%rbp), %rsi
movslq -0x18(%rbp), %rcx
leaq 0x3a52(%rip), %rax      # 0x5a20
movl (%rax,%rcx,4), %edx
callq 0x1450
movl -0x18(%rbp), %esi
leaq 0x1270(%rip), %rdi      # 0x3250
movb $0x0, %al
callq 0x1050
movq -0x60(%rbp), %rdi
movq -0x70(%rbp), %rsi
movslq -0x18(%rbp), %rcx
leaq 0x3a46(%rip), %rax      # 0x5a40
movl (%rax,%rcx,4), %edx
callq 0x1450
movl -0x14(%rbp), %edi
leaq -0x86(%rbp), %rsi
movl $0x1, %edx
callq 0x1140
cmpl $-0x1, %eax
jne 0x2031
leaq 0x10d5(%rip), %rdi      # 0x30f7
callq 0x1120
movl $0x1, %edi
callq 0x1160
movl -0x18(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rcx
leaq 0x31df(%rip), %rax      # 0x5220
movl (%rax,%rcx,4), %edi
leaq -0x40(%rbp), %rsi
movl $0x20, %edx
callq 0x1040
movq -0x58(%rbp), %rdi
movslq -0x18(%rbp), %rcx
leaq 0x39bf(%rip), %rax      # 0x5a20
movl (%rax,%rcx,4), %esi
callq 0x13b0
movl %eax, -0x48(%rbp)
movq -0x60(%rbp), %rdi
movslq -0x18(%rbp), %rcx
leaq 0x39c5(%rip), %rax      # 0x5a40
movl (%rax,%rcx,4), %esi
callq 0x13b0
movl %eax, -0x4c(%rbp)
cmpl $0x15, -0x4c(%rbp)
jle 0x209f
movl -0x18(%rbp), %esi
leaq 0x11e1(%rip), %rdi      # 0x3277
movb $0x0, %al
callq 0x1050
jmp 0x20ea
movl -0x48(%rbp), %eax
cmpl -0x4c(%rbp), %eax
jne 0x20ba
movl -0x18(%rbp), %esi
leaq 0x11f1(%rip), %rdi      # 0x32a2
movb $0x0, %al
callq 0x1050
jmp 0x20e8
movl -0x48(%rbp), %eax
cmpl -0x4c(%rbp), %eax
jge 0x20d5
movl -0x18(%rbp), %esi
leaq 0x1219(%rip), %rdi      # 0x32e5
movb $0x0, %al
callq 0x1050
jmp 0x20e6
movl -0x18(%rbp), %esi
leaq 0x1249(%rip), %rdi      # 0x3328
movb $0x0, %al
callq 0x1050
jmp 0x20e8
jmp 0x20ea
movq -0x8(%rbp), %rax
addq $0x90, %rsp
popq %rbp
retq
nopw (%rax,%rax)