#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 */
struct probans {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
struct probans *malloc(size_t);
int /*<<< orphan*/ stderr;
void ar_malloc(size_t size, struct probans **ans, char *method) {
  *ans = malloc(size);
  if (*ans == NULL) {
    fprintf(stderr, "error: failed to malloc to load answers for %s.\n",
            method);
    exit(1);
  }
}


x86 assembly (clang, -O0):
<ar_malloc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <malloc@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
jne    1188 <ar_malloc+0x58>
mov    0x2e74(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xe87(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ar_malloc>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%rbx
call   1040 <malloc@plt>
mov    %rax,(%rbx)
test   %rax,%rax
je     114f <ar_malloc+0x1f>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2e8a(%rip),%rax
mov    (%rax),%edi
lea    0xea1(%rip),%rsi
mov    %r14,%rdx
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
%struct.probans = type { i32 }
@stderr = global i32 0
@.str = [49 x i8] c"error: failed to malloc to load answers for %s.\0A\00"
define void @ar_malloc(i64 %0, %struct.probans** %1, i8* %2) {
%4 = alloca i64
%5 = alloca %struct.probans**
%6 = alloca i8*
store i64 %0, i64* %4
store %struct.probans** %1, %struct.probans*** %5
store i8* %2, i8** %6
%7 = load i64, i64* %4
%8 = call %struct.probans* @malloc(i64 %7)
%9 = load %struct.probans**, %struct.probans*** %5
store %struct.probans* %8, %struct.probans** %9
%10 = load %struct.probans**, %struct.probans*** %5
%11 = load %struct.probans*, %struct.probans** %10
%12 = icmp eq %struct.probans* %11, null
br i1 %12, label %13, label %18
13: ; preds = %3
%14 = load i32, i32* @stderr
%15 = load i8*, i8** %6
%16 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = call i32 @exit(i32 1)
unreachable
18: ; preds = %3
ret void
}

LLVM IR (-O2):
%struct.probans = type { i32 }
@stderr = global i32 0
@.str = [49 x i8] c"error: failed to malloc to load answers for %s.\0A\00"
define void @ar_malloc(i64 %0, %struct.probans** nocapture writeonly %1, i8* %2) {
%4 = tail call %struct.probans* @malloc(i64 %0)
store %struct.probans* %4, %struct.probans** %1
%5 = icmp eq %struct.probans* %4, null
br i1 %5, label %6, label %10
6: ; preds = %3
%7 = load i32, i32* @stderr
%8 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0), i8* %2)
%9 = tail call i32 @exit(i32 1)
unreachable
10: ; preds = %3
ret void
}