#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 scanf(char *, int *);
int main() {
  int i, n, result;
  int p, num1, num2, num;
  while (scanf("%d", &n) == 1) {
    result = check_prime(n);
    if (n == 1) {
      printf("%d is prime.\n", n);
    } else if (result == 1) {
      num1 = n;
      num2 = 0;
      while (num1 != 0) {
        p = num1 % 10;
        num2 = p + num2 * 10;
        num1 = num1 / 10;
      }
      num = check_prime(num2);
      if (num == 1 && num2 != n) {
        printf("%d is emirp.\n", n);
      } else {
        printf("%d is prime.\n", n);
      }
    } else {
      printf("%d is not prime.\n", n);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1050 <scanf@plt>
cmp    $0x1,%eax
jne    1231 <main+0x101>
mov    -0xc(%rbp),%edi
call   1030 <check_prime@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x1,-0xc(%rbp)
jne    1181 <main+0x51>
mov    -0xc(%rbp),%esi
lea    0xe8c(%rip),%rdi
call   1040 <printf@plt>
jmp    122c <main+0xfc>
cmpl   $0x1,-0x10(%rbp)
jne    1218 <main+0xe8>
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     11cf <main+0x9f>
mov    -0x18(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x14(%rbp)
mov    -0x14(%rbp),%eax
imul   $0xa,-0x1c(%rbp),%ecx
add    %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x18(%rbp)
jmp    1198 <main+0x68>
mov    -0x1c(%rbp),%edi
call   1030 <check_prime@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x1,-0x20(%rbp)
jne    1204 <main+0xd4>
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
je     1204 <main+0xd4>
mov    -0xc(%rbp),%esi
lea    0xe17(%rip),%rdi
call   1040 <printf@plt>
jmp    1213 <main+0xe3>
mov    -0xc(%rbp),%esi
lea    0xdf5(%rip),%rdi
call   1040 <printf@plt>
jmp    1227 <main+0xf7>
mov    -0xc(%rbp),%esi
lea    0xdfd(%rip),%rdi
call   1040 <printf@plt>
jmp    122c <main+0xfc>
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>
cmp    $0x1,%eax
jne    1224 <main+0xf4>
lea    0xea7(%rip),%r14
lea    0xe9d(%rip),%r15
lea    0x4(%rsp),%rbx
lea    0xea2(%rip),%r12
lea    0xea9(%rip),%r13
jmp    11a1 <main+0x71>
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    $0x1,%esi
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
cmp    $0x1,%eax
jne    1224 <main+0xf4>
mov    0x4(%rsp),%edi
call   1030 <check_prime@plt>
mov    0x4(%rsp),%esi
cmp    $0x1,%esi
je     1180 <main+0x50>
cmp    $0x1,%eax
jne    1210 <main+0xe0>
xor    %ebp,%ebp
test   %esi,%esi
je     11f0 <main+0xc0>
xchg   %ax,%ax
lea    0x0(%rbp,%rbp,4),%eax
movslq %esi,%rcx
imul   $0x66666667,%rcx,%rsi
mov    %rsi,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rsi
add    %edx,%esi
lea    (%rsi,%rsi,1),%edx
lea    (%rdx,%rdx,4),%edx
mov    %ecx,%edi
sub    %edx,%edi
lea    (%rdi,%rax,2),%ebp
add    $0x9,%ecx
cmp    $0x12,%ecx
ja     11c0 <main+0x90>
mov    %ebp,%edi
call   1030 <check_prime@plt>
mov    0x4(%rsp),%esi
cmp    $0x1,%eax
jne    1218 <main+0xe8>
cmp    %esi,%ebp
je     121a <main+0xea>
mov    %r12,%rdi
jmp    1188 <main+0x58>
nopl   0x0(%rax)
mov    %r13,%rdi
jmp    1188 <main+0x58>
mov    %esi,%ebp
mov    %r14,%rdi
mov    %ebp,%esi
jmp    1188 <main+0x58>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [14 x i8] c"%d is prime.\0A\00"
@.str.2 = [14 x i8] c"%d is emirp.\0A\00"
@.str.3 = [18 x i8] c"%d is not prime.\0A\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
br label %9
9: ; preds = %57, %0
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%11 = icmp eq i32 %10, 1
br i1 %11, label %12, label %58
12: ; preds = %9
%13 = load i32, i32* %3
%14 = call i32 @check_prime(i32 %13)
store i32 %14, i32* %4
%15 = load i32, i32* %3
%16 = icmp eq i32 %15, 1
br i1 %16, label %17, label %20
17: ; preds = %12
%18 = load i32, i32* %3
%19 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %18)
br label %57
20: ; preds = %12
%21 = load i32, i32* %4
%22 = icmp eq i32 %21, 1
br i1 %22, label %23, label %53
23: ; preds = %20
%24 = load i32, i32* %3
store i32 %24, i32* %6
store i32 0, i32* %7
br label %25
25: ; preds = %28, %23
%26 = load i32, i32* %6
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %37
28: ; preds = %25
%29 = load i32, i32* %6
%30 = srem i32 %29, 10
store i32 %30, i32* %5
%31 = load i32, i32* %5
%32 = load i32, i32* %7
%33 = mul nsw i32 %32, 10
%34 = add nsw i32 %31, %33
store i32 %34, i32* %7
%35 = load i32, i32* %6
%36 = sdiv i32 %35, 10
store i32 %36, i32* %6
br label %25
37: ; preds = %25
%38 = load i32, i32* %7
%39 = call i32 @check_prime(i32 %38)
store i32 %39, i32* %8
%40 = load i32, i32* %8
%41 = icmp eq i32 %40, 1
br i1 %41, label %42, label %49
42: ; preds = %37
%43 = load i32, i32* %7
%44 = load i32, i32* %3
%45 = icmp ne i32 %43, %44
br i1 %45, label %46, label %49
46: ; preds = %42
%47 = load i32, i32* %3
%48 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %47)
br label %52
49: ; preds = %42, %37
%50 = load i32, i32* %3
%51 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %50)
br label %52
52: ; preds = %49, %46
br label %56
53: ; preds = %20
%54 = load i32, i32* %3
%55 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i32 %54)
br label %56
56: ; preds = %53, %52
br label %57
57: ; preds = %56, %17
br label %9
58: ; preds = %9
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [14 x i8] c"%d is prime.\0A\00"
@.str.2 = [14 x i8] c"%d is emirp.\0A\00"
@.str.3 = [18 x i8] c"%d is not prime.\0A\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 = icmp eq i32 %3, 1
br i1 %4, label %5, label %42
5: ; preds = %0, %39
%6 = load i32, i32* %1
%7 = call i32 @check_prime(i32 %6)
%8 = load i32, i32* %1
%9 = icmp eq i32 %8, 1
br i1 %9, label %10, label %12
10: ; preds = %5
%11 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 1)
br label %39
12: ; preds = %5
%13 = icmp eq i32 %7, 1
br i1 %13, label %14, label %37
14: ; preds = %12
%15 = icmp eq i32 %8, 0
br i1 %15, label %25, label %16
16: ; preds = %14, %16
%17 = phi i32 [ %22, %16 ], [ %8, %14 ]
%18 = phi i32 [ %21, %16 ], [ 0, %14 ]
%19 = srem i32 %17, 10
%20 = mul nsw i32 %18, 10
%21 = add nsw i32 %19, %20
%22 = sdiv i32 %17, 10
%23 = add i32 %17, 9
%24 = icmp ult i32 %23, 19
br i1 %24, label %25, label %16
25: ; preds = %16, %14
%26 = phi i32 [ 0, %14 ], [ %21, %16 ]
%27 = call i32 @check_prime(i32 %26)
%28 = icmp eq i32 %27, 1
%29 = load i32, i32* %1
br i1 %28, label %30, label %34
30: ; preds = %25
%31 = icmp eq i32 %26, %29
br i1 %31, label %34, label %32
32: ; preds = %30
%33 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %29)
br label %39
34: ; preds = %25, %30
%35 = phi i32 [ %26, %30 ], [ %29, %25 ]
%36 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %35)
br label %39
37: ; preds = %12
%38 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i32 %8)
br label %39
39: ; preds = %37, %34, %32, %10
%40 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%41 = icmp eq i32 %40, 1
br i1 %41, label %5, label %42
42: ; preds = %39, %0
ret i32 0
}