#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 a, b, n, i, c = 0, d, x = 0;
  scanf("%d", &n);
  a = check_prime(n);
  if (a == 0) {
    for (i = n + 1; 1; i++) {
      b = check_prime(i);
      if (b != 0) {
        printf("%d", b);
        break;
      }
    }
  } else
    printf("%d", a);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
lea    0xeac(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x10(%rbp),%edi
call   1030 <check_prime@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    11cb <main+0x9b>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    $0x1,%al
test   $0x1,%al
jne    118a <main+0x5a>
jmp    11c6 <main+0x96>
mov    -0x14(%rbp),%edi
call   1030 <check_prime@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     11b3 <main+0x83>
mov    -0xc(%rbp),%esi
lea    0xe57(%rip),%rdi
call   1040 <printf@plt>
jmp    11c6 <main+0x96>
jmp    11b8 <main+0x88>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    117b <main+0x4b>
jmp    11da <main+0xaa>
mov    -0x8(%rbp),%esi
lea    0xe2b(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xec4(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%edi
call   1030 <check_prime@plt>
test   %eax,%eax
jne    116e <main+0x3e>
mov    0xc(%rsp),%ebx
add    $0x1,%ebx
nopw   0x0(%rax,%rax,1)
mov    %ebx,%edi
call   1030 <check_prime@plt>
add    $0x1,%ebx
test   %eax,%eax
je     1160 <main+0x30>
lea    0xe8b(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
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
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %6
store i32 0, i32* %8
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%10 = load i32, i32* %4
%11 = call i32 @check_prime(i32 %10)
store i32 %11, i32* %2
%12 = load i32, i32* %2
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %31
14: ; preds = %0
%15 = load i32, i32* %4
%16 = add nsw i32 %15, 1
store i32 %16, i32* %5
br label %17
17: ; preds = %27, %14
br i1 true, label %18, label %30
18: ; preds = %17
%19 = load i32, i32* %5
%20 = call i32 @check_prime(i32 %19)
store i32 %20, i32* %3
%21 = load i32, i32* %3
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %18
%24 = load i32, i32* %3
%25 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %24)
br label %30
26: ; preds = %18
br label %27
27: ; preds = %26
%28 = load i32, i32* %5
%29 = add nsw i32 %28, 1
store i32 %29, i32* %5
br label %17
30: ; preds = %23, %17
br label %34
31: ; preds = %0
%32 = load i32, i32* %2
%33 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %32)
br label %34
34: ; preds = %31, %30
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
br i1 %6, label %7, label %14
7: ; preds = %0
%8 = load i32, i32* %1
br label %9
9: ; preds = %9, %7
%10 = phi i32 [ %8, %7 ], [ %11, %9 ]
%11 = add nsw i32 %10, 1
%12 = call i32 @check_prime(i32 %11)
%13 = icmp eq i32 %12, 0
br i1 %13, label %9, label %14
14: ; preds = %9, %0
%15 = phi i32 [ %5, %0 ], [ %12, %9 ]
%16 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %15)
ret i32 0
}