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

/* Variables and functions */
int /*<<< orphan*/ close(int);
int recv(int, char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ send(int, char *, int, int /*<<< orphan*/);
scalar_t__ strncmp(char *, char *, int);
void *Child(void *arg) {
  char line[100];
  int bytes_read;
  int client = *(int *)arg;
  do {
    bytes_read = recv(client, line, sizeof(line), 0);
    send(client, line, bytes_read, 0);
  } while (strncmp(line, "bye\r", 4) != 0);
  close(client);
  return arg;
}


x86 assembly (clang, -O0):
<Child>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x78(%rbp)
mov    -0x78(%rbp),%edi
lea    -0x70(%rbp),%rsi
mov    $0x64,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %eax,-0x74(%rbp)
mov    -0x78(%rbp),%edi
lea    -0x70(%rbp),%rsi
mov    -0x74(%rbp),%edx
xor    %ecx,%ecx
call   1050 <send@plt>
lea    -0x70(%rbp),%rdi
lea    0xe76(%rip),%rsi
mov    $0x4,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    1158 <Child+0x18>
mov    -0x78(%rbp),%edi
call   1060 <close@plt>
mov    -0x8(%rbp),%rax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Child>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x68,%rsp
mov    %rdi,%r14
mov    (%rdi),%ebp
mov    %rsp,%rbx
lea    0xea7(%rip),%r15
nopl   0x0(%rax)
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x64,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1050 <send@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    $0x4,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
jne    1160 <Child+0x20>
mov    %ebp,%edi
call   1060 <close@plt>
mov    %r14,%rax
add    $0x68,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"bye\0D\00"
define i8* @Child(i8* %0) {
%2 = alloca i8*
%3 = alloca [100 x i8]
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = bitcast i8* %6 to i32*
%8 = load i32, i32* %7
store i32 %8, i32* %5
br label %9
9: ; preds = %17, %1
%10 = load i32, i32* %5
%11 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%12 = call i32 @recv(i32 %10, i8* %11, i32 100, i32 0)
store i32 %12, i32* %4
%13 = load i32, i32* %5
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%15 = load i32, i32* %4
%16 = call i32 @send(i32 %13, i8* %14, i32 %15, i32 0)
br label %17
17: ; preds = %9
%18 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%19 = call i64 @strncmp(i8* %18, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 4)
%20 = icmp ne i64 %19, 0
br i1 %20, label %9, label %21
21: ; preds = %17
%22 = load i32, i32* %5
%23 = call i32 @close(i32 %22)
%24 = load i8*, i8** %2
ret i8* %24
}

LLVM IR (-O2):
@.str = [5 x i8] c"bye\0D\00"
define i8* @Child(i8* returned %0) {
%2 = alloca [100 x i8]
%3 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%4 = bitcast i8* %0 to i32*
%5 = load i32, i32* %4
br label %6
6: ; preds = %6, %1
%7 = call i32 @recv(i32 %5, i8* %3, i32 100, i32 0)
%8 = call i32 @send(i32 %5, i8* %3, i32 %7, i32 0)
%9 = call i64 @strncmp(i8* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 4)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %6
11: ; preds = %6
%12 = call i32 @close(i32 %5)
ret i8* %0
}