#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 */
unsigned long pow(int, int);
int /*<<< orphan*/ printf(char *, float);
float timeit();
int main(int argc, char *argv[]) {
  float start = timeit();
  unsigned long total = 0;
  int sum = 0;
  for (int i = 0; i <= 100; i++)
    total += i * i;
  for (int i = 0; i <= 100; i++)
    sum += i;
  total = pow(sum, 2) - total;
  float stop = timeit();
  printf("Answer: %ld\n", total);
  printf("Time: %.8f\n", stop - start);
  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)
mov    $0x0,%al
call   1050 <timeit@plt>
movss  %xmm0,-0x14(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
cmpl   $0x64,-0x28(%rbp)
jg     1191 <main+0x61>
mov    -0x28(%rbp),%eax
imul   -0x28(%rbp),%eax
cltq
add    -0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1168 <main+0x38>
movl   $0x0,-0x2c(%rbp)
cmpl   $0x64,-0x2c(%rbp)
jg     11b9 <main+0x89>
mov    -0x2c(%rbp),%eax
add    -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1198 <main+0x68>
mov    -0x24(%rbp),%edi
mov    $0x2,%esi
call   1040 <pow@plt>
mov    -0x20(%rbp),%rcx
sub    %rcx,%rax
mov    %rax,-0x20(%rbp)
xor    %eax,%eax
call   1050 <timeit@plt>
movss  %xmm0,-0x30(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rdx
shr    %rdx
mov    %eax,%ecx
and    $0x1,%ecx
or     %rdx,%rcx
cvtsi2ss %rcx,%xmm0
addss  %xmm0,%xmm0
cvtsi2ss %rax,%xmm1
movss  %xmm1,-0x38(%rbp)
test   %rax,%rax
movss  %xmm0,-0x34(%rbp)
js     121a <main+0xea>
movss  -0x38(%rbp),%xmm0
movss  %xmm0,-0x34(%rbp)
movss  -0x34(%rbp),%xmm0
lea    0xdda(%rip),%rdi
call   1030 <printf@plt>
movss  -0x30(%rbp),%xmm0
subss  -0x14(%rbp),%xmm0
lea    0xdd1(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
xor    %eax,%eax
call   1050 <timeit@plt>
movss  %xmm0,0xc(%rsp)
mov    $0x13ba,%edi
mov    $0x2,%esi
call   1040 <pow@plt>
mov    %rax,%rbx
add    $0xfffffffffffad652,%rbx
xor    %eax,%eax
call   1050 <timeit@plt>
movss  %xmm0,0x8(%rsp)
test   %rbx,%rbx
js     1177 <main+0x47>
xorps  %xmm0,%xmm0
cvtsi2ss %rbx,%xmm0
jmp    118f <main+0x5f>
mov    %rbx,%rax
shr    %rax
and    $0x1,%ebx
or     %rax,%rbx
xorps  %xmm0,%xmm0
cvtsi2ss %rbx,%xmm0
addss  %xmm0,%xmm0
lea    0xe6a(%rip),%rdi
call   1030 <printf@plt>
movss  0x8(%rsp),%xmm0
subss  0xc(%rsp),%xmm0
lea    0xe5f(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [13 x i8] c"Answer: %ld\0A\00"
@.str.1 = [12 x i8] c"Time: %.8f\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca float
%7 = alloca i64
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca float
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = call float (...) @timeit()
store float %12, float* %6
store i64 0, i64* %7
store i32 0, i32* %8
store i32 0, i32* %9
br label %13
13: ; preds = %23, %2
%14 = load i32, i32* %9
%15 = icmp sle i32 %14, 100
br i1 %15, label %16, label %26
16: ; preds = %13
%17 = load i32, i32* %9
%18 = load i32, i32* %9
%19 = mul nsw i32 %17, %18
%20 = sext i32 %19 to i64
%21 = load i64, i64* %7
%22 = add i64 %21, %20
store i64 %22, i64* %7
br label %23
23: ; preds = %16
%24 = load i32, i32* %9
%25 = add nsw i32 %24, 1
store i32 %25, i32* %9
br label %13
26: ; preds = %13
store i32 0, i32* %10
br label %27
27: ; preds = %34, %26
%28 = load i32, i32* %10
%29 = icmp sle i32 %28, 100
br i1 %29, label %30, label %37
30: ; preds = %27
%31 = load i32, i32* %10
%32 = load i32, i32* %8
%33 = add nsw i32 %32, %31
store i32 %33, i32* %8
br label %34
34: ; preds = %30
%35 = load i32, i32* %10
%36 = add nsw i32 %35, 1
store i32 %36, i32* %10
br label %27
37: ; preds = %27
%38 = load i32, i32* %8
%39 = call i64 @pow(i32 %38, i32 2)
%40 = load i64, i64* %7
%41 = sub i64 %39, %40
store i64 %41, i64* %7
%42 = call float (...) @timeit()
store float %42, float* %11
%43 = load i64, i64* %7
%44 = uitofp i64 %43 to float
%45 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), float %44)
%46 = load float, float* %11
%47 = load float, float* %6
%48 = fsub float %46, %47
%49 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), float %48)
ret i32 0
}

LLVM IR (-O2):
@.str = [13 x i8] c"Answer: %ld\0A\00"
@.str.1 = [12 x i8] c"Time: %.8f\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call float (...) @timeit()
%4 = tail call i64 @pow(i32 5050, i32 2)
%5 = add i64 %4, -338350
%6 = tail call float (...) @timeit()
%7 = uitofp i64 %5 to float
%8 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), float %7)
%9 = fsub float %6, %3
%10 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), float %9)
ret i32 0
}