#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);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int num, check, i, count = 0;
  scanf("%d", &num);
  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>
mov    -0x8(%rbp),%edi
call   1030 <check_prime@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    117f <main+0x4f>
mov    -0x8(%rbp),%esi
lea    0xe8b(%rip),%rdi
call   1040 <printf@plt>
jmp    11d5 <main+0xa5>
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     11c6 <main+0x96>
mov    -0x10(%rbp),%edi
call   1030 <check_prime@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    11b3 <main+0x83>
jmp    11c6 <main+0x96>
jmp    11b8 <main+0x88>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1188 <main+0x58>
mov    -0x10(%rbp),%esi
lea    0xe30(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0xec6(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%edi
call   1030 <check_prime@plt>
mov    0x4(%rsp),%ebx
test   %eax,%eax
je     1185 <main+0x55>
cs nopw 0x0(%rax,%rax,1)
nop
lea    0x1(%rbx),%ebp
mov    %ebp,%edi
call   1030 <check_prime@plt>
test   %eax,%eax
je     1182 <main+0x52>
mov    0x4(%rsp),%eax
add    $0x14,%eax
mov    %ebp,%ebx
cmp    %eax,%ebp
jl     1160 <main+0x30>
add    $0x1,%ebp
mov    %ebp,%ebx
jmp    1185 <main+0x55>
add    $0x1,%ebx
lea    0xe74(%rip),%rdi
mov    %ebx,%esi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\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 = call i32 @check_prime(i32 %7)
store i32 %8, i32* %3
%9 = load i32, i32* %3
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %0
%12 = load i32, i32* %2
%13 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %12)
br label %35
14: ; preds = %0
%15 = load i32, i32* %2
%16 = add nsw i32 %15, 1
store i32 %16, i32* %4
br label %17
17: ; preds = %29, %14
%18 = load i32, i32* %4
%19 = load i32, i32* %2
%20 = add nsw i32 %19, 20
%21 = icmp sle i32 %18, %20
br i1 %21, label %22, label %32
22: ; preds = %17
%23 = load i32, i32* %4
%24 = call i32 @check_prime(i32 %23)
store i32 %24, i32* %3
%25 = load i32, i32* %3
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %22
br label %32
28: ; preds = %22
br label %29
29: ; preds = %28
%30 = load i32, i32* %4
%31 = add nsw i32 %30, 1
store i32 %31, i32* %4
br label %17
32: ; preds = %27, %17
%33 = load i32, i32* %4
%34 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %33)
br label %35
35: ; preds = %32, %11
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 = call i32 @check_prime(i32 %4)
%6 = icmp eq i32 %5, 0
%7 = load i32, i32* %1
br i1 %6, label %19, label %8
8: ; preds = %0
%9 = add nsw i32 %7, 1
br label %10
10: ; preds = %8, %14
%11 = phi i32 [ %9, %8 ], [ %16, %14 ]
%12 = call i32 @check_prime(i32 %11)
%13 = icmp eq i32 %12, 0
br i1 %13, label %19, label %14
14: ; preds = %10
%15 = load i32, i32* %1
%16 = add nsw i32 %11, 1
%17 = add nsw i32 %15, 20
%18 = icmp slt i32 %11, %17
br i1 %18, label %10, label %19
19: ; preds = %14, %10, %0
%20 = phi i32 [ %7, %0 ], [ %16, %14 ], [ %11, %10 ]
%21 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %20)
ret i32 0
}