#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__ prime(int);
int /*<<< orphan*/ printf(char *, int);
int reverse(int);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int num, rev;
  scanf("%d", &num);
  while (1) {
    rev = reverse(num);
    if (num == rev) {
      if (prime(num)) {
        printf("%d", num);
        break;
      } else {
        num++;
      }
    } else {
      num++;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x8(%rbp),%edi
call   1030 <reverse@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    11aa <main+0x6a>
mov    -0x8(%rbp),%edi
call   1060 <prime@plt>
cmp    $0x0,%rax
je     119c <main+0x5c>
mov    -0x8(%rbp),%esi
lea    0xe6e(%rip),%rdi
call   1040 <printf@plt>
jmp    11b8 <main+0x78>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11b3 <main+0x73>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    115f <main+0x1f>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xeb8(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%esi
jmp    1167 <main+0x27>
nopl   0x0(%rax,%rax,1)
add    $0x1,%esi
mov    %esi,0x4(%rsp)
mov    %esi,%edi
call   1030 <reverse@plt>
mov    0x4(%rsp),%esi
cmp    %eax,%esi
jne    1160 <main+0x20>
mov    %eax,%edi
call   1060 <prime@plt>
mov    0x4(%rsp),%esi
test   %rax,%rax
je     1160 <main+0x20>
lea    0xe73(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

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