#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*/ LOG_ERR;
int /*<<< orphan*/ LOG_INFO;
int /*<<< orphan*/ logIT(int /*<<< orphan*/, char *, ...);
int openCliSocket(char *, int, int /*<<< orphan*/);
int connectServer(char *host, int port) {
  int sockfd;
  if (host[0] != '/') {
    sockfd = openCliSocket(host, port, 0);
    if (sockfd) {
      logIT(LOG_INFO, "Verbindung zu %s Port %d aufgebaut", host, port);
    } else {
      logIT(LOG_INFO, "Verbindung zu %s Port %d gescheitert", host, port);
      return (-1);
    }
  } else {
    logIT(LOG_ERR, "Host Format: IP|Name:Port");
    return (-1);
  }
  return (sockfd);
}


x86 assembly (clang, -O0):
<connectServer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
je     11ac <connectServer+0x8c>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
xor    %edx,%edx
call   1030 <openCliSocket@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     117d <connectServer+0x5d>
mov    0x2e7f(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
mov    -0x14(%rbp),%ecx
lea    0xe8f(%rip),%rsi
mov    $0x0,%al
call   1040 <logIT@plt>
jmp    11a7 <connectServer+0x87>
mov    0x2e5c(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
mov    -0x14(%rbp),%ecx
lea    0xe8f(%rip),%rsi
mov    $0x0,%al
call   1040 <logIT@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11d5 <connectServer+0xb5>
jmp    11cf <connectServer+0xaf>
mov    0x2e1d(%rip),%rax
mov    (%rax),%edi
lea    0xe8c(%rip),%rsi
mov    $0x0,%al
call   1040 <logIT@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11d5 <connectServer+0xb5>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<connectServer>:
push   %rbp
push   %r14
push   %rbx
cmpb   $0x2f,(%rdi)
jne    1142 <connectServer+0x22>
mov    0x2ea0(%rip),%rax
mov    (%rax),%edi
lea    0xf0f(%rip),%rsi
xor    %eax,%eax
call   1040 <logIT@plt>
jmp    1188 <connectServer+0x68>
mov    %esi,%r14d
mov    %rdi,%rbx
xor    %edx,%edx
call   1030 <openCliSocket@plt>
mov    %eax,%ebp
mov    0x2e88(%rip),%rax
mov    (%rax),%edi
test   %ebp,%ebp
je     1174 <connectServer+0x54>
lea    0xe9b(%rip),%rsi
mov    %rbx,%rdx
mov    %r14d,%ecx
xor    %eax,%eax
call   1040 <logIT@plt>
jmp    118d <connectServer+0x6d>
lea    0xea8(%rip),%rsi
mov    %rbx,%rdx
mov    %r14d,%ecx
xor    %eax,%eax
call   1040 <logIT@plt>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@LOG_INFO = global i32 0
@.str = [35 x i8] c"Verbindung zu %s Port %d aufgebaut\00"
@.str.1 = [37 x i8] c"Verbindung zu %s Port %d gescheitert\00"
@LOG_ERR = global i32 0
@.str.2 = [26 x i8] c"Host Format: IP|Name:Port\00"
define i32 @connectServer(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
%7 = load i8*, i8** %4
%8 = getelementptr inbounds i8, i8* %7, i64 0
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp ne i32 %10, 47
br i1 %11, label %12, label %29
12: ; preds = %2
%13 = load i8*, i8** %4
%14 = load i32, i32* %5
%15 = call i32 @openCliSocket(i8* %13, i32 %14, i32 0)
store i32 %15, i32* %6
%16 = load i32, i32* %6
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %23
18: ; preds = %12
%19 = load i32, i32* @LOG_INFO
%20 = load i8*, i8** %4
%21 = load i32, i32* %5
%22 = call i32 (i32, i8*, ...) @logIT(i32 %19, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8* %20, i32 %21)
br label %28
23: ; preds = %12
%24 = load i32, i32* @LOG_INFO
%25 = load i8*, i8** %4
%26 = load i32, i32* %5
%27 = call i32 (i32, i8*, ...) @logIT(i32 %24, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i8* %25, i32 %26)
store i32 -1, i32* %3
br label %34
28: ; preds = %18
br label %32
29: ; preds = %2
%30 = load i32, i32* @LOG_ERR
%31 = call i32 (i32, i8*, ...) @logIT(i32 %30, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %3
br label %34
32: ; preds = %28
%33 = load i32, i32* %6
store i32 %33, i32* %3
br label %34
34: ; preds = %32, %29, %23
%35 = load i32, i32* %3
ret i32 %35
}

LLVM IR (-O2):
@LOG_INFO = global i32 0
@.str = [35 x i8] c"Verbindung zu %s Port %d aufgebaut\00"
@.str.1 = [37 x i8] c"Verbindung zu %s Port %d gescheitert\00"
@LOG_ERR = global i32 0
@.str.2 = [26 x i8] c"Host Format: IP|Name:Port\00"
define i32 @connectServer(i8* %0, i32 %1) {
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 47
br i1 %4, label %13, label %5
5: ; preds = %2
%6 = tail call i32 @openCliSocket(i8* %0, i32 %1, i32 0)
%7 = icmp eq i32 %6, 0
%8 = load i32, i32* @LOG_INFO
br i1 %7, label %11, label %9
9: ; preds = %5
%10 = tail call i32 (i32, i8*, ...) @logIT(i32 %8, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %1)
br label %16
11: ; preds = %5
%12 = tail call i32 (i32, i8*, ...) @logIT(i32 %8, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i8* %0, i32 %1)
br label %16
13: ; preds = %2
%14 = load i32, i32* @LOG_ERR
%15 = tail call i32 (i32, i8*, ...) @logIT(i32 %14, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
br label %16
16: ; preds = %9, %13, %11
%17 = phi i32 [ %6, %9 ], [ -1, %11 ], [ -1, %13 ]
ret i32 %17
}