#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;
double clock();
int is_validate(unsigned int);
int pow(int, int);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  double start, end;
  unsigned int total = 0;
  printf("Algorithm starts, please wait...\n");
  start = clock();
  for (unsigned int i = 1; i < (int)(1 * pow(10, 6)); i++) {
    if (is_validate(i) == 1)
      total += i;
  }
  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    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x24(%rbp)
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <clock@plt>
movsd  %xmm0,-0x18(%rbp)
movl   $0x1,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    $0xa,%edi
mov    $0x6,%esi
call   1050 <pow@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
shl    $0x0,%ecx
cmp    %ecx,%eax
jae    11d0 <main+0x90>
mov    -0x28(%rbp),%edi
call   1060 <is_validate@plt>
cmp    $0x1,%eax
jne    11bd <main+0x7d>
mov    -0x28(%rbp),%eax
add    -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
jmp    11c2 <main+0x82>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    117e <main+0x3e>
mov    $0x0,%al
call   1030 <clock@plt>
movsd  %xmm0,-0x20(%rbp)
lea    0xe3f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movsd  -0x20(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
mov    0x2ded(%rip),%rax
divsd  (%rax),%xmm0
lea    0xe2c(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xeb4(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1040 <clock@plt>
movsd  %xmm0,0x8(%rsp)
mov    $0xa,%edi
mov    $0x6,%esi
call   1060 <pow@plt>
cmp    $0x2,%eax
jb     11ad <main+0x5d>
mov    $0x1,%ebx
nopw   0x0(%rax,%rax,1)
mov    %ebx,%edi
call   1070 <is_validate@plt>
add    $0x1,%ebx
mov    $0xa,%edi
mov    $0x6,%esi
call   1060 <pow@plt>
cmp    %eax,%ebx
jb     1190 <main+0x40>
xor    %eax,%eax
call   1040 <clock@plt>
movsd  %xmm0,(%rsp)
lea    0xe71(%rip),%rdi
call   1030 <puts@plt>
movsd  (%rsp),%xmm0
subsd  0x8(%rsp),%xmm0
mov    0x2e11(%rip),%rax
divsd  (%rax),%xmm0
lea    0xe1e(%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 i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %8
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%11 = call double (...) @clock()
store double %11, double* %6
store i32 1, i32* %9
br label %12
12: ; preds = %26, %2
%13 = load i32, i32* %9
%14 = call i32 @pow(i32 10, i32 6)
%15 = mul nsw i32 1, %14
%16 = icmp ult i32 %13, %15
br i1 %16, label %17, label %29
17: ; preds = %12
%18 = load i32, i32* %9
%19 = call i32 @is_validate(i32 %18)
%20 = icmp eq i32 %19, 1
br i1 %20, label %21, label %25
21: ; preds = %17
%22 = load i32, i32* %9
%23 = load i32, i32* %8
%24 = add i32 %23, %22
store i32 %24, i32* %8
br label %25
25: ; preds = %21, %17
br label %26
26: ; preds = %25
%27 = load i32, i32* %9
%28 = add i32 %27, 1
store i32 %28, i32* %9
br label %12
29: ; preds = %12
%30 = call double (...) @clock()
store double %30, double* %7
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%32 = load double, double* %7
%33 = load double, double* %6
%34 = fsub double %32, %33
%35 = load double, double* @CLOCKS_PER_SEC
%36 = fdiv double %34, %35
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), double %36)
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 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
%4 = tail call double (...) @clock()
%5 = tail call i32 @pow(i32 10, i32 6)
%6 = icmp ugt i32 %5, 1
br i1 %6, label %14, label %7
7: ; preds = %14, %2
%8 = tail call double (...) @clock()
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.3, i64 0, i64 0))
%10 = fsub double %8, %4
%11 = load double, double* @CLOCKS_PER_SEC
%12 = fdiv double %10, %11
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), double %12)
ret i32 0
14: ; preds = %2, %14
%15 = phi i32 [ %17, %14 ], [ 1, %2 ]
%16 = tail call i32 @is_validate(i32 %15)
%17 = add nuw i32 %15, 1
%18 = tail call i32 @pow(i32 10, i32 6)
%19 = icmp ult i32 %17, %18
br i1 %19, label %14, label %7
}