#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 */
void *brk(int /*<<< orphan*/);
int /*<<< orphan*/ chug(int /*<<< orphan*/);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
void *malloc(int);
int /*<<< orphan*/ printf(char *, void *);
int /*<<< orphan*/ puts(char *);
int main(int argc, char *argv[]) {
  int beers;
  void *x;
  for (beers = 99; beers; chug(beers--))
    puts("");
  printf("%p\n", brk(0));
  x = malloc(1000);
  printf("%p\n", x);
  puts("\nTime to buy more beer!\n");
  exit(0);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x63,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     11a8 <main+0x48>
lea    0xe8e(%rip),%rdi
call   1040 <puts@plt>
mov    -0x14(%rbp),%edi
mov    %edi,%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
call   1030 <chug@plt>
jmp    117d <main+0x1d>
xor    %edi,%edi
call   1060 <brk@plt>
mov    %rax,%rsi
lea    0xe47(%rip),%rdi
call   1050 <printf@plt>
mov    $0x3e8,%edi
call   1070 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
lea    0xe29(%rip),%rdi
call   1050 <printf@plt>
lea    0xe21(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   1080 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0x63,%ebx
cs nopw 0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    %ebx,%edi
call   1030 <chug@plt>
add    $0xffffffff,%ebx
jne    1180 <main+0x10>
xor    %edi,%edi
call   1070 <brk@plt>
lea    0xe5c(%rip),%rbx
mov    %rbx,%rdi
mov    %rax,%rsi
call   1060 <printf@plt>
mov    $0x3e8,%edi
call   1080 <malloc@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1060 <printf@plt>
lea    0xe39(%rip),%rdi
call   1050 <puts@plt>
xor    %edi,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@.str.1 = [4 x i8] c"%p\0A\00"
@.str.2 = [25 x i8] c"\0ATime to buy more beer!\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 99, i32* %6
br label %8
8: ; preds = %13, %2
%9 = load i32, i32* %6
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %17
11: ; preds = %8
%12 = call i32 @puts(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; preds = %11
%14 = load i32, i32* %6
%15 = add nsw i32 %14, -1
store i32 %15, i32* %6
%16 = call i32 @chug(i32 %14)
br label %8
17: ; preds = %8
%18 = call i8* @brk(i32 0)
%19 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %18)
%20 = call i8* @malloc(i32 1000)
store i8* %20, i8** %7
%21 = load i8*, i8** %7
%22 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %21)
%23 = call i32 @puts(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%24 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str.1 = [4 x i8] c"%p\0A\00"
@.str.2 = [25 x i8] c"\0ATime to buy more beer!\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
br label %3
3: ; preds = %2, %3
%4 = phi i32 [ 99, %2 ], [ %6, %3 ]
%5 = tail call i32 @putchar(i32 10)
%6 = add nsw i32 %4, -1
%7 = tail call i32 @chug(i32 %4)
%8 = icmp eq i32 %6, 0
br i1 %8, label %9, label %3
9: ; preds = %3
%10 = tail call i8* @brk(i32 0)
%11 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%12 = tail call dereferenceable_or_null(1000) i8* @malloc(i32 1000)
%13 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %12)
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%15 = tail call i32 @exit(i32 0)
unreachable
}