#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*/ LOG_CRIT;
int /*<<< orphan*/ _debug(char *, int, int /*<<< orphan*/, char *,
                          int /*<<< orphan*/);
int /*<<< orphan*/ abort();
int /*<<< orphan*/ errno;
int fork();
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
pid_t safe_fork(void) {
  pid_t result;
  result = fork();
  if (result == -1) {
    _debug("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
           "2022-01-22/02-19-57/repos/lynxis/nodogsplash/refs/heads/master/src/"
           "safe.c",
           97, LOG_CRIT, "Failed to fork: %s. Bailing out", strerror(errno));
    abort();
  } else if (result == 0) {
  }
  return result;
}


x86 assembly (clang, -O0):
<safe_fork>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1060 <fork@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0xffffffff,-0x4(%rbp)
jne    119b <safe_fork+0x5b>
mov    0x2e85(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
mov    0x2e69(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
mov    -0x8(%rbp),%edx
mov    %eax,%r8d
lea    0xe7d(%rip),%rdi
mov    $0x61,%esi
lea    0xefb(%rip),%rcx
call   1040 <_debug@plt>
mov    $0x0,%al
call   1030 <abort@plt>
cmpl   $0x0,-0x4(%rbp)
jne    11aa <safe_fork+0x6a>
jmp    11aa <safe_fork+0x6a>
jmp    11af <safe_fork+0x6f>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<safe_fork>:
push   %rbx
xor    %eax,%eax
call   1060 <fork@plt>
cmp    $0xffffffff,%eax
je     114f <safe_fork+0xf>
pop    %rbx
ret
mov    0x2e92(%rip),%rax
mov    (%rax),%ebx
mov    0x2e79(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
lea    0xe93(%rip),%rdi
lea    0xf16(%rip),%rcx
mov    $0x61,%esi
mov    %ebx,%edx
mov    %eax,%r8d
call   1040 <_debug@plt>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@.str = [138 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/lynxis/nodogsplash/refs/heads/master/src/safe.c\00"
@LOG_CRIT = global i32 0
@.str.1 = [32 x i8] c"Failed to fork: %s. Bailing out\00"
@errno = global i32 0
define i32 @safe_fork() {
%1 = alloca i32
%2 = call i32 (...) @fork()
store i32 %2, i32* %1
%3 = load i32, i32* %1
%4 = icmp eq i32 %3, -1
br i1 %4, label %5, label %11
5: ; preds = %0
%6 = load i32, i32* @LOG_CRIT
%7 = load i32, i32* @errno
%8 = call i32 @strerror(i32 %7)
%9 = call i32 @_debug(i8* getelementptr inbounds ([138 x i8], [138 x i8]* @.str, i64 0, i64 0), i32 97, i32 %6, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 %8)
%10 = call i32 (...) @abort()
unreachable
11: ; preds = %0
%12 = load i32, i32* %1
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %11
br label %15
15: ; preds = %14, %11
br label %16
16: ; preds = %15
%17 = load i32, i32* %1
ret i32 %17
}

LLVM IR (-O2):
@.str = [138 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/lynxis/nodogsplash/refs/heads/master/src/safe.c\00"
@LOG_CRIT = global i32 0
@.str.1 = [32 x i8] c"Failed to fork: %s. Bailing out\00"
@errno = global i32 0
define i32 @safe_fork() {
%1 = tail call i32 (...) @fork()
%2 = icmp eq i32 %1, -1
br i1 %2, label %3, label %9
3: ; preds = %0
%4 = load i32, i32* @LOG_CRIT
%5 = load i32, i32* @errno
%6 = tail call i32 @strerror(i32 %5)
%7 = tail call i32 @_debug(i8* getelementptr inbounds ([138 x i8], [138 x i8]* @.str, i64 0, i64 0), i32 97, i32 %4, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 %6)
%8 = tail call i32 (...) @abort()
unreachable
9: ; preds = %0
ret i32 %1
}