#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 /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  double start, end;
  unsigned long long int total = 0;
  printf("Algorithm stars... please wait.\n");
  start = clock();
  for (unsigned int i = 1; i <= 1000; i++) {
    unsigned long long int temp = i;
    for (unsigned int j = 0; j < (i - 1); j++) {
      temp = (temp * i) % 10000000000;
    }
    total = (total + temp) % 10000000000;
  }
  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    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x28(%rbp)
lea    0xebb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <clock@plt>
movsd  %xmm0,-0x18(%rbp)
movl   $0x1,-0x2c(%rbp)
cmpl   $0x3e8,-0x2c(%rbp)
ja     11e0 <main+0xc0>
mov    -0x2c(%rbp),%eax
mov    %rax,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
mov    -0x2c(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jae    11b7 <main+0x97>
mov    -0x38(%rbp),%rax
mov    -0x2c(%rbp),%ecx
imul   %rcx,%rax
movabs $0x2540be400,%rcx
xor    %edx,%edx
div    %rcx
mov    %rdx,-0x38(%rbp)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    117a <main+0x5a>
mov    -0x28(%rbp),%rax
add    -0x38(%rbp),%rax
movabs $0x2540be400,%rcx
xor    %edx,%edx
div    %rcx
mov    %rdx,-0x28(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    115f <main+0x3f>
mov    $0x0,%al
call   1030 <clock@plt>
movsd  %xmm0,-0x20(%rbp)
lea    0xe2e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movsd  -0x20(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
mov    0x2ddd(%rip),%rax
divsd  (%rax),%xmm0
lea    0xe1b(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xed5(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1040 <clock@plt>
movsd  %xmm0,0x10(%rsp)
xor    %eax,%eax
call   1040 <clock@plt>
movsd  %xmm0,0x8(%rsp)
lea    0xecf(%rip),%rdi
call   1030 <puts@plt>
movsd  0x8(%rsp),%xmm0
subsd  0x10(%rsp),%xmm0
mov    0x2e6f(%rip),%rax
divsd  (%rax),%xmm0
lea    0xe7c(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [33 x i8] c"Algorithm stars... 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 i64
%9 = alloca i32
%10 = alloca i64
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 0, i64* %8
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%13 = call double (...) @clock()
store double %13, double* %6
store i32 1, i32* %9
br label %14
14: ; preds = %39, %2
%15 = load i32, i32* %9
%16 = icmp ule i32 %15, 1000
br i1 %16, label %17, label %42
17: ; preds = %14
%18 = load i32, i32* %9
%19 = zext i32 %18 to i64
store i64 %19, i64* %10
store i32 0, i32* %11
br label %20
20: ; preds = %31, %17
%21 = load i32, i32* %11
%22 = load i32, i32* %9
%23 = sub i32 %22, 1
%24 = icmp ult i32 %21, %23
br i1 %24, label %25, label %34
25: ; preds = %20
%26 = load i64, i64* %10
%27 = load i32, i32* %9
%28 = zext i32 %27 to i64
%29 = mul i64 %26, %28
%30 = urem i64 %29, 10000000000
store i64 %30, i64* %10
br label %31
31: ; preds = %25
%32 = load i32, i32* %11
%33 = add i32 %32, 1
store i32 %33, i32* %11
br label %20
34: ; preds = %20
%35 = load i64, i64* %8
%36 = load i64, i64* %10
%37 = add i64 %35, %36
%38 = urem i64 %37, 10000000000
store i64 %38, i64* %8
br label %39
39: ; preds = %34
%40 = load i32, i32* %9
%41 = add i32 %40, 1
store i32 %41, i32* %9
br label %14
42: ; preds = %14
%43 = call double (...) @clock()
store double %43, double* %7
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%45 = load double, double* %7
%46 = load double, double* %6
%47 = fsub double %45, %46
%48 = load double, double* @CLOCKS_PER_SEC
%49 = fdiv double %47, %48
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), double %49)
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 = [32 x i8] c"Algorithm stars... 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 ([32 x i8], [32 x i8]* @str, i64 0, i64 0))
%4 = tail call double (...) @clock()
%5 = tail call double (...) @clock()
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.3, i64 0, i64 0))
%7 = fsub double %5, %4
%8 = load double, double* @CLOCKS_PER_SEC
%9 = fdiv double %7, %8
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), double %9)
ret i32 0
}