#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 int pivot[1000] = {1}, swapper[1000] = {1}, numbers[1000] = {1};
  unsigned int total = 2;
  printf("Algorithm starts, please wait\n");
  start = clock();
  while (numbers[(1000 - 1)] == 0) {
    for (unsigned int i = 0; i < 1000; i++) {
      numbers[i] = pivot[i] + swapper[i];
      if (numbers[i] > 9) {
        pivot[i + 1] += numbers[i] / 10;
        numbers[i] %= 10;
      }
      pivot[i] = swapper[i];
      swapper[i] = numbers[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    $0x2f10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0xfc0(%rbp),%rdi
xor    %esi,%esi
mov    $0xfa0,%edx
call   1050 <memset@plt>
movl   $0x1,-0xfc0(%rbp)
lea    -0x1f60(%rbp),%rdi
xor    %esi,%esi
mov    $0xfa0,%edx
call   1050 <memset@plt>
movl   $0x1,-0x1f60(%rbp)
lea    -0x2f00(%rbp),%rdi
xor    %esi,%esi
mov    $0xfa0,%edx
call   1050 <memset@plt>
movl   $0x1,-0x2f00(%rbp)
movl   $0x2,-0x2f04(%rbp)
lea    0xe4f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <clock@plt>
movsd  %xmm0,-0x18(%rbp)
cmpl   $0x0,-0x1f64(%rbp)
jne    12de <main+0x1ae>
movl   $0x0,-0x2f08(%rbp)
cmpl   $0x3e8,-0x2f08(%rbp)
jae    12ca <main+0x19a>
mov    -0x2f08(%rbp),%eax
mov    -0xfc0(%rbp,%rax,4),%ecx
mov    -0x2f08(%rbp),%eax
add    -0x1f60(%rbp,%rax,4),%ecx
mov    -0x2f08(%rbp),%eax
mov    %ecx,-0x2f00(%rbp,%rax,4)
mov    -0x2f08(%rbp),%eax
cmpl   $0x9,-0x2f00(%rbp,%rax,4)
09
jbe    1282 <main+0x152>
mov    -0x2f08(%rbp),%eax
mov    -0x2f00(%rbp,%rax,4),%eax
mov    $0xa,%ecx
xor    %edx,%edx
div    %ecx
mov    %eax,%ecx
mov    -0x2f08(%rbp),%eax
add    $0x1,%eax
mov    %eax,%eax
add    -0xfc0(%rbp,%rax,4),%ecx
mov    %ecx,-0xfc0(%rbp,%rax,4)
mov    -0x2f08(%rbp),%eax
mov    %rax,-0x2f10(%rbp)
mov    -0x2f00(%rbp,%rax,4),%eax
mov    $0xa,%ecx
xor    %edx,%edx
div    %ecx
mov    -0x2f10(%rbp),%rax
mov    %edx,-0x2f00(%rbp,%rax,4)
mov    -0x2f08(%rbp),%eax
mov    -0x1f60(%rbp,%rax,4),%ecx
mov    -0x2f08(%rbp),%eax
mov    %ecx,-0xfc0(%rbp,%rax,4)
mov    -0x2f08(%rbp),%eax
mov    -0x2f00(%rbp,%rax,4),%ecx
mov    -0x2f08(%rbp),%eax
mov    %ecx,-0x1f60(%rbp,%rax,4)
mov    -0x2f08(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2f08(%rbp)
jmp    11db <main+0xab>
mov    -0x2f04(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2f04(%rbp)
jmp    11c4 <main+0x94>
mov    $0x0,%al
call   1030 <clock@plt>
movsd  %xmm0,-0x20(%rbp)
lea    0xd2e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movsd  -0x20(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
mov    0x2cdf(%rip),%rax
divsd  (%rax),%xmm0
lea    0xd1a(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x2f10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x2ef0,%rsp
lea    0x10(%rsp),%rdi
xor    %ebx,%ebx
mov    $0xfa0,%edx
xor    %esi,%esi
call   1060 <memset@plt>
movl   $0x1,0x10(%rsp)
lea    0x1f50(%rsp),%rdi
mov    $0xfa0,%edx
xor    %esi,%esi
call   1060 <memset@plt>
movl   $0x1,0x1f50(%rsp)
lea    0xfb0(%rsp),%rdi
mov    $0xfa0,%edx
xor    %esi,%esi
call   1060 <memset@plt>
lea    0xe73(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1040 <clock@plt>
movsd  %xmm0,0x8(%rsp)
mov    $0xcccccccd,%eax
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x1f50(%rsp,%rbx,4),%ecx
mov    0x10(%rsp,%rbx,4),%edx
add    %ecx,%edx
mov    %edx,0xfb0(%rsp,%rbx,4)
lea    0x1(%rbx),%rsi
cmp    $0x9,%edx
jbe    11f9 <main+0xb9>
mov    %edx,%edi
imul   %rax,%rdi
shr    $0x23,%rdi
add    %edi,0x14(%rsp,%rbx,4)
add    %edi,%edi
lea    (%rdi,%rdi,4),%edi
sub    %edi,%edx
mov    %edx,0xfb0(%rsp,%rbx,4)
mov    %ecx,0x10(%rsp,%rbx,4)
mov    %edx,0x1f50(%rsp,%rbx,4)
mov    %rsi,%rbx
cmp    $0x3e8,%rsi
jne    11c0 <main+0x80>
cmpl   $0x0,0x1f4c(%rsp)
mov    $0x0,%ebx
je     11c0 <main+0x80>
xor    %eax,%eax
call   1040 <clock@plt>
movsd  %xmm0,(%rsp)
lea    0xdfc(%rip),%rdi
call   1030 <puts@plt>
movsd  (%rsp),%xmm0
subsd  0x8(%rsp),%xmm0
mov    0x2d9f(%rip),%rax
divsd  (%rax),%xmm0
lea    0xdac(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x2ef0,%rsp
pop    %rbx
ret

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