#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 const *, int const);
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: %s (%d) at %s line %d\n", strerror(errno), errno,
            file, line);
    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    11ae <wrapper_fork+0x6e>
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,%rdx
mov    0x2e4e(%rip),%rax
mov    (%rax),%ecx
mov    -0x8(%rbp),%r8
mov    -0xc(%rbp),%r9d
lea    0xe65(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e29(%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   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
xor    %eax,%eax
call   1060 <fork@plt>
cmp    $0xffffffff,%eax
je     1163 <wrapper_fork+0x23>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2e76(%rip),%rax
mov    (%rax),%r14d
mov    0x2e64(%rip),%r15
mov    (%r15),%edi
call   1050 <strerror@plt>
mov    (%r15),%ecx
lea    0xe7a(%rip),%rsi
mov    %r14d,%edi
mov    %rax,%rdx
mov    %rbx,%r8
mov    %ebp,%r9d
call   1030 <fprintf@plt>
mov    0x2e32(%rip),%rax
mov    (%rax),%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [30 x i8] c"Error: %s (%d) at %s line %d\0A\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 %19
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 = load i8*, i8** %3
%15 = load i32, i32* %4
%16 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %12, i32 %13, i8* %14, i32 %15)
%17 = load i32, i32* @EXIT_FAILURE
%18 = call i32 @exit(i32 %17)
unreachable
19: ; preds = %2
%20 = load i32, i32* %5
ret i32 %20
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [30 x i8] c"Error: %s (%d) at %s line %d\0A\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
define i32 @wrapper_fork(i8* %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 ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %8, i32 %9, i8* %0, i32 %1)
%11 = load i32, i32* @EXIT_FAILURE
%12 = tail call i32 @exit(i32 %11)
unreachable
13: ; preds = %2
ret i32 %3
}