#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 /*<<< orphan*/ abort();
scalar_t__ calloc(int, int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exifdie(char const *);
int /*<<< orphan*/ exifwarn(char *);
scalar_t__ strerror(int /*<<< orphan*/);
void exifstralloc(char **str, int len) {
  if (*str) {
    exifwarn("tried to alloc over non-null string");
    abort();
  }
  if (!(*str = (char *)calloc(1, len)))
    exifdie((const char *)strerror(errno));
}


x86 assembly (clang, -O0):
<exifstralloc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
cmpq   $0x0,(%rax)
je     1180 <exifstralloc+0x30>
lea    0xe8c(%rip),%rdi
call   1050 <exifwarn@plt>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0xc(%rbp),%esi
mov    $0x1,%edi
call   1040 <calloc@plt>
mov    -0x8(%rbp),%rcx
mov    %rax,(%rcx)
cmp    $0x0,%rax
jne    11b4 <exifstralloc+0x64>
mov    0x2e3b(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
mov    %rax,%rdi
call   1060 <exifdie@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<exifstralloc>:
push   %rbx
cmpq   $0x0,(%rdi)
jne    1185 <exifstralloc+0x35>
mov    %rdi,%rbx
mov    $0x1,%edi
call   1040 <calloc@plt>
mov    %rax,(%rbx)
test   %rax,%rax
je     116e <exifstralloc+0x1e>
pop    %rbx
ret
mov    0x2e6b(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
mov    %rax,%rdi
pop    %rbx
jmp    1060 <exifdie@plt>
lea    0xe74(%rip),%rdi
call   1050 <exifwarn@plt>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@.str = [36 x i8] c"tried to alloc over non-null string\00"
@errno = global i32 0
define void @exifstralloc(i8** %0, i32 %1) {
%3 = alloca i8**
%4 = alloca i32
store i8** %0, i8*** %3
store i32 %1, i32* %4
%5 = load i8**, i8*** %3
%6 = load i8*, i8** %5
%7 = icmp ne i8* %6, null
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = call i32 @exifwarn(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (...) @abort()
unreachable
11: ; preds = %2
%12 = load i32, i32* %4
%13 = call i64 @calloc(i32 1, i32 %12)
%14 = inttoptr i64 %13 to i8*
%15 = load i8**, i8*** %3
store i8* %14, i8** %15
%16 = icmp ne i8* %14, null
br i1 %16, label %22, label %17
17: ; preds = %11
%18 = load i32, i32* @errno
%19 = call i64 @strerror(i32 %18)
%20 = inttoptr i64 %19 to i8*
%21 = call i32 @exifdie(i8* %20)
br label %22
22: ; preds = %17, %11
ret void
}

LLVM IR (-O2):
@.str = [36 x i8] c"tried to alloc over non-null string\00"
@errno = global i32 0
define void @exifstralloc(i8** nocapture %0, i32 %1) {
%3 = load i8*, i8** %0
%4 = icmp eq i8* %3, null
br i1 %4, label %8, label %5
5: ; preds = %2
%6 = tail call i32 @exifwarn(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 (...) @abort()
unreachable
8: ; preds = %2
%9 = tail call i64 @calloc(i32 1, i32 %1)
%10 = inttoptr i64 %9 to i8*
store i8* %10, i8** %0
%11 = icmp eq i64 %9, 0
br i1 %11, label %12, label %17
12: ; preds = %8
%13 = load i32, i32* @errno
%14 = tail call i64 @strerror(i32 %13)
%15 = inttoptr i64 %14 to i8*
%16 = tail call i32 @exifdie(i8* %15)
br label %17
17: ; preds = %12, %8
ret void
}