#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 */
int connect(int, struct sockaddr const *, int /*<<< orphan*/);
scalar_t__ errno;
int /*<<< orphan*/ exit(scalar_t__);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int, char *);
int /*<<< orphan*/ stderr;
char *strerror(scalar_t__);
int Connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen) {
  if (connect(sockfd, addr, addrlen) == -1) {
    do {
      fprintf(stderr,
              "[SYSLOG] [%s][%d]"
              "ERROR: connected failed!\n"
              "%s\n",
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/Windeal/Demo/refs/heads/master/"
              "Chatting/C/common/socketapi.c",
              48, (errno <= 0 ? "" : strerror(errno)));
    } while (0);
    ;
    exit(errno);
  }
  return 0;
}


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   1050 <connect@plt>
cmp    $0xffffffff,%eax
jne    11dd <Connect+0x9d>
jmp    116f <Connect+0x2f>
mov    0x2e6a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    0x2e56(%rip),%rax
cmpq   $0x0,(%rax)
jg     119c <Connect+0x5c>
lea    0xe9a(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    11af <Connect+0x6f>
mov    0x2e35(%rip),%rax
mov    (%rax),%rdi
call   1060 <strerror@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%edi
mov    -0x20(%rbp),%r8
lea    0xe43(%rip),%rsi
lea    0xe6a(%rip),%rdx
mov    $0x30,%ecx
call   1030 <fprintf@plt>
mov    0x2e03(%rip),%rax
mov    (%rax),%rdi
call   1040 <exit@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Connect>:
push   %r14
push   %rbx
push   %rax
call   1050 <connect@plt>
cmp    $0xffffffff,%eax
je     1158 <Connect+0x18>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2e81(%rip),%rax
mov    (%rax),%ebx
mov    0x2e70(%rip),%r14
mov    (%r14),%rdi
test   %rdi,%rdi
jg     1179 <Connect+0x39>
lea    0xeb6(%rip),%r8
jmp    1181 <Connect+0x41>
call   1060 <strerror@plt>
mov    %rax,%r8
lea    0xe78(%rip),%rsi
lea    0xe9f(%rip),%rdx
mov    %ebx,%edi
mov    $0x30,%ecx
call   1030 <fprintf@plt>
mov    (%r14),%rdi
call   1040 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr = type { i32 }
@stderr = global i32 0
@.str = [46 x i8] c"[SYSLOG] [%s][%d]ERROR: connected failed!\0A%s\0A\00"
@.str.1 = [151 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/Windeal/Demo/refs/heads/master/Chatting/C/common/socketapi.c\00"
@errno = global i64 0
@.str.2 = [1 x i8] zeroinitializer
define i32 @Connect(i32 %0, %struct.sockaddr* %1, i32 %2) {
%4 = alloca i32
%5 = alloca %struct.sockaddr*
%6 = alloca i32
store i32 %0, i32* %4
store %struct.sockaddr* %1, %struct.sockaddr** %5
store i32 %2, i32* %6
%7 = load i32, i32* %4
%8 = load %struct.sockaddr*, %struct.sockaddr** %5
%9 = load i32, i32* %6
%10 = call i32 @connect(i32 %7, %struct.sockaddr* %8, i32 %9)
%11 = icmp eq i32 %10, -1
br i1 %11, label %12, label %27
12: ; preds = %3
br label %13
13: ; preds = %12
%14 = load i32, i32* @stderr
%15 = load i64, i64* @errno
%16 = icmp sle i64 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %13
br label %21
18: ; preds = %13
%19 = load i64, i64* @errno
%20 = call i8* @strerror(i64 %19)
br label %21
21: ; preds = %18, %17
%22 = phi i8* [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), %17 ], [ %20, %18 ]
%23 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([151 x i8], [151 x i8]* @.str.1, i64 0, i64 0), i32 48, i8* %22)
br label %24
24: ; preds = %21
%25 = load i64, i64* @errno
%26 = call i32 @exit(i64 %25)
unreachable
27: ; preds = %3
ret i32 0
}

LLVM IR (-O2):
%struct.sockaddr = type { i32 }
@stderr = global i32 0
@.str = [46 x i8] c"[SYSLOG] [%s][%d]ERROR: connected failed!\0A%s\0A\00"
@.str.1 = [151 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/Windeal/Demo/refs/heads/master/Chatting/C/common/socketapi.c\00"
@errno = global i64 0
@.str.2 = [1 x i8] zeroinitializer
define i32 @Connect(i32 %0, %struct.sockaddr* %1, i32 %2) {
%4 = tail call i32 @connect(i32 %0, %struct.sockaddr* %1, i32 %2)
%5 = icmp eq i32 %4, -1
br i1 %5, label %6, label %17
6: ; preds = %3
%7 = load i32, i32* @stderr
%8 = load i64, i64* @errno
%9 = icmp slt i64 %8, 1
br i1 %9, label %12, label %10
10: ; preds = %6
%11 = tail call i8* @strerror(i64 %8)
br label %12
12: ; preds = %6, %10
%13 = phi i8* [ %11, %10 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), %6 ]
%14 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([151 x i8], [151 x i8]* @.str.1, i64 0, i64 0), i32 48, i8* %13)
%15 = load i64, i64* @errno
%16 = tail call i32 @exit(i64 %15)
unreachable
17: ; preds = %3
ret i32 0
}