#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 bind(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 Bind(int sockfd, const struct sockaddr *addr, socklen_t addrlen) {
  if (bind(sockfd, addr, addrlen) == -1) {
    do {
      fprintf(stderr,
              "[SYSLOG] [%s][%d]"
              "ERROR: Bind 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",
              38, (errno <= 0 ? "" : strerror(errno)));
    } while (0);
    ;
    exit(errno);
  }
  return 0;
}


x86 assembly (clang, -O0):
<Bind>:
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 <bind@plt>
cmp    $0xffffffff,%eax
jne    11dd <Bind+0x9d>
jmp    116f <Bind+0x2f>
mov    0x2e6a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    0x2e56(%rip),%rax
cmpq   $0x0,(%rax)
jg     119c <Bind+0x5c>
lea    0xe94(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    11af <Bind+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    0xe64(%rip),%rdx
mov    $0x26,%ecx
call   1030 <fprintf@plt>
mov    0x2e03(%rip),%rax
mov    (%rax),%rdi
call   1050 <exit@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Bind>:
push   %r14
push   %rbx
push   %rax
call   1040 <bind@plt>
cmp    $0xffffffff,%eax
je     1158 <Bind+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 <Bind+0x39>
lea    0xeb0(%rip),%r8
jmp    1181 <Bind+0x41>
call   1060 <strerror@plt>
mov    %rax,%r8
lea    0xe78(%rip),%rsi
lea    0xe99(%rip),%rdx
mov    %ebx,%edi
mov    $0x26,%ecx
call   1030 <fprintf@plt>
mov    (%r14),%rdi
call   1050 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr = type { i32 }
@stderr = global i32 0
@.str = [40 x i8] c"[SYSLOG] [%s][%d]ERROR: Bind 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 @Bind(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 @bind(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 ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([151 x i8], [151 x i8]* @.str.1, i64 0, i64 0), i32 38, 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 = [40 x i8] c"[SYSLOG] [%s][%d]ERROR: Bind 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 @Bind(i32 %0, %struct.sockaddr* %1, i32 %2) {
%4 = tail call i32 @bind(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 ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([151 x i8], [151 x i8]* @.str.1, i64 0, i64 0), i32 38, i8* %13)
%15 = load i64, i64* @errno
%16 = tail call i32 @exit(i64 %15)
unreachable
17: ; preds = %3
ret i32 0
}