#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__ is_prime(int);
int /*<<< orphan*/ printf(char *, int);
void problem_007(void) {
  int n = 10001;
  int i;
  int j = 1;
  for (i = 3; i <= n * n; i += 2) {
    if (is_prime(i)) {
      j++;
    }
    if (j == n) {
      printf("%i", i);
      return;
    }
  }
  return;
}


x86 assembly (clang, -O0):
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x2711,-0x4(%rbp)
movl   $0x1,-0xc(%rbp)
movl   $0x3,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    -0x4(%rbp),%ecx
imul   -0x4(%rbp),%ecx
cmp    %ecx,%eax
jg     119d <problem_007+0x7d>
mov    -0x8(%rbp),%edi
call   1040 <is_prime@plt>
cmp    $0x0,%rax
je     116a <problem_007+0x4a>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x4(%rbp),%eax
jne    118a <problem_007+0x6a>
mov    -0x8(%rbp),%esi
lea    0xe80(%rip),%rdi
call   1030 <printf@plt>
jmp    11a2 <problem_007+0x82>
jmp    118f <problem_007+0x6f>
mov    -0x8(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x8(%rbp)
jmp    113d <problem_007+0x1d>
jmp    11a2 <problem_007+0x82>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
push   %rbp
push   %rbx
push   %rax
mov    $0x3,%ebx
mov    $0x1,%ebp
nopl   (%rax)
mov    %ebx,%edi
call   1040 <is_prime@plt>
cmp    $0x1,%rax
sbb    $0xffffffff,%ebp
cmp    $0x2711,%ebp
je     115a <problem_007+0x3a>
lea    0x2(%rbx),%eax
cmp    $0x5f62f20,%ebx
mov    %eax,%ebx
jb     1130 <problem_007+0x10>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xe9f(%rip),%rdi
mov    %ebx,%esi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <printf@plt>

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

LLVM IR (-O2):
@.str = [3 x i8] c"%i\00"
define void @problem_007() {
br label %1
1: ; preds = %0, %11
%2 = phi i32 [ 1, %0 ], [ %7, %11 ]
%3 = phi i32 [ 3, %0 ], [ %12, %11 ]
%4 = tail call i64 @is_prime(i32 %3)
%5 = icmp ne i64 %4, 0
%6 = zext i1 %5 to i32
%7 = add nuw nsw i32 %2, %6
%8 = icmp eq i32 %7, 10001
br i1 %8, label %9, label %11
9: ; preds = %1
%10 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %3)
br label %14
11: ; preds = %1
%12 = add nuw nsw i32 %3, 2
%13 = icmp ult i32 %3, 100020000
br i1 %13, label %1, label %14
14: ; preds = %11, %9
ret void
}