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

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int accept(int, struct sockaddr *, int *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int, char *);
int /*<<< orphan*/ stderr;
int chat_server_client_handler(int socket_fd) {
  int fd = -1;
  struct sockaddr_in sock;
  socklen_t socklen;
  socklen = sizeof(socklen);
  if ((fd = accept(socket_fd, (struct sockaddr *)&sock, &socklen)) < 0) {
    fprintf(stderr, "%s:%d >> Error: %s\n",
            "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/dorneanu/rsachat/refs/heads/master/src/"
            "server.c",
            220, "Error on new connection");
    exit(EXIT_FAILURE);
  };
  return fd;
}


x86 assembly (clang, -O0):
<chat_server_client_handler>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movl   $0xffffffff,-0x8(%rbp)
movl   $0x4,-0x14(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x10(%rbp),%rsi
lea    -0x14(%rbp),%rdx
call   1040 <accept@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jge    119b <chat_server_client_handler+0x6b>
mov    0x2e74(%rip),%rax
mov    (%rax),%edi
lea    0xe8b(%rip),%rsi
lea    0xe98(%rip),%rdx
mov    $0xdc,%ecx
lea    0xf16(%rip),%r8
call   1030 <fprintf@plt>
mov    0x2e44(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
mov    -0x8(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<chat_server_client_handler>:
sub    $0x18,%rsp
movl   $0x4,0xc(%rsp)
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
call   1040 <accept@plt>
test   %eax,%eax
js     1154 <chat_server_client_handler+0x24>
add    $0x18,%rsp
ret
mov    0x2e85(%rip),%rax
mov    (%rax),%edi
lea    0xe9c(%rip),%rsi
lea    0xea9(%rip),%rdx
lea    0xf2c(%rip),%r8
mov    $0xdc,%ecx
call   1030 <fprintf@plt>
mov    0x2e55(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32 }
%struct.sockaddr = type { i32 }
@stderr = global i32 0
@.str = [20 x i8] c"%s:%d >> Error: %s\0A\00"
@.str.1 = [138 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/dorneanu/rsachat/refs/heads/master/src/server.c\00"
@.str.2 = [24 x i8] c"Error on new connection\00"
@EXIT_FAILURE = global i32 0
define i32 @chat_server_client_handler(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca %struct.sockaddr_in
%5 = alloca i32
store i32 %0, i32* %2
store i32 -1, i32* %3
store i32 4, i32* %5
%6 = load i32, i32* %2
%7 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
%8 = call i32 @accept(i32 %6, %struct.sockaddr* %7, i32* %5)
store i32 %8, i32* %3
%9 = icmp slt i32 %8, 0
br i1 %9, label %10, label %15
10: ; preds = %1
%11 = load i32, i32* @stderr
%12 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([138 x i8], [138 x i8]* @.str.1, i64 0, i64 0), i32 220, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%13 = load i32, i32* @EXIT_FAILURE
%14 = call i32 @exit(i32 %13)
unreachable
15: ; preds = %1
%16 = load i32, i32* %3
ret i32 %16
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32 }
%struct.sockaddr = type { i32 }
@stderr = global i32 0
@.str = [20 x i8] c"%s:%d >> Error: %s\0A\00"
@.str.1 = [138 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/dorneanu/rsachat/refs/heads/master/src/server.c\00"
@.str.2 = [24 x i8] c"Error on new connection\00"
@EXIT_FAILURE = global i32 0
define i32 @chat_server_client_handler(i32 %0) {
%2 = alloca %struct.sockaddr_in
%3 = alloca i32
%4 = bitcast %struct.sockaddr_in* %2 to i8*
%5 = bitcast i32* %3 to i8*
store i32 4, i32* %3
%6 = bitcast %struct.sockaddr_in* %2 to %struct.sockaddr*
%7 = call i32 @accept(i32 %0, %struct.sockaddr* %6, i32* %3)
%8 = icmp slt i32 %7, 0
br i1 %8, label %9, label %14
9: ; preds = %1
%10 = load i32, i32* @stderr
%11 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([138 x i8], [138 x i8]* @.str.1, i64 0, i64 0), i32 220, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%12 = load i32, i32* @EXIT_FAILURE
%13 = call i32 @exit(i32 %12)
unreachable
14: ; preds = %1
ret i32 %7
}