#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 */
scalar_t__ check_palindrome(int);
scalar_t__ check_prime(int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, int *);
int main(int argc, char const *argv[]) {
  int number = 0;
  scanf("%d", &number);
  while (number <= 1003001) {
    if (check_palindrome(number) && check_prime(number)) {
      printf("%d\n", number);
      break;
    }
    number++;
  }
  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)
movl   $0x0,-0x14(%rbp)
lea    0xe9c(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0xf4df9,-0x14(%rbp)
jg     11c0 <main+0x80>
mov    -0x14(%rbp),%edi
call   1060 <check_palindrome@plt>
cmp    $0x0,%rax
je     11b2 <main+0x72>
mov    -0x14(%rbp),%edi
call   1030 <check_prime@plt>
cmp    $0x0,%rax
je     11b2 <main+0x72>
mov    -0x14(%rbp),%esi
lea    0xe5b(%rip),%rdi
call   1040 <printf@plt>
jmp    11c0 <main+0x80>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    116d <main+0x2d>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
movl   $0x0,0x4(%rsp)
lea    0xeb0(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%edi
cmp    $0xf4df9,%edi
jle    1182 <main+0x42>
jmp    11aa <main+0x6a>
nopl   0x0(%rax,%rax,1)
mov    0x4(%rsp),%eax
lea    0x1(%rax),%edi
mov    %edi,0x4(%rsp)
cmp    $0xf4df9,%eax
jge    11aa <main+0x6a>
call   1060 <check_palindrome@plt>
test   %rax,%rax
je     1170 <main+0x30>
mov    0x4(%rsp),%edi
call   1030 <check_prime@plt>
test   %rax,%rax
je     1170 <main+0x30>
mov    0x4(%rsp),%esi
lea    0xe5e(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %6)
br label %8
8: ; preds = %22, %2
%9 = load i32, i32* %6
%10 = icmp sle i32 %9, 1003001
br i1 %10, label %11, label %25
11: ; preds = %8
%12 = load i32, i32* %6
%13 = call i64 @check_palindrome(i32 %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %22
15: ; preds = %11
%16 = load i32, i32* %6
%17 = call i64 @check_prime(i32 %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %15
%20 = load i32, i32* %6
%21 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %20)
br label %25
22: ; preds = %15, %11
%23 = load i32, i32* %6
%24 = add nsw i32 %23, 1
store i32 %24, i32* %6
br label %8
25: ; preds = %19, %8
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, 1003002
br i1 %7, label %8, label %23
8: ; preds = %2, %19
%9 = phi i32 [ %21, %19 ], [ %6, %2 ]
%10 = call i64 @check_palindrome(i32 %9)
%11 = icmp eq i64 %10, 0
br i1 %11, label %19, label %12
12: ; preds = %8
%13 = load i32, i32* %3
%14 = call i64 @check_prime(i32 %13)
%15 = icmp eq i64 %14, 0
br i1 %15, label %19, label %16
16: ; preds = %12
%17 = load i32, i32* %3
%18 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %17)
br label %23
19: ; preds = %12, %8
%20 = load i32, i32* %3
%21 = add nsw i32 %20, 1
store i32 %21, i32* %3
%22 = icmp slt i32 %20, 1003001
br i1 %22, label %8, label %23
23: ; preds = %19, %2, %16
ret i32 0
}