int main() {
  int my_helper[1024];
  char my_memory[1024];
  clear_memory(my_helper);
  printf("free = %d\n", how_many_free(my_helper));
  give_me(my_memory, my_helper, 1);
  printf("free = %d\n", how_many_free(my_helper));
  printf("is there free = %s\n", is_there_free(my_helper) ? "Yes" : "No");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1410,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x1010(%rbp),%rdi
mov    $0x0,%al
call   1060 <clear_memory@plt>
lea    -0x1010(%rbp),%rdi
mov    $0x0,%al
call   1040 <how_many_free@plt>
mov    %eax,%esi
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x1410(%rbp),%rdi
lea    -0x1010(%rbp),%rsi
mov    $0x1,%edx
mov    $0x0,%al
call   1070 <give_me@plt>
lea    -0x1010(%rbp),%rdi
mov    $0x0,%al
call   1040 <how_many_free@plt>
mov    %eax,%esi
lea    0xe41(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x1010(%rbp),%rdi
mov    $0x0,%al
call   1030 <is_there_free@plt>
mov    %eax,%ecx
lea    0xe46(%rip),%rsi
lea    0xe3b(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rsi
lea    0xe19(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x1410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x1408,%rsp
lea    0x400(%rsp),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <clear_memory@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <how_many_free@plt>
lea    0xe83(%rip),%r14
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rsp,%rdi
mov    %rbx,%rsi
mov    $0x1,%edx
xor    %eax,%eax
call   1070 <give_me@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <how_many_free@plt>
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <is_there_free@plt>
test   %eax,%eax
lea    0xe5f(%rip),%rax
lea    0xe54(%rip),%rsi
cmove  %rax,%rsi
lea    0xe35(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x1408,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [11 x i8] c"free = %d\0A\00"
@.str.1 = [20 x i8] c"is there free = %s\0A\00"
@.str.2 = [4 x i8] c"Yes\00"
@.str.3 = [3 x i8] c"No\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [1024 x i32]
%3 = alloca [1024 x i8]
store i32 0, i32* %1
%4 = getelementptr inbounds [1024 x i32], [1024 x i32]* %2, i64 0, i64 0
%5 = call i32 (i32*, ...) bitcast (i32 (...)* @clear_memory to i32 (i32*, ...)*)(i32* %4)
%6 = getelementptr inbounds [1024 x i32], [1024 x i32]* %2, i64 0, i64 0
%7 = call i32 (i32*, ...) bitcast (i32 (...)* @how_many_free to i32 (i32*, ...)*)(i32* %6)
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%10 = getelementptr inbounds [1024 x i32], [1024 x i32]* %2, i64 0, i64 0
%11 = call i32 (i8*, i32*, i32, ...) bitcast (i32 (...)* @give_me to i32 (i8*, i32*, i32, ...)*)(i8* %9, i32* %10, i32 1)
%12 = getelementptr inbounds [1024 x i32], [1024 x i32]* %2, i64 0, i64 0
%13 = call i32 (i32*, ...) bitcast (i32 (...)* @how_many_free to i32 (i32*, ...)*)(i32* %12)
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = getelementptr inbounds [1024 x i32], [1024 x i32]* %2, i64 0, i64 0
%16 = call i32 (i32*, ...) bitcast (i32 (...)* @is_there_free to i32 (i32*, ...)*)(i32* %15)
%17 = icmp ne i32 %16, 0
%18 = zext i1 %17 to i64
%19 = select i1 %17, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0)
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %19)
ret i32 0
}

LLVM IR (-O2):
@.str = [11 x i8] c"free = %d\0A\00"
@.str.1 = [20 x i8] c"is there free = %s\0A\00"
@.str.2 = [4 x i8] c"Yes\00"
@.str.3 = [3 x i8] c"No\00"
define i32 @main() {
%1 = alloca [1024 x i32]
%2 = alloca [1024 x i8]
%3 = bitcast [1024 x i32]* %1 to i8*
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [1024 x i32], [1024 x i32]* %1, i64 0, i64 0
%6 = call i32 (i32*, ...) bitcast (i32 (...)* @clear_memory to i32 (i32*, ...)*)(i32* %5)
%7 = call i32 (i32*, ...) bitcast (i32 (...)* @how_many_free to i32 (i32*, ...)*)(i32* %5)
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = call i32 (i8*, i32*, i32, ...) bitcast (i32 (...)* @give_me to i32 (i8*, i32*, i32, ...)*)(i8* %4, i32* %5, i32 1)
%10 = call i32 (i32*, ...) bitcast (i32 (...)* @how_many_free to i32 (i32*, ...)*)(i32* %5)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = call i32 (i32*, ...) bitcast (i32 (...)* @is_there_free to i32 (i32*, ...)*)(i32* %5)
%13 = icmp eq i32 %12, 0
%14 = select i1 %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0)
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %14)
ret i32 0
}