#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 *generate_primes(int);
scalar_t__ pandigital(long);
int /*<<< orphan*/ printf(char *, int const);
int main(int argc, char **argv) {
  const int *primes = generate_primes(10000000);
  const int *last_prime = primes;
  for (; *last_prime; ++last_prime)
    ;
  --last_prime;
  for (const int *p = last_prime; p > primes; --p) {
    if (pandigital((long)*p)) {
      printf("%d\n", *p);
      break;
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x989680,%edi
call   1030 <generate_primes@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmpl   $0x0,(%rax)
je     117f <main+0x4f>
jmp    116e <main+0x3e>
mov    -0x20(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x20(%rbp)
jmp    115c <main+0x2c>
mov    -0x20(%rbp),%rax
add    $0xfffffffffffffffc,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x18(%rbp),%rax
jbe    11e4 <main+0xb4>
mov    -0x28(%rbp),%rax
movslq (%rax),%rdi
call   1050 <pandigital@plt>
cmp    $0x0,%rax
je     11ce <main+0x9e>
mov    -0x28(%rbp),%rax
mov    (%rax),%esi
lea    0xe3c(%rip),%rdi
call   1040 <printf@plt>
jmp    11e4 <main+0xb4>
jmp    11d3 <main+0xa3>
mov    -0x28(%rbp),%rax
add    $0xfffffffffffffffc,%rax
mov    %rax,-0x28(%rbp)
jmp    1193 <main+0x63>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0x989680,%edi
call   1030 <generate_primes@plt>
mov    %rax,%r14
lea    -0x8(%rax),%rbx
cs nopw 0x0(%rax,%rax,1)
nop
cmpl   $0x0,0x8(%rbx)
lea    0x4(%rbx),%rbx
jne    1150 <main+0x20>
jmp    1171 <main+0x41>
nopl   0x0(%rax)
movslq (%rbx),%rdi
call   1050 <pandigital@plt>
add    $0xfffffffffffffffc,%rbx
test   %rax,%rax
jne    1178 <main+0x48>
cmp    %r14,%rbx
ja     1160 <main+0x30>
jmp    1187 <main+0x57>
mov    0x4(%rbx),%esi
lea    0xe7e(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32* @generate_primes(i32 10000000)
br label %4
4: ; preds = %4, %2
%5 = phi i32* [ %3, %2 ], [ %8, %4 ]
%6 = load i32, i32* %5
%7 = icmp eq i32 %6, 0
%8 = getelementptr inbounds i32, i32* %5, i64 1
br i1 %7, label %9, label %4
9: ; preds = %4, %13
%10 = phi i32* [ %11, %13 ], [ %5, %4 ]
%11 = getelementptr inbounds i32, i32* %10, i64 -1
%12 = icmp ugt i32* %11, %3
br i1 %12, label %13, label %21
13: ; preds = %9
%14 = load i32, i32* %11
%15 = sext i32 %14 to i64
%16 = tail call i64 @pandigital(i64 %15)
%17 = icmp eq i64 %16, 0
br i1 %17, label %9, label %18
18: ; preds = %13
%19 = load i32, i32* %11
%20 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %19)
br label %21
21: ; preds = %9, %18
ret i32 0
}