#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*/ Panic(char *, char *, int, ...);
void *calloc(size_t, size_t);
void *UtilSafeCallocInternal(int bugNumber, size_t nmemb, size_t size,
                             char *file, int lineno) {
  void *result = calloc(nmemb, size);
  if (result == ((void *)0) && nmemb != 0 && size != 0) {
    if (bugNumber == -1) {
      Panic("Unrecoverable memory allocation failure at %s:%d\n", file, lineno);
    } else {
      Panic("Unrecoverable memory allocation failure at %s:%d.  Bug "
            "number: %d\n",
            file, lineno, bugNumber);
    }
  }
  return result;
}


x86 assembly (clang, -O0):
<UtilSafeCallocInternal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <calloc@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    11ae <UtilSafeCallocInternal+0x8e>
cmpq   $0x0,-0x10(%rbp)
je     11ae <UtilSafeCallocInternal+0x8e>
cmpq   $0x0,-0x18(%rbp)
je     11ae <UtilSafeCallocInternal+0x8e>
cmpl   $0xffffffff,-0x4(%rbp)
jne    1191 <UtilSafeCallocInternal+0x71>
mov    -0x20(%rbp),%rsi
mov    -0x24(%rbp),%edx
lea    0xe7b(%rip),%rdi
mov    $0x0,%al
call   1040 <Panic@plt>
jmp    11a9 <UtilSafeCallocInternal+0x89>
mov    -0x20(%rbp),%rsi
mov    -0x24(%rbp),%edx
mov    -0x4(%rbp),%ecx
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1040 <Panic@plt>
jmp    11ae <UtilSafeCallocInternal+0x8e>
mov    -0x30(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<UtilSafeCallocInternal>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8d,%r14d
mov    %rcx,%r15
mov    %rdx,%rbx
mov    %rsi,%rbp
mov    %edi,%r12d
mov    %rsi,%rdi
mov    %rdx,%rsi
call   1030 <calloc@plt>
mov    %rax,%r13
test   %rbx,%rbx
je     118a <UtilSafeCallocInternal+0x6a>
test   %rbp,%rbp
je     118a <UtilSafeCallocInternal+0x6a>
test   %r13,%r13
jne    118a <UtilSafeCallocInternal+0x6a>
cmp    $0xffffffff,%r12d
je     1176 <UtilSafeCallocInternal+0x56>
lea    0xece(%rip),%rdi
mov    %r15,%rsi
mov    %r14d,%edx
mov    %r12d,%ecx
xor    %eax,%eax
call   1040 <Panic@plt>
jmp    118a <UtilSafeCallocInternal+0x6a>
lea    0xe83(%rip),%rdi
mov    %r15,%rsi
mov    %r14d,%edx
xor    %eax,%eax
call   1040 <Panic@plt>
mov    %r13,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [50 x i8] c"Unrecoverable memory allocation failure at %s:%d\0A\00"
@.str.1 = [67 x i8] c"Unrecoverable memory allocation failure at %s:%d. Bug number: %d\0A\00"
define i8* @UtilSafeCallocInternal(i32 %0, i64 %1, i64 %2, i8* %3, i32 %4) {
%6 = alloca i32
%7 = alloca i64
%8 = alloca i64
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i8*
store i32 %0, i32* %6
store i64 %1, i64* %7
store i64 %2, i64* %8
store i8* %3, i8** %9
store i32 %4, i32* %10
%12 = load i64, i64* %7
%13 = load i64, i64* %8
%14 = call i8* @calloc(i64 %12, i64 %13)
store i8* %14, i8** %11
%15 = load i8*, i8** %11
%16 = icmp eq i8* %15, null
br i1 %16, label %17, label %36
17: ; preds = %5
%18 = load i64, i64* %7
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %36
20: ; preds = %17
%21 = load i64, i64* %8
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %36
23: ; preds = %20
%24 = load i32, i32* %6
%25 = icmp eq i32 %24, -1
br i1 %25, label %26, label %30
26: ; preds = %23
%27 = load i8*, i8** %9
%28 = load i32, i32* %10
%29 = call i32 (i8*, i8*, i32, ...) @Panic(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), i8* %27, i32 %28)
br label %35
30: ; preds = %23
%31 = load i8*, i8** %9
%32 = load i32, i32* %10
%33 = load i32, i32* %6
%34 = call i32 (i8*, i8*, i32, ...) @Panic(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.1, i64 0, i64 0), i8* %31, i32 %32, i32 %33)
br label %35
35: ; preds = %30, %26
br label %36
36: ; preds = %35, %20, %17, %5
%37 = load i8*, i8** %11
ret i8* %37
}

LLVM IR (-O2):
@.str = [50 x i8] c"Unrecoverable memory allocation failure at %s:%d\0A\00"
@.str.1 = [67 x i8] c"Unrecoverable memory allocation failure at %s:%d. Bug number: %d\0A\00"
define noalias i8* @UtilSafeCallocInternal(i32 %0, i64 %1, i64 %2, i8* %3, i32 %4) {
%6 = tail call i8* @calloc(i64 %1, i64 %2)
%7 = icmp eq i8* %6, null
%8 = icmp ne i64 %1, 0
%9 = and i1 %8, %7
%10 = icmp ne i64 %2, 0
%11 = and i1 %10, %9
br i1 %11, label %12, label %18
12: ; preds = %5
%13 = icmp eq i32 %0, -1
br i1 %13, label %14, label %16
14: ; preds = %12
%15 = tail call i32 (i8*, i8*, i32, ...) @Panic(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), i8* %3, i32 %4)
br label %18
16: ; preds = %12
%17 = tail call i32 (i8*, i8*, i32, ...) @Panic(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.1, i64 0, i64 0), i8* %3, i32 %4, i32 %0)
br label %18
18: ; preds = %14, %16, %5
ret i8* %6
}