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


x86 assembly (clang, -O0):
<maalloc_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   1050 <align_size@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rax
sub    %rcx,%rax
mov    %rax,%rsp
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    11b5 <maalloc_impl+0x75>
jmp    118d <maalloc_impl+0x4d>
mov    -0xc(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%r8
lea    0xe61(%rip),%rdi
lea    0xe81(%rip),%rsi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rdx
xor    %esi,%esi
call   1040 <memset@plt>
mov    -0x30(%rbp),%rax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<maalloc_impl>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
push   %rax
call   1040 <align_size@plt>
mov    %rsp,%rbx
lea    0xf(%rax),%rcx
and    $0xfffffffffffffff0,%rcx
sub    %rcx,%rbx
mov    %rbx,%rsp
mov    %rbx,%rdi
xor    %esi,%esi
mov    %rax,%rdx
call   1030 <memset@plt>
mov    %rbx,%rax
lea    -0x8(%rbp),%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [39 x i8] c"%s ERROR: \0Aline: %i\0Afunc: %s\0Afile: %s\0A\00"
@.str.1 = [8 x i8] c"maalloc\00"
define i8* @maalloc_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 = alloca i8, 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):
define i8* @maalloc_impl(i64 %0, i32 %1, i8* nocapture readnone %2, i8* nocapture readnone %3) {
%5 = tail call i64 @align_size(i64 %0)
%6 = alloca i8, i64 %5
%7 = call i32 @memset(i8* %6, i32 0, i64 %5)
ret i8* %6
}