#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*/ clear(int);
int /*<<< orphan*/ printf(char *, int);
int random(int);
int /*<<< orphan*/ set(int);
int /*<<< orphan*/ test(int);
int get_rand_nums(int n) {
  int index = 0;
  int rand_v = 0;
  for (; index < 10000000; index++)
    clear(index);
  index = 0;
  while (index < n) {
    rand_v = random(10000000);
    if (!test(rand_v)) {
      printf("%d\n", rand_v);
      set(rand_v);
      index++;
    }
  }
  for (index = 0; index < 10000000; index++) {
    clear(index);
  }
  return 0;
}


x86 assembly (clang, -O0):
<get_rand_nums>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x989680,-0x8(%rbp)
jge    118c <get_rand_nums+0x3c>
mov    -0x8(%rbp),%edi
call   1050 <clear@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1169 <get_rand_nums+0x19>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11e2 <get_rand_nums+0x92>
mov    $0x989680,%edi
call   1040 <random@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
call   1070 <test@plt>
cmp    $0x0,%eax
jne    11dd <get_rand_nums+0x8d>
mov    -0xc(%rbp),%esi
lea    0xe39(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%edi
call   1060 <set@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1193 <get_rand_nums+0x43>
movl   $0x0,-0x8(%rbp)
cmpl   $0x989680,-0x8(%rbp)
jge    120c <get_rand_nums+0xbc>
mov    -0x8(%rbp),%edi
call   1050 <clear@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11e9 <get_rand_nums+0x99>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_rand_nums>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edi,%r15d
xor    %ebp,%ebp
nopl   0x0(%rax)
mov    %ebp,%edi
call   1050 <clear@plt>
add    $0x1,%ebp
cmp    $0x989680,%ebp
jne    1160 <get_rand_nums+0x10>
test   %r15d,%r15d
jle    11c2 <get_rand_nums+0x72>
xor    %ebx,%ebx
lea    0xe80(%rip),%r14
jmp    1195 <get_rand_nums+0x45>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cmp    %r15d,%ebx
jge    11c2 <get_rand_nums+0x72>
mov    $0x989680,%edi
call   1040 <random@plt>
mov    %eax,%ebp
mov    %eax,%edi
call   1070 <test@plt>
test   %eax,%eax
jne    1190 <get_rand_nums+0x40>
mov    %r14,%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
mov    %ebp,%edi
call   1060 <set@plt>
add    $0x1,%ebx
jmp    1190 <get_rand_nums+0x40>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %ebx,%edi
call   1050 <clear@plt>
add    $0x1,%ebx
cmp    $0x989680,%ebx
jne    11d0 <get_rand_nums+0x80>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d\0A\00"
define i32 @get_rand_nums(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
br label %5
5: ; preds = %11, %1
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, 10000000
br i1 %7, label %8, label %14
8: ; preds = %5
%9 = load i32, i32* %3
%10 = call i32 @clear(i32 %9)
br label %11
11: ; preds = %8
%12 = load i32, i32* %3
%13 = add nsw i32 %12, 1
store i32 %13, i32* %3
br label %5
14: ; preds = %5
store i32 0, i32* %3
br label %15
15: ; preds = %31, %14
%16 = load i32, i32* %3
%17 = load i32, i32* %2
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %32
19: ; preds = %15
%20 = call i32 @random(i32 10000000)
store i32 %20, i32* %4
%21 = load i32, i32* %4
%22 = call i32 @test(i32 %21)
%23 = icmp ne i32 %22, 0
br i1 %23, label %31, label %24
24: ; preds = %19
%25 = load i32, i32* %4
%26 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %25)
%27 = load i32, i32* %4
%28 = call i32 @set(i32 %27)
%29 = load i32, i32* %3
%30 = add nsw i32 %29, 1
store i32 %30, i32* %3
br label %31
31: ; preds = %24, %19
br label %15
32: ; preds = %15
store i32 0, i32* %3
br label %33
33: ; preds = %39, %32
%34 = load i32, i32* %3
%35 = icmp slt i32 %34, 10000000
br i1 %35, label %36, label %42
36: ; preds = %33
%37 = load i32, i32* %3
%38 = call i32 @clear(i32 %37)
br label %39
39: ; preds = %36
%40 = load i32, i32* %3
%41 = add nsw i32 %40, 1
store i32 %41, i32* %3
br label %33
42: ; preds = %33
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
define i32 @get_rand_nums(i32 %0) {
br label %4
2: ; preds = %4
%3 = icmp sgt i32 %0, 0
br i1 %3, label %9, label %21
4: ; preds = %1, %4
%5 = phi i32 [ 0, %1 ], [ %7, %4 ]
%6 = tail call i32 @clear(i32 %5)
%7 = add nuw nsw i32 %5, 1
%8 = icmp eq i32 %7, 10000000
br i1 %8, label %2, label %4
9: ; preds = %2, %18
%10 = phi i32 [ %19, %18 ], [ 0, %2 ]
%11 = tail call i32 @random(i32 10000000)
%12 = tail call i32 @test(i32 %11)
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %9
%15 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %11)
%16 = tail call i32 @set(i32 %11)
%17 = add nsw i32 %10, 1
br label %18
18: ; preds = %14, %9
%19 = phi i32 [ %10, %9 ], [ %17, %14 ]
%20 = icmp slt i32 %19, %0
br i1 %20, label %9, label %21
21: ; preds = %18, %2
br label %22
22: ; preds = %21, %22
%23 = phi i32 [ %25, %22 ], [ 0, %21 ]
%24 = tail call i32 @clear(i32 %23)
%25 = add nuw nsw i32 %23, 1
%26 = icmp eq i32 %25, 10000000
br i1 %26, label %27, label %22
27: ; preds = %22
ret i32 0
}