#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 atoi(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  int n;
  int i, j;
  int flag;
  int primes[1000];
  int level;
  if (argc != 2) {
    printf("Usage: %s <number>\n", argv[0]);
    exit(10);
  }
  n = atoi(argv[1]);
  level = 0;
  for (i = 2; i <= n; i++) {
    for (j = 0, flag = 1; j < level && flag; j++)
      flag = (i % primes[j]);
    if (flag) {
      printf("%12d\n", i);
      if (level < 1000)
        primes[level++] = i;
    }
  }
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xfd0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1172 <main+0x42>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0xa,%edi
call   1050 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <atoi@plt>
mov    %eax,-0x14(%rbp)
movl   $0x0,-0xfc4(%rbp)
movl   $0x2,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     1264 <main+0x134>
movl   $0x0,-0x1c(%rbp)
movl   $0x1,-0x20(%rbp)
mov    -0x1c(%rbp),%ecx
xor    %eax,%eax
cmp    -0xfc4(%rbp),%ecx
mov    %al,-0xfc5(%rbp)
jge    11d1 <main+0xa1>
cmpl   $0x0,-0x20(%rbp)
setne  %al
mov    %al,-0xfc5(%rbp)
mov    -0xfc5(%rbp),%al
test   $0x1,%al
jne    11e4 <main+0xb4>
jmp    1204 <main+0xd4>
mov    -0x18(%rbp),%eax
movslq -0x1c(%rbp),%rcx
cltd
idivl  -0xfc0(%rbp,%rcx,4)
mov    %edx,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11ad <main+0x7d>
cmpl   $0x0,-0x20(%rbp)
je     1251 <main+0x121>
mov    -0x18(%rbp),%esi
lea    0xdfc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x3e8,-0xfc4(%rbp)
jge    124c <main+0x11c>
mov    -0x18(%rbp),%ecx
mov    -0xfc4(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0xfc4(%rbp)
cltq
mov    %ecx,-0xfc0(%rbp,%rax,4)
jmp    1251 <main+0x121>
jmp    1256 <main+0x126>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1193 <main+0x63>
xor    %edi,%edi
call   1050 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0xfa8,%rsp
cmp    $0x2,%edi
jne    1157 <main+0x27>
mov    0x8(%rsi),%rdi
call   1040 <atoi@plt>
cmp    $0x2,%eax
jge    1172 <main+0x42>
xor    %edi,%edi
call   1050 <exit@plt>
mov    (%rsi),%rsi
lea    0xe9f(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0xa,%edi
call   1050 <exit@plt>
mov    %eax,%r15d
mov    $0x2,%ebx
lea    0xe93(%rip),%r14
xor    %ebp,%ebp
jmp    11af <main+0x7f>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
movslq %ebp,%rax
add    $0x1,%ebp
mov    %ebx,(%rsp,%rax,4)
lea    0x1(%rbx),%eax
cmp    %r15d,%ebx
mov    %eax,%ebx
je     1150 <main+0x20>
test   %ebp,%ebp
jle    1190 <main+0x60>
mov    %ebp,%ecx
mov    $0x1,%esi
nopw   0x0(%rax,%rax,1)
mov    %ebx,%eax
cltd
idivl  -0x4(%rsp,%rsi,4)
cmp    %rcx,%rsi
jae    11d4 <main+0xa4>
add    $0x1,%rsi
test   %edx,%edx
jne    11c0 <main+0x90>
test   %edx,%edx
je     11a5 <main+0x75>
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
cmp    $0x3e7,%ebp
jle    119c <main+0x6c>
jmp    11a5 <main+0x75>

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

LLVM IR (-O2):
@.str = [20 x i8] c"Usage: %s <number>\0A\00"
@.str.1 = [6 x i8] c"%12d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1000 x i32]
%4 = bitcast [1000 x i32]* %3 to i8*
%5 = icmp eq i32 %0, 2
br i1 %5, label %10, label %6
6: ; preds = %2
%7 = load i8*, i8** %1
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = tail call i32 @exit(i32 10)
unreachable
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = tail call i32 @atoi(i8* %12)
%14 = icmp slt i32 %13, 2
br i1 %14, label %44, label %15
15: ; preds = %10, %40
%16 = phi i32 [ %41, %40 ], [ 0, %10 ]
%17 = phi i32 [ %42, %40 ], [ 2, %10 ]
%18 = icmp sgt i32 %16, 0
br i1 %18, label %21, label %19
19: ; preds = %15
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %17)
br label %36
21: ; preds = %15
%22 = zext i32 %16 to i64
br label %23
23: ; preds = %21, %23
%24 = phi i64 [ 0, %21 ], [ %28, %23 ]
%25 = getelementptr inbounds [1000 x i32], [1000 x i32]* %3, i64 0, i64 %24
%26 = load i32, i32* %25
%27 = srem i32 %17, %26
%28 = add nuw nsw i64 %24, 1
%29 = icmp ult i64 %28, %22
%30 = icmp ne i32 %27, 0
%31 = select i1 %29, i1 %30, i1 false
br i1 %31, label %23, label %32
32: ; preds = %23
br i1 %30, label %33, label %40
33: ; preds = %32
%34 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %17)
%35 = icmp slt i32 %16, 1000
br i1 %35, label %36, label %40
36: ; preds = %19, %33
%37 = add nsw i32 %16, 1
%38 = sext i32 %16 to i64
%39 = getelementptr inbounds [1000 x i32], [1000 x i32]* %3, i64 0, i64 %38
store i32 %17, i32* %39
br label %40
40: ; preds = %32, %36, %33
%41 = phi i32 [ %37, %36 ], [ %16, %33 ], [ %16, %32 ]
%42 = add nuw i32 %17, 1
%43 = icmp eq i32 %17, %13
br i1 %43, label %44, label %15
44: ; preds = %40, %10
%45 = tail call i32 @exit(i32 0)
unreachable
}