#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*/ debugprintf(char *, ...);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
void check_connection(int x) {
  if (x < 0) {
    perror("Error: Connection Failed ");
    exit(errno);
  } else {
    debugprintf("Connection Established\n");
    debugprintf("Server Socket %d Connected\n", x);
  }
}


x86 assembly (clang, -O0):
<check_connection>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jge    115f <check_connection+0x2f>
lea    0xeb4(%rip),%rdi
call   1040 <perror@plt>
mov    0x2e88(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
lea    0xeb4(%rip),%rdi
mov    $0x0,%al
call   1030 <debugprintf@plt>
mov    -0x4(%rbp),%esi
lea    0xebb(%rip),%rdi
mov    $0x0,%al
call   1030 <debugprintf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_connection>:
push   %rbx
test   %edi,%edi
js     1156 <check_connection+0x26>
mov    %edi,%ebx
lea    0xedc(%rip),%rdi
xor    %eax,%eax
call   1030 <debugprintf@plt>
lea    0xee6(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
pop    %rbx
jmp    1030 <debugprintf@plt>
lea    0xea3(%rip),%rdi
call   1040 <perror@plt>
mov    0x2e77(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [26 x i8] c"Error: Connection Failed \00"
@errno = global i32 0
@.str.1 = [24 x i8] c"Connection Established\0A\00"
@.str.2 = [28 x i8] c"Server Socket %d Connected\0A\00"
define void @check_connection(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = icmp slt i32 %3, 0
br i1 %4, label %5, label %9
5: ; preds = %1
%6 = call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%7 = load i32, i32* @errno
%8 = call i32 @exit(i32 %7)
unreachable
9: ; preds = %1
%10 = call i32 (i8*, ...) @debugprintf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%11 = load i32, i32* %2
%12 = call i32 (i8*, ...) @debugprintf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i32 %11)
br label %13
13: ; preds = %9
ret void
}

LLVM IR (-O2):
@.str = [26 x i8] c"Error: Connection Failed \00"
@errno = global i32 0
@.str.1 = [24 x i8] c"Connection Established\0A\00"
@.str.2 = [28 x i8] c"Server Socket %d Connected\0A\00"
define void @check_connection(i32 %0) {
%2 = icmp slt i32 %0, 0
br i1 %2, label %3, label %7
3: ; preds = %1
%4 = tail call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%5 = load i32, i32* @errno
%6 = tail call i32 @exit(i32 %5)
unreachable
7: ; preds = %1
%8 = tail call i32 (i8*, ...) @debugprintf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%9 = tail call i32 (i8*, ...) @debugprintf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i32 %0)
ret void
}