#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 */
scalar_t__ isPrime(int);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *const argv[]) {
  for (int i = 0; i < 10000; ++i) {
    if (isPrime(i)) {
      printf("%d\t", i);
    }
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x2710,-0x14(%rbp)
jge    1180 <main+0x60>
mov    -0x14(%rbp),%edi
call   1040 <isPrime@plt>
cmp    $0x0,%rax
je     116d <main+0x4d>
mov    -0x14(%rbp),%esi
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1172 <main+0x52>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    113d <main+0x1d>
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0xec6(%rip),%rbx
xor    %ebp,%ebp
jmp    114b <main+0x1b>
xchg   %ax,%ax
add    $0x1,%ebp
cmp    $0x2710,%ebp
je     1165 <main+0x35>
mov    %ebp,%edi
call   1050 <isPrime@plt>
test   %rax,%rax
je     1140 <main+0x10>
mov    %rbx,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1140 <main+0x10>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d\09\00"
@.str.1 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
br label %7
7: ; preds = %18, %2
%8 = load i32, i32* %6
%9 = icmp slt i32 %8, 10000
br i1 %9, label %10, label %21
10: ; preds = %7
%11 = load i32, i32* %6
%12 = call i64 @isPrime(i32 %11)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %10
%15 = load i32, i32* %6
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %15)
br label %17
17: ; preds = %14, %10
br label %18
18: ; preds = %17
%19 = load i32, i32* %6
%20 = add nsw i32 %19, 1
store i32 %20, i32* %6
br label %7
21: ; preds = %7
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%23 = load i32, i32* %3
ret i32 %23
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\09\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
br label %5
3: ; preds = %11
%4 = tail call i32 @putchar(i32 10)
ret i32 0
5: ; preds = %2, %11
%6 = phi i32 [ 0, %2 ], [ %12, %11 ]
%7 = tail call i64 @isPrime(i32 %6)
%8 = icmp eq i64 %7, 0
br i1 %8, label %11, label %9
9: ; preds = %5
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %6)
br label %11
11: ; preds = %5, %9
%12 = add nuw nsw i32 %6, 1
%13 = icmp eq i32 %12, 10000
br i1 %13, label %3, label %5
}