#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*/ printf(char *, int);
int main() {
  int primes[100];
  int i = 0;
  primes[i++] = 2;
  int j;
  for (j = 3; j < 100; j++) {
    int k;
    for (k = 0; primes[k] <= j / primes[k]; k++) {
      if (j % primes[k] == 0)
        goto end;
    }
    primes[i++] = j;
    printf("%d\n", j);
  end:;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1b0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x1a4(%rbp)
mov    -0x1a4(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x1a4(%rbp)
cltq
movl   $0x2,-0x1a0(%rbp,%rax,4)
movl   $0x3,-0x1a8(%rbp)
cmpl   $0x64,-0x1a8(%rbp)
jge    122b <main+0x11b>
movl   $0x0,-0x1ac(%rbp)
movslq -0x1ac(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%eax
mov    %eax,-0x1b0(%rbp)
mov    -0x1a8(%rbp),%eax
movslq -0x1ac(%rbp),%rcx
cltd
idivl  -0x1a0(%rbp,%rcx,4)
mov    %eax,%ecx
mov    -0x1b0(%rbp),%eax
cmp    %ecx,%eax
jg     11e0 <main+0xd0>
mov    -0x1a8(%rbp),%eax
movslq -0x1ac(%rbp),%rcx
cltd
idivl  -0x1a0(%rbp,%rcx,4)
cmp    $0x0,%edx
jne    11c7 <main+0xb7>
jmp    1212 <main+0x102>
jmp    11cc <main+0xbc>
mov    -0x1ac(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1ac(%rbp)
jmp    116b <main+0x5b>
mov    -0x1a8(%rbp),%ecx
mov    -0x1a4(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x1a4(%rbp)
cltq
mov    %ecx,-0x1a0(%rbp,%rax,4)
mov    -0x1a8(%rbp),%esi
lea    0xdf3(%rip),%rdi
call   1030 <printf@plt>
jmp    1217 <main+0x107>
mov    -0x1a8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1a8(%rbp)
jmp    1154 <main+0x44>
xor    %eax,%eax
add    $0x1b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x198,%rsp
movl   $0x2,(%rsp)
mov    $0x1,%ebp
mov    $0x3,%ebx
mov    $0x2,%ecx
lea    0x4(%rsp),%r15
lea    0xec1(%rip),%r14
nop
mov    %ebx,%eax
cltd
idiv   %ecx
cmp    %eax,%ecx
jg     1168 <main+0x58>
mov    %r15,%rsi
nopl   0x0(%rax)
mov    %ebx,%eax
cltd
idiv   %ecx
test   %edx,%edx
je     117b <main+0x6b>
mov    (%rsi),%ecx
mov    %ebx,%eax
cltd
idiv   %ecx
add    $0x4,%rsi
cmp    %eax,%ecx
jle    1150 <main+0x40>
movslq %ebp,%rax
add    $0x1,%ebp
mov    %ebx,(%rsp,%rax,4)
mov    %r14,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
add    $0x1,%ebx
cmp    $0x64,%ebx
je     1188 <main+0x78>
mov    (%rsp),%ecx
jmp    1140 <main+0x30>
xor    %eax,%eax
add    $0x198,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
%6 = load i32, i32* %3
%7 = add nsw i32 %6, 1
store i32 %7, i32* %3
%8 = sext i32 %6 to i64
%9 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %8
store i32 2, i32* %9
store i32 3, i32* %4
br label %10
10: ; preds = %48, %0
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 100
br i1 %12, label %13, label %51
13: ; preds = %10
store i32 0, i32* %5
br label %14
14: ; preds = %36, %13
%15 = load i32, i32* %5
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %16
%18 = load i32, i32* %17
%19 = load i32, i32* %4
%20 = load i32, i32* %5
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %21
%23 = load i32, i32* %22
%24 = sdiv i32 %19, %23
%25 = icmp sle i32 %18, %24
br i1 %25, label %26, label %39
26: ; preds = %14
%27 = load i32, i32* %4
%28 = load i32, i32* %5
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %29
%31 = load i32, i32* %30
%32 = srem i32 %27, %31
%33 = icmp eq i32 %32, 0
br i1 %33, label %34, label %35
34: ; preds = %26
br label %47
35: ; preds = %26
br label %36
36: ; preds = %35
%37 = load i32, i32* %5
%38 = add nsw i32 %37, 1
store i32 %38, i32* %5
br label %14
39: ; preds = %14
%40 = load i32, i32* %4
%41 = load i32, i32* %3
%42 = add nsw i32 %41, 1
store i32 %42, i32* %3
%43 = sext i32 %41 to i64
%44 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %43
store i32 %40, i32* %44
%45 = load i32, i32* %4
%46 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %45)
br label %47
47: ; preds = %39, %34
br label %48
48: ; preds = %47
%49 = load i32, i32* %4
%50 = add nsw i32 %49, 1
store i32 %50, i32* %4
br label %10
51: ; preds = %10
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca [100 x i32]
%2 = bitcast [100 x i32]* %1 to i8*
%3 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 0
store i32 2, i32* %3
br label %4
4: ; preds = %30, %0
%5 = phi i32 [ 2, %0 ], [ %31, %30 ]
%6 = phi i32 [ 3, %0 ], [ %28, %30 ]
%7 = phi i32 [ 1, %0 ], [ %27, %30 ]
%8 = sdiv i32 %6, %5
%9 = icmp sgt i32 %5, %8
br i1 %9, label %21, label %15
10: ; preds = %15
%11 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %20
%12 = load i32, i32* %11
%13 = sdiv i32 %6, %12
%14 = icmp sgt i32 %12, %13
br i1 %14, label %21, label %15
15: ; preds = %4, %10
%16 = phi i64 [ %20, %10 ], [ 0, %4 ]
%17 = phi i32 [ %12, %10 ], [ %5, %4 ]
%18 = srem i32 %6, %17
%19 = icmp eq i32 %18, 0
%20 = add nuw i64 %16, 1
br i1 %19, label %26, label %10
21: ; preds = %10, %4
%22 = add nsw i32 %7, 1
%23 = sext i32 %7 to i64
%24 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %23
store i32 %6, i32* %24
%25 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %6)
br label %26
26: ; preds = %15, %21
%27 = phi i32 [ %22, %21 ], [ %7, %15 ]
%28 = add nuw nsw i32 %6, 1
%29 = icmp eq i32 %28, 100
br i1 %29, label %32, label %30
30: ; preds = %26
%31 = load i32, i32* %3
br label %4
32: ; preds = %26
ret i32 0
}