#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;
scalar_t__ check_pandigital(unsigned int);
double clock();
int pow(int, int);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  double start, end;
  unsigned int total = 0, totals[(int)(1 * pow(10, 4))];
  start = clock();
  printf("Algorithm starts, please wait...\n");
  for (unsigned int i = (int)((int)(1 * pow(10, 4)) / 2);
       i <= (int)(1 * pow(10, 4)); i++) {
    total = i * 2 + (int)(1 * pow(10, 4)) * (i);
    if (check_pandigital(total)) {
      totals[i] = total;
    }
  }
  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,-0x24(%rbp)
mov    $0xa,%edi
mov    $0x4,%esi
call   1060 <pow@plt>
mov    %eax,%eax
mov    %rsp,%rcx
mov    %rcx,-0x30(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x48(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x38(%rbp)
mov    $0x0,%al
call   1030 <clock@plt>
movsd  %xmm0,-0x18(%rbp)
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0xa,%edi
mov    $0x4,%esi
call   1060 <pow@plt>
shl    $0x0,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
mov    %eax,-0x4c(%rbp)
mov    $0xa,%edi
mov    $0x4,%esi
call   1060 <pow@plt>
mov    %eax,%ecx
mov    -0x4c(%rbp),%eax
shl    $0x0,%ecx
cmp    %ecx,%eax
ja     1249 <main+0x109>
mov    -0x3c(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x50(%rbp)
mov    $0xa,%edi
mov    $0x4,%esi
call   1060 <pow@plt>
mov    %eax,%ecx
mov    -0x50(%rbp),%eax
shl    $0x0,%ecx
imul   -0x3c(%rbp),%ecx
add    %ecx,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%edi
call   1050 <check_pandigital@plt>
cmp    $0x0,%rax
je     1236 <main+0xf6>
mov    -0x48(%rbp),%rax
mov    -0x24(%rbp),%edx
mov    -0x3c(%rbp),%ecx
mov    %edx,(%rax,%rcx,4)
jmp    123b <main+0xfb>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    11c9 <main+0x89>
mov    $0x0,%al
call   1030 <clock@plt>
movsd  %xmm0,-0x20(%rbp)
lea    0xdc6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movsd  -0x20(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
mov    0x2d74(%rip),%rax
divsd  (%rax),%xmm0
lea    0xdb3(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
mov    $0xa,%edi
mov    $0x4,%esi
call   1070 <pow@plt>
xor    %eax,%eax
call   1040 <clock@plt>
movsd  %xmm0,0x8(%rsp)
lea    0xe98(%rip),%rdi
call   1030 <puts@plt>
mov    $0xa,%edi
mov    $0x4,%esi
call   1070 <pow@plt>
mov    %eax,%ebx
shr    $0x1f,%ebx
add    %eax,%ebx
sar    %ebx
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0xa,%edi
mov    $0x4,%esi
call   1070 <pow@plt>
cmp    %eax,%ebx
ja     11d2 <main+0x82>
mov    $0xa,%edi
mov    $0x4,%esi
call   1070 <pow@plt>
lea    0x2(%rax),%edi
imul   %ebx,%edi
call   1060 <check_pandigital@plt>
add    $0x1,%ebx
jmp    11a0 <main+0x50>
xor    %eax,%eax
call   1040 <clock@plt>
movsd  %xmm0,(%rsp)
lea    0xe4c(%rip),%rdi
call   1030 <puts@plt>
movsd  (%rsp),%xmm0
subsd  0x8(%rsp),%xmm0
mov    0x2dec(%rip),%rax
divsd  (%rax),%xmm0
lea    0xdf9(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
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 i8*
%10 = alloca i64
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %8
%12 = call i32 @pow(i32 10, i32 4)
%13 = mul nsw i32 1, %12
%14 = zext i32 %13 to i64
%15 = call i8* @llvm.stacksave()
store i8* %15, i8** %9
%16 = alloca i32, i64 %14
store i64 %14, i64* %10
%17 = call double (...) @clock()
store double %17, double* %6
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%19 = call i32 @pow(i32 10, i32 4)
%20 = mul nsw i32 1, %19
%21 = sdiv i32 %20, 2
store i32 %21, i32* %11
br label %22
22: ; preds = %44, %2
%23 = load i32, i32* %11
%24 = call i32 @pow(i32 10, i32 4)
%25 = mul nsw i32 1, %24
%26 = icmp ule i32 %23, %25
br i1 %26, label %27, label %47
27: ; preds = %22
%28 = load i32, i32* %11
%29 = mul i32 %28, 2
%30 = call i32 @pow(i32 10, i32 4)
%31 = mul nsw i32 1, %30
%32 = load i32, i32* %11
%33 = mul i32 %31, %32
%34 = add i32 %29, %33
store i32 %34, i32* %8
%35 = load i32, i32* %8
%36 = call i64 @check_pandigital(i32 %35)
%37 = icmp ne i64 %36, 0
br i1 %37, label %38, label %43
38: ; preds = %27
%39 = load i32, i32* %8
%40 = load i32, i32* %11
%41 = zext i32 %40 to i64
%42 = getelementptr inbounds i32, i32* %16, i64 %41
store i32 %39, i32* %42
br label %43
43: ; preds = %38, %27
br label %44
44: ; preds = %43
%45 = load i32, i32* %11
%46 = add i32 %45, 1
store i32 %46, i32* %11
br label %22
47: ; preds = %22
%48 = call double (...) @clock()
store double %48, double* %7
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%50 = load double, double* %7
%51 = load double, double* %6
%52 = fsub double %50, %51
%53 = load double, double* @CLOCKS_PER_SEC
%54 = fdiv double %52, %53
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), double %54)
store i32 0, i32* %3
%56 = load i8*, i8** %9
%57 = load i32, i32* %3
ret i32 %57
}

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 4)
%4 = tail call double (...) @clock()
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 @pow(i32 10, i32 4)
%7 = sdiv i32 %6, 2
%8 = tail call i32 @pow(i32 10, i32 4)
%9 = icmp ugt i32 %7, %8
br i1 %9, label %10, label %17
10: ; preds = %17, %2
%11 = tail call double (...) @clock()
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.3, i64 0, i64 0))
%13 = fsub double %11, %4
%14 = load double, double* @CLOCKS_PER_SEC
%15 = fdiv double %13, %14
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), double %15)
ret i32 0
17: ; preds = %2, %17
%18 = phi i32 [ %23, %17 ], [ %7, %2 ]
%19 = tail call i32 @pow(i32 10, i32 4)
%20 = add i32 %19, 2
%21 = mul i32 %20, %18
%22 = tail call i64 @check_pandigital(i32 %21)
%23 = add i32 %18, 1
%24 = tail call i32 @pow(i32 10, i32 4)
%25 = icmp ugt i32 %23, %24
br i1 %25, label %10, label %17
}