#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 prime(int);
int /*<<< orphan*/ printf(char *, ...);
void main(void) {
  int n, i = 0;
  for (n = 1; n <= 10000; n++) {
    if (1 == prime(n)) {
      ++i;
      printf("%d\t", n);
      if (0 == i % 10) {
        printf("\n");
      }
    }
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x8(%rbp)
movl   $0x1,-0x4(%rbp)
cmpl   $0x2710,-0x4(%rbp)
jg     11af <main+0x8f>
mov    -0x4(%rbp),%edi
call   1040 <prime@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    %ecx,%eax
jne    119c <main+0x7c>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%esi
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
xor    %eax,%eax
cmp    %edx,%eax
jne    1197 <main+0x77>
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    119c <main+0x7c>
jmp    11a1 <main+0x81>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1136 <main+0x16>
lea    0xe4e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    $0x1,%ebx
lea    0xec0(%rip),%r14
xor    %ebp,%ebp
jmp    115b <main+0x2b>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%ebx
cmp    $0x2711,%ebx
je     1196 <main+0x66>
mov    %ebx,%edi
call   1050 <prime@plt>
cmp    $0x1,%eax
jne    1150 <main+0x20>
add    $0x1,%ebp
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
imul   $0xcccccccd,%ebp,%eax
add    $0x19999998,%eax
ror    %eax
cmp    $0x19999998,%eax
ja     1150 <main+0x20>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    1150 <main+0x20>
mov    $0xa,%edi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <putchar@plt>

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

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