#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 */
struct sockaddr_in {
  int dummy;
};
struct sockaddr {
  int dummy;
};
typedef int /*<<< orphan*/ socklen_t;

/* Variables and functions */
int /*<<< orphan*/ abort();
int connect(int, struct sockaddr *, int /*<<< orphan*/);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ stderr;
void connect_to_server(int socket, struct sockaddr_in *socket_conf) {
  if (connect(socket, (struct sockaddr *)socket_conf,
              (socklen_t)sizeof(struct sockaddr)) == -1) {
    perror("connect");
    fputs("Connection attempt failed.\n", stderr);
    abort();
  }
}


x86 assembly (clang, -O0):
<connect_to_server>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    $0x4,%edx
call   1060 <connect@plt>
cmp    $0xffffffff,%eax
jne    1191 <connect_to_server+0x51>
lea    0xe90(%rip),%rdi
call   1050 <perror@plt>
mov    0x2e64(%rip),%rax
mov    (%rax),%esi
lea    0xe83(%rip),%rdi
call   1040 <fputs@plt>
mov    $0x0,%al
call   1030 <abort@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<connect_to_server>:
push   %rax
mov    $0x4,%edx
call   1060 <connect@plt>
cmp    $0xffffffff,%eax
je     1152 <connect_to_server+0x12>
pop    %rax
ret
lea    0xea7(%rip),%rdi
call   1050 <perror@plt>
mov    0x2e7b(%rip),%rax
mov    (%rax),%esi
lea    0xe9a(%rip),%rdi
call   1040 <fputs@plt>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [8 x i8] c"connect\00"
@.str.1 = [28 x i8] c"Connection attempt failed.\0A\00"
@stderr = global i32 0
define void @connect_to_server(i32 %0, %struct.sockaddr_in* %1) {
%3 = alloca i32
%4 = alloca %struct.sockaddr_in*
store i32 %0, i32* %3
store %struct.sockaddr_in* %1, %struct.sockaddr_in** %4
%5 = load i32, i32* %3
%6 = load %struct.sockaddr_in*, %struct.sockaddr_in** %4
%7 = bitcast %struct.sockaddr_in* %6 to %struct.sockaddr*
%8 = call i32 @connect(i32 %5, %struct.sockaddr* %7, i32 4)
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %15
10: ; preds = %2
%11 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%12 = load i32, i32* @stderr
%13 = call i32 @fputs(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 %12)
%14 = call i32 (...) @abort()
unreachable
15: ; preds = %2
ret void
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [8 x i8] c"connect\00"
@.str.1 = [28 x i8] c"Connection attempt failed.\0A\00"
@stderr = global i32 0
define void @connect_to_server(i32 %0, %struct.sockaddr_in* %1) {
%3 = bitcast %struct.sockaddr_in* %1 to %struct.sockaddr*
%4 = tail call i32 @connect(i32 %0, %struct.sockaddr* %3, i32 4)
%5 = icmp eq i32 %4, -1
br i1 %5, label %6, label %11
6: ; preds = %2
%7 = tail call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%8 = load i32, i32* @stderr
%9 = tail call i32 @fputs(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 %8)
%10 = tail call i32 (...) @abort()
unreachable
11: ; preds = %2
ret void
}