#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__ EOF;
scalar_t__ isPrime(int);
int /*<<< orphan*/ printf(char *, int);
scalar_t__ scanf(char *, int *);
int main() {
  int num, rev;
  int temp;
  while (scanf("%d\n", &num) != EOF) {
    temp = num;
    if (isPrime(temp) == 0) {
      printf("%d is not prime.\n", num);
    } else {
      rev = 0;
      while (temp > 0) {
        rev = rev * 10 + temp % 10;
        temp /= 10;
      }
      if (rev != num && isPrime(rev)) {
        printf("%d is emirp.\n", num);
      } else {
        printf("%d is prime.\n", num);
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
mov    0x2e92(%rip),%rcx
cmp    (%rcx),%rax
je     1214 <main+0xe4>
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%edi
call   1040 <isPrime@plt>
cmp    $0x0,%rax
jne    118b <main+0x5b>
mov    -0x8(%rbp),%esi
lea    0xe83(%rip),%rdi
call   1030 <printf@plt>
jmp    120f <main+0xdf>
movl   $0x0,-0xc(%rbp)
cmpl   $0x0,-0x10(%rbp)
jle    11c9 <main+0x99>
imul   $0xa,-0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    -0x14(%rbp),%eax
add    %edx,%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
jmp    1192 <main+0x62>
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
je     11fb <main+0xcb>
mov    -0xc(%rbp),%edi
call   1040 <isPrime@plt>
cmp    $0x0,%rax
je     11fb <main+0xcb>
mov    -0x8(%rbp),%esi
lea    0xe25(%rip),%rdi
call   1030 <printf@plt>
jmp    120a <main+0xda>
mov    -0x8(%rbp),%esi
lea    0xe1f(%rip),%rdi
call   1030 <printf@plt>
jmp    120f <main+0xdf>
jmp    113f <main+0xf>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xebe(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x2e95(%rip),%r13
cmp    0x0(%r13),%rax
jne    116a <main+0x3a>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe8f(%rip),%r15
lea    0x4(%rsp),%rbx
mov    $0xcccccccd,%r14d
lea    0xea1(%rip),%r12
jmp    11b1 <main+0x81>
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x4(%rsp),%esi
lea    0xe69(%rip),%rdi
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
cmp    0x0(%r13),%rax
je     1159 <main+0x29>
mov    0x4(%rsp),%ebp
mov    %ebp,%edi
call   1040 <isPrime@plt>
test   %rax,%rax
je     1190 <main+0x60>
xor    %esi,%esi
test   %ebp,%ebp
jle    11f1 <main+0xc1>
nopw   0x0(%rax,%rax,1)
lea    (%rsi,%rsi,4),%eax
mov    %ebp,%ecx
imul   %r14,%rcx
shr    $0x23,%rcx
lea    (%rcx,%rcx,1),%edx
lea    (%rdx,%rdx,4),%edx
mov    %ebp,%esi
sub    %edx,%esi
lea    (%rsi,%rax,2),%esi
cmp    $0x9,%ebp
mov    %ecx,%ebp
ja     11d0 <main+0xa0>
cmp    0x4(%rsp),%esi
je     1210 <main+0xe0>
mov    %esi,%edi
call   1040 <isPrime@plt>
mov    0x4(%rsp),%esi
test   %rax,%rax
je     1210 <main+0xe0>
lea    0xe08(%rip),%rdi
jmp    1213 <main+0xe3>
mov    %r12,%rdi
jmp    119b <main+0x6b>

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

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
@EOF = global i64 0
@.str.1 = [18 x i8] c"%d is not prime.\0A\00"
@.str.2 = [14 x i8] c"%d is emirp.\0A\00"
@.str.3 = [14 x i8] c"%d is prime.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i64 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %1)
%4 = load i64, i64* @EOF
%5 = icmp eq i64 %3, %4
br i1 %5, label %40, label %6
6: ; preds = %0, %36
%7 = load i32, i32* %1
%8 = call i64 @isPrime(i32 %7)
%9 = icmp eq i64 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %6
%11 = icmp sgt i32 %7, 0
br i1 %11, label %15, label %23
12: ; preds = %6
%13 = load i32, i32* %1
%14 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %13)
br label %36
15: ; preds = %10, %15
%16 = phi i32 [ %21, %15 ], [ %7, %10 ]
%17 = phi i32 [ %20, %15 ], [ 0, %10 ]
%18 = mul nsw i32 %17, 10
%19 = urem i32 %16, 10
%20 = add nsw i32 %19, %18
%21 = udiv i32 %16, 10
%22 = icmp ult i32 %16, 10
br i1 %22, label %23, label %15
23: ; preds = %15, %10
%24 = phi i32 [ 0, %10 ], [ %20, %15 ]
%25 = load i32, i32* %1
%26 = icmp eq i32 %24, %25
br i1 %26, label %33, label %27
27: ; preds = %23
%28 = call i64 @isPrime(i32 %24)
%29 = icmp eq i64 %28, 0
%30 = load i32, i32* %1
br i1 %29, label %33, label %31
31: ; preds = %27
%32 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %30)
br label %36
33: ; preds = %27, %23
%34 = phi i32 [ %24, %23 ], [ %30, %27 ]
%35 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %34)
br label %36
36: ; preds = %31, %33, %12
%37 = call i64 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %1)
%38 = load i64, i64* @EOF
%39 = icmp eq i64 %37, %38
br i1 %39, label %40, label %6
40: ; preds = %36, %0
ret i32 0
}