#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__ pali(int);
scalar_t__ prime(int, int *);
int /*<<< orphan*/ printf(char *, int);
int main(void) {
  int primes[256] = {2, 3};
  int i, m = 3, c = 2;
  for (i = 5; i < 1000; i += 2) {
    if (prime(i, primes)) {
      primes[c++] = i;
      if (pali(i))
        m = i;
    }
  }
  printf("%d\n", m);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x410(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1050 <memset@plt>
movl   $0x2,-0x410(%rbp)
movl   $0x3,-0x40c(%rbp)
movl   $0x3,-0x418(%rbp)
movl   $0x2,-0x41c(%rbp)
movl   $0x5,-0x414(%rbp)
cmpl   $0x3e8,-0x414(%rbp)
jge    1222 <main+0xe2>
mov    -0x414(%rbp),%edi
lea    -0x410(%rbp),%rsi
call   1060 <prime@plt>
cmp    $0x0,%rax
je     1209 <main+0xc9>
mov    -0x414(%rbp),%ecx
mov    -0x41c(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x41c(%rbp)
cltq
mov    %ecx,-0x410(%rbp,%rax,4)
mov    -0x414(%rbp),%edi
call   1040 <pali@plt>
cmp    $0x0,%rax
je     1204 <main+0xc4>
mov    -0x414(%rbp),%eax
mov    %eax,-0x418(%rbp)
jmp    1209 <main+0xc9>
jmp    120e <main+0xce>
mov    -0x414(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x414(%rbp)
jmp    1197 <main+0x57>
mov    -0x418(%rbp),%esi
lea    0xdd1(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x408,%rsp
mov    %rsp,%r14
mov    $0x400,%edx
mov    %r14,%rdi
xor    %esi,%esi
call   1050 <memset@plt>
movabs $0x300000002,%rax
mov    %rax,(%rsp)
mov    $0x2,%ebp
mov    $0x3,%ebx
mov    $0x3,%r15d
jmp    1188 <main+0x48>
nop
cmp    $0x3e6,%ebx
jae    11b3 <main+0x73>
add    $0x2,%ebx
mov    %ebx,%edi
mov    %r14,%rsi
call   1060 <prime@plt>
test   %rax,%rax
je     1180 <main+0x40>
movslq %ebp,%rax
add    $0x1,%ebp
mov    %ebx,(%rsp,%rax,4)
mov    %ebx,%edi
call   1040 <pali@plt>
test   %rax,%rax
cmovne %ebx,%r15d
jmp    1180 <main+0x40>
lea    0xe46(%rip),%rdi
mov    %r15d,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x408,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca [256 x i32]
%2 = bitcast [256 x i32]* %1 to i8*
%3 = getelementptr inbounds [256 x i32], [256 x i32]* %1, i64 0, i64 0
store i32 2, i32* %3
%4 = getelementptr inbounds [256 x i32], [256 x i32]* %1, i64 0, i64 1
store i32 3, i32* %4
br label %5
5: ; preds = %0, %18
%6 = phi i32 [ 2, %0 ], [ %20, %18 ]
%7 = phi i32 [ 3, %0 ], [ %19, %18 ]
%8 = phi i32 [ 5, %0 ], [ %21, %18 ]
%9 = call i64 @prime(i32 %8, i32* %3)
%10 = icmp eq i64 %9, 0
br i1 %10, label %18, label %11
11: ; preds = %5
%12 = add nsw i32 %6, 1
%13 = sext i32 %6 to i64
%14 = getelementptr inbounds [256 x i32], [256 x i32]* %1, i64 0, i64 %13
store i32 %8, i32* %14
%15 = call i64 @pali(i32 %8)
%16 = icmp eq i64 %15, 0
%17 = select i1 %16, i32 %7, i32 %8
br label %18
18: ; preds = %11, %5
%19 = phi i32 [ %7, %5 ], [ %17, %11 ]
%20 = phi i32 [ %6, %5 ], [ %12, %11 ]
%21 = add nuw nsw i32 %8, 2
%22 = icmp ult i32 %8, 998
br i1 %22, label %5, label %23
23: ; preds = %18
%24 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %19)
ret i32 0
}