#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_bit(int *, unsigned int);
int /*<<< orphan*/ printf(char *, unsigned int);
int /*<<< orphan*/ set_bit(int *, unsigned int);
scalar_t__ test_bit(int *, unsigned int);
void FindPrimerNumber(void) {
  int signal[1000];
  unsigned int number = 0;
  unsigned int num = 0;
  for (number = 0; number < 1000; number++) {
    set_bit(signal, number);
  }
  for (number = 1; number <= 1000; number++) {
    if (test_bit(signal, number)) {
      for (num = number + 2; num <= 1000; num++) {
        if (num % (number + 1) == 0) {
          clear_bit(signal, num - 1);
        }
      }
    }
  }
  for (number = 0; number < 1000; number++) {
    if (signal[number] != 0) {
      printf("%d\t", number + 1);
    }
  }
}


x86 assembly (clang, -O0):
<FindPrimerNumber>:
push   %rbp
mov    %rsp,%rbp
sub    $0xfb0,%rsp
movl   $0x0,-0xfa4(%rbp)
movl   $0x0,-0xfa8(%rbp)
movl   $0x0,-0xfa4(%rbp)
cmpl   $0x3e8,-0xfa4(%rbp)
jae    119f <FindPrimerNumber+0x5f>
lea    -0xfa0(%rbp),%rdi
mov    -0xfa4(%rbp),%esi
call   1050 <set_bit@plt>
mov    -0xfa4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xfa4(%rbp)
jmp    1169 <FindPrimerNumber+0x29>
movl   $0x1,-0xfa4(%rbp)
cmpl   $0x3e8,-0xfa4(%rbp)
ja     125c <FindPrimerNumber+0x11c>
lea    -0xfa0(%rbp),%rdi
mov    -0xfa4(%rbp),%esi
call   1060 <test_bit@plt>
cmp    $0x0,%rax
je     1243 <FindPrimerNumber+0x103>
mov    -0xfa4(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0xfa8(%rbp)
cmpl   $0x3e8,-0xfa8(%rbp)
ja     123e <FindPrimerNumber+0xfe>
mov    -0xfa8(%rbp),%eax
mov    -0xfa4(%rbp),%ecx
add    $0x1,%ecx
xor    %edx,%edx
div    %ecx
cmp    $0x0,%edx
jne    1225 <FindPrimerNumber+0xe5>
lea    -0xfa0(%rbp),%rdi
mov    -0xfa8(%rbp),%esi
sub    $0x1,%esi
call   1040 <clear_bit@plt>
jmp    122a <FindPrimerNumber+0xea>
mov    -0xfa8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xfa8(%rbp)
jmp    11e4 <FindPrimerNumber+0xa4>
jmp    1243 <FindPrimerNumber+0x103>
jmp    1248 <FindPrimerNumber+0x108>
mov    -0xfa4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xfa4(%rbp)
jmp    11a9 <FindPrimerNumber+0x69>
movl   $0x0,-0xfa4(%rbp)
cmpl   $0x3e8,-0xfa4(%rbp)
jae    12b8 <FindPrimerNumber+0x178>
mov    -0xfa4(%rbp),%eax
cmpl   $0x0,-0xfa0(%rbp,%rax,4)
je     129f <FindPrimerNumber+0x15f>
mov    -0xfa4(%rbp),%esi
add    $0x1,%esi
lea    0xd66(%rip),%rdi
call   1030 <printf@plt>
jmp    12a4 <FindPrimerNumber+0x164>
mov    -0xfa4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xfa4(%rbp)
jmp    1266 <FindPrimerNumber+0x126>
add    $0xfb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<FindPrimerNumber>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0xfa8,%rsp
xor    %ebx,%ebx
mov    %rsp,%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %ebx,%esi
call   1050 <set_bit@plt>
add    $0x1,%ebx
cmp    $0x3e8,%ebx
jne    1160 <FindPrimerNumber+0x20>
mov    $0x1,%r15d
mov    %rsp,%r14
jmp    118d <FindPrimerNumber+0x4d>
add    $0x1,%r15d
cmp    $0x3e9,%r15d
je     11d2 <FindPrimerNumber+0x92>
mov    %r14,%rdi
mov    %r15d,%esi
call   1060 <test_bit@plt>
test   %rax,%rax
je     1180 <FindPrimerNumber+0x40>
cmp    $0x3e6,%r15d
ja     1180 <FindPrimerNumber+0x40>
lea    0x2(%r15),%ebx
lea    0x1(%r15),%ebp
jmp    11bb <FindPrimerNumber+0x7b>
add    $0x1,%ebx
cmp    $0x3e9,%ebx
je     1180 <FindPrimerNumber+0x40>
mov    %ebx,%eax
xor    %edx,%edx
div    %ebp
test   %edx,%edx
jne    11b0 <FindPrimerNumber+0x70>
lea    -0x1(%rbx),%esi
mov    %r14,%rdi
call   1040 <clear_bit@plt>
jmp    11b0 <FindPrimerNumber+0x70>
xor    %esi,%esi
lea    0xe25(%rip),%rbx
jmp    11ec <FindPrimerNumber+0xac>
nopl   (%rax)
mov    %rbp,%rsi
cmp    $0x3e8,%rbp
je     1203 <FindPrimerNumber+0xc3>
lea    0x1(%rsi),%rbp
cmpl   $0x0,(%rsp,%rsi,4)
je     11e0 <FindPrimerNumber+0xa0>
add    $0x1,%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
jmp    11e0 <FindPrimerNumber+0xa0>
add    $0xfa8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d\09\00"
define void @FindPrimerNumber() {
%1 = alloca [1000 x i32]
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %2
br label %4
4: ; preds = %11, %0
%5 = load i32, i32* %2
%6 = icmp ult i32 %5, 1000
br i1 %6, label %7, label %14
7: ; preds = %4
%8 = getelementptr inbounds [1000 x i32], [1000 x i32]* %1, i64 0, i64 0
%9 = load i32, i32* %2
%10 = call i32 @set_bit(i32* %8, i32 %9)
br label %11
11: ; preds = %7
%12 = load i32, i32* %2
%13 = add i32 %12, 1
store i32 %13, i32* %2
br label %4
14: ; preds = %4
store i32 1, i32* %2
br label %15
15: ; preds = %46, %14
%16 = load i32, i32* %2
%17 = icmp ule i32 %16, 1000
br i1 %17, label %18, label %49
18: ; preds = %15
%19 = getelementptr inbounds [1000 x i32], [1000 x i32]* %1, i64 0, i64 0
%20 = load i32, i32* %2
%21 = call i64 @test_bit(i32* %19, i32 %20)
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %45
23: ; preds = %18
%24 = load i32, i32* %2
%25 = add i32 %24, 2
store i32 %25, i32* %3
br label %26
26: ; preds = %41, %23
%27 = load i32, i32* %3
%28 = icmp ule i32 %27, 1000
br i1 %28, label %29, label %44
29: ; preds = %26
%30 = load i32, i32* %3
%31 = load i32, i32* %2
%32 = add i32 %31, 1
%33 = urem i32 %30, %32
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %40
35: ; preds = %29
%36 = getelementptr inbounds [1000 x i32], [1000 x i32]* %1, i64 0, i64 0
%37 = load i32, i32* %3
%38 = sub i32 %37, 1
%39 = call i32 @clear_bit(i32* %36, i32 %38)
br label %40
40: ; preds = %35, %29
br label %41
41: ; preds = %40
%42 = load i32, i32* %3
%43 = add i32 %42, 1
store i32 %43, i32* %3
br label %26
44: ; preds = %26
br label %45
45: ; preds = %44, %18
br label %46
46: ; preds = %45
%47 = load i32, i32* %2
%48 = add i32 %47, 1
store i32 %48, i32* %2
br label %15
49: ; preds = %15
store i32 0, i32* %2
br label %50
50: ; preds = %64, %49
%51 = load i32, i32* %2
%52 = icmp ult i32 %51, 1000
br i1 %52, label %53, label %67
53: ; preds = %50
%54 = load i32, i32* %2
%55 = zext i32 %54 to i64
%56 = getelementptr inbounds [1000 x i32], [1000 x i32]* %1, i64 0, i64 %55
%57 = load i32, i32* %56
%58 = icmp ne i32 %57, 0
br i1 %58, label %59, label %63
59: ; preds = %53
%60 = load i32, i32* %2
%61 = add i32 %60, 1
%62 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %61)
br label %63
63: ; preds = %59, %53
br label %64
64: ; preds = %63
%65 = load i32, i32* %2
%66 = add i32 %65, 1
store i32 %66, i32* %2
br label %50
67: ; preds = %50
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\09\00"
define void @FindPrimerNumber() {
%1 = alloca [1000 x i32]
%2 = bitcast [1000 x i32]* %1 to i8*
%3 = getelementptr inbounds [1000 x i32], [1000 x i32]* %1, i64 0, i64 0
br label %4
4: ; preds = %0, %4
%5 = phi i32 [ 0, %0 ], [ %7, %4 ]
%6 = call i32 @set_bit(i32* %3, i32 %5)
%7 = add nuw nsw i32 %5, 1
%8 = icmp eq i32 %7, 1000
br i1 %8, label %9, label %4
9: ; preds = %4, %28
%10 = phi i32 [ %29, %28 ], [ 1, %4 ]
%11 = call i64 @test_bit(i32* %3, i32 %10)
%12 = icmp ne i64 %11, 0
%13 = icmp ult i32 %10, 999
%14 = and i1 %12, %13
br i1 %14, label %15, label %28
15: ; preds = %9
%16 = add nuw nsw i32 %10, 2
%17 = add nuw nsw i32 %10, 1
br label %18
18: ; preds = %15, %25
%19 = phi i32 [ %16, %15 ], [ %26, %25 ]
%20 = urem i32 %19, %17
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %18
%23 = add nsw i32 %19, -1
%24 = call i32 @clear_bit(i32* %3, i32 %23)
br label %25
25: ; preds = %18, %22
%26 = add nuw nsw i32 %19, 1
%27 = icmp eq i32 %26, 1001
br i1 %27, label %28, label %18
28: ; preds = %25, %9
%29 = add nuw nsw i32 %10, 1
%30 = icmp eq i32 %29, 1001
br i1 %30, label %31, label %9
31: ; preds = %28, %40
%32 = phi i64 [ %36, %40 ], [ 0, %28 ]
%33 = getelementptr inbounds [1000 x i32], [1000 x i32]* %1, i64 0, i64 %32
%34 = load i32, i32* %33
%35 = icmp eq i32 %34, 0
%36 = add nuw nsw i64 %32, 1
br i1 %35, label %40, label %37
37: ; preds = %31
%38 = trunc i64 %36 to i32
%39 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %38)
br label %40
40: ; preds = %31, %37
%41 = icmp eq i64 %36, 1000
br i1 %41, label %42, label %31
42: ; preds = %40
ret void
}