#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 */
typedef int pid_t;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int fork();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int, char *,
                           int);
int /*<<< orphan*/ stderr;
char *strerror(int);
pid_t wrapper_fork(const char *file, const int line) {
  pid_t pid = fork();
  if (pid == -1) {
    fprintf(stderr,
            "Error: couldn't fork process: "
            "%s, line %d\n    %s (%d)\n",
            "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/paulgriffiths/pgutils/refs/heads/master/"
            "wrappers/unix_wrappers.c",
            17, strerror(errno), errno);
    exit(EXIT_FAILURE);
  }
  return pid;
}


x86 assembly (clang, -O0):
<wrapper_fork>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    $0x0,%al
call   1060 <fork@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0xffffffff,-0x10(%rbp)
jne    11b3 <wrapper_fork+0x73>
mov    0x2e76(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    0x2e62(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
mov    -0x14(%rbp),%edi
mov    %rax,%r8
mov    0x2e4e(%rip),%rax
mov    (%rax),%r9d
lea    0xe6c(%rip),%rsi
lea    0xe9c(%rip),%rdx
mov    $0x11,%ecx
call   1030 <fprintf@plt>
mov    0x2e24(%rip),%rax
mov    (%rax),%edi
call   1040 <exit@plt>
mov    -0x10(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wrapper_fork>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1060 <fork@plt>
cmp    $0xffffffff,%eax
je     1158 <wrapper_fork+0x18>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2e81(%rip),%rax
mov    (%rax),%ebx
mov    0x2e70(%rip),%r14
mov    (%r14),%edi
call   1050 <strerror@plt>
mov    (%r14),%r9d
lea    0xe86(%rip),%rsi
lea    0xeb6(%rip),%rdx
mov    %ebx,%edi
mov    $0x11,%ecx
mov    %rax,%r8
call   1030 <fprintf@plt>
mov    0x2e39(%rip),%rax
mov    (%rax),%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [55 x i8] c"Error: couldn't fork process: %s, line %d\0A %s (%d)\0A\00"
@.str.1 = [155 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/paulgriffiths/pgutils/refs/heads/master/wrappers/unix_wrappers.c\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
define i32 @wrapper_fork(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%6 = call i32 (...) @fork()
store i32 %6, i32* %5
%7 = load i32, i32* %5
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %17
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = load i32, i32* @errno
%12 = call i8* @strerror(i32 %11)
%13 = load i32, i32* @errno
%14 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([155 x i8], [155 x i8]* @.str.1, i64 0, i64 0), i32 17, i8* %12, i32 %13)
%15 = load i32, i32* @EXIT_FAILURE
%16 = call i32 @exit(i32 %15)
unreachable
17: ; preds = %2
%18 = load i32, i32* %5
ret i32 %18
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [55 x i8] c"Error: couldn't fork process: %s, line %d\0A %s (%d)\0A\00"
@.str.1 = [155 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/paulgriffiths/pgutils/refs/heads/master/wrappers/unix_wrappers.c\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
define i32 @wrapper_fork(i8* nocapture readnone %0, i32 %1) {
%3 = tail call i32 (...) @fork()
%4 = icmp eq i32 %3, -1
br i1 %4, label %5, label %13
5: ; preds = %2
%6 = load i32, i32* @stderr
%7 = load i32, i32* @errno
%8 = tail call i8* @strerror(i32 %7)
%9 = load i32, i32* @errno
%10 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([155 x i8], [155 x i8]* @.str.1, i64 0, i64 0), i32 17, i8* %8, i32 %9)
%11 = load i32, i32* @EXIT_FAILURE
%12 = tail call i32 @exit(i32 %11)
unreachable
13: ; preds = %2
ret i32 %3
}