#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 */

/* Variables and functions */
int /*<<< orphan*/ bzero(char *, int);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *);
scalar_t__ read(int, char *, int);
int /*<<< orphan*/ stdin;
scalar_t__ strlen(char *);
scalar_t__ write(int, char *, scalar_t__);
int create_client_loop(int cfd) {
  char sendline[128];
  char recvline[128];
  while (1) {
    bzero(sendline, 128);
    bzero(recvline, 128);
    fgets(sendline, 128, stdin);
    if (write(cfd, sendline, strlen(sendline) - 1) <= 0)
      break;
    if (read(cfd, recvline, 128) <= 0)
      break;
    printf("%s", recvline);
  }
  return (0);
}


x86 assembly (clang, -O0):
<create_client_loop>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x90(%rbp),%rdi
mov    $0x80,%esi
call   1080 <bzero@plt>
lea    -0x110(%rbp),%rdi
mov    $0x80,%esi
call   1080 <bzero@plt>
lea    -0x90(%rbp),%rdi
mov    0x2e4a(%rip),%rax
mov    (%rax),%edx
mov    $0x80,%esi
call   1070 <fgets@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x11c(%rbp)
lea    -0x90(%rbp),%rax
mov    %rax,-0x118(%rbp)
lea    -0x90(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x11c(%rbp),%edi
mov    -0x118(%rbp),%rsi
mov    %rax,%rdx
sub    $0x1,%rdx
call   1030 <write@plt>
cmp    $0x0,%rax
jg     11f5 <create_client_loop+0x95>
jmp    1230 <create_client_loop+0xd0>
mov    -0x4(%rbp),%edi
lea    -0x110(%rbp),%rsi
mov    $0x80,%edx
call   1060 <read@plt>
cmp    $0x0,%rax
jg     1218 <create_client_loop+0xb8>
jmp    1230 <create_client_loop+0xd0>
lea    -0x110(%rbp),%rsi
lea    0xdda(%rip),%rdi
call   1050 <printf@plt>
jmp    116e <create_client_loop+0xe>
xor    %eax,%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_client_loop>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x100,%rsp
mov    %edi,%ebp
lea    0x80(%rsp),%rbx
mov    %rsp,%r14
mov    0x2e65(%rip),%r12
lea    0xe76(%rip),%r15
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    $0x80,%esi
call   1080 <bzero@plt>
mov    %r14,%rdi
mov    $0x80,%esi
call   1080 <bzero@plt>
mov    (%r12),%edx
mov    %rbx,%rdi
mov    $0x80,%esi
call   1070 <fgets@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
lea    -0x1(%rax),%rdx
mov    %ebp,%edi
mov    %rbx,%rsi
call   1030 <write@plt>
test   %rax,%rax
jle    11f7 <create_client_loop+0x97>
mov    %ebp,%edi
mov    %r14,%rsi
mov    $0x80,%edx
call   1060 <read@plt>
test   %rax,%rax
jle    11f7 <create_client_loop+0x97>
mov    %r15,%rdi
mov    %r14,%rsi
call   1050 <printf@plt>
jmp    1190 <create_client_loop+0x30>
xor    %eax,%eax
add    $0x100,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stdin = global i32 0
@.str = [3 x i8] c"%s\00"
define i32 @create_client_loop(i32 %0) {
%2 = alloca i32
%3 = alloca [128 x i8]
%4 = alloca [128 x i8]
store i32 %0, i32* %2
br label %5
5: ; preds = %1, %27
%6 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%7 = call i32 @bzero(i8* %6, i32 128)
%8 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%9 = call i32 @bzero(i8* %8, i32 128)
%10 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%11 = load i32, i32* @stdin
%12 = call i32 @fgets(i8* %10, i32 128, i32 %11)
%13 = load i32, i32* %2
%14 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%15 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%16 = call i64 @strlen(i8* %15)
%17 = sub nsw i64 %16, 1
%18 = call i64 @write(i32 %13, i8* %14, i64 %17)
%19 = icmp sle i64 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %5
br label %30
21: ; preds = %5
%22 = load i32, i32* %2
%23 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%24 = call i64 @read(i32 %22, i8* %23, i32 128)
%25 = icmp sle i64 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %21
br label %30
27: ; preds = %21
%28 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%29 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %28)
br label %5
30: ; preds = %26, %20
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [3 x i8] c"%s\00"
define i32 @create_client_loop(i32 %0) {
%2 = alloca [128 x i8]
%3 = alloca [128 x i8]
%4 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
br label %6
6: ; preds = %18, %1
%7 = call i32 @bzero(i8* %4, i32 128)
%8 = call i32 @bzero(i8* %5, i32 128)
%9 = load i32, i32* @stdin
%10 = call i32 @fgets(i8* %4, i32 128, i32 %9)
%11 = call i64 @strlen(i8* %4)
%12 = add nsw i64 %11, -1
%13 = call i64 @write(i32 %0, i8* %4, i64 %12)
%14 = icmp slt i64 %13, 1
br i1 %14, label %20, label %15
15: ; preds = %6
%16 = call i64 @read(i32 %0, i8* %5, i32 128)
%17 = icmp slt i64 %16, 1
br i1 %17, label %20, label %18
18: ; preds = %15
%19 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %5)
br label %6
20: ; preds = %15, %6
ret i32 0
}