// File: /workspace/github_c_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq 0x2c1a(%rip), %rax      # 0x4198
cmpl $0x0, 0x8(%rax)
jne 0x1759
leaq 0xbff(%rip), %rbx       # 0x218e
leaq 0xad3(%rip), %r14       # 0x2069
movq 0x2a33(%rip), %r13      # 0x3fd0
movq 0x2a34(%rip), %r12      # 0x3fd8
cmpl $0x0, 0x4(%rax)
je 0x16c9
movl $0xa, %edi
callq 0x1040
leaq 0xbc8(%rip), %rdi       # 0x2187
callq 0x1060
movq %rbx, %rdi
callq 0x1060
movq %r14, %rdi
xorl %eax, %eax
callq 0x1090
movq (%r13), %rdi
callq 0x10d0
movq (%r12), %rdx
leaq -0x32(%rbp), %r15
movq %r15, %rdi
movl $0xa, %esi
callq 0x10a0
movq %r15, %rdi
callq 0x1140
cmpl $0x1, %eax
je 0x161b
cmpl $0x2, %eax
je 0x16dc
leaq 0xb86(%rip), %rdi       # 0x2197
callq 0x1060
jmp 0x16b7
movq %r13, %r12
movq %r14, %r13
movq %rbx, %r14
movl 0x2b6a(%rip), %edi      # 0x4194
movl $0x1, %edx
leaq 0x2b3a(%rip), %rsi      # 0x4170
callq 0x1150
cmpl $-0x1, %eax
je 0x1768
movl $0x544948, 0x2b52(%rip) # imm = 0x544948
leaq 0xa31(%rip), %rdi       # 0x2086
leaq 0x2b44(%rip), %rbx      # 0x41a0
movq %rbx, %rsi
xorl %eax, %eax
callq 0x1090
movq 0x2b2b(%rip), %r15      # 0x4198
leaq 0xc(%r15), %rdi
movl $0x20, %edx
movq %rbx, %rsi
callq 0x1050
movl $0x0, 0x4(%r15)
movl 0x2b08(%rip), %edi      # 0x4194
movl $0x1, %edx
leaq 0x2ade(%rip), %rsi      # 0x4176
callq 0x1150
movl $0x1, %edi
callq 0x1180
movq %r14, %rbx
movq %r13, %r14
movq %r12, %r13
movq 0x2921(%rip), %r12      # 0x3fd8
leaq -0x32(%rbp), %r15
movq %r15, %rdi
callq 0x1080
movb $0x0, -0x1(%rax,%r15)
movq 0x2ac8(%rip), %rax      # 0x4198
cmpl $0x0, 0x8(%rax)
je 0x15a4
jmp 0x1759
movl 0x2ab2(%rip), %edi      # 0x4194
leaq 0x2a87(%rip), %rsi      # 0x4170
movl $0x1, %edx
callq 0x1150
cmpl $-0x1, %eax
je 0x176d
movw $0x44, 0x2aa3(%rip)     # 0x41a4
movl $0x4e415453, 0x2a95(%rip) # imm = 0x4E415453
leaq 0x2a8e(%rip), %rbx      # 0x41a0
leaq 0x96d(%rip), %rdi       # 0x2086
movq %rbx, %rsi
xorl %eax, %eax
callq 0x1090
movq 0x2a6e(%rip), %r14      # 0x4198
leaq 0xc(%r14), %rdi
movl $0x20, %edx
movq %rbx, %rsi
callq 0x1050
movq $0x0, (%r14)
movl 0x2a4c(%rip), %edi      # 0x4194
leaq 0x2a27(%rip), %rsi      # 0x4176
movl $0x1, %edx
callq 0x1150
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x11b8
callq 0x11a0