#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*/ fprintf(int /*<<< orphan*/, char *, size_t);
scalar_t__ malloc(size_t);
int /*<<< orphan*/ memset(void *, int /*<<< orphan*/, size_t);
int /*<<< orphan*/ stderr;
void *xmallocd0(size_t s, char *descr) {
  void *new = (void *)malloc(s);
  if (!new)
    fprintf(stderr, "mplib: Memory exhausted: Could not allocate %d bytes\n",
            s);
  else
    memset(new, 0, s);
  return new;
}


x86 assembly (clang, -O0):
<xmallocd0>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1176 <xmallocd0+0x46>
mov    0x2e81(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe94(%rip),%rsi
call   1040 <fprintf@plt>
jmp    1185 <xmallocd0+0x55>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rdx
xor    %esi,%esi
call   1030 <memset@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xmallocd0>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1050 <malloc@plt>
mov    %rax,%rbx
test   %rax,%rax
je     1153 <xmallocd0+0x23>
mov    %rbx,%rdi
xor    %esi,%esi
mov    %r14,%rdx
call   1030 <memset@plt>
jmp    116b <xmallocd0+0x3b>
mov    0x2e86(%rip),%rax
mov    (%rax),%edi
lea    0xe9d(%rip),%rsi
mov    %r14,%rdx
call   1040 <fprintf@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [54 x i8] c"mplib: Memory exhausted: Could not allocate %d bytes\0A\00"
define i8* @xmallocd0(i64 %0, i8* %1) {
%3 = alloca i64
%4 = alloca i8*
%5 = alloca i8*
store i64 %0, i64* %3
store i8* %1, i8** %4
%6 = load i64, i64* %3
%7 = call i64 @malloc(i64 %6)
%8 = inttoptr i64 %7 to i8*
store i8* %8, i8** %5
%9 = load i8*, i8** %5
%10 = icmp ne i8* %9, null
br i1 %10, label %15, label %11
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = load i64, i64* %3
%14 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0), i64 %13)
br label %19
15: ; preds = %2
%16 = load i8*, i8** %5
%17 = load i64, i64* %3
%18 = call i32 @memset(i8* %16, i32 0, i64 %17)
br label %19
19: ; preds = %15, %11
%20 = load i8*, i8** %5
ret i8* %20
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [54 x i8] c"mplib: Memory exhausted: Could not allocate %d bytes\0A\00"
define i8* @xmallocd0(i64 %0, i8* nocapture readnone %1) {
%3 = tail call i64 @malloc(i64 %0)
%4 = inttoptr i64 %3 to i8*
%5 = icmp eq i64 %3, 0
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0), i64 %0)
br label %11
9: ; preds = %2
%10 = tail call i32 @memset(i8* %4, i32 0, i64 %0)
br label %11
11: ; preds = %9, %6
ret i8* %4
}