#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 */

/* Variables and functions */
int errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int, char const *,
                           char *, int, int, char *);
int /*<<< orphan*/ stderr;
char *strerror(int);
int checkreturn(int res, const char *name, char *arg, int line) {
  if (res >= 0)
    return res;
  fprintf(stderr, "mkbox.c:%d: error: %s(%s) failed: r=%d errno=%d (%s)\n",
          line, name, arg, res, errno, strerror(errno));
  exit(-1);
}


x86 assembly (clang, -O0):
<checkreturn>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
cmpl   $0x0,-0x4(%rbp)
jl     1159 <checkreturn+0x29>
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret
mov    0x2e80(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x40(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    0x2e50(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    0x2e44(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
mov    -0x40(%rbp),%edi
mov    -0x3c(%rbp),%edx
mov    -0x38(%rbp),%rcx
mov    -0x30(%rbp),%r8
mov    -0x24(%rbp),%r9d
mov    -0x20(%rbp),%r10d
lea    0xe48(%rip),%rsi
mov    %r10d,(%rsp)
mov    %rax,0x8(%rsp)
call   1030 <fprintf@plt>
mov    $0xffffffff,%edi
call   1040 <exit@plt>

x86 assembly (clang, -O2):
<checkreturn>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edi,%ebx
test   %edi,%edi
js     1152 <checkreturn+0x22>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %ecx,%r15d
mov    %rdx,%r14
mov    %rsi,%rbp
mov    0x2e7e(%rip),%rax
mov    (%rax),%r12d
mov    0x2e6c(%rip),%rax
mov    (%rax),%r13d
mov    %r13d,%edi
call   1050 <strerror@plt>
lea    0xe82(%rip),%rsi
mov    %r12d,%edi
mov    %r15d,%edx
mov    %rbp,%rcx
mov    %r14,%r8
mov    %ebx,%r9d
push   %rax
push   %r13
call   1030 <fprintf@plt>
add    $0x10,%rsp
mov    $0xffffffff,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [54 x i8] c"mkbox.c:%d: error: %s(%s) failed: r=%d errno=%d (%s)\0A\00"
@errno = global i32 0
define i32 @checkreturn(i32 %0, i8* %1, i8* %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
store i32 %0, i32* %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i32 %3, i32* %8
%9 = load i32, i32* %5
%10 = icmp sge i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %4
%12 = load i32, i32* %5
ret i32 %12
13: ; preds = %4
%14 = load i32, i32* @stderr
%15 = load i32, i32* %8
%16 = load i8*, i8** %6
%17 = load i8*, i8** %7
%18 = load i32, i32* %5
%19 = load i32, i32* @errno
%20 = load i32, i32* @errno
%21 = call i8* @strerror(i32 %20)
%22 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0), i32 %15, i8* %16, i8* %17, i32 %18, i32 %19, i8* %21)
%23 = call i32 @exit(i32 -1)
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [54 x i8] c"mkbox.c:%d: error: %s(%s) failed: r=%d errno=%d (%s)\0A\00"
@errno = global i32 0
define i32 @checkreturn(i32 returned %0, i8* %1, i8* %2, i32 %3) {
%5 = icmp sgt i32 %0, -1
br i1 %5, label %6, label %7
6: ; preds = %4
ret i32 %0
7: ; preds = %4
%8 = load i32, i32* @stderr
%9 = load i32, i32* @errno
%10 = tail call i8* @strerror(i32 %9)
%11 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0), i32 %3, i8* %1, i8* %2, i32 %0, i32 %9, i8* %10)
%12 = tail call i32 @exit(i32 -1)
unreachable
}