#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*/ assert(int *);
int *calloc(int, int);
int /*<<< orphan*/ free(int *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, int *);
int nth_simple_number() {
  int n = -2048;
  scanf("%d", &n);
  if (n == -2048) {
    return -2048;
  }
  int *array_of_simple_numbers = calloc(n, sizeof(*array_of_simple_numbers));
  assert(array_of_simple_numbers);
  array_of_simple_numbers[0] = 2;
  for (int i = 1; i < n; i++) {
    array_of_simple_numbers[i] = 0;
  }
  for (int i = 0; i < n; i++) {
    for (int j = array_of_simple_numbers[i] + 1;; j++) {
      int is_simple = 1;
      for (int k = 0; k <= i; k++) {
        if (j % array_of_simple_numbers[k] == 0) {
          is_simple = 0;
          break;
        }
      }
      if (is_simple) {
        array_of_simple_numbers[i + 1] = j;
        break;
      }
    }
  }
  printf("%d\n", array_of_simple_numbers[n - 1]);
  free(array_of_simple_numbers);
  array_of_simple_numbers = 0;
  return 0;
}


x86 assembly (clang, -O0):
<nth_simple_number>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0xfffff800,-0x8(%rbp)
lea    0xe9a(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1070 <scanf@plt>
cmpl   $0xfffff800,-0x8(%rbp)
jne    1188 <nth_simple_number+0x38>
movl   $0xfffff800,-0x4(%rbp)
jmp    12cd <nth_simple_number+0x17d>
mov    -0x8(%rbp),%edi
mov    $0x4,%esi
call   1050 <calloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <assert@plt>
mov    -0x10(%rbp),%rax
movl   $0x2,(%rax)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11dc <nth_simple_number+0x8c>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11b3 <nth_simple_number+0x63>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1299 <nth_simple_number+0x149>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
movl   $0x1,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x18(%rbp),%eax
jg     1251 <nth_simple_number+0x101>
mov    -0x1c(%rbp),%eax
mov    -0x10(%rbp),%rcx
movslq -0x24(%rbp),%rsi
cltd
idivl  (%rcx,%rsi,4)
cmp    $0x0,%edx
jne    123e <nth_simple_number+0xee>
movl   $0x0,-0x20(%rbp)
jmp    1251 <nth_simple_number+0x101>
jmp    1243 <nth_simple_number+0xf3>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    120e <nth_simple_number+0xbe>
cmpl   $0x0,-0x20(%rbp)
je     1273 <nth_simple_number+0x123>
mov    -0x1c(%rbp),%edx
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
jmp    1286 <nth_simple_number+0x136>
jmp    1278 <nth_simple_number+0x128>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1200 <nth_simple_number+0xb0>
jmp    128b <nth_simple_number+0x13b>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11e3 <nth_simple_number+0x93>
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%esi
lea    0xd53(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x10(%rbp)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nth_simple_number>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
movl   $0xfffff800,0xc(%rsp)
ff
lea    0xe88(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1080 <scanf@plt>
mov    0xc(%rsp),%edi
mov    $0xfffff800,%eax
cmp    $0xfffff800,%edi
je     1240 <nth_simple_number+0xe0>
mov    $0x4,%esi
call   1060 <calloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1070 <assert@plt>
movl   $0x2,(%rbx)
movslq 0xc(%rsp),%r14
mov    %r14d,%r15d
cmp    $0x2,%r14
jl     11d8 <nth_simple_number+0x78>
mov    %rbx,%rdi
add    $0x4,%rdi
lea    -0x1(%r14),%edx
shl    $0x2,%rdx
xor    %esi,%esi
call   1050 <memset@plt>
jmp    11de <nth_simple_number+0x7e>
cmp    $0x1,%r15d
jne    1225 <nth_simple_number+0xc5>
mov    $0x1,%esi
mov    $0x2,%ecx
xor    %r8d,%r8d
nopl   0x0(%rax,%rax,1)
add    $0x1,%ecx
xor    %edi,%edi
cs nopw 0x0(%rax,%rax,1)
nop
mov    %ecx,%eax
cltd
idivl  (%rbx,%rdi,4)
test   %edx,%edx
je     11f0 <nth_simple_number+0x90>
add    $0x1,%rdi
cmp    %rdi,%rsi
jne    1200 <nth_simple_number+0xa0>
mov    %ecx,0x4(%rbx,%r8,4)
add    $0x1,%r8
add    $0x1,%rsi
cmp    %r15,%r8
jne    11f0 <nth_simple_number+0x90>
mov    -0x4(%rbx,%r14,4),%esi
lea    0xdd2(%rip),%rdi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @nth_simple_number() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 -2048, i32* %2
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%10 = load i32, i32* %2
%11 = icmp eq i32 %10, -2048
br i1 %11, label %12, label %13
12: ; preds = %0
store i32 -2048, i32* %1
br label %91
13: ; preds = %0
%14 = load i32, i32* %2
%15 = call i32* @calloc(i32 %14, i32 4)
store i32* %15, i32** %3
%16 = load i32*, i32** %3
%17 = call i32 @assert(i32* %16)
%18 = load i32*, i32** %3
%19 = getelementptr inbounds i32, i32* %18, i64 0
store i32 2, i32* %19
store i32 1, i32* %4
br label %20
20: ; preds = %29, %13
%21 = load i32, i32* %4
%22 = load i32, i32* %2
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %32
24: ; preds = %20
%25 = load i32*, i32** %3
%26 = load i32, i32* %4
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i32, i32* %25, i64 %27
store i32 0, i32* %28
br label %29
29: ; preds = %24
%30 = load i32, i32* %4
%31 = add nsw i32 %30, 1
store i32 %31, i32* %4
br label %20
32: ; preds = %20
store i32 0, i32* %5
br label %33
33: ; preds = %78, %32
%34 = load i32, i32* %5
%35 = load i32, i32* %2
%36 = icmp slt i32 %34, %35
br i1 %36, label %37, label %81
37: ; preds = %33
%38 = load i32*, i32** %3
%39 = load i32, i32* %5
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i32, i32* %38, i64 %40
%42 = load i32, i32* %41
%43 = add nsw i32 %42, 1
store i32 %43, i32* %6
br label %44
44: ; preds = %74, %37
store i32 1, i32* %7
store i32 0, i32* %8
br label %45
45: ; preds = %60, %44
%46 = load i32, i32* %8
%47 = load i32, i32* %5
%48 = icmp sle i32 %46, %47
br i1 %48, label %49, label %63
49: ; preds = %45
%50 = load i32, i32* %6
%51 = load i32*, i32** %3
%52 = load i32, i32* %8
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i32, i32* %51, i64 %53
%55 = load i32, i32* %54
%56 = srem i32 %50, %55
%57 = icmp eq i32 %56, 0
br i1 %57, label %58, label %59
58: ; preds = %49
store i32 0, i32* %7
br label %63
59: ; preds = %49
br label %60
60: ; preds = %59
%61 = load i32, i32* %8
%62 = add nsw i32 %61, 1
store i32 %62, i32* %8
br label %45
63: ; preds = %58, %45
%64 = load i32, i32* %7
%65 = icmp ne i32 %64, 0
br i1 %65, label %66, label %73
66: ; preds = %63
%67 = load i32, i32* %6
%68 = load i32*, i32** %3
%69 = load i32, i32* %5
%70 = add nsw i32 %69, 1
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds i32, i32* %68, i64 %71
store i32 %67, i32* %72
br label %77
73: ; preds = %63
br label %74
74: ; preds = %73
%75 = load i32, i32* %6
%76 = add nsw i32 %75, 1
store i32 %76, i32* %6
br label %44
77: ; preds = %66
br label %78
78: ; preds = %77
%79 = load i32, i32* %5
%80 = add nsw i32 %79, 1
store i32 %80, i32* %5
br label %33
81: ; preds = %33
%82 = load i32*, i32** %3
%83 = load i32, i32* %2
%84 = sub nsw i32 %83, 1
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds i32, i32* %82, i64 %85
%87 = load i32, i32* %86
%88 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %87)
%89 = load i32*, i32** %3
%90 = call i32 @free(i32* %89)
store i32* null, i32** %3
store i32 0, i32* %1
br label %91
91: ; preds = %81, %12
%92 = load i32, i32* %1
ret i32 %92
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @nth_simple_number() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 -2048, i32* %1
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%4 = load i32, i32* %1
%5 = icmp eq i32 %4, -2048
br i1 %5, label %49, label %6
6: ; preds = %0
%7 = call i32* @calloc(i32 %4, i32 4)
%8 = call i32 @assert(i32* %7)
store i32 2, i32* %7
%9 = load i32, i32* %1
%10 = icmp sgt i32 %9, 1
br i1 %10, label %11, label %17
11: ; preds = %6
%12 = getelementptr i32, i32* %7, i64 1
%13 = bitcast i32* %12 to i8*
%14 = add nsw i32 %9, -1
%15 = zext i32 %14 to i64
%16 = shl nuw nsw i64 %15, 2
br label %19
17: ; preds = %6
%18 = icmp eq i32 %9, 1
br i1 %18, label %19, label %21
19: ; preds = %11, %17
%20 = zext i32 %9 to i64
br label %28
21: ; preds = %44, %17
%22 = add nsw i32 %9, -1
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i32, i32* %7, i64 %23
%25 = load i32, i32* %24
%26 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %25)
%27 = call i32 @free(i32* %7)
br label %49
28: ; preds = %19, %44
%29 = phi i32 [ 2, %19 ], [ %34, %44 ]
%30 = phi i64 [ 0, %19 ], [ %45, %44 ]
%31 = phi i64 [ 1, %19 ], [ %47, %44 ]
br label %32
32: ; preds = %38, %28
%33 = phi i32 [ %29, %28 ], [ %34, %38 ]
%34 = add nsw i32 %33, 1
br label %38
35: ; preds = %38
%36 = add nuw nsw i64 %39, 1
%37 = icmp eq i64 %36, %31
br i1 %37, label %44, label %38
38: ; preds = %32, %35
%39 = phi i64 [ 0, %32 ], [ %36, %35 ]
%40 = getelementptr inbounds i32, i32* %7, i64 %39
%41 = load i32, i32* %40
%42 = srem i32 %34, %41
%43 = icmp eq i32 %42, 0
br i1 %43, label %32, label %35
44: ; preds = %35
%45 = add nuw nsw i64 %30, 1
%46 = getelementptr inbounds i32, i32* %7, i64 %45
store i32 %34, i32* %46
%47 = add nuw nsw i64 %31, 1
%48 = icmp eq i64 %45, %20
br i1 %48, label %21, label %28
49: ; preds = %0, %21
%50 = phi i32 [ 0, %21 ], [ -2048, %0 ]
ret i32 %50
}