#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 */
typedef int /*<<< orphan*/ uint;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
int rand();
scalar_t__ vector_get(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ *vector_init(int);
int /*<<< orphan*/ vector_set(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ vector_unset(int /*<<< orphan*/ *, int);
int main() {
  int i, r, set = 15, max = 30000;
  uint *vector = vector_init(max);
  for (i = 0; i < set; i++) {
    r = rand() % max;
    printf("set number:  %5d\n", r);
    vector_set(vector, r);
  }
  printf("\n");
  for (i = 0; i < max; i++) {
    if (vector_get(vector, i)) {
      printf("have in vector/set:  %5d\n", i);
      if (rand() % 3)
        vector_unset(vector, i);
    }
  }
  printf("\nunset some\n\n");
  for (i = 0; i < max; i++) {
    if (vector_get(vector, i))
      printf("have in vector/set:  %5d\n", i);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xf,-0x10(%rbp)
movl   $0x7530,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1030 <vector_init@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11d5 <main+0x75>
mov    $0x0,%al
call   1080 <rand@plt>
cltd
idivl  -0x14(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe4c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x20(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1070 <vector_set@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1190 <main+0x30>
lea    0xe5c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1259 <main+0xf9>
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1040 <vector_get@plt>
cmp    $0x0,%rax
je     1246 <main+0xe6>
mov    -0x8(%rbp),%esi
lea    0xdfc(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1080 <rand@plt>
mov    $0x3,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     1241 <main+0xe1>
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1060 <vector_unset@plt>
jmp    1246 <main+0xe6>
jmp    124b <main+0xeb>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11ea <main+0x8a>
lea    0xdcc(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    12b4 <main+0x154>
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1040 <vector_get@plt>
cmp    $0x0,%rax
je     12a1 <main+0x141>
mov    -0x8(%rbp),%esi
lea    0xd78(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    12a6 <main+0x146>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    126e <main+0x10e>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    $0x7530,%edi
call   1040 <vector_init@plt>
mov    %rax,%r15
mov    $0xf,%ebx
lea    0xe60(%rip),%r14
xor    %eax,%eax
call   10a0 <rand@plt>
movslq %eax,%rbp
imul   $0x45e7b273,%rbp,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x2d,%rax
add    %ecx,%eax
imul   $0x7530,%eax,%eax
sub    %eax,%ebp
mov    %r14,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r15,%rdi
mov    %ebp,%esi
call   1090 <vector_set@plt>
add    $0xffffffff,%ebx
jne    11a0 <main+0x20>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe20(%rip),%r14
xor    %ebp,%ebp
jmp    120b <main+0x8b>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%ebp
cmp    $0x7530,%ebp
je     124b <main+0xcb>
mov    %r15,%rdi
mov    %ebp,%esi
call   1060 <vector_get@plt>
test   %rax,%rax
je     1200 <main+0x80>
mov    %r14,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1070 <printf@plt>
xor    %eax,%eax
call   10a0 <rand@plt>
imul   $0xaaaaaaab,%eax,%eax
add    $0x2aaaaaaa,%eax
cmp    $0x55555555,%eax
jb     1200 <main+0x80>
mov    %r15,%rdi
mov    %ebp,%esi
call   1080 <vector_unset@plt>
jmp    1200 <main+0x80>
lea    0xdda(%rip),%rdi
call   1050 <puts@plt>
lea    0xdb4(%rip),%r14
xor    %ebp,%ebp
jmp    127b <main+0xfb>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%ebp
cmp    $0x7530,%ebp
je     1298 <main+0x118>
mov    %r15,%rdi
mov    %ebp,%esi
call   1060 <vector_get@plt>
test   %rax,%rax
je     1270 <main+0xf0>
mov    %r14,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1070 <printf@plt>
jmp    1270 <main+0xf0>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [18 x i8] c"set number: %5d\0A\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [26 x i8] c"have in vector/set: %5d\0A\00"
@.str.3 = [14 x i8] c"\0Aunset some\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32*
store i32 0, i32* %1
store i32 15, i32* %4
store i32 30000, i32* %5
%7 = load i32, i32* %5
%8 = call i32* @vector_init(i32 %7)
store i32* %8, i32** %6
store i32 0, i32* %2
br label %9
9: ; preds = %22, %0
%10 = load i32, i32* %2
%11 = load i32, i32* %4
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %25
13: ; preds = %9
%14 = call i32 (...) @rand()
%15 = load i32, i32* %5
%16 = srem i32 %14, %15
store i32 %16, i32* %3
%17 = load i32, i32* %3
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %17)
%19 = load i32*, i32** %6
%20 = load i32, i32* %3
%21 = call i32 @vector_set(i32* %19, i32 %20)
br label %22
22: ; preds = %13
%23 = load i32, i32* %2
%24 = add nsw i32 %23, 1
store i32 %24, i32* %2
br label %9
25: ; preds = %9
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %2
br label %27
27: ; preds = %48, %25
%28 = load i32, i32* %2
%29 = load i32, i32* %5
%30 = icmp slt i32 %28, %29
br i1 %30, label %31, label %51
31: ; preds = %27
%32 = load i32*, i32** %6
%33 = load i32, i32* %2
%34 = call i64 @vector_get(i32* %32, i32 %33)
%35 = icmp ne i64 %34, 0
br i1 %35, label %36, label %47
36: ; preds = %31
%37 = load i32, i32* %2
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 %37)
%39 = call i32 (...) @rand()
%40 = srem i32 %39, 3
%41 = icmp ne i32 %40, 0
br i1 %41, label %42, label %46
42: ; preds = %36
%43 = load i32*, i32** %6
%44 = load i32, i32* %2
%45 = call i32 @vector_unset(i32* %43, i32 %44)
br label %46
46: ; preds = %42, %36
br label %47
47: ; preds = %46, %31
br label %48
48: ; preds = %47
%49 = load i32, i32* %2
%50 = add nsw i32 %49, 1
store i32 %50, i32* %2
br label %27
51: ; preds = %27
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %2
br label %53
53: ; preds = %66, %51
%54 = load i32, i32* %2
%55 = load i32, i32* %5
%56 = icmp slt i32 %54, %55
br i1 %56, label %57, label %69
57: ; preds = %53
%58 = load i32*, i32** %6
%59 = load i32, i32* %2
%60 = call i64 @vector_get(i32* %58, i32 %59)
%61 = icmp ne i64 %60, 0
br i1 %61, label %62, label %65
62: ; preds = %57
%63 = load i32, i32* %2
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 %63)
br label %65
65: ; preds = %62, %57
br label %66
66: ; preds = %65
%67 = load i32, i32* %2
%68 = add nsw i32 %67, 1
store i32 %68, i32* %2
br label %53
69: ; preds = %53
ret i32 0
}

LLVM IR (-O2):
@.str = [18 x i8] c"set number: %5d\0A\00"
@.str.2 = [26 x i8] c"have in vector/set: %5d\0A\00"
@str = [13 x i8] c"\0Aunset some\0A\00"
define i32 @main() {
%1 = tail call i32* @vector_init(i32 30000)
br label %2
2: ; preds = %0, %2
%3 = phi i32 [ 0, %0 ], [ %8, %2 ]
%4 = tail call i32 (...) @rand()
%5 = srem i32 %4, 30000
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = tail call i32 @vector_set(i32* %1, i32 %5)
%8 = add nuw nsw i32 %3, 1
%9 = icmp eq i32 %8, 15
br i1 %9, label %10, label %2
10: ; preds = %2
%11 = tail call i32 @putchar(i32 10)
br label %12
12: ; preds = %10, %23
%13 = phi i32 [ 0, %10 ], [ %24, %23 ]
%14 = tail call i64 @vector_get(i32* %1, i32 %13)
%15 = icmp eq i64 %14, 0
br i1 %15, label %23, label %16
16: ; preds = %12
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 %13)
%18 = tail call i32 (...) @rand()
%19 = srem i32 %18, 3
%20 = icmp eq i32 %19, 0
br i1 %20, label %23, label %21
21: ; preds = %16
%22 = tail call i32 @vector_unset(i32* %1, i32 %13)
br label %23
23: ; preds = %12, %21, %16
%24 = add nuw nsw i32 %13, 1
%25 = icmp eq i32 %24, 30000
br i1 %25, label %26, label %12
26: ; preds = %23
%27 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
br label %28
28: ; preds = %26, %34
%29 = phi i32 [ 0, %26 ], [ %35, %34 ]
%30 = tail call i64 @vector_get(i32* %1, i32 %29)
%31 = icmp eq i64 %30, 0
br i1 %31, label %34, label %32
32: ; preds = %28
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 %29)
br label %34
34: ; preds = %28, %32
%35 = add nuw nsw i32 %29, 1
%36 = icmp eq i32 %35, 30000
br i1 %36, label %37, label %28
37: ; preds = %34
ret i32 0
}