#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);
main() {
  int i;
  int n;
  n = 2;
  while (++n <= 5000) {
    i = 1;
    while (++i < n)
      if (n % i == 0)
        break;
    if (i == n)
      printf("%d\n", n);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x2,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
cmp    $0x1388,%eax
jg     118d <main+0x7d>
movl   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
cmp    -0xc(%rbp),%eax
jge    116d <main+0x5d>
mov    -0xc(%rbp),%eax
cltd
idivl  -0x8(%rbp)
cmp    $0x0,%edx
jne    1168 <main+0x58>
jmp    116d <main+0x5d>
jmp    1141 <main+0x31>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    1188 <main+0x78>
mov    -0xc(%rbp),%esi
lea    0xe7d(%rip),%rdi
call   1030 <printf@plt>
jmp    1126 <main+0x16>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    $0x3,%ebx
mov    $0x2,%r15d
xor    %ebp,%ebp
lea    0xed5(%rip),%r14
jmp    114d <main+0x3d>
nopl   (%rax)
mov    %r14,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
add    $0x1,%ebx
add    $0x1,%r15d
add    $0xffffffff,%ebp
cmp    $0x1388,%r15d
je     117e <main+0x6e>
mov    $0x2,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    (%rcx,%rbp,1),%eax
cmp    $0x3,%eax
je     1130 <main+0x20>
mov    %ebx,%eax
xor    %edx,%edx
div    %ecx
add    $0x1,%ecx
test   %edx,%edx
jne    1160 <main+0x50>
add    %ebp,%ecx
cmp    $0x4,%ecx
je     1130 <main+0x20>
jmp    113a <main+0x2a>
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 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 2, i32* %3
br label %4
4: ; preds = %28, %0
%5 = load i32, i32* %3
%6 = add nsw i32 %5, 1
store i32 %6, i32* %3
%7 = icmp sle i32 %6, 5000
br i1 %7, label %8, label %29
8: ; preds = %4
store i32 1, i32* %2
br label %9
9: ; preds = %20, %8
%10 = load i32, i32* %2
%11 = add nsw i32 %10, 1
store i32 %11, i32* %2
%12 = load i32, i32* %3
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %21
14: ; preds = %9
%15 = load i32, i32* %3
%16 = load i32, i32* %2
%17 = srem i32 %15, %16
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %14
br label %21
20: ; preds = %14
br label %9
21: ; preds = %19, %9
%22 = load i32, i32* %2
%23 = load i32, i32* %3
%24 = icmp eq i32 %22, %23
br i1 %24, label %25, label %28
25: ; preds = %21
%26 = load i32, i32* %3
%27 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %26)
br label %28
28: ; preds = %25, %21
br label %4
29: ; preds = %4
%30 = load i32, i32* %1
ret i32 %30
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
br label %1
1: ; preds = %0, %15
%2 = phi i32 [ 2, %0 ], [ %17, %15 ]
%3 = phi i32 [ 3, %0 ], [ %16, %15 ]
br label %4
4: ; preds = %1, %8
%5 = phi i32 [ %6, %8 ], [ 1, %1 ]
%6 = add nuw nsw i32 %5, 1
%7 = icmp eq i32 %5, %2
br i1 %7, label %13, label %8
8: ; preds = %4
%9 = urem i32 %3, %6
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %4
11: ; preds = %8
%12 = icmp eq i32 %5, %2
br i1 %12, label %13, label %15
13: ; preds = %4, %11
%14 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %3)
br label %15
15: ; preds = %13, %11
%16 = add nuw nsw i32 %3, 1
%17 = add nuw nsw i32 %2, 1
%18 = icmp eq i32 %17, 5000
br i1 %18, label %19, label %1
19: ; preds = %15
ret i32 0
}