#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 */
size_t align_size(size_t);
int /*<<< orphan*/ exit(int);
void *malloc(size_t);
int /*<<< orphan*/ memset(void *, int /*<<< orphan*/, size_t);
int /*<<< orphan*/ printf(char *, char *, int, char const *, char const *);
void *mzalloc_impl(size_t s, int line, const char *func, const char *file) {
  size_t aligned;
  void *p;
  aligned = align_size(s);
  p = malloc(aligned);
  if (!p) {
    do {
      printf("%s ERROR: \nline: %i\nfunc: %s\nfile: %s\n", "mzalloc", line,
             func, file);
      exit(1);
    } while (0);
  }
  memset(p, 0, aligned);
  return p;
}


x86 assembly (clang, -O0):
<mzalloc_impl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <align_size@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   1050 <malloc@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    11b9 <mzalloc_impl+0x69>
jmp    1191 <mzalloc_impl+0x41>
mov    -0xc(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%r8
lea    0xe5d(%rip),%rdi
lea    0xe7d(%rip),%rsi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rdx
xor    %esi,%esi
call   1040 <memset@plt>
mov    -0x30(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mzalloc_impl>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rcx,%r14
mov    %rdx,%r15
mov    %esi,%r12d
call   1060 <align_size@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1050 <malloc@plt>
test   %rax,%rax
je     1192 <mzalloc_impl+0x42>
mov    %rax,%rbp
mov    %rax,%rdi
xor    %esi,%esi
mov    %rbx,%rdx
call   1040 <memset@plt>
mov    %rbp,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe67(%rip),%rdi
lea    0xe87(%rip),%rsi
mov    %r12d,%edx
mov    %r15,%rcx
mov    %r14,%r8
call   1030 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [39 x i8] c"%s ERROR: \0Aline: %i\0Afunc: %s\0Afile: %s\0A\00"
@.str.1 = [8 x i8] c"mzalloc\00"
define i8* @mzalloc_impl(i64 %0, i32 %1, i8* %2, i8* %3) {
%5 = alloca i64
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i8*
store i64 %0, i64* %5
store i32 %1, i32* %6
store i8* %2, i8** %7
store i8* %3, i8** %8
%11 = load i64, i64* %5
%12 = call i64 @align_size(i64 %11)
store i64 %12, i64* %9
%13 = load i64, i64* %9
%14 = call i8* @malloc(i64 %13)
store i8* %14, i8** %10
%15 = load i8*, i8** %10
%16 = icmp ne i8* %15, null
br i1 %16, label %25, label %17
17: ; preds = %4
br label %18
18: ; preds = %17
%19 = load i32, i32* %6
%20 = load i8*, i8** %7
%21 = load i8*, i8** %8
%22 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %19, i8* %20, i8* %21)
%23 = call i32 @exit(i32 1)
unreachable
24: ; No predecessors!
br label %25
25: ; preds = %24, %4
%26 = load i8*, i8** %10
%27 = load i64, i64* %9
%28 = call i32 @memset(i8* %26, i32 0, i64 %27)
%29 = load i8*, i8** %10
ret i8* %29
}

LLVM IR (-O2):
@.str = [39 x i8] c"%s ERROR: \0Aline: %i\0Afunc: %s\0Afile: %s\0A\00"
@.str.1 = [8 x i8] c"mzalloc\00"
define i8* @mzalloc_impl(i64 %0, i32 %1, i8* %2, i8* %3) {
%5 = tail call i64 @align_size(i64 %0)
%6 = tail call i8* @malloc(i64 %5)
%7 = icmp eq i8* %6, null
br i1 %7, label %8, label %11
8: ; preds = %4
%9 = tail call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %1, i8* %2, i8* %3)
%10 = tail call i32 @exit(i32 1)
unreachable
11: ; preds = %4
%12 = tail call i32 @memset(i8* %6, i32 0, i64 %5)
ret i8* %6
}