#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 */
char *create_storage(int const);
int /*<<< orphan*/ free(char *);
int lookup_number(char *, int);
int /*<<< orphan*/ printf(char *, int, int);
int /*<<< orphan*/ set_number(char *, int);
int main() {
  const int num_blocks = 10;
  char *bit_vector = create_storage(num_blocks);
  set_number(bit_vector, 10);
  set_number(bit_vector, 20);
  bool has_ten = lookup_number(bit_vector, 10);
  bool has_thirty = lookup_number(bit_vector, 30);
  printf("Has ten? %d\nHas thirty? %d\n", has_ten, has_thirty);
  free(bit_vector);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xa,-0x8(%rbp)
mov    $0xa,%edi
call   1060 <create_storage@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0xa,%esi
call   1040 <set_number@plt>
mov    -0x10(%rbp),%rdi
mov    $0x14,%esi
call   1040 <set_number@plt>
mov    -0x10(%rbp),%rdi
mov    $0xa,%esi
call   1070 <lookup_number@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x1e,%esi
call   1070 <lookup_number@plt>
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xe41(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    $0xa,%edi
call   1060 <create_storage@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0xa,%esi
call   1040 <set_number@plt>
mov    %rbx,%rdi
mov    $0x14,%esi
call   1040 <set_number@plt>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1070 <lookup_number@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
mov    $0x1e,%esi
call   1070 <lookup_number@plt>
lea    0xe63(%rip),%rdi
mov    %ebp,%esi
mov    %eax,%edx
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [28 x i8] c"Has ten? %d\0AHas thirty? %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 10, i32* %2
%6 = call i8* @create_storage(i32 10)
store i8* %6, i8** %3
%7 = load i8*, i8** %3
%8 = call i32 @set_number(i8* %7, i32 10)
%9 = load i8*, i8** %3
%10 = call i32 @set_number(i8* %9, i32 20)
%11 = load i8*, i8** %3
%12 = call i32 @lookup_number(i8* %11, i32 10)
store i32 %12, i32* %4
%13 = load i8*, i8** %3
%14 = call i32 @lookup_number(i8* %13, i32 30)
store i32 %14, i32* %5
%15 = load i32, i32* %4
%16 = load i32, i32* %5
%17 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 %15, i32 %16)
%18 = load i8*, i8** %3
%19 = call i32 @free(i8* %18)
ret i32 0
}

LLVM IR (-O2):
@.str = [28 x i8] c"Has ten? %d\0AHas thirty? %d\0A\00"
define i32 @main() {
%1 = tail call i8* @create_storage(i32 10)
%2 = tail call i32 @set_number(i8* %1, i32 10)
%3 = tail call i32 @set_number(i8* %1, i32 20)
%4 = tail call i32 @lookup_number(i8* %1, i32 10)
%5 = tail call i32 @lookup_number(i8* %1, i32 30)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 %4, i32 %5)
%7 = tail call i32 @free(i8* %1)
ret i32 0
}