#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 /*<<< orphan*/ buffer;

/* Variables and functions */
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ snprintf(char *, int, char *, char const *, int,
                            char const *, long, int /*<<< orphan*/);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
int check(long r, const char *expr, const char *file, int line) {
  char buffer[256];
  if (r < 0) {
    snprintf(buffer, sizeof(buffer), "%s:%d: %s: result %ld, %s", file, line,
             expr, r, strerror(errno));
    exit(-1);
  }
  return r;
}


x86 assembly (clang, -O0):
<check>:
push   %rbp
mov    %rsp,%rbp
sub    $0x160,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
cmpq   $0x0,-0x8(%rbp)
jge    11e1 <check+0xb1>
lea    -0x120(%rbp),%rax
mov    %rax,-0x148(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x140(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x134(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x130(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x128(%rbp)
mov    0x2e4c(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
mov    -0x148(%rbp),%rdi
mov    -0x140(%rbp),%rcx
mov    -0x134(%rbp),%r8d
mov    -0x130(%rbp),%r9
mov    -0x128(%rbp),%r10
mov    $0x100,%esi
lea    0xe36(%rip),%rdx
mov    %r10,(%rsp)
mov    %eax,0x8(%rsp)
call   1030 <snprintf@plt>
mov    $0xffffffff,%edi
call   1040 <exit@plt>
mov    -0x8(%rbp),%rax
add    $0x160,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x108,%rsp
mov    %rdi,%rbx
test   %rdi,%rdi
js     1155 <check+0x25>
mov    %ebx,%eax
add    $0x108,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %ecx,%r14d
mov    %rdx,%rbp
mov    %rsi,%r15
mov    0x2e7b(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
lea    0xe8d(%rip),%rdx
mov    %rsp,%rdi
mov    $0x100,%esi
mov    %rbp,%rcx
mov    %r14d,%r8d
mov    %r15,%r9
push   %rax
push   %rbx
call   1030 <snprintf@plt>
add    $0x10,%rsp
mov    $0xffffffff,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@.str = [26 x i8] c"%s:%d: %s: result %ld, %s\00"
@errno = global i32 0
define i32 @check(i64 %0, i8* %1, i8* %2, i32 %3) {
%5 = alloca i64
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca [256 x i8]
store i64 %0, i64* %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i32 %3, i32* %8
%10 = load i64, i64* %5
%11 = icmp slt i64 %10, 0
br i1 %11, label %12, label %22
12: ; preds = %4
%13 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%14 = load i8*, i8** %7
%15 = load i32, i32* %8
%16 = load i8*, i8** %6
%17 = load i64, i64* %5
%18 = load i32, i32* @errno
%19 = call i32 @strerror(i32 %18)
%20 = call i32 @snprintf(i8* %13, i32 256, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %14, i32 %15, i8* %16, i64 %17, i32 %19)
%21 = call i32 @exit(i32 -1)
unreachable
22: ; preds = %4
%23 = load i64, i64* %5
%24 = trunc i64 %23 to i32
ret i32 %24
}

LLVM IR (-O2):
@.str = [26 x i8] c"%s:%d: %s: result %ld, %s\00"
@errno = global i32 0
define i32 @check(i64 %0, i8* %1, i8* %2, i32 %3) {
%5 = alloca [256 x i8]
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%7 = icmp slt i64 %0, 0
br i1 %7, label %8, label %13
8: ; preds = %4
%9 = load i32, i32* @errno
%10 = tail call i32 @strerror(i32 %9)
%11 = call i32 @snprintf(i8* %6, i32 256, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %2, i32 %3, i8* %1, i64 %0, i32 %10)
%12 = call i32 @exit(i32 -1)
unreachable
13: ; preds = %4
%14 = trunc i64 %0 to i32
ret i32 %14
}