#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int /*<<< orphan*/ fd_set;
typedef int /*<<< orphan*/ command;

/* Variables and functions */
scalar_t__ FD_ISSET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_SET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_ZERO(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ recv(int, char *, int, int /*<<< orphan*/);
int select(int, int /*<<< orphan*/ *, int /*<<< orphan*/ *,
           int /*<<< orphan*/ *, int /*<<< orphan*/ *);
scalar_t__ send(int, char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
scalar_t__ strcmp(char *, char *);
int strlen(char *);
void start_Chat(char recv_name[256], int send_sockfd, int recv_sockfd) {
  fd_set read_fds;
  fd_set tmp_fds;
  int fdmax;
  FD_ZERO(&read_fds);
  FD_ZERO(&tmp_fds);
  FD_SET(send_sockfd, &read_fds);
  FD_SET(0, &read_fds);
  fdmax = send_sockfd;
  char command[1024];
  sprintf(command, "c");
  if (send(send_sockfd, command, strlen(command), 0) < 0) {
    fprintf(stderr, "ERROR: Unable writing on socket!\n");
    return;
  }
  memset(command, 0, 1024);
  if (recv(recv_sockfd, command, sizeof(command), 0) <= 0) {
    fprintf(stderr, "ERROR: Unable reading from socket!\n");
    return;
  }
  if (strcmp(command, "ok") != 0) {
    return;
  }
  printf("INFO: Chat activated!\n");
  while (1) {
    tmp_fds = read_fds;
    if (select(fdmax + 1, &tmp_fds, NULL, NULL, NULL) == -1) {
      fprintf(stderr, "ERROR CLIENT: Unable in select!\n");
      return;
    }
    if (FD_ISSET(0, &tmp_fds)) {
      memset(command, 0, 1024);
      if (fgets(command, sizeof(command), stdin) != NULL) {
        command[strlen(command) - 1] = '\0';
        if (send(send_sockfd, command, strlen(command), 0) < 0) {
          fprintf(stderr, "ERROR: Unable writing on socket!\n");
          return;
        }
        if (strcmp(command, "exit") == 0) {
          printf("INFO: Chat deactivated!\n");
          return;
        }
      }
    }
    if (FD_ISSET(send_sockfd, &tmp_fds)) {
      memset(command, 0, 1024);
      if (recv(recv_sockfd, command, sizeof(command), 0) <= 0) {
        fprintf(stderr, "ERROR: Unable reading from socket!\n");
        return;
      }
      if (strcmp(command, "exit") == 0) {
        printf("INFO: %s left the conversation!\n", recv_name);
        return;
      }
      printf("%s: %s\n", recv_name, command);
    }
  }
}


x86 assembly (clang, -O0):
<start_Chat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x440,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
lea    -0x14(%rbp),%rdi
call   10c0 <FD_ZERO@plt>
lea    -0x18(%rbp),%rdi
call   10c0 <FD_ZERO@plt>
mov    -0xc(%rbp),%edi
lea    -0x14(%rbp),%rsi
call   10f0 <FD_SET@plt>
xor    %edi,%edi
lea    -0x14(%rbp),%rsi
call   10f0 <FD_SET@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x1c(%rbp)
lea    -0x420(%rbp),%rdi
lea    0xdde(%rip),%rsi
call   10e0 <sprintf@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x42c(%rbp)
lea    -0x420(%rbp),%rax
mov    %rax,-0x428(%rbp)
lea    -0x420(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x42c(%rbp),%edi
mov    -0x428(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1060 <send@plt>
cmp    $0x0,%rax
jge    1284 <start_Chat+0xb4>
mov    0x2d67(%rip),%rax
mov    (%rax),%edi
lea    0xd88(%rip),%rsi
call   10b0 <fprintf@plt>
jmp    14f5 <start_Chat+0x325>
lea    -0x420(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1080 <memset@plt>
mov    -0x10(%rbp),%edi
lea    -0x420(%rbp),%rsi
mov    $0x400,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
cmp    $0x0,%rax
jg     12d1 <start_Chat+0x101>
mov    0x2d1a(%rip),%rax
mov    (%rax),%edi
lea    0xd5d(%rip),%rsi
call   10b0 <fprintf@plt>
jmp    14f5 <start_Chat+0x325>
lea    -0x420(%rbp),%rdi
lea    0xd69(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%rax
je     12f3 <start_Chat+0x123>
jmp    14f5 <start_Chat+0x325>
lea    0xd51(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x1c(%rbp),%edi
add    $0x1,%edi
lea    -0x18(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%r8d
mov    %r8,%rdx
mov    %r8,%rcx
call   10d0 <select@plt>
cmp    $0xffffffff,%eax
jne    1344 <start_Chat+0x174>
mov    0x2ca7(%rip),%rax
mov    (%rax),%edi
lea    0xd28(%rip),%rsi
call   10b0 <fprintf@plt>
jmp    14f5 <start_Chat+0x325>
xor    %edi,%edi
lea    -0x18(%rbp),%rsi
call   1040 <FD_ISSET@plt>
cmp    $0x0,%rax
je     1440 <start_Chat+0x270>
lea    -0x420(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1080 <memset@plt>
lea    -0x420(%rbp),%rdi
mov    0x2c6e(%rip),%rax
mov    (%rax),%edx
mov    $0x400,%esi
call   1090 <fgets@plt>
cmp    $0x0,%rax
je     143b <start_Chat+0x26b>
lea    -0x420(%rbp),%rdi
call   1050 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0x420(%rbp,%rax,1)
mov    -0xc(%rbp),%eax
mov    %eax,-0x43c(%rbp)
lea    -0x420(%rbp),%rax
mov    %rax,-0x438(%rbp)
lea    -0x420(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x43c(%rbp),%edi
mov    -0x438(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1060 <send@plt>
cmp    $0x0,%rax
jge    1406 <start_Chat+0x236>
mov    0x2be5(%rip),%rax
mov    (%rax),%edi
lea    0xc06(%rip),%rsi
call   10b0 <fprintf@plt>
jmp    14f5 <start_Chat+0x325>
lea    -0x420(%rbp),%rdi
lea    0xc6f(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%rax
jne    1436 <start_Chat+0x266>
lea    0xc5e(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    14f5 <start_Chat+0x325>
jmp    143b <start_Chat+0x26b>
jmp    1440 <start_Chat+0x270>
mov    -0xc(%rbp),%edi
lea    -0x18(%rbp),%rsi
call   1040 <FD_ISSET@plt>
cmp    $0x0,%rax
je     14f0 <start_Chat+0x320>
lea    -0x420(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1080 <memset@plt>
mov    -0x10(%rbp),%edi
lea    -0x420(%rbp),%rsi
mov    $0x400,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
cmp    $0x0,%rax
jg     14a3 <start_Chat+0x2d3>
mov    0x2b48(%rip),%rax
mov    (%rax),%edi
lea    0xb8b(%rip),%rsi
call   10b0 <fprintf@plt>
jmp    14f5 <start_Chat+0x325>
lea    -0x420(%rbp),%rdi
lea    0xbd2(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%rax
jne    14d7 <start_Chat+0x307>
mov    -0x8(%rbp),%rsi
lea    0xbd6(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    14f5 <start_Chat+0x325>
mov    -0x8(%rbp),%rsi
lea    -0x420(%rbp),%rdx
lea    0xbd9(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1301 <start_Chat+0x131>
add    $0x440,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<start_Chat>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x418,%rsp
mov    %edx,%r15d
mov    %esi,%ebx
mov    %rdi,%r14
lea    0xc(%rsp),%rbp
mov    %rbp,%rdi
call   10d0 <FD_ZERO@plt>
lea    0x8(%rsp),%rdi
call   10d0 <FD_ZERO@plt>
mov    %ebx,%edi
mov    %rbp,%rsi
call   10f0 <FD_SET@plt>
xor    %edi,%edi
mov    %rbp,%rsi
call   10f0 <FD_SET@plt>
movw   $0x63,0x10(%rsp)
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
call   1060 <strlen@plt>
mov    %ebx,%edi
mov    %rbp,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1070 <send@plt>
test   %rax,%rax
js     13e6 <start_Chat+0x216>
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1090 <memset@plt>
mov    %r15d,%edi
mov    %rbp,%rsi
mov    $0x400,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
test   %rax,%rax
jle    13f8 <start_Chat+0x228>
lea    0xdd1(%rip),%rsi
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
call   10b0 <strcmp@plt>
test   %rax,%rax
jne    141f <start_Chat+0x24f>
lea    0xe06(%rip),%rdi
call   1040 <puts@plt>
lea    0x1(%rbx),%r12d
mov    0xc(%rsp),%eax
mov    %eax,0x8(%rsp)
lea    0x8(%rsp),%rsi
mov    %r12d,%edi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   10e0 <select@plt>
cmp    $0xffffffff,%eax
je     140a <start_Chat+0x23a>
lea    0x8(%rsp),%r13
jmp    1307 <start_Chat+0x137>
nopw   0x0(%rax,%rax,1)
lea    0xdb9(%rip),%rdi
mov    %r14,%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1080 <printf@plt>
mov    0xc(%rsp),%eax
mov    %eax,0x8(%rsp)
mov    %r12d,%edi
mov    %r13,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   10e0 <select@plt>
cmp    $0xffffffff,%eax
je     140a <start_Chat+0x23a>
xor    %edi,%edi
mov    %r13,%rsi
call   1050 <FD_ISSET@plt>
test   %rax,%rax
je     1382 <start_Chat+0x1b2>
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1090 <memset@plt>
mov    0x2cbc(%rip),%rax
mov    (%rax),%edx
mov    %rbp,%rdi
mov    $0x400,%esi
call   10a0 <fgets@plt>
test   %rax,%rax
je     1382 <start_Chat+0x1b2>
mov    %rbp,%rdi
call   1060 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbp,1)
mov    %rbp,%rdi
call   1060 <strlen@plt>
mov    %ebx,%edi
mov    %rbp,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1070 <send@plt>
test   %rax,%rax
js     13e6 <start_Chat+0x216>
mov    %rbp,%rdi
lea    0xcf6(%rip),%rsi
call   10b0 <strcmp@plt>
test   %rax,%rax
je     1431 <start_Chat+0x261>
mov    %ebx,%edi
mov    %r13,%rsi
call   1050 <FD_ISSET@plt>
test   %rax,%rax
je     12e4 <start_Chat+0x114>
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1090 <memset@plt>
mov    %r15d,%edi
mov    %rbp,%rsi
mov    $0x400,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
test   %rax,%rax
jle    13f8 <start_Chat+0x228>
mov    %rbp,%rdi
lea    0xca5(%rip),%rsi
call   10b0 <strcmp@plt>
test   %rax,%rax
jne    12d0 <start_Chat+0x100>
lea    0xc95(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
jmp    141f <start_Chat+0x24f>
mov    0x2beb(%rip),%rax
mov    (%rax),%edi
lea    0xc0a(%rip),%rsi
jmp    141a <start_Chat+0x24a>
mov    0x2bd9(%rip),%rax
mov    (%rax),%edi
lea    0xc1a(%rip),%rsi
jmp    141a <start_Chat+0x24a>
mov    0x2bc7(%rip),%rax
mov    (%rax),%edi
lea    0xc2f(%rip),%rsi
call   10c0 <fprintf@plt>
add    $0x418,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc76(%rip),%rdi
call   1040 <puts@plt>
jmp    141f <start_Chat+0x24f>

LLVM IR (-O0):
@.str = [2 x i8] c"c\00"
@stderr = global i32 0
@.str.1 = [34 x i8] c"ERROR: Unable writing on socket!\0A\00"
@.str.2 = [36 x i8] c"ERROR: Unable reading from socket!\0A\00"
@.str.3 = [3 x i8] c"ok\00"
@.str.4 = [23 x i8] c"INFO: Chat activated!\0A\00"
@.str.5 = [33 x i8] c"ERROR CLIENT: Unable in select!\0A\00"
@stdin = global i32 0
@.str.6 = [5 x i8] c"exit\00"
@.str.7 = [25 x i8] c"INFO: Chat deactivated!\0A\00"
@.str.8 = [33 x i8] c"INFO: %s left the conversation!\0A\00"
@.str.9 = [8 x i8] c"%s: %s\0A\00"
define void @start_Chat(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca [1024 x i8]
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%11 = call i32 @FD_ZERO(i32* %7)
%12 = call i32 @FD_ZERO(i32* %8)
%13 = load i32, i32* %5
%14 = call i32 @FD_SET(i32 %13, i32* %7)
%15 = call i32 @FD_SET(i32 0, i32* %7)
%16 = load i32, i32* %5
store i32 %16, i32* %9
%17 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%18 = call i32 @sprintf(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%19 = load i32, i32* %5
%20 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%21 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%22 = call i32 @strlen(i8* %21)
%23 = call i64 @send(i32 %19, i8* %20, i32 %22, i32 0)
%24 = icmp slt i64 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %3
%26 = load i32, i32* @stderr
%27 = call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
br label %113
28: ; preds = %3
%29 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%30 = call i32 @memset(i8* %29, i32 0, i32 1024)
%31 = load i32, i32* %6
%32 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%33 = call i64 @recv(i32 %31, i8* %32, i32 1024, i32 0)
%34 = icmp sle i64 %33, 0
br i1 %34, label %35, label %38
35: ; preds = %28
%36 = load i32, i32* @stderr
%37 = call i32 @fprintf(i32 %36, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0))
br label %113
38: ; preds = %28
%39 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%40 = call i64 @strcmp(i8* %39, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%41 = icmp ne i64 %40, 0
br i1 %41, label %42, label %43
42: ; preds = %38
br label %113
43: ; preds = %38
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0))
br label %45
45: ; preds = %43, %112
%46 = load i32, i32* %7
store i32 %46, i32* %8
%47 = load i32, i32* %9
%48 = add nsw i32 %47, 1
%49 = call i32 @select(i32 %48, i32* %8, i32* null, i32* null, i32* null)
%50 = icmp eq i32 %49, -1
br i1 %50, label %51, label %54
51: ; preds = %45
%52 = load i32, i32* @stderr
%53 = call i32 @fprintf(i32 %52, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0))
br label %113
54: ; preds = %45
%55 = call i64 @FD_ISSET(i32 0, i32* %8)
%56 = icmp ne i64 %55, 0
br i1 %56, label %57, label %87
57: ; preds = %54
%58 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%59 = call i32 @memset(i8* %58, i32 0, i32 1024)
%60 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%61 = load i32, i32* @stdin
%62 = call i32* @fgets(i8* %60, i32 1024, i32 %61)
%63 = icmp ne i32* %62, null
br i1 %63, label %64, label %86
64: ; preds = %57
%65 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%66 = call i32 @strlen(i8* %65)
%67 = sub nsw i32 %66, 1
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 %68
store i8 0, i8* %69
%70 = load i32, i32* %5
%71 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%72 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%73 = call i32 @strlen(i8* %72)
%74 = call i64 @send(i32 %70, i8* %71, i32 %73, i32 0)
%75 = icmp slt i64 %74, 0
br i1 %75, label %76, label %79
76: ; preds = %64
%77 = load i32, i32* @stderr
%78 = call i32 @fprintf(i32 %77, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
br label %113
79: ; preds = %64
%80 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%81 = call i64 @strcmp(i8* %80, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%82 = icmp eq i64 %81, 0
br i1 %82, label %83, label %85
83: ; preds = %79
%84 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0))
br label %113
85: ; preds = %79
br label %86
86: ; preds = %85, %57
br label %87
87: ; preds = %86, %54
%88 = load i32, i32* %5
%89 = call i64 @FD_ISSET(i32 %88, i32* %8)
%90 = icmp ne i64 %89, 0
br i1 %90, label %91, label %112
91: ; preds = %87
%92 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%93 = call i32 @memset(i8* %92, i32 0, i32 1024)
%94 = load i32, i32* %6
%95 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%96 = call i64 @recv(i32 %94, i8* %95, i32 1024, i32 0)
%97 = icmp sle i64 %96, 0
br i1 %97, label %98, label %101
98: ; preds = %91
%99 = load i32, i32* @stderr
%100 = call i32 @fprintf(i32 %99, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0))
br label %113
101: ; preds = %91
%102 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%103 = call i64 @strcmp(i8* %102, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%104 = icmp eq i64 %103, 0
br i1 %104, label %105, label %108
105: ; preds = %101
%106 = load i8*, i8** %4
%107 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.8, i64 0, i64 0), i8* %106)
br label %113
108: ; preds = %101
%109 = load i8*, i8** %4
%110 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%111 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0), i8* %109, i8* %110)
br label %112
112: ; preds = %108, %87
br label %45
113: ; preds = %105, %98, %83, %76, %51, %42, %35, %25
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str.1 = [34 x i8] c"ERROR: Unable writing on socket!\0A\00"
@.str.2 = [36 x i8] c"ERROR: Unable reading from socket!\0A\00"
@.str.3 = [3 x i8] c"ok\00"
@.str.5 = [33 x i8] c"ERROR CLIENT: Unable in select!\0A\00"
@stdin = global i32 0
@.str.6 = [5 x i8] c"exit\00"
@.str.8 = [33 x i8] c"INFO: %s left the conversation!\0A\00"
@.str.9 = [8 x i8] c"%s: %s\0A\00"
@str = [22 x i8] c"INFO: Chat activated!\00"
@str.10 = [24 x i8] c"INFO: Chat deactivated!\00"
define void @start_Chat(i8* %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca [1024 x i8]
%7 = bitcast i32* %4 to i8*
%8 = bitcast i32* %5 to i8*
%9 = call i32 @FD_ZERO(i32* %4)
%10 = call i32 @FD_ZERO(i32* %5)
%11 = call i32 @FD_SET(i32 %1, i32* %4)
%12 = call i32 @FD_SET(i32 0, i32* %4)
%13 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%14 = bitcast [1024 x i8]* %6 to i16*
store i16 99, i16* %14
%15 = call i32 @strlen(i8* %13)
%16 = call i64 @send(i32 %1, i8* %13, i32 %15, i32 0)
%17 = icmp slt i64 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %3
%19 = load i32, i32* @stderr
%20 = call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
br label %85
21: ; preds = %3
%22 = call i32 @memset(i8* %13, i32 0, i32 1024)
%23 = call i64 @recv(i32 %2, i8* %13, i32 1024, i32 0)
%24 = icmp slt i64 %23, 1
br i1 %24, label %25, label %28
25: ; preds = %21
%26 = load i32, i32* @stderr
%27 = call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0))
br label %85
28: ; preds = %21
%29 = call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %85
31: ; preds = %28
%32 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%33 = add nsw i32 %1, 1
%34 = load i32, i32* %4
store i32 %34, i32* %5
%35 = call i32 @select(i32 %33, i32* %5, i32* null, i32* null, i32* null)
%36 = icmp eq i32 %35, -1
br i1 %36, label %37, label %40
37: ; preds = %81, %31
%38 = load i32, i32* @stderr
%39 = call i32 @fprintf(i32 %38, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0))
br label %85
40: ; preds = %31, %81
%41 = call i64 @FD_ISSET(i32 0, i32* %5)
%42 = icmp eq i64 %41, 0
br i1 %42, label %64, label %43
43: ; preds = %40
%44 = call i32 @memset(i8* %13, i32 0, i32 1024)
%45 = load i32, i32* @stdin
%46 = call i32* @fgets(i8* %13, i32 1024, i32 %45)
%47 = icmp eq i32* %46, null
br i1 %47, label %64, label %48
48: ; preds = %43
%49 = call i32 @strlen(i8* %13)
%50 = add nsw i32 %49, -1
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 %51
store i8 0, i8* %52
%53 = call i32 @strlen(i8* %13)
%54 = call i64 @send(i32 %1, i8* %13, i32 %53, i32 0)
%55 = icmp slt i64 %54, 0
br i1 %55, label %56, label %59
56: ; preds = %48
%57 = load i32, i32* @stderr
%58 = call i32 @fprintf(i32 %57, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
br label %85
59: ; preds = %48
%60 = call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%61 = icmp eq i64 %60, 0
br i1 %61, label %62, label %64
62: ; preds = %59
%63 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.10, i64 0, i64 0))
br label %85
64: ; preds = %43, %59, %40
%65 = call i64 @FD_ISSET(i32 %1, i32* %5)
%66 = icmp eq i64 %65, 0
br i1 %66, label %81, label %67
67: ; preds = %64
%68 = call i32 @memset(i8* %13, i32 0, i32 1024)
%69 = call i64 @recv(i32 %2, i8* %13, i32 1024, i32 0)
%70 = icmp slt i64 %69, 1
br i1 %70, label %71, label %74
71: ; preds = %67
%72 = load i32, i32* @stderr
%73 = call i32 @fprintf(i32 %72, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0))
br label %85
74: ; preds = %67
%75 = call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%76 = icmp eq i64 %75, 0
br i1 %76, label %77, label %79
77: ; preds = %74
%78 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.8, i64 0, i64 0), i8* %0)
br label %85
79: ; preds = %74
%80 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0), i8* %0, i8* %13)
br label %81
81: ; preds = %79, %64
%82 = load i32, i32* %4
store i32 %82, i32* %5
%83 = call i32 @select(i32 %33, i32* %5, i32* null, i32* null, i32* null)
%84 = icmp eq i32 %83, -1
br i1 %84, label %37, label %40
85: ; preds = %28, %77, %71, %62, %56, %37, %25, %18
ret void
}