// File: /workspace/github_c_makefile_star2_O0/PARKINHYO[P]BlackjackGame/fifo/fifo_client.c
// Function: send_msg
void* send_msg()
{
	int fd2;
	char filename[BUFF_SIZE];

	sprintf(filename, "%s%d", TO_SERVER_FILE, getpid());
	if ((fd2 = open(filename, O_WRONLY)) == -1) {
		printf("[SYSTEM] in send_msg() open error!!\n");
	}

	int choice;
	char strChoice[10];
	while (1) {
		sleep(1);
		if (finalcheck) { break; }
		/*check2==1 -> HIT/STAND 입력대기*/
		if (check2 == 1) {
			printf("\n");
			printf("1. Hit\n");
			printf("2. Stand\n");
			printf("Please choose 1 or 2: ");
			fflush(stdout);

			fgets(strChoice, sizeof(strChoice), stdin);
			choice = atoi(strChoice);

			if (choice == 1)
			{
				strcpy(buffer, HIT);
				//HIT 서버로 전달
				write(fd2, buffer, BUFFER_SIZE);

				printf("Sending: %s\n", buffer);

				check2 = 2;
				sleep(1);
			}
			else if (choice == 2)
			{
				strcpy(buffer, STAND);
				//STAND 서버로 전달
				write(fd2, buffer, BUFFER_SIZE);

				printf("Sending: %s\n", buffer);
				check2 = 0;
				check = 0;
				finalcheck = 1;
				break;
			}
			else {
				printf("Unrecognized choice. Choose again.\n");
			}
			strChoice[strlen(strChoice) - 1] = '\0';
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
leaq -0x30(%rbp), %rax
movq %rax, -0x48(%rbp)
callq 0x1050
movq -0x48(%rbp), %rdi
movl %eax, %ecx
leaq 0xa9b(%rip), %rsi       # 0x20dd
leaq 0xa20(%rip), %rdx       # 0x2069
movb $0x0, %al
callq 0x10f0
leaq -0x30(%rbp), %rdi
movl $0x1, %esi
movb $0x0, %al
callq 0x10d0
movl %eax, -0xc(%rbp)
cmpl $-0x1, %eax
jne 0x1676
leaq 0xa73(%rip), %rdi       # 0x20e2
movb $0x0, %al
callq 0x1070
jmp 0x1678
movl $0x1, %edi
callq 0x1120
cmpl $0x0, 0x2acf(%rip)      # 0x4158
je 0x1690
jmp 0x17e9
cmpl $0x1, 0x2abd(%rip)      # 0x4154
jne 0x17e4
leaq 0xa37(%rip), %rdi       # 0x20db
movb $0x0, %al
callq 0x1070
leaq 0xa55(%rip), %rdi       # 0x2107
movb $0x0, %al
callq 0x1070
leaq 0xa4f(%rip), %rdi       # 0x210f
movb $0x0, %al
callq 0x1070
leaq 0xa4b(%rip), %rdi       # 0x2119
movb $0x0, %al
callq 0x1070
movq 0x28f4(%rip), %rax      # 0x3fd0
movq (%rax), %rdi
callq 0x10b0
leaq -0x3e(%rbp), %rdi
movq 0x28e9(%rip), %rax      # 0x3fd8
movq (%rax), %rdx
movl $0xa, %esi
callq 0x1090
leaq -0x3e(%rbp), %rdi
callq 0x10e0
movl %eax, -0x34(%rbp)
cmpl $0x1, -0x34(%rbp)
jne 0x1760
leaq 0x2a8b(%rip), %rdi      # 0x41a0
leaq 0xa14(%rip), %rsi       # 0x2130
callq 0x1030
movl -0xc(%rbp), %edi
leaq 0x2a75(%rip), %rsi      # 0x41a0
movl $0x20, %edx
callq 0x1040
leaq 0x9f8(%rip), %rdi       # 0x2134
leaq 0x2a5d(%rip), %rsi      # 0x41a0
movb $0x0, %al
callq 0x1070
movl $0x2, 0x2a00(%rip)      # 0x4154
movl $0x1, %edi
callq 0x1120
jmp 0x17d2
cmpl $0x2, -0x34(%rbp)
jne 0x17c2
leaq 0x2a33(%rip), %rdi      # 0x41a0
leaq 0x9cd(%rip), %rsi       # 0x2141
callq 0x1030
movl -0xc(%rbp), %edi
leaq 0x2a1d(%rip), %rsi      # 0x41a0
movl $0x20, %edx
callq 0x1040
leaq 0x9a0(%rip), %rdi       # 0x2134
leaq 0x2a05(%rip), %rsi      # 0x41a0
movb $0x0, %al
callq 0x1070
movl $0x0, 0x29a8(%rip)      # 0x4154
movl $0x0, 0x299a(%rip)      # 0x4150
movl $0x1, 0x2998(%rip)      # 0x4158
jmp 0x17e9
leaq 0x97e(%rip), %rdi       # 0x2147
movb $0x0, %al
callq 0x1070
jmp 0x17d2
leaq -0x3e(%rbp), %rdi
callq 0x1060
subq $0x1, %rax
movb $0x0, -0x3e(%rbp,%rax)
jmp 0x1678
movq -0x8(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)