#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 */
void *calloc(long, long);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ sprintf(char *, char *, long, char const *);
void *xcalloc(long n, long s, long l, const char *f) {
  void *tmp;
  tmp = calloc(n, s);
  if (tmp == 0) {
    char buf[200];
    sprintf(buf, "\n\nFatal error on line %ld of %s", l, f);
    perror(buf);
    exit(1);
  }
  return tmp;
}


x86 assembly (clang, -O0):
<xcalloc>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <calloc@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11a8 <xcalloc+0x68>
lea    -0xf0(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
lea    0xe73(%rip),%rsi
call   1050 <sprintf@plt>
lea    -0xf0(%rbp),%rdi
call   1040 <perror@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x28(%rbp),%rax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xcalloc>:
push   %r15
push   %r14
push   %rbx
sub    $0xd0,%rsp
mov    %rcx,%r14
mov    %rdx,%rbx
call   1030 <calloc@plt>
test   %rax,%rax
je     1169 <xcalloc+0x29>
add    $0xd0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xe90(%rip),%rsi
mov    %rsp,%r15
mov    %r15,%rdi
mov    %rbx,%rdx
mov    %r14,%rcx
call   1050 <sprintf@plt>
mov    %r15,%rdi
call   1040 <perror@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [32 x i8] c"\0A\0AFatal error on line %ld of %s\00"
define i8* @xcalloc(i64 %0, i64 %1, i64 %2, i8* %3) {
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca [200 x i8]
store i64 %0, i64* %5
store i64 %1, i64* %6
store i64 %2, i64* %7
store i8* %3, i8** %8
%11 = load i64, i64* %5
%12 = load i64, i64* %6
%13 = call i8* @calloc(i64 %11, i64 %12)
store i8* %13, i8** %9
%14 = load i8*, i8** %9
%15 = icmp eq i8* %14, null
br i1 %15, label %16, label %24
16: ; preds = %4
%17 = getelementptr inbounds [200 x i8], [200 x i8]* %10, i64 0, i64 0
%18 = load i64, i64* %7
%19 = load i8*, i8** %8
%20 = call i32 @sprintf(i8* %17, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i64 %18, i8* %19)
%21 = getelementptr inbounds [200 x i8], [200 x i8]* %10, i64 0, i64 0
%22 = call i32 @perror(i8* %21)
%23 = call i32 @exit(i32 1)
unreachable
24: ; preds = %4
%25 = load i8*, i8** %9
ret i8* %25
}

LLVM IR (-O2):
@.str = [32 x i8] c"\0A\0AFatal error on line %ld of %s\00"
define noalias i8* @xcalloc(i64 %0, i64 %1, i64 %2, i8* %3) {
%5 = alloca [200 x i8]
%6 = tail call i8* @calloc(i64 %0, i64 %1)
%7 = icmp eq i8* %6, null
br i1 %7, label %8, label %13
8: ; preds = %4
%9 = getelementptr inbounds [200 x i8], [200 x i8]* %5, i64 0, i64 0
%10 = call i32 @sprintf(i8* %9, i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i64 %2, i8* %3)
%11 = call i32 @perror(i8* %9)
%12 = tail call i32 @exit(i32 1)
unreachable
13: ; preds = %4
ret i8* %6
}