// File: /workspace/github_c_makefile_star2_O1/PARKINHYO[P]BlackjackGame/shm/shm_server.c
// Function: play_game_one
void* play_game_one(void *data)
{
  int gnShmID2;      /* Shared Memory Indicator */
  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;

  /* Shared Memory */
  key_t keyShm;       /* Shared Memory Key */
  _ST_SHM *shared_data;      /* 공용 메모리 구조체 */

  /* 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};  // 세마포어 돌려주기

  /* Shared Memory의 키값을 생성한다. */
  keyShm = (key_t)shmId;
  /* Semapore 키값을 생성한다. */
  keySem = (key_t)semId;
  /* 공유 메모리 세그먼트를 연다 - 필요하면 만든다. */
  if((gnShmID2 = shmget( keyShm, SEGSIZE, IPC_CREAT | IPC_EXCL | 0666 )) == -1)
  {
    printf("Shared memory segment exist - opening as client\n");
    /* 세그먼트가 이미 존재한다면 - try as a client */
    if( (gnShmID2 = shmget( keyShm, SEGSIZE, 0 )) == -1 )
    {
      perror("shmget");
      exit(1);
          }
  }
  else
  {
    printf("Creating new shared memory segment\n");
  }
  /* 현재 프로세스에 공유 메모리 세그먼트를 연결한다. */
  if((shared_data = (_ST_SHM *)shmat(gnShmID2, 0, 0)) == NULL)
  {
    perror("shmat");
    exit(1);
  }
  /* 공유 Semapore 세그먼트를 연다 - 필요하면 만든다. */
  if((gnSemID2 = semget( keySem, 1, IPC_CREAT | IPC_EXCL | 0666 )) == -1)
  {
    printf("Semapore segment exist - opening as client\n");
    /* 세그먼트가 이미 존재한다면 - try as a client */
    if( (gnSemID2 = semget( keySem, 0, 0 )) == -1 )
    {
      perror("semget");
      exit(1);
    }
  }
  else
  {
    printf("Creating new semapore segment\n");
  }

  /* 공유 메모리 초기화 */
  shared_data->check = 0;
  shared_data->check2 = 0;
  shared_data->finalcheck=0;
  /* 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);
	}
  /* shared memory 전송 */
  strncpy(shared_data->data, buffer, BUFFER_SIZE);
	printf("send: first cardset\n");
  shared_data->check = 1;
  semop(gnSemID2, &mysem_close, 1);
  /******* 임계영역 *******/

  while(shared_data->check) {
     sleep(1);
     printf("waiting...\n");
   }
  /* 첫 카드를 주고서*/
  printf("\n");
  printf("Player %d Hand: ", id );
  display_state(player_hand_values, player_hand_suits, nplayers[id]);
  printf("Dealer Hand with player %d: ", id);
  display_state(dealer_hand_values, dealer_hand_suits, ndealers[id]);

  while(TRUE){
    if(!shared_data->check2){
      if( semop(gnSemID2, &mysem_open, 1) == -1 ) // 대기상태
      {
        perror("semop");
        exit(1);
      }
    }
    /* HIT, STAND signal 빋기*/
    if(!shared_data->check2)
    {
      strncpy(buffer, shared_data->data, BUFFER_SIZE);
      shared_data->check2=1;
      printf("I received from player %d: %s\n", id, buffer);
      strncpy(shared_data->data, "\0", BUFFER_SIZE);

      /* 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);

        strncpy(shared_data->data, buffer, BUFFER_SIZE);
        printf("I send to player %d: %s\n", id, buffer);
        shared_data->check=2;
        buffer[0] = '\0';
        semop(gnSemID2, &mysem_close, 1);

        /* 플레이어 결과가 21이 넘을 경우*/
        if (calc_sum(player_hand_values, nplayers[id]) > 21)
        {
          printf("Player %d busted. Dealer wins.\n", id);
          break;
        }
        /* 플레이어 결과가 21일 경우 이기기 때문에 break */
        else if (calc_sum(player_hand_values, nplayers[id]) == 21)
          break;
      }
      /* 플레이어의 signal이 STAND인 경우 stop*/
      else if (strcmp(buffer, STAND) == 0){
        //shared_data->finalcheck=1;
        shared_data->check=0;
        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("Player %d Hand: ", id);
  display_state(player_hand_values, player_hand_suits, nplayers[id]);
  printf("Dealer %d Hand: ", id);
  display_state(dealer_hand_values, dealer_hand_suits, ndealers[id]);

  if( semop(gnSemID2, &mysem_open, 1) == -1 )
  {
          perror("semop");
          exit(1);
  }
  strncpy(shared_data->data, buffer, BUFFER_SIZE);
  shared_data->finalcheck=1;
  semop(gnSemID2, &mysem_close, 1);

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

  if (dealer_sum > 21)
    printf("\nDealer busted! Player %d wins!\n", id);
  else if (player_sum == dealer_sum)
    printf("\nPlayer %d and dealer have the same score. It's a push!\n", id);
  else if (player_sum < dealer_sum)
    printf("\nDealer has a higher score than player %d. Dealer wins!\n", id);
  else
    printf("\nPlayer %d has a higher score. Player wins!\n", id);


    /* 세마포어, shared memory 제거*/
  if(shmdt(shared_data) == -1) {
     perror("shmdt failed");
     exit(1);
  }

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rdi, %r15
leal 0xeac4(%rdi), %ebx
movw $0x1000, %ax            # imm = 0x1000
movw %ax, -0x4c(%rbp)
movl $0xffff0000, -0x50(%rbp) # imm = 0xFFFF0000
movw %ax, -0x44(%rbp)
movl $0x10000, -0x48(%rbp)   # imm = 0x10000
movl $0x2c, %esi
movl %ebx, %edi
movl $0x7b6, %edx            # imm = 0x7B6
callq 0x1150
cmpl $-0x1, %eax
je 0x191d
movl %eax, %r14d
leaq 0x196d(%rip), %rdi      # 0x3283
callq 0x1080
jmp 0x1943
leaq 0x1982(%rip), %rdi      # 0x32a6
callq 0x1080
movl $0x2c, %esi
movl %ebx, %edi
xorl %edx, %edx
callq 0x1150
movl %eax, %r14d
cmpl $-0x1, %eax
je 0x2059
movl %r14d, %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0x1140
movq %rax, -0x38(%rbp)
testq %rax, %rax
je 0x2045
leal 0xeac5(%r15), %ebx
movl %ebx, %edi
movl $0x1, %esi
movl $0x7b6, %edx            # imm = 0x7B6
callq 0x1030
cmpl $-0x1, %eax
je 0x198d
movl %eax, %r14d
leaq 0x1953(%rip), %rdi      # 0x32d6
callq 0x1080
movl %r14d, %eax
jmp 0x19ad
leaq 0x1960(%rip), %rdi      # 0x32f4
callq 0x1080
movl %ebx, %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0x1030
cmpl $-0x1, %eax
je 0x205e
movq %r15, -0x40(%rbp)
movslq %r15d, %r15
movq %r15, %rcx
shlq $0x4, %rcx
leaq (%rcx,%rcx,4), %rbx
leaq 0x399a(%rip), %r13      # 0x5360
addq %rbx, %r13
leaq 0x3ad0(%rip), %rcx      # 0x54a0
leaq (%rcx,%rbx), %r14
leaq 0x3c05(%rip), %r12      # 0x55e0
addq %rbx, %r12
leaq 0x3d3b(%rip), %rcx      # 0x5720
addq %rcx, %rbx
movq -0x38(%rbp), %rcx
movq $0x0, (%rcx)
xorl %edx, %edx
movl %edx, 0x8(%rcx)
movl $0x1, %ecx
movl %eax, %edi
movl %eax, -0x2c(%rbp)
xorl %esi, %esi
movl $0x10, %edx
xorl %eax, %eax
callq 0x1130
leaq 0x3e49(%rip), %rax      # 0x5860
xorl %ecx, %ecx
movl %ecx, (%rax,%r15,4)
leaq 0x3e4c(%rip), %rax      # 0x5870
movl %ecx, (%rax,%r15,4)
leaq 0x3e51(%rip), %rdi      # 0x5880
callq 0x11b0
movslq 0x3915(%rip), %rax      # 0x5350
leaq 0x3e1e(%rip), %r8       # 0x5860
movslq (%r8,%r15,4), %rcx
leaq 0x3763(%rip), %rsi      # 0x51b0
movq (%rsi,%rax,4), %rdx
movq %rdx, (%r13,%rcx,4)
leaq 0x3823(%rip), %rdi      # 0x5280
movq (%rdi,%rax,4), %rdx
movq %rdx, (%r12,%rcx,4)
leal 0x2(%rax), %edx
leal 0x2(%rcx), %ecx
movl %edx, 0x38df(%rip)      # 0x5350
movl %ecx, (%r8,%r15,4)
movslq %edx, %rcx
movl (%rsi,%rcx,4), %edx
leaq 0x3dee(%rip), %r8       # 0x5870
movslq (%r8,%r15,4), %rsi
movl %edx, (%r14,%rsi,4)
movl (%rdi,%rcx,4), %ecx
movl %ecx, (%rbx,%rsi,4)
addl $0x3, %eax
movl %eax, 0x38b7(%rip)      # 0x5350
leal 0x1(%rsi), %eax
movq %r15, -0x58(%rbp)
movl %eax, (%r8,%r15,4)
leaq 0x3dd5(%rip), %rdi      # 0x5880
callq 0x10f0
movslq (%r13), %rax
leaq 0x1887(%rip), %rcx      # 0x3342
movb (%rax,%rcx), %al
movb %al, -0x80(%rbp)
movslq (%r12), %rax
leaq 0x1872(%rip), %rdx      # 0x333e
movb (%rax,%rdx), %al
movb %al, -0x7f(%rbp)
movq %r13, -0x90(%rbp)
movslq 0x4(%r13), %rax
movb (%rax,%rcx), %al
movb %al, -0x7e(%rbp)
movq %r12, -0x98(%rbp)
movslq 0x4(%r12), %rax
movb (%rax,%rdx), %al
movb %al, -0x7d(%rbp)
movq %r14, -0x88(%rbp)
movslq (%r14), %rax
movb (%rax,%rcx), %al
movb %al, -0x7c(%rbp)
movq %rbx, -0xa0(%rbp)
movslq (%rbx), %rax
movb (%rax,%rdx), %al
movb %al, -0x7b(%rbp)
movb $0x0, -0x7a(%rbp)
leaq -0x50(%rbp), %rsi
movl $0x1, %edx
movl -0x2c(%rbp), %ebx
movl %ebx, %edi
callq 0x1160
cmpl $-0x1, %eax
je 0x204a
movq -0x38(%rbp), %r14
movq %r14, %r12
addq $0xc, %r12
leaq -0x80(%rbp), %rsi
movl $0x20, %edx
movq %r12, %rdi
callq 0x1050
leaq 0x17c7(%rip), %rdi      # 0x331f
callq 0x1080
movl $0x1, (%r14)
leaq -0x48(%rbp), %rsi
movl $0x1, %edx
movl %ebx, %edi
callq 0x1160
cmpl $0x0, (%r14)
je 0x1b9c
leaq 0x17b2(%rip), %rbx      # 0x3333
movl $0x1, %edi
callq 0x11a0
movq %rbx, %rdi
callq 0x1080
movq -0x38(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x1b81
movl $0xa, %edi
callq 0x1040
leaq 0x14e9(%rip), %rdi      # 0x3096
movq -0x40(%rbp), %rbx
movl %ebx, %esi
xorl %eax, %eax
callq 0x10a0
movq -0x58(%rbp), %r13
leaq 0x3c9b(%rip), %rax      # 0x5860
movl (%rax,%r13,4), %edx
movq -0x90(%rbp), %rdi
movq -0x98(%rbp), %rsi
callq 0x14a0
leaq 0x14c4(%rip), %rdi      # 0x30a7
movq %rbx, %r14
movl %ebx, %esi
xorl %eax, %eax
callq 0x10a0
leaq 0x3c7a(%rip), %rax      # 0x5870
movl (%rax,%r13,4), %edx
movq -0x88(%rbp), %rdi
movq -0xa0(%rbp), %rsi
callq 0x14a0
leaq -0x80(%rbp), %r15
leaq 0x3598(%rip), %r13      # 0x51b0
movq -0x38(%rbp), %rax
cmpl $0x0, 0x4(%rax)
jne 0x1c3c
movl $0x1, %edx
movl -0x2c(%rbp), %edi
leaq -0x50(%rbp), %rsi
callq 0x1160
cmpl $-0x1, %eax
je 0x2040
movq -0x38(%rbp), %rax
cmpl $0x0, 0x4(%rax)
jne 0x1c18
movl $0x20, %edx
movq %r15, %rdi
movq %r12, %rsi
callq 0x1050
movq -0x38(%rbp), %rax
movl $0x1, 0x4(%rax)
leaq 0x145c(%rip), %rdi      # 0x30c4
movq %r14, %rbx
movl %ebx, %esi
movq %r15, %rdx
xorl %eax, %eax
callq 0x10a0
xorps %xmm0, %xmm0
movups %xmm0, (%r12)
movups %xmm0, 0x10(%r12)
cmpl $0x544948, -0x80(%rbp)  # imm = 0x544948
jne 0x1d91
leaq 0x3be7(%rip), %rdi      # 0x5880
callq 0x11b0
movslq 0x36ab(%rip), %rax      # 0x5350
movslq (%r13,%rax,4), %rcx
movq -0x58(%rbp), %r14
leaq 0x3bab(%rip), %r13      # 0x5860
movslq (%r13,%r14,4), %rdx
movq -0x90(%rbp), %rsi
movl %ecx, (%rsi,%rdx,4)
leaq 0x35b5(%rip), %rsi      # 0x5280
movslq (%rsi,%rax,4), %rsi
movq -0x98(%rbp), %rdi
movl %esi, (%rdi,%rdx,4)
leaq 0x1662(%rip), %rdi      # 0x3342
movb (%rcx,%rdi), %cl
movb %cl, -0x80(%rbp)
leaq 0x1651(%rip), %rcx      # 0x333e
movb (%rsi,%rcx), %cl
movb %cl, -0x7f(%rbp)
xorl %ecx, %ecx
movb %cl, -0x7e(%rbp)
incl %eax
movl %eax, 0x3650(%rip)      # 0x5350
leal 0x1(%rdx), %eax
movl %eax, (%r13,%r14,4)
leaq 0x3b71(%rip), %rdi      # 0x5880
callq 0x10f0
movl $0x20, %edx
movq %r12, %rbx
movq %r12, %rdi
movq %r15, %rsi
callq 0x1050
leaq 0x13b5(%rip), %rdi      # 0x30e3
movq -0x40(%rbp), %rsi
movq %r15, %r12
movq %r15, %rdx
xorl %eax, %eax
callq 0x10a0
movq -0x38(%rbp), %rax
movl $0x2, (%rax)
xorl %eax, %eax
movb %al, -0x80(%rbp)
movl $0x1, %edx
movl -0x2c(%rbp), %edi
leaq -0x48(%rbp), %rsi
callq 0x1160
movl (%r13,%r14,4), %esi
movq -0x90(%rbp), %rdi
callq 0x144b
cmpl $0x16, %eax
jge 0x1dc7
cmpl $0x15, %eax
movq -0x40(%rbp), %r14
leaq 0x342d(%rip), %r13      # 0x51b0
movq %r12, %r15
movq %rbx, %r12
jne 0x1c18
jmp 0x1de6
movl -0x80(%rbp), %eax
movl $0x4e415453, %ecx       # imm = 0x4E415453
xorl %ecx, %eax
movzwl -0x7c(%rbp), %ecx
xorl $0x44, %ecx
orl %eax, %ecx
jne 0x1c18
movq -0x38(%rbp), %rax
movl $0x0, (%rax)
leaq -0x48(%rbp), %rsi
movl $0x1, %edx
movl -0x2c(%rbp), %edi
callq 0x1160
jmp 0x1de6
leaq 0x132e(%rip), %rdi      # 0x30fc
movq -0x40(%rbp), %rsi
movq %rsi, %r14
xorl %eax, %eax
callq 0x10a0
movq %rbx, %r12
leaq 0x33ca(%rip), %r13      # 0x51b0
movq -0x58(%rbp), %r15
leaq 0x3a7f(%rip), %rax      # 0x5870
movl (%rax,%r15,4), %esi
movq -0x88(%rbp), %rdi
movq %rsi, %rbx
callq 0x144b
cmpl $0x10, %eax
jg 0x1f05
movq %r12, -0xa8(%rbp)
movq %rbx, %r12
movslq %r12d, %rax
movslq 0x352f(%rip), %rcx      # 0x5350
leal 0x1(%rcx), %edx
movq %rdx, -0xc0(%rbp)
shlq $0x2, %rcx
movq %rcx, -0xb8(%rbp)
leaq (%r15,%r15,4), %rcx
shlq $0x4, %rcx
leaq (%rcx,%rax,4), %rax
movq %rax, -0xb0(%rbp)
incl %r12d
xorl %r15d, %r15d
xorl %ebx, %ebx
movq -0x88(%rbp), %r14
movq -0xb8(%rbp), %rax
leaq (%rax,%r15,4), %rax
movslq (%r13,%rax), %rcx
movq -0xb0(%rbp), %rdx
leaq (%rdx,%r15,4), %rdx
leaq 0x3626(%rip), %rsi      # 0x54a0
movl %ecx, (%rsi,%rdx)
leaq 0x33fc(%rip), %rsi      # 0x5280
movslq (%rsi,%rax), %rax
leaq 0x3891(%rip), %rsi      # 0x5720
movl %eax, (%rsi,%rdx)
leaq 0x14a9(%rip), %rdx      # 0x3342
movb (%rcx,%rdx), %cl
movb %cl, -0x80(%rbp,%r15,2)
leaq 0x1496(%rip), %rcx      # 0x333e
movb (%rax,%rcx), %al
addq $0x2, %rbx
movb %al, -0x7f(%rbp,%r15,2)
movq -0xc0(%rbp), %rax
addl %r15d, %eax
movl %eax, 0x348c(%rip)      # 0x5350
leal (%r12,%r15), %esi
movq -0x58(%rbp), %rax
leaq 0x399d(%rip), %rcx      # 0x5870
movl %esi, (%rcx,%rax,4)
movq %r14, %rdi
callq 0x144b
incq %r15
cmpl $0x11, %eax
jl 0x1e58
andl $-0x2, %ebx
movq -0x40(%rbp), %r14
movq -0x58(%rbp), %r15
leaq 0x3964(%rip), %r13      # 0x5860
movq -0xa8(%rbp), %r12
jmp 0x1f0e
xorl %ebx, %ebx
leaq 0x3952(%rip), %r13      # 0x5860
movb $0x0, -0x80(%rbp,%rbx)
movl $0xa, %edi
callq 0x1040
leaq 0x1172(%rip), %rdi      # 0x3096
movl %r14d, %esi
xorl %eax, %eax
callq 0x10a0
movl (%r13,%r15,4), %edx
movq -0x90(%rbp), %rbx
movq %rbx, %rdi
movq -0x98(%rbp), %rsi
callq 0x14a0
leaq 0x11d2(%rip), %rdi      # 0x3122
movl %r14d, %esi
xorl %eax, %eax
callq 0x10a0
leaq 0x390f(%rip), %rax      # 0x5870
movl (%rax,%r15,4), %edx
movq -0x88(%rbp), %rdi
movq %rdi, %r14
movq -0xa0(%rbp), %rsi
callq 0x14a0
leaq -0x50(%rbp), %rsi
movl $0x1, %edx
movl -0x2c(%rbp), %edi
callq 0x1160
cmpl $-0x1, %eax
je 0x204f
leaq -0x80(%rbp), %rsi
movl $0x20, %edx
movq %r12, %rdi
callq 0x1050
movq -0x38(%rbp), %rax
movl $0x1, 0x8(%rax)
leaq -0x48(%rbp), %rsi
movl $0x1, %edx
movl -0x2c(%rbp), %edi
callq 0x1160
movl (%r13,%r15,4), %esi
movq %rbx, %rdi
callq 0x144b
movl %eax, %ebx
leaq 0x3898(%rip), %rax      # 0x5870
movl (%rax,%r15,4), %esi
movq %r14, %rdi
callq 0x144b
cmpl $0x15, %eax
jle 0x1ff6
leaq 0x1143(%rip), %rdi      # 0x3133
movq -0x40(%rbp), %rsi
jmp 0x2019
cmpl %eax, %ebx
movq -0x40(%rbp), %rsi
jne 0x2007
leaq 0x114f(%rip), %rdi      # 0x3154
jmp 0x2019
leaq 0x117f(%rip), %rax      # 0x318d
leaq 0x11b1(%rip), %rdi      # 0x31c6
cmovlq %rax, %rdi
xorl %eax, %eax
callq 0x10a0
movq -0x38(%rbp), %rdi
callq 0x1090
cmpl $-0x1, %eax
je 0x2054
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x1270
callq 0x12b8
callq 0x1288
callq 0x1258
callq 0x1240
callq 0x12d0
callq 0x12a0