#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 log10(int);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  double start, end;
  unsigned int digits[200] = {1};
  unsigned int total = 0, k = 0;
  printf("Algorithm starts, plase wait... \n");
  start = clock();
  for (unsigned short int i = 1; i <= 100; i++) {
    for (unsigned short int j = 0; j < (int)(100 * log10(100)); j++) {
      digits[j] = (digits[j] * i) + k;
      k = (digits[j] / 10);
      digits[j] %= 10;
    }
  }
  for (unsigned short int i = (int)(100 * log10(100)); i > 0; i--) {
    total += digits[i];
  }
  end = clock();
  printf("Algorithm finish.\n");
  printf("Total time: %f\n", (end - start) / CLOCKS_PER_SEC);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x360,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x340(%rbp),%rdi
xor    %esi,%esi
mov    $0x320,%edx
call   1050 <memset@plt>
movl   $0x1,-0x340(%rbp)
movl   $0x0,-0x344(%rbp)
movl   $0x0,-0x348(%rbp)
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <clock@plt>
movsd  %xmm0,-0x18(%rbp)
movw   $0x1,-0x34a(%rbp)
movzwl -0x34a(%rbp),%eax
cmp    $0x64,%eax
jg     1298 <main+0x158>
movw   $0x0,-0x34c(%rbp)
movzwl -0x34c(%rbp),%eax
mov    %eax,-0x354(%rbp)
mov    $0x64,%edi
call   1060 <log10@plt>
mov    %eax,%ecx
mov    -0x354(%rbp),%eax
imul   $0x64,%ecx,%ecx
cmp    %ecx,%eax
jge    127c <main+0x13c>
movzwl -0x34c(%rbp),%eax
mov    -0x340(%rbp,%rax,4),%ecx
movzwl -0x34a(%rbp),%eax
imul   %eax,%ecx
add    -0x348(%rbp),%ecx
movzwl -0x34c(%rbp),%eax
mov    %ecx,-0x340(%rbp,%rax,4)
movzwl -0x34c(%rbp),%eax
mov    -0x340(%rbp,%rax,4),%eax
mov    $0xa,%ecx
xor    %edx,%edx
div    %ecx
mov    %eax,-0x348(%rbp)
movzwl -0x34c(%rbp),%eax
mov    %rax,-0x360(%rbp)
mov    -0x340(%rbp,%rax,4),%eax
mov    $0xa,%ecx
xor    %edx,%edx
div    %ecx
mov    -0x360(%rbp),%rax
mov    %edx,-0x340(%rbp,%rax,4)
mov    -0x34c(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x34c(%rbp)
jmp    11c6 <main+0x86>
jmp    1281 <main+0x141>
mov    -0x34a(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x34a(%rbp)
jmp    11ad <main+0x6d>
mov    $0x64,%edi
call   1060 <log10@plt>
imul   $0x64,%eax,%eax
mov    %ax,-0x34e(%rbp)
movzwl -0x34e(%rbp),%eax
cmp    $0x0,%eax
jle    12ed <main+0x1ad>
movzwl -0x34e(%rbp),%eax
mov    -0x340(%rbp,%rax,4),%eax
add    -0x344(%rbp),%eax
mov    %eax,-0x344(%rbp)
mov    -0x34e(%rbp),%ax
add    $0xffff,%ax
mov    %ax,-0x34e(%rbp)
jmp    12ac <main+0x16c>
mov    $0x0,%al
call   1030 <clock@plt>
movsd  %xmm0,-0x20(%rbp)
lea    0xd22(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movsd  -0x20(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
mov    0x2cd0(%rip),%rax
divsd  (%rax),%xmm0
lea    0xd12(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x360,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x330,%rsp
lea    0x10(%rsp),%rdi
xor    %ebx,%ebx
mov    $0x320,%edx
xor    %esi,%esi
call   1060 <memset@plt>
movl   $0x1,0x10(%rsp)
lea    0xe8f(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1040 <clock@plt>
movsd  %xmm0,0x8(%rsp)
mov    $0x1,%r15d
mov    $0xcccccccd,%r14d
jmp    11ba <main+0x6a>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%r15d
cmp    $0x65,%r15d
je     120f <main+0xbf>
mov    $0x64,%edi
call   1070 <log10@plt>
test   %eax,%eax
jle    11b0 <main+0x60>
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
movzwl %bp,%eax
mov    0x10(%rsp,%rax,4),%ecx
imul   %r15d,%ecx
add    %ebx,%ecx
mov    %rcx,%rbx
imul   %r14,%rbx
shr    $0x23,%rbx
lea    (%rbx,%rbx,1),%edx
lea    (%rdx,%rdx,4),%edx
sub    %edx,%ecx
mov    %ecx,0x10(%rsp,%rax,4)
add    $0x1,%ebp
movzwl %bp,%r12d
mov    $0x64,%edi
call   1070 <log10@plt>
imul   $0x64,%eax,%eax
cmp    %r12d,%eax
jg     11d0 <main+0x80>
jmp    11b0 <main+0x60>
mov    $0x64,%edi
call   1070 <log10@plt>
xor    %eax,%eax
call   1040 <clock@plt>
movsd  %xmm0,(%rsp)
lea    0xe05(%rip),%rdi
call   1030 <puts@plt>
movsd  (%rsp),%xmm0
subsd  0x8(%rsp),%xmm0
mov    0x2da5(%rip),%rax
divsd  (%rax),%xmm0
lea    0xdb2(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x330,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [34 x i8] c"Algorithm starts, plase wait... \0A\00"
@.str.1 = [19 x i8] c"Algorithm finish.\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 [200 x i32]
%9 = alloca i32
%10 = alloca i32
%11 = alloca i16
%12 = alloca i16
%13 = alloca i16
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = bitcast [200 x i32]* %8 to i8*
%15 = bitcast i8* %14 to <{ i32, [199 x i32] }>*
%16 = getelementptr inbounds <{ i32, [199 x i32] }>, <{ i32, [199 x i32] }>* %15, i32 0, i32 0
store i32 1, i32* %16
store i32 0, i32* %9
store i32 0, i32* %10
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%18 = call double (...) @clock()
store double %18, double* %6
store i16 1, i16* %11
br label %19
19: ; preds = %57, %2
%20 = load i16, i16* %11
%21 = zext i16 %20 to i32
%22 = icmp sle i32 %21, 100
br i1 %22, label %23, label %60
23: ; preds = %19
store i16 0, i16* %12
br label %24
24: ; preds = %53, %23
%25 = load i16, i16* %12
%26 = zext i16 %25 to i32
%27 = call i32 @log10(i32 100)
%28 = mul nsw i32 100, %27
%29 = icmp slt i32 %26, %28
br i1 %29, label %30, label %56
30: ; preds = %24
%31 = load i16, i16* %12
%32 = zext i16 %31 to i64
%33 = getelementptr inbounds [200 x i32], [200 x i32]* %8, i64 0, i64 %32
%34 = load i32, i32* %33
%35 = load i16, i16* %11
%36 = zext i16 %35 to i32
%37 = mul i32 %34, %36
%38 = load i32, i32* %10
%39 = add i32 %37, %38
%40 = load i16, i16* %12
%41 = zext i16 %40 to i64
%42 = getelementptr inbounds [200 x i32], [200 x i32]* %8, i64 0, i64 %41
store i32 %39, i32* %42
%43 = load i16, i16* %12
%44 = zext i16 %43 to i64
%45 = getelementptr inbounds [200 x i32], [200 x i32]* %8, i64 0, i64 %44
%46 = load i32, i32* %45
%47 = udiv i32 %46, 10
store i32 %47, i32* %10
%48 = load i16, i16* %12
%49 = zext i16 %48 to i64
%50 = getelementptr inbounds [200 x i32], [200 x i32]* %8, i64 0, i64 %49
%51 = load i32, i32* %50
%52 = urem i32 %51, 10
store i32 %52, i32* %50
br label %53
53: ; preds = %30
%54 = load i16, i16* %12
%55 = add i16 %54, 1
store i16 %55, i16* %12
br label %24
56: ; preds = %24
br label %57
57: ; preds = %56
%58 = load i16, i16* %11
%59 = add i16 %58, 1
store i16 %59, i16* %11
br label %19
60: ; preds = %19
%61 = call i32 @log10(i32 100)
%62 = mul nsw i32 100, %61
%63 = trunc i32 %62 to i16
store i16 %63, i16* %13
br label %64
64: ; preds = %75, %60
%65 = load i16, i16* %13
%66 = zext i16 %65 to i32
%67 = icmp sgt i32 %66, 0
br i1 %67, label %68, label %78
68: ; preds = %64
%69 = load i16, i16* %13
%70 = zext i16 %69 to i64
%71 = getelementptr inbounds [200 x i32], [200 x i32]* %8, i64 0, i64 %70
%72 = load i32, i32* %71
%73 = load i32, i32* %9
%74 = add i32 %73, %72
store i32 %74, i32* %9
br label %75
75: ; preds = %68
%76 = load i16, i16* %13
%77 = add i16 %76, -1
store i16 %77, i16* %13
br label %64
78: ; preds = %64
%79 = call double (...) @clock()
store double %79, double* %7
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%81 = load double, double* %7
%82 = load double, double* %6
%83 = fsub double %81, %82
%84 = load double, double* @CLOCKS_PER_SEC
%85 = fdiv double %83, %84
%86 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), double %85)
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, plase wait... \00"
@str.3 = [18 x i8] c"Algorithm finish.\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [200 x i32]
%4 = bitcast [200 x i32]* %3 to i8*
%5 = getelementptr inbounds [200 x i32], [200 x i32]* %3, i64 0, i64 0
store i32 1, i32* %5
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
%7 = tail call double (...) @clock()
br label %8
8: ; preds = %2, %21
%9 = phi i32 [ 1, %2 ], [ %23, %21 ]
%10 = phi i32 [ 0, %2 ], [ %22, %21 ]
%11 = tail call i32 @log10(i32 100)
%12 = icmp sgt i32 %11, 0
br i1 %12, label %25, label %21
13: ; preds = %21
%14 = tail call i32 @log10(i32 100)
%15 = tail call double (...) @clock()
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.3, i64 0, i64 0))
%17 = fsub double %15, %7
%18 = load double, double* @CLOCKS_PER_SEC
%19 = fdiv double %17, %18
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), double %19)
ret i32 0
21: ; preds = %25, %8
%22 = phi i32 [ %10, %8 ], [ %33, %25 ]
%23 = add nuw nsw i32 %9, 1
%24 = icmp eq i32 %23, 101
br i1 %24, label %13, label %8
25: ; preds = %8, %25
%26 = phi i16 [ %35, %25 ], [ 0, %8 ]
%27 = phi i32 [ %33, %25 ], [ %10, %8 ]
%28 = zext i16 %26 to i64
%29 = getelementptr inbounds [200 x i32], [200 x i32]* %3, i64 0, i64 %28
%30 = load i32, i32* %29
%31 = mul i32 %30, %9
%32 = add i32 %31, %27
%33 = udiv i32 %32, 10
%34 = urem i32 %32, 10
store i32 %34, i32* %29
%35 = add i16 %26, 1
%36 = zext i16 %35 to i32
%37 = tail call i32 @log10(i32 100)
%38 = mul nsw i32 %37, 100
%39 = icmp sgt i32 %38, %36
br i1 %39, label %25, label %21
}