#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 close(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ stderr;
int close_connection(int s) {
  int status = 0, verbose = 0;
  if (verbose > 0)
    fprintf(stderr, "close_connection: socket = %d\n", s);
  if (s > 0)
    status = (close(s));
  if (status != 0)
    perror("close_connection");
  return status;
}


x86 assembly (clang, -O0):
<close_connection>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jle    116b <close_connection+0x3b>
mov    0x2e86(%rip),%rax
mov    (%rax),%edi
mov    -0x4(%rbp),%edx
lea    0xe9a(%rip),%rsi
call   1040 <fprintf@plt>
cmpl   $0x0,-0x4(%rbp)
jle    1180 <close_connection+0x50>
mov    -0x4(%rbp),%edi
call   1030 <close@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     1196 <close_connection+0x66>
lea    0xe8e(%rip),%rdi
call   1050 <perror@plt>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<close_connection>:
push   %rbp
push   %rbx
push   %rax
xor    %ebx,%ebx
test   %edi,%edi
jle    1132 <close_connection+0x12>
call   1030 <close@plt>
test   %eax,%eax
jne    113b <close_connection+0x1b>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    %eax,%ebp
lea    0xebc(%rip),%rdi
call   1040 <perror@plt>
mov    %ebp,%ebx
jmp    1132 <close_connection+0x12>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [31 x i8] c"close_connection: socket = %d\0A\00"
@.str.1 = [17 x i8] c"close_connection\00"
define i32 @close_connection(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
%5 = load i32, i32* %4
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %11
7: ; preds = %1
%8 = load i32, i32* @stderr
%9 = load i32, i32* %2
%10 = call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 %9)
br label %11
11: ; preds = %7, %1
%12 = load i32, i32* %2
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %11
%15 = load i32, i32* %2
%16 = call i32 @close(i32 %15)
store i32 %16, i32* %3
br label %17
17: ; preds = %14, %11
%18 = load i32, i32* %3
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
br label %22
22: ; preds = %20, %17
%23 = load i32, i32* %3
ret i32 %23
}

LLVM IR (-O2):
@stderr = global i32 0
@.str.1 = [17 x i8] c"close_connection\00"
define i32 @close_connection(i32 %0) {
%2 = icmp sgt i32 %0, 0
br i1 %2, label %3, label %8
3: ; preds = %1
%4 = tail call i32 @close(i32 %0)
%5 = icmp eq i32 %4, 0
br i1 %5, label %8, label %6
6: ; preds = %3
%7 = tail call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
br label %8
8: ; preds = %1, %6, %3
%9 = phi i32 [ %4, %6 ], [ 0, %3 ], [ 0, %1 ]
ret i32 %9
}