#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 check_prime(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int num, check, i, count = 0;
  scanf("%d", &num);
  if (num == 1)
    printf("2");
  else {
    check = check_prime(num);
    if (check == 0)
      printf("%d", num);
    else {
      for (i = num + 1; i <= num + 20; i++) {
        check = check_prime(i);
        if (check == 0)
          break;
      }
      printf("%d", i);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xeb3(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0x1,-0x8(%rbp)
jne    1173 <main+0x43>
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11fb <main+0xcb>
mov    -0x8(%rbp),%edi
call   1030 <check_prime@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    119e <main+0x6e>
mov    -0x8(%rbp),%esi
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11f6 <main+0xc6>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0x8(%rbp),%ecx
add    $0x14,%ecx
cmp    %ecx,%eax
jg     11e5 <main+0xb5>
mov    -0x10(%rbp),%edi
call   1030 <check_prime@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    11d2 <main+0xa2>
jmp    11e5 <main+0xb5>
jmp    11d7 <main+0xa7>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11a7 <main+0x77>
mov    -0x10(%rbp),%esi
lea    0xe11(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11fb <main+0xcb>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0xeb6(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1060 <scanf@plt>
mov    0x4(%rsp),%edi
cmp    $0x1,%edi
jne    1169 <main+0x29>
mov    $0x32,%edi
call   1030 <putchar@plt>
jmp    11b5 <main+0x75>
call   1040 <check_prime@plt>
mov    0x4(%rsp),%ebx
test   %eax,%eax
je     11a5 <main+0x65>
cs nopw 0x0(%rax,%rax,1)
lea    0x1(%rbx),%ebp
mov    %ebp,%edi
call   1040 <check_prime@plt>
test   %eax,%eax
je     11a2 <main+0x62>
mov    0x4(%rsp),%eax
add    $0x14,%eax
mov    %ebp,%ebx
cmp    %eax,%ebp
jl     1180 <main+0x40>
add    $0x1,%ebp
mov    %ebp,%ebx
jmp    11a5 <main+0x65>
add    $0x1,%ebx
lea    0xe54(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [2 x i8] c"2\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %5
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%7 = load i32, i32* %2
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %11
9: ; preds = %0
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %41
11: ; preds = %0
%12 = load i32, i32* %2
%13 = call i32 @check_prime(i32 %12)
store i32 %13, i32* %3
%14 = load i32, i32* %3
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %11
%17 = load i32, i32* %2
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %17)
br label %40
19: ; preds = %11
%20 = load i32, i32* %2
%21 = add nsw i32 %20, 1
store i32 %21, i32* %4
br label %22
22: ; preds = %34, %19
%23 = load i32, i32* %4
%24 = load i32, i32* %2
%25 = add nsw i32 %24, 20
%26 = icmp sle i32 %23, %25
br i1 %26, label %27, label %37
27: ; preds = %22
%28 = load i32, i32* %4
%29 = call i32 @check_prime(i32 %28)
store i32 %29, i32* %3
%30 = load i32, i32* %3
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %33
32: ; preds = %27
br label %37
33: ; preds = %27
br label %34
34: ; preds = %33
%35 = load i32, i32* %4
%36 = add nsw i32 %35, 1
store i32 %36, i32* %4
br label %22
37: ; preds = %32, %22
%38 = load i32, i32* %4
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %38)
br label %40
40: ; preds = %37, %16
br label %41
41: ; preds = %40, %9
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%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, 1
br i1 %5, label %6, label %8
6: ; preds = %0
%7 = call i32 @putchar(i32 50)
br label %28
8: ; preds = %0
%9 = call i32 @check_prime(i32 %4)
%10 = icmp eq i32 %9, 0
%11 = load i32, i32* %1
br i1 %10, label %14, label %12
12: ; preds = %8
%13 = add nsw i32 %11, 1
br label %16
14: ; preds = %8
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %11)
br label %28
16: ; preds = %12, %20
%17 = phi i32 [ %13, %12 ], [ %22, %20 ]
%18 = call i32 @check_prime(i32 %17)
%19 = icmp eq i32 %18, 0
br i1 %19, label %25, label %20
20: ; preds = %16
%21 = load i32, i32* %1
%22 = add nsw i32 %17, 1
%23 = add nsw i32 %21, 20
%24 = icmp slt i32 %17, %23
br i1 %24, label %16, label %25
25: ; preds = %16, %20
%26 = phi i32 [ %17, %16 ], [ %22, %20 ]
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %26)
br label %28
28: ; preds = %14, %25, %6
ret i32 0
}