void handle_client(int client) {
  int i;
  for (i = 0; i < 3; i++)
    close(i), dup(client);
  do1();
  char a[20];
  shutdown(client, 2);
  while (recv(client, a, sizeof(a), 0) > 0)
    ;
  close(client);
  exit(0);
}


x86 assembly (clang, -O0):
<handle_client>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    119e <handle_client+0x3e>
mov    -0x8(%rbp),%edi
mov    $0x0,%al
call   1060 <close@plt>
mov    -0x4(%rbp),%edi
mov    $0x0,%al
call   1050 <dup@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1172 <handle_client+0x12>
mov    $0x0,%al
call   1070 <do1@plt>
mov    -0x4(%rbp),%edi
mov    $0x2,%esi
mov    $0x0,%al
call   1040 <shutdown@plt>
mov    -0x4(%rbp),%edi
lea    -0x20(%rbp),%rsi
mov    $0x14,%edx
xor    %ecx,%ecx
mov    $0x0,%al
call   1030 <recv@plt>
cmp    $0x0,%eax
jle    11d7 <handle_client+0x77>
jmp    11b4 <handle_client+0x54>
mov    -0x4(%rbp),%edi
mov    $0x0,%al
call   1060 <close@plt>
xor    %edi,%edi
call   1080 <exit@plt>

x86 assembly (clang, -O2):
<handle_client>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %edi,%ebp
xor    %edi,%edi
xor    %eax,%eax
call   1060 <close@plt>
mov    %ebp,%edi
xor    %eax,%eax
call   1050 <dup@plt>
mov    $0x1,%edi
xor    %eax,%eax
call   1060 <close@plt>
mov    %ebp,%edi
xor    %eax,%eax
call   1050 <dup@plt>
mov    $0x2,%edi
xor    %eax,%eax
call   1060 <close@plt>
mov    %ebp,%edi
xor    %eax,%eax
call   1050 <dup@plt>
xor    %eax,%eax
call   1070 <do1@plt>
mov    %ebp,%edi
mov    $0x2,%esi
xor    %eax,%eax
call   1040 <shutdown@plt>
mov    %rsp,%rbx
nopl   0x0(%rax)
mov    $0x14,%edx
mov    %ebp,%edi
mov    %rbx,%rsi
xor    %ecx,%ecx
xor    %eax,%eax
call   1030 <recv@plt>
test   %eax,%eax
jg     11c0 <handle_client+0x60>
mov    %ebp,%edi
xor    %eax,%eax
call   1060 <close@plt>
xor    %edi,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
define void @handle_client(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca [20 x i8]
store i32 %0, i32* %2
store i32 0, i32* %3
br label %5
5: ; preds = %13, %1
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, 3
br i1 %7, label %8, label %16
8: ; preds = %5
%9 = load i32, i32* %3
%10 = call i32 (i32, ...) bitcast (i32 (...)* @close to i32 (i32, ...)*)(i32 %9)
%11 = load i32, i32* %2
%12 = call i32 (i32, ...) bitcast (i32 (...)* @dup to i32 (i32, ...)*)(i32 %11)
br label %13
13: ; preds = %8
%14 = load i32, i32* %3
%15 = add nsw i32 %14, 1
store i32 %15, i32* %3
br label %5
16: ; preds = %5
%17 = call i32 (...) @do1()
%18 = load i32, i32* %2
%19 = call i32 (i32, i32, ...) bitcast (i32 (...)* @shutdown to i32 (i32, i32, ...)*)(i32 %18, i32 2)
br label %20
20: ; preds = %25, %16
%21 = load i32, i32* %2
%22 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%23 = call i32 (i32, i8*, i64, i32, ...) bitcast (i32 (...)* @recv to i32 (i32, i8*, i64, i32, ...)*)(i32 %21, i8* %22, i64 20, i32 0)
%24 = icmp sgt i32 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %20
br label %20
26: ; preds = %20
%27 = load i32, i32* %2
%28 = call i32 (i32, ...) bitcast (i32 (...)* @close to i32 (i32, ...)*)(i32 %27)
unreachable
}

LLVM IR (-O2):
define void @handle_client(i32 %0) {
%2 = alloca [20 x i8]
%3 = tail call i32 (i32, ...) bitcast (i32 (...)* @close to i32 (i32, ...)*)(i32 0)
%4 = tail call i32 (i32, ...) bitcast (i32 (...)* @dup to i32 (i32, ...)*)(i32 %0)
%5 = tail call i32 (i32, ...) bitcast (i32 (...)* @close to i32 (i32, ...)*)(i32 1)
%6 = tail call i32 (i32, ...) bitcast (i32 (...)* @dup to i32 (i32, ...)*)(i32 %0)
%7 = tail call i32 (i32, ...) bitcast (i32 (...)* @close to i32 (i32, ...)*)(i32 2)
%8 = tail call i32 (i32, ...) bitcast (i32 (...)* @dup to i32 (i32, ...)*)(i32 %0)
%9 = tail call i32 (...) @do1()
%10 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%11 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @shutdown to i32 (i32, i32, ...)*)(i32 %0, i32 2)
br label %12
12: ; preds = %12, %1
%13 = call i32 (i32, i8*, i64, i32, ...) bitcast (i32 (...)* @recv to i32 (i32, i8*, i64, i32, ...)*)(i32 %0, i8* %10, i64 20, i32 0)
%14 = icmp sgt i32 %13, 0
br i1 %14, label %12, label %15
15: ; preds = %12
%16 = call i32 (i32, ...) bitcast (i32 (...)* @close to i32 (i32, ...)*)(i32 %0)
unreachable
}