#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 /*<<< orphan*/ get_prime(int const);
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ printf(char *, int const, int /*<<< orphan*/);
int main(void) {
  const int N = 10000;
  printf("the %d th prime is %ld\n", N, get_prime(N));
  getchar();
  for (int i = 1; i < N; i++) {
    printf("the %d th prime is %ld\n", i, get_prime(i));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x2710,-0x8(%rbp)
mov    $0x2710,%edi
call   1030 <get_prime@plt>
mov    %eax,%edx
lea    0xea7(%rip),%rdi
mov    $0x2710,%esi
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
movl   $0x1,-0xc(%rbp)
cmpl   $0x2710,-0xc(%rbp)
jge    11ab <main+0x7b>
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%edi
call   1030 <get_prime@plt>
mov    -0x10(%rbp),%esi
mov    %eax,%edx
lea    0xe68(%rip),%rdi
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1171 <main+0x41>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    $0x2710,%edi
call   1030 <get_prime@plt>
lea    0xebc(%rip),%rbx
mov    %rbx,%rdi
mov    $0x2710,%esi
mov    %eax,%edx
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    $0x1,%ebp
nop
mov    %ebp,%edi
call   1030 <get_prime@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %eax,%edx
call   1040 <printf@plt>
add    $0x1,%ebp
cmp    $0x2710,%ebp
jne    1160 <main+0x30>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [24 x i8] c"the %d th prime is %ld\0A\00"
define i32 @main() {
%1 = tail call i32 @get_prime(i32 10000)
%2 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 10000, i32 %1)
%3 = tail call i32 (...) @getchar()
br label %5
4: ; preds = %5
ret i32 0
5: ; preds = %0, %5
%6 = phi i32 [ 1, %0 ], [ %9, %5 ]
%7 = tail call i32 @get_prime(i32 %6)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %6, i32 %7)
%9 = add nuw nsw i32 %6, 1
%10 = icmp eq i32 %9, 10000
br i1 %10, label %4, label %5
}