#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*/ mbox_property(int, unsigned int *);
int /*<<< orphan*/ printf(char *, unsigned int);
unsigned mem_alloc(int file_desc, unsigned size, unsigned align,
                   unsigned flags) {
  int i = 0;
  unsigned p[32];
  printf("Requesting %d bytes\n", size);
  p[i++] = 0;
  p[i++] = 0x00000000;
  p[i++] = 0x3000c;
  p[i++] = 12;
  p[i++] = 12;
  p[i++] = size;
  p[i++] = align;
  p[i++] = flags;
  p[i++] = 0x00000000;
  p[0] = i * sizeof *p;
  mbox_property(file_desc, p);
  return p[5];
}


x86 assembly (clang, -O0):
<mem_alloc>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%esi
lea    0xeb8(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x14(%rbp)
cltq
movl   $0x0,-0xa0(%rbp,%rax,4)
mov    -0x14(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x14(%rbp)
cltq
movl   $0x0,-0xa0(%rbp,%rax,4)
mov    -0x14(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x14(%rbp)
cltq
movl   $0x3000c,-0xa0(%rbp,%rax,4)
mov    -0x14(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x14(%rbp)
cltq
movl   $0xc,-0xa0(%rbp,%rax,4)
mov    -0x14(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x14(%rbp)
cltq
movl   $0xc,-0xa0(%rbp,%rax,4)
mov    -0x8(%rbp),%ecx
mov    -0x14(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x14(%rbp)
cltq
mov    %ecx,-0xa0(%rbp,%rax,4)
mov    -0xc(%rbp),%ecx
mov    -0x14(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x14(%rbp)
cltq
mov    %ecx,-0xa0(%rbp,%rax,4)
mov    -0x10(%rbp),%ecx
mov    -0x14(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x14(%rbp)
cltq
mov    %ecx,-0xa0(%rbp,%rax,4)
mov    -0x14(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x14(%rbp)
cltq
movl   $0x0,-0xa0(%rbp,%rax,4)
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
mov    %eax,-0xa0(%rbp)
mov    -0x4(%rbp),%edi
lea    -0xa0(%rbp),%rsi
call   1040 <mbox_property@plt>
mov    -0x8c(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mem_alloc>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x88,%rsp
mov    %ecx,%r14d
mov    %edx,%ebp
mov    %esi,%ebx
mov    %edi,%r15d
lea    0xed2(%rip),%rdi
call   1030 <printf@plt>
movl   $0xc,0x10(%rsp)
mov    %ebx,0x14(%rsp)
mov    %ebp,0x18(%rsp)
mov    %r14d,0x1c(%rsp)
movl   $0x0,0x20(%rsp)
movaps 0xe99(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rsi
mov    %r15d,%edi
call   1040 <mbox_property@plt>
mov    0x14(%rsp),%eax
add    $0x88,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [21 x i8] c"Requesting %d bytes\0A\00"
define i32 @mem_alloc(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca [32 x i32]
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
store i32 0, i32* %9
%11 = load i32, i32* %6
%12 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = load i32, i32* %9
%14 = add nsw i32 %13, 1
store i32 %14, i32* %9
%15 = sext i32 %13 to i64
%16 = getelementptr inbounds [32 x i32], [32 x i32]* %10, i64 0, i64 %15
store i32 0, i32* %16
%17 = load i32, i32* %9
%18 = add nsw i32 %17, 1
store i32 %18, i32* %9
%19 = sext i32 %17 to i64
%20 = getelementptr inbounds [32 x i32], [32 x i32]* %10, i64 0, i64 %19
store i32 0, i32* %20
%21 = load i32, i32* %9
%22 = add nsw i32 %21, 1
store i32 %22, i32* %9
%23 = sext i32 %21 to i64
%24 = getelementptr inbounds [32 x i32], [32 x i32]* %10, i64 0, i64 %23
store i32 196620, i32* %24
%25 = load i32, i32* %9
%26 = add nsw i32 %25, 1
store i32 %26, i32* %9
%27 = sext i32 %25 to i64
%28 = getelementptr inbounds [32 x i32], [32 x i32]* %10, i64 0, i64 %27
store i32 12, i32* %28
%29 = load i32, i32* %9
%30 = add nsw i32 %29, 1
store i32 %30, i32* %9
%31 = sext i32 %29 to i64
%32 = getelementptr inbounds [32 x i32], [32 x i32]* %10, i64 0, i64 %31
store i32 12, i32* %32
%33 = load i32, i32* %6
%34 = load i32, i32* %9
%35 = add nsw i32 %34, 1
store i32 %35, i32* %9
%36 = sext i32 %34 to i64
%37 = getelementptr inbounds [32 x i32], [32 x i32]* %10, i64 0, i64 %36
store i32 %33, i32* %37
%38 = load i32, i32* %7
%39 = load i32, i32* %9
%40 = add nsw i32 %39, 1
store i32 %40, i32* %9
%41 = sext i32 %39 to i64
%42 = getelementptr inbounds [32 x i32], [32 x i32]* %10, i64 0, i64 %41
store i32 %38, i32* %42
%43 = load i32, i32* %8
%44 = load i32, i32* %9
%45 = add nsw i32 %44, 1
store i32 %45, i32* %9
%46 = sext i32 %44 to i64
%47 = getelementptr inbounds [32 x i32], [32 x i32]* %10, i64 0, i64 %46
store i32 %43, i32* %47
%48 = load i32, i32* %9
%49 = add nsw i32 %48, 1
store i32 %49, i32* %9
%50 = sext i32 %48 to i64
%51 = getelementptr inbounds [32 x i32], [32 x i32]* %10, i64 0, i64 %50
store i32 0, i32* %51
%52 = load i32, i32* %9
%53 = sext i32 %52 to i64
%54 = mul i64 %53, 4
%55 = trunc i64 %54 to i32
%56 = getelementptr inbounds [32 x i32], [32 x i32]* %10, i64 0, i64 0
store i32 %55, i32* %56
%57 = load i32, i32* %5
%58 = getelementptr inbounds [32 x i32], [32 x i32]* %10, i64 0, i64 0
%59 = call i32 @mbox_property(i32 %57, i32* %58)
%60 = getelementptr inbounds [32 x i32], [32 x i32]* %10, i64 0, i64 5
%61 = load i32, i32* %60
ret i32 %61
}

LLVM IR (-O2):
@.str = [21 x i8] c"Requesting %d bytes\0A\00"
define i32 @mem_alloc(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca [32 x i32]
%6 = bitcast [32 x i32]* %5 to i8*
%7 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %1)
%8 = getelementptr inbounds [32 x i32], [32 x i32]* %5, i64 0, i64 0
%9 = getelementptr inbounds [32 x i32], [32 x i32]* %5, i64 0, i64 4
store i32 12, i32* %9
%10 = getelementptr inbounds [32 x i32], [32 x i32]* %5, i64 0, i64 5
store i32 %1, i32* %10
%11 = getelementptr inbounds [32 x i32], [32 x i32]* %5, i64 0, i64 6
store i32 %2, i32* %11
%12 = getelementptr inbounds [32 x i32], [32 x i32]* %5, i64 0, i64 7
store i32 %3, i32* %12
%13 = getelementptr inbounds [32 x i32], [32 x i32]* %5, i64 0, i64 8
store i32 0, i32* %13
%14 = bitcast [32 x i32]* %5 to <4 x i32>*
store <4 x i32> <i32 36, i32 0, i32 196620, i32 12>, <4 x i32>* %14
%15 = call i32 @mbox_property(i32 %0, i32* %8)
%16 = load i32, i32* %10
ret i32 %16
}