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


x86 assembly (clang, -O0):
<Accept>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1040 <accept@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0xffffffff,%eax
jne    11e2 <Accept+0xa2>
jmp    1174 <Accept+0x34>
mov    0x2e65(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    0x2e51(%rip),%rax
cmpq   $0x0,(%rax)
jg     11a1 <Accept+0x61>
lea    0xe94(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    11b4 <Accept+0x74>
mov    0x2e30(%rip),%rax
mov    (%rax),%rdi
call   1060 <strerror@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%edi
mov    -0x28(%rbp),%r8
lea    0xe3e(%rip),%rsi
lea    0xe64(%rip),%rdx
mov    $0x46,%ecx
call   1030 <fprintf@plt>
mov    0x2dfe(%rip),%rax
mov    (%rax),%rdi
call   1050 <exit@plt>
mov    -0x1c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Accept>:
push   %r14
push   %rbx
push   %rax
call   1040 <accept@plt>
cmp    $0xffffffff,%eax
je     1156 <Accept+0x16>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2e83(%rip),%rax
mov    (%rax),%ebx
mov    0x2e72(%rip),%r14
mov    (%r14),%rdi
test   %rdi,%rdi
jg     1177 <Accept+0x37>
lea    0xeb7(%rip),%r8
jmp    117f <Accept+0x3f>
call   1060 <strerror@plt>
mov    %rax,%r8
lea    0xe7a(%rip),%rsi
lea    0xea0(%rip),%rdx
mov    %ebx,%edi
mov    $0x46,%ecx
call   1030 <fprintf@plt>
mov    (%r14),%rdi
call   1050 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr = type { i32 }
@stderr = global i32 0
@.str = [45 x i8] c"[SYSLOG] [%s][%d]ERROR: Accept 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 @Accept(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 @accept(i32 %8, %struct.sockaddr* %9, i32* %10)
store i32 %11, i32* %7
%12 = icmp eq i32 %11, -1
br i1 %12, label %13, label %28
13: ; preds = %3
br label %14
14: ; preds = %13
%15 = load i32, i32* @stderr
%16 = load i64, i64* @errno
%17 = icmp sle i64 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %14
br label %22
19: ; preds = %14
%20 = load i64, i64* @errno
%21 = call i8* @strerror(i64 %20)
br label %22
22: ; preds = %19, %18
%23 = phi i8* [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), %18 ], [ %21, %19 ]
%24 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([151 x i8], [151 x i8]* @.str.1, i64 0, i64 0), i32 70, i8* %23)
br label %25
25: ; preds = %22
%26 = load i64, i64* @errno
%27 = call i32 @exit(i64 %26)
unreachable
28: ; preds = %3
%29 = load i32, i32* %7
ret i32 %29
}

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