#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*/ printf(char *, int /*<<< orphan*/);
int /*<<< orphan*/ sbrk(int /*<<< orphan*/);
int /*<<< orphan*/ srand(unsigned int);
int /*<<< orphan*/ test1();
int /*<<< orphan*/ test2();
scalar_t__ time(int /*<<< orphan*/ *);
int main() {
  srand((unsigned int)time(NULL));
  printf("original val brk: %p\n", sbrk(0));
  test1();
  printf("brk after  test1: %p\n", sbrk(0));
  test2();
  printf("brk after  test2: %p\n", sbrk(0));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
xor    %edi,%edi
call   1060 <sbrk@plt>
mov    %eax,%esi
lea    0xe71(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <test1@plt>
xor    %edi,%edi
call   1060 <sbrk@plt>
mov    %eax,%esi
lea    0xe6b(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1080 <test2@plt>
xor    %edi,%edi
call   1060 <sbrk@plt>
mov    %eax,%esi
lea    0xe65(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
xor    %edi,%edi
call   1060 <sbrk@plt>
lea    0xe83(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
xor    %eax,%eax
call   1030 <test1@plt>
xor    %edi,%edi
call   1060 <sbrk@plt>
lea    0xe7d(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
xor    %eax,%eax
call   1080 <test2@plt>
xor    %edi,%edi
call   1060 <sbrk@plt>
lea    0xe77(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [22 x i8] c"original val brk: %p\0A\00"
@.str.1 = [22 x i8] c"brk after test1: %p\0A\00"
@.str.2 = [22 x i8] c"brk after test2: %p\0A\00"
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i64 @time(i32* null)
%3 = trunc i64 %2 to i32
%4 = call i32 @srand(i32 %3)
%5 = call i32 @sbrk(i32 0)
%6 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = call i32 (...) @test1()
%8 = call i32 @sbrk(i32 0)
%9 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 %8)
%10 = call i32 (...) @test2()
%11 = call i32 @sbrk(i32 0)
%12 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i32 %11)
ret i32 0
}

LLVM IR (-O2):
@.str = [22 x i8] c"original val brk: %p\0A\00"
@.str.1 = [22 x i8] c"brk after test1: %p\0A\00"
@.str.2 = [22 x i8] c"brk after test2: %p\0A\00"
define i32 @main() {
%1 = tail call i64 @time(i32* null)
%2 = trunc i64 %1 to i32
%3 = tail call i32 @srand(i32 %2)
%4 = tail call i32 @sbrk(i32 0)
%5 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = tail call i32 (...) @test1()
%7 = tail call i32 @sbrk(i32 0)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 %7)
%9 = tail call i32 (...) @test2()
%10 = tail call i32 @sbrk(i32 0)
%11 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i32 %10)
ret i32 0
}