// File: /workspace/github_c_makefile_star2_O0/PARKINHYO[P]BlackjackGame/shm/shm_client.c
// Function: send_msg
void* send_msg(void *x)
{
  //sleep(0.2);
  int choice;
  char strChoice[10];
  while(1){
    /* 게임 종료시그널을 받으면 전송 스레드도 종료*/
    if(pstShm2->finalcheck){break;}

    /*HIT STAND를 보내야 할 상황일 때*/
    if(pstShm2->check2){
      printf("\n");
      printf("1. Hit\n");
      printf("2. Stand\n");
      printf("Please choose 1 or 2: ");
      fflush(stdout);

      /*문자열 제한 get*/
      fgets(strChoice, sizeof(strChoice), stdin);
      choice = atoi(strChoice);
      /*HIT을 선택할 경우*/
      if (choice == 1)
      {
        /*임계영역*/
        if( semop(gnSemID2, &mysem_open, 1) == -1 )
        {
              perror("semop");
              exit(1);
        }
        strcpy(buffer, HIT);
        printf("Sending: %s\n", buffer);
        /* HIT send */
        strncpy(pstShm2->data, buffer, BUFFER_SIZE);
        pstShm2->check2 = 0;
        semop(gnSemID2, &mysem_close, 1);
        /*임계영역*/
        sleep(1);
      }
      /*STAND를 선택한 경우*/
      else if (choice == 2)
      {
        /*임계영역*/
        if( semop(gnSemID2, &mysem_open, 1) == -1 )
        {
              perror("semop");
              exit(1);
        }
        strcpy(buffer, STAND);
        printf("Sending: %s\n", buffer);
        strncpy(pstShm2->data, buffer, BUFFER_SIZE);
        pstShm2->check2 = 0;
        pstShm2->check = 0;
        semop(gnSemID2, &mysem_close, 1);
        /*임계영역*/
        break;
      }
      else
        printf("Unrecognized choice. Choose again.\n");
      /*문자열 초기화*/
      strChoice[strlen(strChoice)-1] = '\0';
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq 0x3be5(%rip), %rax      # 0x5198
cmpl $0x0, 0x8(%rax)
je 0x15be
jmp 0x17c9
movq 0x3bd3(%rip), %rax      # 0x5198
cmpl $0x0, 0x4(%rax)
je 0x17c4
leaq 0x1d6b(%rip), %rdi      # 0x3341
movb $0x0, %al
callq 0x1090
leaq 0x1b0b(%rip), %rdi      # 0x30ef
movb $0x0, %al
callq 0x1090
leaq 0x1b05(%rip), %rdi      # 0x30f7
movb $0x0, %al
callq 0x1090
leaq 0x1b01(%rip), %rdi      # 0x3101
movb $0x0, %al
callq 0x1090
movq 0x39c2(%rip), %rax      # 0x4fd0
movq (%rax), %rdi
callq 0x10d0
leaq -0x1e(%rbp), %rdi
movq 0x39b7(%rip), %rax      # 0x4fd8
movq (%rax), %rdx
movl $0xa, %esi
callq 0x10a0
leaq -0x1e(%rbp), %rdi
callq 0x1140
movl %eax, -0x14(%rbp)
cmpl $0x1, -0x14(%rbp)
jne 0x16ee
movl 0x3b4a(%rip), %edi      # 0x5194
leaq 0x3b1f(%rip), %rsi      # 0x5170
movl $0x1, %edx
callq 0x1150
cmpl $-0x1, %eax
jne 0x1676
leaq 0x1ab1(%rip), %rdi      # 0x3118
callq 0x1100
movl $0x1, %edi
callq 0x1160
leaq 0x3b23(%rip), %rdi      # 0x51a0
leaq 0x1a9a(%rip), %rsi      # 0x311e
callq 0x1060
leaq 0x1a92(%rip), %rdi      # 0x3122
leaq 0x3b09(%rip), %rsi      # 0x51a0
movb $0x0, %al
callq 0x1090
movq 0x3af3(%rip), %rdi      # 0x5198
addq $0xc, %rdi
leaq 0x3af0(%rip), %rsi      # 0x51a0
movl $0x20, %edx
callq 0x1040
movq 0x3ad7(%rip), %rax      # 0x5198
movl $0x0, 0x4(%rax)
movl 0x3ac6(%rip), %edi      # 0x5194
leaq 0x3aa1(%rip), %rsi      # 0x5176
movl $0x1, %edx
callq 0x1150
movl $0x1, %edi
callq 0x1180
jmp 0x17b2
cmpl $0x2, -0x14(%rbp)
jne 0x17a2
movl 0x3a96(%rip), %edi      # 0x5194
leaq 0x3a6b(%rip), %rsi      # 0x5170
movl $0x1, %edx
callq 0x1150
cmpl $-0x1, %eax
jne 0x172a
leaq 0x19fd(%rip), %rdi      # 0x3118
callq 0x1100
movl $0x1, %edi
callq 0x1160
leaq 0x3a6f(%rip), %rdi      # 0x51a0
leaq 0x19f7(%rip), %rsi      # 0x312f
callq 0x1060
leaq 0x19de(%rip), %rdi      # 0x3122
leaq 0x3a55(%rip), %rsi      # 0x51a0
movb $0x0, %al
callq 0x1090
movq 0x3a3f(%rip), %rdi      # 0x5198
addq $0xc, %rdi
leaq 0x3a3c(%rip), %rsi      # 0x51a0
movl $0x20, %edx
callq 0x1040
movq 0x3a23(%rip), %rax      # 0x5198
movl $0x0, 0x4(%rax)
movq 0x3a15(%rip), %rax      # 0x5198
movl $0x0, (%rax)
movl 0x3a05(%rip), %edi      # 0x5194
leaq 0x39e0(%rip), %rsi      # 0x5176
movl $0x1, %edx
callq 0x1150
jmp 0x17c9
leaq 0x198c(%rip), %rdi      # 0x3135
movb $0x0, %al
callq 0x1090
jmp 0x17b2
leaq -0x1e(%rbp), %rdi
callq 0x1080
subq $0x1, %rax
movb $0x0, -0x1e(%rbp,%rax)
jmp 0x15ac
movq -0x8(%rbp), %rax
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)