#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 n, cont = 1;
  for (n = 3; cont <= 10001; n += 2) {
    if (isPrime(n)) {
      cont++;
      if (cont == 10001)
        printf("%d° numero primo: %d\n", cont, n);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0xc(%rbp)
movl   $0x3,-0x8(%rbp)
cmpl   $0x2711,-0xc(%rbp)
jg     119c <main+0x7c>
mov    -0x8(%rbp),%edi
call   1040 <isPrime@plt>
cmp    $0x0,%rax
je     1189 <main+0x69>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x2711,-0xc(%rbp)
jne    1184 <main+0x64>
mov    -0xc(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xe81(%rip),%rdi
call   1030 <printf@plt>
jmp    1189 <main+0x69>
jmp    118e <main+0x6e>
mov    -0x8(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x8(%rbp)
jmp    113d <main+0x1d>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

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

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

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