#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 /*<<< orphan*/ preparePrimeSieve(int *, int);
int /*<<< orphan*/ printf(char *, int);
int reverseNum(int);
scalar_t__ scanf(char *, int *);
int main(void) {
  int primeSieve[1000000], n, reverseN;
  preparePrimeSieve(primeSieve, 1000000);
  while (scanf("%d", &n) > 0) {
    if (primeSieve[n]) {
      reverseN = reverseNum(n);
      if (reverseN != n && primeSieve[reverseN])
        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    $0x3d0920,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x3d0910(%rbp),%rdi
mov    $0xf4240,%esi
call   1050 <preparePrimeSieve@plt>
lea    0xe96(%rip),%rdi
lea    -0x3d0914(%rbp),%rsi
call   1060 <scanf@plt>
cmp    $0x0,%rax
jle    1212 <main+0xd2>
movslq -0x3d0914(%rbp),%rax
cmpl   $0x0,-0x3d0910(%rbp,%rax,4)
je     11fb <main+0xbb>
mov    -0x3d0914(%rbp),%edi
call   1040 <reverseNum@plt>
mov    %eax,-0x3d0918(%rbp)
mov    -0x3d0918(%rbp),%eax
cmp    -0x3d0914(%rbp),%eax
je     11e4 <main+0xa4>
movslq -0x3d0918(%rbp),%rax
cmpl   $0x0,-0x3d0910(%rbp,%rax,4)
je     11e4 <main+0xa4>
mov    -0x3d0914(%rbp),%esi
lea    0xe29(%rip),%rdi
call   1030 <printf@plt>
jmp    11f6 <main+0xb6>
mov    -0x3d0914(%rbp),%esi
lea    0xe20(%rip),%rdi
call   1030 <printf@plt>
jmp    120d <main+0xcd>
mov    -0x3d0914(%rbp),%esi
lea    0xe17(%rip),%rdi
call   1030 <printf@plt>
jmp    1163 <main+0x23>
xor    %eax,%eax
add    $0x3d0920,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x3d0910,%rsp
lea    0x10(%rsp),%rdi
mov    $0xf4240,%esi
call   1050 <preparePrimeSieve@plt>
lea    0xe9a(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
test   %rax,%rax
jle    11f5 <main+0xb5>
lea    0xe9f(%rip),%r14
lea    0xe79(%rip),%r15
lea    0xc(%rsp),%rbx
lea    0xe7e(%rip),%r12
lea    0xe69(%rip),%r13
jmp    11b8 <main+0x78>
nopl   0x0(%rax)
mov    %r12,%rdi
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
test   %rax,%rax
jle    11f5 <main+0xb5>
movslq 0xc(%rsp),%rsi
cmpl   $0x0,0x10(%rsp,%rsi,4)
je     11f0 <main+0xb0>
mov    %esi,%edi
call   1040 <reverseNum@plt>
mov    0xc(%rsp),%esi
cmp    %esi,%eax
je     11a0 <main+0x60>
cltq
cmpl   $0x0,0x10(%rsp,%rax,4)
je     11a0 <main+0x60>
mov    %r13,%rdi
jmp    11a3 <main+0x63>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
jmp    11a3 <main+0x63>
xor    %eax,%eax
add    $0x3d0910,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

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