#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 */
double CLOCKS_PER_SEC;
int /*<<< orphan*/ assert(unsigned int *);
double clock();
scalar_t__ is_pandigital(unsigned int);
unsigned int *malloc(int);
int pow(int, int);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  double start, end;
  unsigned int *primes, result = 0;
  assert(primes = malloc((int)(1 * pow(10, 7)) * sizeof(int)));
  primes[0] = primes[1] = 0;
  for (unsigned int i = 2; i < (int)(1 * pow(10, 7)); i++) {
    primes[i] = 1;
  }
  printf("Algorithm starts, please wait...\n");
  start = clock();
  for (unsigned int i = 2; i < 1000; i++) {
    if (primes[i]) {
      for (unsigned int j = (i * 2); j < (int)(1 * pow(10, 7)); j += i) {
        primes[j] = 0;
      }
    }
  }
  for (unsigned int i = ((int)(1 * pow(10, 7)) - 1); i > 0; i--) {
    if (primes[i] && is_pandigital(i)) {
      result = i;
      break;
    }
  }
  end = clock();
  printf("Algorithm end.\n");
  printf("Total time: %f\n", (end - start) / CLOCKS_PER_SEC);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    $0xa,%edi
mov    $0x7,%esi
call   1070 <pow@plt>
shl    $0x0,%eax
cltq
shl    $0x2,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,%rdi
mov    %rdi,-0x28(%rbp)
call   1050 <assert@plt>
mov    -0x28(%rbp),%rax
movl   $0x0,0x4(%rax)
mov    -0x28(%rbp),%rax
movl   $0x0,(%rax)
movl   $0x2,-0x30(%rbp)
mov    -0x30(%rbp),%eax
mov    %eax,-0x40(%rbp)
mov    $0xa,%edi
mov    $0x7,%esi
call   1070 <pow@plt>
mov    %eax,%ecx
mov    -0x40(%rbp),%eax
shl    $0x0,%ecx
cmp    %ecx,%eax
jae    1205 <main+0xa5>
mov    -0x28(%rbp),%rax
mov    -0x30(%rbp),%ecx
movl   $0x1,(%rax,%rcx,4)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    11c4 <main+0x64>
lea    0xdf4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <clock@plt>
movsd  %xmm0,-0x18(%rbp)
movl   $0x2,-0x34(%rbp)
cmpl   $0x3e8,-0x34(%rbp)
jae    12a6 <main+0x146>
mov    -0x28(%rbp),%rax
mov    -0x34(%rbp),%ecx
cmpl   $0x0,(%rax,%rcx,4)
je     1293 <main+0x133>
mov    -0x34(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    $0xa,%edi
mov    $0x7,%esi
call   1070 <pow@plt>
mov    %eax,%ecx
mov    -0x44(%rbp),%eax
shl    $0x0,%ecx
cmp    %ecx,%eax
jae    128e <main+0x12e>
mov    -0x28(%rbp),%rax
mov    -0x38(%rbp),%ecx
movl   $0x0,(%rax,%rcx,4)
mov    -0x34(%rbp),%eax
add    -0x38(%rbp),%eax
mov    %eax,-0x38(%rbp)
jmp    124d <main+0xed>
jmp    1293 <main+0x133>
jmp    1298 <main+0x138>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1226 <main+0xc6>
mov    $0xa,%edi
mov    $0x7,%esi
call   1070 <pow@plt>
shl    $0x0,%eax
sub    $0x1,%eax
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
jbe    1309 <main+0x1a9>
mov    -0x28(%rbp),%rax
mov    -0x3c(%rbp),%ecx
cmpl   $0x0,(%rax,%rcx,4)
je     12f6 <main+0x196>
mov    -0x3c(%rbp),%edi
call   1080 <is_pandigital@plt>
cmp    $0x0,%rax
je     12f6 <main+0x196>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
jmp    1309 <main+0x1a9>
jmp    12fb <main+0x19b>
mov    -0x3c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x3c(%rbp)
jmp    12be <main+0x15e>
mov    $0x0,%al
call   1030 <clock@plt>
movsd  %xmm0,-0x20(%rbp)
lea    0xd06(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movsd  -0x20(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
mov    0x2cb4(%rip),%rax
divsd  (%rax),%xmm0
lea    0xcf3(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    $0xa,%edi
mov    $0x7,%esi
call   1080 <pow@plt>
lea    0x0(,%rax,4),%edi
call   1070 <malloc@plt>
mov    %rax,%r14
mov    %rax,%rdi
call   1060 <assert@plt>
movq   $0x0,(%r14)
mov    $0xa,%edi
mov    $0x7,%esi
call   1080 <pow@plt>
cmp    $0x3,%eax
jb     11e2 <main+0x72>
mov    $0x2,%ebx
xchg   %ax,%ax
movl   $0x1,(%r14,%rbx,4)
add    $0x1,%rbx
mov    $0xa,%edi
mov    $0x7,%esi
call   1080 <pow@plt>
mov    %eax,%eax
cmp    %rax,%rbx
jb     11c0 <main+0x50>
lea    0xe27(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1040 <clock@plt>
movsd  %xmm0,0x8(%rsp)
mov    $0x2,%ebp
jmp    121d <main+0xad>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%rbp
cmp    $0x3e8,%rbp
je     1261 <main+0xf1>
cmpl   $0x0,(%r14,%rbp,4)
je     1210 <main+0xa0>
mov    %rbp,%rbx
add    %rbp,%rbx
mov    $0xa,%edi
mov    $0x7,%esi
call   1080 <pow@plt>
mov    %eax,%eax
cmp    %rax,%rbx
jae    1210 <main+0xa0>
mov    %ebx,%eax
movl   $0x0,(%r14,%rax,4)
add    %ebp,%ebx
mov    $0xa,%edi
mov    $0x7,%esi
call   1080 <pow@plt>
cmp    %eax,%ebx
jb     1240 <main+0xd0>
jmp    1210 <main+0xa0>
mov    $0xa,%edi
mov    $0x7,%esi
call   1080 <pow@plt>
mov    %eax,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0xffffffff,%ebp
je     129a <main+0x12a>
mov    %ebp,%eax
cmpl   $0x0,(%r14,%rax,4)
je     1280 <main+0x110>
mov    %ebp,%edi
call   1090 <is_pandigital@plt>
test   %rax,%rax
je     1280 <main+0x110>
xor    %eax,%eax
call   1040 <clock@plt>
movsd  %xmm0,(%rsp)
lea    0xd84(%rip),%rdi
call   1030 <puts@plt>
movsd  (%rsp),%xmm0
subsd  0x8(%rsp),%xmm0
mov    0x2d24(%rip),%rax
divsd  (%rax),%xmm0
lea    0xd31(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [34 x i8] c"Algorithm starts, please wait...\0A\00"
@.str.1 = [16 x i8] c"Algorithm end.\0A\00"
@.str.2 = [16 x i8] c"Total time: %f\0A\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca double
%7 = alloca double
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %9
%14 = call i32 @pow(i32 10, i32 7)
%15 = mul nsw i32 1, %14
%16 = sext i32 %15 to i64
%17 = mul i64 %16, 4
%18 = trunc i64 %17 to i32
%19 = call i32* @malloc(i32 %18)
store i32* %19, i32** %8
%20 = call i32 @assert(i32* %19)
%21 = load i32*, i32** %8
%22 = getelementptr inbounds i32, i32* %21, i64 1
store i32 0, i32* %22
%23 = load i32*, i32** %8
%24 = getelementptr inbounds i32, i32* %23, i64 0
store i32 0, i32* %24
store i32 2, i32* %10
br label %25
25: ; preds = %35, %2
%26 = load i32, i32* %10
%27 = call i32 @pow(i32 10, i32 7)
%28 = mul nsw i32 1, %27
%29 = icmp ult i32 %26, %28
br i1 %29, label %30, label %38
30: ; preds = %25
%31 = load i32*, i32** %8
%32 = load i32, i32* %10
%33 = zext i32 %32 to i64
%34 = getelementptr inbounds i32, i32* %31, i64 %33
store i32 1, i32* %34
br label %35
35: ; preds = %30
%36 = load i32, i32* %10
%37 = add i32 %36, 1
store i32 %37, i32* %10
br label %25
38: ; preds = %25
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%40 = call double (...) @clock()
store double %40, double* %6
store i32 2, i32* %11
br label %41
41: ; preds = %70, %38
%42 = load i32, i32* %11
%43 = icmp ult i32 %42, 1000
br i1 %43, label %44, label %73
44: ; preds = %41
%45 = load i32*, i32** %8
%46 = load i32, i32* %11
%47 = zext i32 %46 to i64
%48 = getelementptr inbounds i32, i32* %45, i64 %47
%49 = load i32, i32* %48
%50 = icmp ne i32 %49, 0
br i1 %50, label %51, label %69
51: ; preds = %44
%52 = load i32, i32* %11
%53 = mul i32 %52, 2
store i32 %53, i32* %12
br label %54
54: ; preds = %64, %51
%55 = load i32, i32* %12
%56 = call i32 @pow(i32 10, i32 7)
%57 = mul nsw i32 1, %56
%58 = icmp ult i32 %55, %57
br i1 %58, label %59, label %68
59: ; preds = %54
%60 = load i32*, i32** %8
%61 = load i32, i32* %12
%62 = zext i32 %61 to i64
%63 = getelementptr inbounds i32, i32* %60, i64 %62
store i32 0, i32* %63
br label %64
64: ; preds = %59
%65 = load i32, i32* %11
%66 = load i32, i32* %12
%67 = add i32 %66, %65
store i32 %67, i32* %12
br label %54
68: ; preds = %54
br label %69
69: ; preds = %68, %44
br label %70
70: ; preds = %69
%71 = load i32, i32* %11
%72 = add i32 %71, 1
store i32 %72, i32* %11
br label %41
73: ; preds = %41
%74 = call i32 @pow(i32 10, i32 7)
%75 = mul nsw i32 1, %74
%76 = sub nsw i32 %75, 1
store i32 %76, i32* %13
br label %77
77: ; preds = %94, %73
%78 = load i32, i32* %13
%79 = icmp ugt i32 %78, 0
br i1 %79, label %80, label %97
80: ; preds = %77
%81 = load i32*, i32** %8
%82 = load i32, i32* %13
%83 = zext i32 %82 to i64
%84 = getelementptr inbounds i32, i32* %81, i64 %83
%85 = load i32, i32* %84
%86 = icmp ne i32 %85, 0
br i1 %86, label %87, label %93
87: ; preds = %80
%88 = load i32, i32* %13
%89 = call i64 @is_pandigital(i32 %88)
%90 = icmp ne i64 %89, 0
br i1 %90, label %91, label %93
91: ; preds = %87
%92 = load i32, i32* %13
store i32 %92, i32* %9
br label %97
93: ; preds = %87, %80
br label %94
94: ; preds = %93
%95 = load i32, i32* %13
%96 = add i32 %95, -1
store i32 %96, i32* %13
br label %77
97: ; preds = %91, %77
%98 = call double (...) @clock()
store double %98, double* %7
%99 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%100 = load double, double* %7
%101 = load double, double* %6
%102 = fsub double %100, %101
%103 = load double, double* @CLOCKS_PER_SEC
%104 = fdiv double %102, %103
%105 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), double %104)
ret i32 0
}

LLVM IR (-O2):
@.str.2 = [16 x i8] c"Total time: %f\0A\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
@str = [33 x i8] c"Algorithm starts, please wait...\00"
@str.3 = [15 x i8] c"Algorithm end.\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @pow(i32 10, i32 7)
%4 = shl i32 %3, 2
%5 = tail call i32* @malloc(i32 %4)
%6 = tail call i32 @assert(i32* %5)
%7 = getelementptr inbounds i32, i32* %5, i64 1
store i32 0, i32* %7
store i32 0, i32* %5
%8 = tail call i32 @pow(i32 10, i32 7)
%9 = icmp ugt i32 %8, 2
br i1 %9, label %13, label %10
10: ; preds = %13, %2
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
%12 = tail call double (...) @clock()
br label %24
13: ; preds = %2, %13
%14 = phi i64 [ %16, %13 ], [ 2, %2 ]
%15 = getelementptr inbounds i32, i32* %5, i64 %14
store i32 1, i32* %15
%16 = add nuw nsw i64 %14, 1
%17 = tail call i32 @pow(i32 10, i32 7)
%18 = zext i32 %17 to i64
%19 = icmp ult i64 %16, %18
br i1 %19, label %13, label %10
20: ; preds = %44
%21 = tail call i32 @pow(i32 10, i32 7)
%22 = add i32 %21, -1
%23 = icmp eq i32 %22, 0
br i1 %23, label %64, label %47
24: ; preds = %10, %44
%25 = phi i64 [ 2, %10 ], [ %45, %44 ]
%26 = getelementptr inbounds i32, i32* %5, i64 %25
%27 = load i32, i32* %26
%28 = icmp eq i32 %27, 0
br i1 %28, label %44, label %29
29: ; preds = %24
%30 = shl nuw nsw i64 %25, 1
%31 = tail call i32 @pow(i32 10, i32 7)
%32 = zext i32 %31 to i64
%33 = icmp ult i64 %30, %32
br i1 %33, label %34, label %44
34: ; preds = %29
%35 = trunc i64 %30 to i32
%36 = trunc i64 %25 to i32
br label %37
37: ; preds = %34, %37
%38 = phi i32 [ %41, %37 ], [ %35, %34 ]
%39 = zext i32 %38 to i64
%40 = getelementptr inbounds i32, i32* %5, i64 %39
store i32 0, i32* %40
%41 = add i32 %38, %36
%42 = tail call i32 @pow(i32 10, i32 7)
%43 = icmp ult i32 %41, %42
br i1 %43, label %37, label %44
44: ; preds = %37, %29, %24
%45 = add nuw nsw i64 %25, 1
%46 = icmp eq i64 %45, 1000
br i1 %46, label %20, label %24
47: ; preds = %20, %62
%48 = phi i32 [ %63, %62 ], [ %22, %20 ]
%49 = zext i32 %48 to i64
%50 = getelementptr inbounds i32, i32* %5, i64 %49
%51 = load i32, i32* %50
%52 = icmp eq i32 %51, 0
br i1 %52, label %59, label %53
53: ; preds = %47
%54 = tail call i64 @is_pandigital(i32 %48)
%55 = icmp ne i64 %54, 0
%56 = add i32 %48, -1
%57 = icmp eq i32 %56, 0
%58 = select i1 %55, i1 true, i1 %57
br i1 %58, label %64, label %62
59: ; preds = %47
%60 = add i32 %48, -1
%61 = icmp eq i32 %60, 0
br i1 %61, label %64, label %62
62: ; preds = %59, %53
%63 = phi i32 [ %60, %59 ], [ %56, %53 ]
br label %47
64: ; preds = %59, %53, %20
%65 = tail call double (...) @clock()
%66 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.3, i64 0, i64 0))
%67 = fsub double %65, %12
%68 = load double, double* @CLOCKS_PER_SEC
%69 = fdiv double %67, %68
%70 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), double %69)
ret i32 0
}