#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 is_prime(int);
int /*<<< orphan*/ printf(char *, int);
int rev(int);
int scanf(char *, int *);
int /*<<< orphan*/ sieve();
int main() {
  int n;
  sieve();
  while (scanf("%d", &n) == 1) {
    if (rev(n) == 1 && is_prime(n) == 1)
      printf("%d is emirp.\n", n);
    else if (is_prime(n) == 1)
      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    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1050 <sieve@plt>
lea    0xe93(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1070 <scanf@plt>
cmp    $0x1,%eax
jne    11f3 <main+0xa3>
mov    -0x8(%rbp),%edi
call   1030 <rev@plt>
cmp    $0x1,%eax
jne    11b5 <main+0x65>
mov    -0x8(%rbp),%edi
call   1060 <is_prime@plt>
cmp    $0x1,%eax
jne    11b5 <main+0x65>
mov    -0x8(%rbp),%esi
lea    0xe58(%rip),%rdi
call   1040 <printf@plt>
jmp    11ee <main+0x9e>
mov    -0x8(%rbp),%edi
call   1060 <is_prime@plt>
cmp    $0x1,%eax
jne    11da <main+0x8a>
mov    -0x8(%rbp),%esi
lea    0xe41(%rip),%rdi
call   1040 <printf@plt>
jmp    11e9 <main+0x99>
mov    -0x8(%rbp),%esi
lea    0xe3b(%rip),%rdi
call   1040 <printf@plt>
jmp    11ee <main+0x9e>
jmp    1166 <main+0x16>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
xor    %eax,%eax
call   1050 <sieve@plt>
lea    0xe95(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1070 <scanf@plt>
cmp    $0x1,%eax
jne    11f7 <main+0xa7>
lea    0xe82(%rip),%r14
lea    0xe78(%rip),%r15
lea    0xc(%rsp),%rbx
lea    0xe7d(%rip),%r12
lea    0xe84(%rip),%r13
jmp    11b8 <main+0x68>
nopl   (%rax)
mov    %r13,%rdi
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1070 <scanf@plt>
cmp    $0x1,%eax
jne    11f7 <main+0xa7>
mov    0xc(%rsp),%edi
call   1030 <rev@plt>
cmp    $0x1,%eax
jne    11e0 <main+0x90>
mov    0xc(%rsp),%edi
call   1060 <is_prime@plt>
cmp    $0x1,%eax
jne    11e0 <main+0x90>
mov    0xc(%rsp),%esi
mov    %r14,%rdi
jmp    11a3 <main+0x53>
nopl   (%rax)
mov    0xc(%rsp),%edi
call   1060 <is_prime@plt>
mov    0xc(%rsp),%esi
cmp    $0x1,%eax
jne    11a0 <main+0x50>
mov    %r12,%rdi
jmp    11a3 <main+0x53>
xor    %eax,%eax
add    $0x10,%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 i32
store i32 0, i32* %1
%3 = call i32 (...) @sieve()
br label %4
4: ; preds = %29, %0
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%6 = icmp eq i32 %5, 1
br i1 %6, label %7, label %30
7: ; preds = %4
%8 = load i32, i32* %2
%9 = call i32 @rev(i32 %8)
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %18
11: ; preds = %7
%12 = load i32, i32* %2
%13 = call i32 @is_prime(i32 %12)
%14 = icmp eq i32 %13, 1
br i1 %14, label %15, label %18
15: ; preds = %11
%16 = load i32, i32* %2
%17 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %16)
br label %29
18: ; preds = %11, %7
%19 = load i32, i32* %2
%20 = call i32 @is_prime(i32 %19)
%21 = icmp eq i32 %20, 1
br i1 %21, label %22, label %25
22: ; preds = %18
%23 = load i32, i32* %2
%24 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %23)
br label %28
25: ; preds = %18
%26 = load i32, i32* %2
%27 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i32 %26)
br label %28
28: ; preds = %25, %22
br label %29
29: ; preds = %28, %15
br label %4
30: ; preds = %4
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 i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (...) @sieve()
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%5 = icmp eq i32 %4, 1
br i1 %5, label %6, label %29
6: ; preds = %0, %26
%7 = load i32, i32* %1
%8 = call i32 @rev(i32 %7)
%9 = icmp eq i32 %8, 1
br i1 %9, label %10, label %17
10: ; preds = %6
%11 = load i32, i32* %1
%12 = call i32 @is_prime(i32 %11)
%13 = icmp eq i32 %12, 1
br i1 %13, label %14, label %17
14: ; preds = %10
%15 = load i32, i32* %1
%16 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %15)
br label %26
17: ; preds = %10, %6
%18 = load i32, i32* %1
%19 = call i32 @is_prime(i32 %18)
%20 = icmp eq i32 %19, 1
%21 = load i32, i32* %1
br i1 %20, label %22, label %24
22: ; preds = %17
%23 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %21)
br label %26
24: ; preds = %17
%25 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i32 %21)
br label %26
26: ; preds = %22, %24, %14
%27 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%28 = icmp eq i32 %27, 1
br i1 %28, label %6, label %29
29: ; preds = %26, %0
ret i32 0
}