#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*/ SHUT_RDWR;
int close(int);
int /*<<< orphan*/ handle_request(int);
int /*<<< orphan*/ logmessage(int, char *);
int shutdown(int, int /*<<< orphan*/);
void handle_connection(int fd) {
  handle_request(fd);
  if (shutdown(fd, SHUT_RDWR) == -1) {
    logmessage(1, "Error shutting down client socket.");
    return;
  }
  if (close(fd) == -1)
    logmessage(1, "Error closing client socket.");
}


x86 assembly (clang, -O0):
<handle_connection>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
call   1050 <handle_request@plt>
mov    -0x4(%rbp),%edi
mov    0x2e93(%rip),%rax
mov    (%rax),%esi
call   1030 <shutdown@plt>
cmp    $0xffffffff,%eax
jne    1183 <handle_connection+0x43>
mov    $0x1,%edi
lea    0xe87(%rip),%rsi
call   1060 <logmessage@plt>
jmp    11a5 <handle_connection+0x65>
mov    -0x4(%rbp),%edi
call   1040 <close@plt>
cmp    $0xffffffff,%eax
jne    11a5 <handle_connection+0x65>
mov    $0x1,%edi
lea    0xe83(%rip),%rsi
call   1060 <logmessage@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<handle_connection>:
push   %rbx
mov    %edi,%ebx
call   1050 <handle_request@plt>
mov    0x2ea1(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
call   1030 <shutdown@plt>
cmp    $0xffffffff,%eax
je     116b <handle_connection+0x2b>
mov    %ebx,%edi
call   1040 <close@plt>
cmp    $0xffffffff,%eax
je     1174 <handle_connection+0x34>
pop    %rbx
ret
lea    0xe8e(%rip),%rsi
jmp    117b <handle_connection+0x3b>
lea    0xea8(%rip),%rsi
mov    $0x1,%edi
pop    %rbx
jmp    1060 <logmessage@plt>

LLVM IR (-O0):
@SHUT_RDWR = global i32 0
@.str = [35 x i8] c"Error shutting down client socket.\00"
@.str.1 = [29 x i8] c"Error closing client socket.\00"
define void @handle_connection(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = call i32 @handle_request(i32 %3)
%5 = load i32, i32* %2
%6 = load i32, i32* @SHUT_RDWR
%7 = call i32 @shutdown(i32 %5, i32 %6)
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %11
9: ; preds = %1
%10 = call i32 @logmessage(i32 1, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
br label %17
11: ; preds = %1
%12 = load i32, i32* %2
%13 = call i32 @close(i32 %12)
%14 = icmp eq i32 %13, -1
br i1 %14, label %15, label %17
15: ; preds = %11
%16 = call i32 @logmessage(i32 1, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
br label %17
17: ; preds = %9, %15, %11
ret void
}

LLVM IR (-O2):
@SHUT_RDWR = global i32 0
@.str = [35 x i8] c"Error shutting down client socket.\00"
@.str.1 = [29 x i8] c"Error closing client socket.\00"
define void @handle_connection(i32 %0) {
%2 = tail call i32 @handle_request(i32 %0)
%3 = load i32, i32* @SHUT_RDWR
%4 = tail call i32 @shutdown(i32 %0, i32 %3)
%5 = icmp eq i32 %4, -1
br i1 %5, label %9, label %6
6: ; preds = %1
%7 = tail call i32 @close(i32 %0)
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %12
9: ; preds = %6, %1
%10 = phi i8* [ getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), %1 ], [ getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), %6 ]
%11 = tail call i32 @logmessage(i32 1, i8* %10)
br label %12
12: ; preds = %9, %6
ret void
}