#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 *);
int divide_check(int);
int /*<<< orphan*/ printf(char *, ...);
int sieve(int);
int main(int argc, char *argv[]) {
  if (argc != 2 || argv[1] == NULL) {
    printf("Usage: nthprime <nth>\n");
    return 1;
  }
  int nth = atoi(argv[1]);
  int prime;
  if (nth >= 6) {
    prime = sieve(nth);
  } else {
    prime = divide_check(nth);
  }
  printf("%i\n", prime);
  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)
cmpl   $0x2,-0x8(%rbp)
jne    116f <main+0x2f>
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x8(%rax)
jne    1189 <main+0x49>
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11d6 <main+0x96>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x6,-0x14(%rbp)
jl     11b3 <main+0x73>
mov    -0x14(%rbp),%edi
call   1040 <sieve@plt>
mov    %eax,-0x18(%rbp)
jmp    11be <main+0x7e>
mov    -0x14(%rbp),%edi
call   1050 <divide_check@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%esi
lea    0xe4f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
cmp    $0x2,%edi
jne    1172 <main+0x22>
mov    0x8(%rsi),%rdi
test   %rdi,%rdi
je     1172 <main+0x22>
call   1070 <atoi@plt>
mov    %eax,%edi
cmp    $0x6,%eax
jl     1185 <main+0x35>
call   1050 <sieve@plt>
jmp    118a <main+0x3a>
lea    0xe8b(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebx
jmp    119c <main+0x4c>
call   1060 <divide_check@plt>
lea    0xe6f(%rip),%rdi
xor    %ebx,%ebx
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [23 x i8] c"Usage: nthprime <nth>\0A\00"
@.str.1 = [4 x i8] c"%i\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
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 2
br i1 %9, label %15, label %10
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = icmp eq i8* %13, null
br i1 %14, label %15, label %17
15: ; preds = %10, %2
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %33
17: ; preds = %10
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i32 @atoi(i8* %20)
store i32 %21, i32* %6
%22 = load i32, i32* %6
%23 = icmp sge i32 %22, 6
br i1 %23, label %24, label %27
24: ; preds = %17
%25 = load i32, i32* %6
%26 = call i32 @sieve(i32 %25)
store i32 %26, i32* %7
br label %30
27: ; preds = %17
%28 = load i32, i32* %6
%29 = call i32 @divide_check(i32 %28)
store i32 %29, i32* %7
br label %30
30: ; preds = %27, %24
%31 = load i32, i32* %7
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %31)
store i32 0, i32* %3
br label %33
33: ; preds = %30, %15
%34 = load i32, i32* %3
ret i32 %34
}

LLVM IR (-O2):
@.str.1 = [4 x i8] c"%i\0A\00"
@str = [22 x i8] c"Usage: nthprime <nth>\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %4, label %8
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = icmp eq i8* %6, null
br i1 %7, label %8, label %10
8: ; preds = %4, %2
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
br label %20
10: ; preds = %4
%11 = tail call i32 @atoi(i8* %6)
%12 = icmp sgt i32 %11, 5
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = tail call i32 @sieve(i32 %11)
br label %17
15: ; preds = %10
%16 = tail call i32 @divide_check(i32 %11)
br label %17
17: ; preds = %15, %13
%18 = phi i32 [ %14, %13 ], [ %16, %15 ]
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %18)
br label %20
20: ; preds = %17, %8
%21 = phi i32 [ 1, %8 ], [ 0, %17 ]
ret i32 %21
}