#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 atoi(char *);
scalar_t__ isPrime(int);
int /*<<< orphan*/ printf(char *, int);
int main(int argc, char **argv) {
  char *numIn = argv[1];
  int whichPrime = atoi(numIn);
  printf("inputted number: %i\n", whichPrime);
  int numFound = 2;
  int n = 3;
  while (numFound < whichPrime) {
    n++;
    if (isPrime(n))
      numFound++;
  }
  printf("that prime: %i\n", n);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%esi
lea    0xe98(%rip),%rdi
call   1030 <printf@plt>
movl   $0x2,-0x20(%rbp)
movl   $0x3,-0x24(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11b0 <main+0x80>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%edi
call   1040 <isPrime@plt>
cmp    $0x0,%rax
je     11ab <main+0x7b>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    117b <main+0x4b>
mov    -0x24(%rbp),%esi
lea    0xe5b(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    0x8(%rsi),%rdi
call   1050 <atoi@plt>
mov    %eax,%r14d
lea    0xeb9(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    $0x3,%ebp
cmp    $0x3,%r14d
jl     1186 <main+0x56>
mov    $0x2,%ebx
mov    $0x3,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%ebp
mov    %ebp,%edi
call   1040 <isPrime@plt>
cmp    $0x1,%rax
sbb    $0xffffffff,%ebx
cmp    %r14d,%ebx
jl     1170 <main+0x40>
lea    0xe88(%rip),%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [21 x i8] c"inputted number: %i\0A\00"
@.str.1 = [16 x i8] c"that prime: %i\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
store i8* %12, i8** %6
%13 = load i8*, i8** %6
%14 = call i32 @atoi(i8* %13)
store i32 %14, i32* %7
%15 = load i32, i32* %7
%16 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %15)
store i32 2, i32* %8
store i32 3, i32* %9
br label %17
17: ; preds = %30, %2
%18 = load i32, i32* %8
%19 = load i32, i32* %7
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %31
21: ; preds = %17
%22 = load i32, i32* %9
%23 = add nsw i32 %22, 1
store i32 %23, i32* %9
%24 = load i32, i32* %9
%25 = call i64 @isPrime(i32 %24)
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %21
%28 = load i32, i32* %8
%29 = add nsw i32 %28, 1
store i32 %29, i32* %8
br label %30
30: ; preds = %27, %21
br label %17
31: ; preds = %17
%32 = load i32, i32* %9
%33 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %32)
%34 = load i32, i32* %3
ret i32 %34
}

LLVM IR (-O2):
@.str = [21 x i8] c"inputted number: %i\0A\00"
@.str.1 = [16 x i8] c"that prime: %i\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = tail call i32 @atoi(i8* %4)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = icmp sgt i32 %5, 2
br i1 %7, label %8, label %17
8: ; preds = %2, %8
%9 = phi i32 [ %11, %8 ], [ 3, %2 ]
%10 = phi i32 [ %15, %8 ], [ 2, %2 ]
%11 = add nuw nsw i32 %9, 1
%12 = tail call i64 @isPrime(i32 %11)
%13 = icmp ne i64 %12, 0
%14 = zext i1 %13 to i32
%15 = add nuw nsw i32 %10, %14
%16 = icmp slt i32 %15, %5
br i1 %16, label %8, label %17
17: ; preds = %8, %2
%18 = phi i32 [ 3, %2 ], [ %11, %8 ]
%19 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %18)
ret i32 0
}