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

/* Variables and functions */
scalar_t__ EINPROGRESS;
int connect(int, struct sockaddr *, int /*<<< orphan*/);
scalar_t__ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int, char *,
                           char *);
int /*<<< orphan*/ stderr;
char *strerror(scalar_t__);
int Connect(int fd, struct sockaddr *addr, socklen_t addrlen) {
  int n;
  n = connect(fd, addr, addrlen);
  if (n < 0) {
    if (errno != EINPROGRESS)
      do {
        fprintf(stderr, "ERROR: [%s:%d] %s: %s\n",
                "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                "outputs/2022-01-22/02-19-57/repos/ystk/debian-freeipmi/refs/"
                "heads/master/ipmipower/src/wrappers.c",
                399, "connect", strerror(errno));
      } while (0);
  }
  return n;
}


x86 assembly (clang, -O0):
<Connect>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1040 <connect@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    11c7 <Connect+0x97>
mov    0x2e6b(%rip),%rax
mov    (%rax),%rax
mov    0x2e79(%rip),%rcx
cmp    (%rcx),%rax
je     11c2 <Connect+0x92>
jmp    117d <Connect+0x4d>
mov    0x2e54(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    0x2e40(%rip),%rax
mov    (%rax),%rdi
call   1050 <strerror@plt>
mov    -0x1c(%rbp),%edi
mov    %rax,%r9
lea    0xe5b(%rip),%rsi
lea    0xe6b(%rip),%rdx
mov    $0x18f,%ecx
lea    0xef9(%rip),%r8
call   1030 <fprintf@plt>
jmp    11c2 <Connect+0x92>
jmp    11c7 <Connect+0x97>
mov    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Connect>:
push   %rbp
push   %rbx
push   %rax
call   1040 <connect@plt>
mov    %eax,%ebx
test   %eax,%eax
jns    1186 <Connect+0x56>
mov    0x2e8b(%rip),%rax
mov    (%rax),%rdi
mov    0x2e99(%rip),%rax
cmp    (%rax),%rdi
je     1186 <Connect+0x56>
mov    0x2e7d(%rip),%rax
mov    (%rax),%ebp
call   1050 <strerror@plt>
lea    0xe97(%rip),%rsi
lea    0xea7(%rip),%rdx
lea    0xf3a(%rip),%r8
mov    %ebp,%edi
mov    $0x18f,%ecx
mov    %rax,%r9
call   1030 <fprintf@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.sockaddr = type { i32 }
@errno = global i64 0
@EINPROGRESS = global i64 0
@stderr = global i32 0
@.str = [23 x i8] c"ERROR: [%s:%d] %s: %s\0A\00"
@.str.1 = [154 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/ystk/debian-freeipmi/refs/heads/master/ipmipower/src/wrappers.c\00"
@.str.2 = [8 x i8] c"connect\00"
define i32 @Connect(i32 %0, %struct.sockaddr* %1, i32 %2) {
%4 = alloca i32
%5 = alloca %struct.sockaddr*
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %4
store %struct.sockaddr* %1, %struct.sockaddr** %5
store i32 %2, i32* %6
%8 = load i32, i32* %4
%9 = load %struct.sockaddr*, %struct.sockaddr** %5
%10 = load i32, i32* %6
%11 = call i32 @connect(i32 %8, %struct.sockaddr* %9, i32 %10)
store i32 %11, i32* %7
%12 = load i32, i32* %7
%13 = icmp slt i32 %12, 0
br i1 %13, label %14, label %26
14: ; preds = %3
%15 = load i64, i64* @errno
%16 = load i64, i64* @EINPROGRESS
%17 = icmp ne i64 %15, %16
br i1 %17, label %18, label %25
18: ; preds = %14
br label %19
19: ; preds = %18
%20 = load i32, i32* @stderr
%21 = load i64, i64* @errno
%22 = call i8* @strerror(i64 %21)
%23 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([154 x i8], [154 x i8]* @.str.1, i64 0, i64 0), i32 399, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* %22)
br label %24
24: ; preds = %19
br label %25
25: ; preds = %24, %14
br label %26
26: ; preds = %25, %3
%27 = load i32, i32* %7
ret i32 %27
}

LLVM IR (-O2):
%struct.sockaddr = type { i32 }
@errno = global i64 0
@EINPROGRESS = global i64 0
@stderr = global i32 0
@.str = [23 x i8] c"ERROR: [%s:%d] %s: %s\0A\00"
@.str.1 = [154 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/ystk/debian-freeipmi/refs/heads/master/ipmipower/src/wrappers.c\00"
@.str.2 = [8 x i8] c"connect\00"
define i32 @Connect(i32 %0, %struct.sockaddr* %1, i32 %2) {
%4 = tail call i32 @connect(i32 %0, %struct.sockaddr* %1, i32 %2)
%5 = icmp slt i32 %4, 0
br i1 %5, label %6, label %14
6: ; preds = %3
%7 = load i64, i64* @errno
%8 = load i64, i64* @EINPROGRESS
%9 = icmp eq i64 %7, %8
br i1 %9, label %14, label %10
10: ; preds = %6
%11 = load i32, i32* @stderr
%12 = tail call i8* @strerror(i64 %7)
%13 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([154 x i8], [154 x i8]* @.str.1, i64 0, i64 0), i32 399, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* %12)
br label %14
14: ; preds = %6, %10, %3
ret i32 %4
}