#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, int);
int main(int argc, char const *argv[]) {
  int num = 1;
  for (int i = 0; num <= 10001; i++) {
    if (isPrime(i)) {
      printf("%d %d\n", num, i);
      num++;
    }
  }
  return 0;
}


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   $0x1,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x2711,-0x14(%rbp)
jg     1191 <main+0x71>
mov    -0x18(%rbp),%edi
call   1040 <isPrime@plt>
cmp    $0x0,%rax
je     117e <main+0x5e>
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xe90(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1183 <main+0x63>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1144 <main+0x24>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    $0x1,%ebx
xor    %ebp,%ebp
lea    0xece(%rip),%r14
jmp    114b <main+0x2b>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%ebp
cmp    $0x2712,%ebx
jge    1168 <main+0x48>
mov    %ebp,%edi
call   1040 <isPrime@plt>
test   %rax,%rax
je     1140 <main+0x20>
mov    %r14,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
call   1030 <printf@plt>
add    $0x1,%ebx
jmp    1140 <main+0x20>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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