#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*/ alignedFree(char *);
char *alignedMalloc(unsigned int, unsigned int);
int /*<<< orphan*/ printf(char *);
unsigned int rand();
int main() {
  for (int i = 0; i < 100; i++) {
    unsigned int alignment = rand();
    unsigned int size = rand();
    char *buf = alignedMalloc(alignment, size);
    alignedFree(buf);
  }
  printf("done\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x64,-0x8(%rbp)
jge    119a <main+0x5a>
mov    $0x0,%al
call   1050 <rand@plt>
mov    %eax,-0xc(%rbp)
mov    $0x0,%al
call   1050 <rand@plt>
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1060 <alignedMalloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <alignedFree@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1156 <main+0x16>
lea    0xe5f(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    $0x64,%ebp
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1050 <rand@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1050 <rand@plt>
mov    %ebx,%edi
mov    %eax,%esi
call   1060 <alignedMalloc@plt>
mov    %rax,%rdi
call   1040 <alignedFree@plt>
add    $0xffffffff,%ebp
jne    1150 <main+0x10>
lea    0xe83(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"done\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
store i32 0, i32* %1
store i32 0, i32* %2
br label %6
6: ; preds = %17, %0
%7 = load i32, i32* %2
%8 = icmp slt i32 %7, 100
br i1 %8, label %9, label %20
9: ; preds = %6
%10 = call i32 (...) @rand()
store i32 %10, i32* %3
%11 = call i32 (...) @rand()
store i32 %11, i32* %4
%12 = load i32, i32* %3
%13 = load i32, i32* %4
%14 = call i8* @alignedMalloc(i32 %12, i32 %13)
store i8* %14, i8** %5
%15 = load i8*, i8** %5
%16 = call i32 @alignedFree(i8* %15)
br label %17
17: ; preds = %9
%18 = load i32, i32* %2
%19 = add nsw i32 %18, 1
store i32 %19, i32* %2
br label %6
20: ; preds = %6
%21 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@str = [5 x i8] c"done\00"
define i32 @main() {
br label %3
1: ; preds = %3
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str, i64 0, i64 0))
ret i32 0
3: ; preds = %0, %3
%4 = phi i32 [ 0, %0 ], [ %9, %3 ]
%5 = tail call i32 (...) @rand()
%6 = tail call i32 (...) @rand()
%7 = tail call i8* @alignedMalloc(i32 %5, i32 %6)
%8 = tail call i32 @alignedFree(i8* %7)
%9 = add nuw nsw i32 %4, 1
%10 = icmp eq i32 %9, 100
br i1 %10, label %1, label %3
}