#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 createSocket();
int listenForClients(int);
int /*<<< orphan*/ perror(char *);
int checkConnection() {
  int socket;
  socket = createSocket();
  if (socket == -1) {
    perror("Socket Error!");
    return (-1);
  }
  if (listenForClients(socket) == -1) {
    perror("Client Connection Error!");
    return (-1);
  }
  return 0;
}


x86 assembly (clang, -O0):
<checkConnection>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1030 <createSocket@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
jne    1164 <checkConnection+0x34>
lea    0xead(%rip),%rdi
call   1050 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1194 <checkConnection+0x64>
mov    -0x8(%rbp),%edi
call   1040 <listenForClients@plt>
cmp    $0xffffffff,%eax
jne    118d <checkConnection+0x5d>
lea    0xe92(%rip),%rdi
call   1050 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1194 <checkConnection+0x64>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkConnection>:
push   %rbx
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <createSocket@plt>
cmp    $0xffffffff,%eax
je     114f <checkConnection+0x1f>
mov    %eax,%edi
call   1040 <listenForClients@plt>
cmp    $0xffffffff,%eax
je     1158 <checkConnection+0x28>
mov    %ebx,%eax
pop    %rbx
ret
lea    0xeaa(%rip),%rdi
jmp    115f <checkConnection+0x2f>
lea    0xeaf(%rip),%rdi
call   1050 <perror@plt>
mov    $0xffffffff,%ebx
jmp    114b <checkConnection+0x1b>

LLVM IR (-O0):
@.str = [14 x i8] c"Socket Error!\00"
@.str.1 = [25 x i8] c"Client Connection Error!\00"
define i32 @checkConnection() {
%1 = alloca i32
%2 = alloca i32
%3 = call i32 (...) @createSocket()
store i32 %3, i32* %2
%4 = load i32, i32* %2
%5 = icmp eq i32 %4, -1
br i1 %5, label %6, label %8
6: ; preds = %0
%7 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %1
br label %15
8: ; preds = %0
%9 = load i32, i32* %2
%10 = call i32 @listenForClients(i32 %9)
%11 = icmp eq i32 %10, -1
br i1 %11, label %12, label %14
12: ; preds = %8
%13 = call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %1
br label %15
14: ; preds = %8
store i32 0, i32* %1
br label %15
15: ; preds = %14, %12, %6
%16 = load i32, i32* %1
ret i32 %16
}

LLVM IR (-O2):
@.str = [14 x i8] c"Socket Error!\00"
@.str.1 = [25 x i8] c"Client Connection Error!\00"
define i32 @checkConnection() {
%1 = tail call i32 (...) @createSocket()
%2 = icmp eq i32 %1, -1
br i1 %2, label %6, label %3
3: ; preds = %0
%4 = tail call i32 @listenForClients(i32 %1)
%5 = icmp eq i32 %4, -1
br i1 %5, label %6, label %9
6: ; preds = %3, %0
%7 = phi i8* [ getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), %0 ], [ getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), %3 ]
%8 = tail call i32 @perror(i8* %7)
br label %9
9: ; preds = %6, %3
%10 = phi i32 [ 0, %3 ], [ -1, %6 ]
ret i32 %10
}