#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 */
typedef scalar_t__ time_t;

/* Variables and functions */
float CLOCKS_PER_SEC;
scalar_t__ clock();
int /*<<< orphan*/ printf(char *, long long);
int main() {
  time_t t0 = clock();
  int L = 10000000;
  long long acc = 0;
  int ini = 0, fim = 2 * L;
  while (ini <= fim)
    acc += ini++;
  time_t t1 = clock();
  printf("Time elapsed single-thread C: %.2lf\n",
         (float)(t1 - t0) / CLOCKS_PER_SEC);
  printf("Result : %lld\n", acc);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x10(%rbp)
movl   $0x989680,-0x14(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x14(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x28(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x28(%rbp),%eax
jg     117f <main+0x5f>
mov    -0x24(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x24(%rbp)
cltq
add    -0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
jmp    1159 <main+0x39>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
sub    -0x10(%rbp),%rax
cvtsi2ss %rax,%xmm0
mov    0x2e4a(%rip),%rax
divss  (%rax),%xmm0
cvttss2si %xmm0,%rsi
lea    0xe52(%rip),%rdi
call   1040 <printf@plt>
mov    -0x20(%rbp),%rsi
lea    0xe67(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1030 <clock@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1030 <clock@plt>
sub    %rbx,%rax
cvtsi2ss %rax,%xmm0
mov    0x2ea7(%rip),%rax
divss  (%rax),%xmm0
cvttss2si %xmm0,%rsi
lea    0xeaf(%rip),%rdi
call   1040 <printf@plt>
lea    0xec8(%rip),%rdi
movabs $0xb5e6218d1680,%rsi
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [37 x i8] c"Time elapsed single-thread C: %.2lf\0A\00"
@CLOCKS_PER_SEC = global float 0.000000e+00
@.str.1 = [15 x i8] c"Result : %lld\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i32
%4 = alloca i64
%5 = alloca i32
%6 = alloca i32
%7 = alloca i64
store i32 0, i32* %1
%8 = call i64 (...) @clock()
store i64 %8, i64* %2
store i32 10000000, i32* %3
store i64 0, i64* %4
store i32 0, i32* %5
%9 = load i32, i32* %3
%10 = mul nsw i32 2, %9
store i32 %10, i32* %6
br label %11
11: ; preds = %15, %0
%12 = load i32, i32* %5
%13 = load i32, i32* %6
%14 = icmp sle i32 %12, %13
br i1 %14, label %15, label %21
15: ; preds = %11
%16 = load i32, i32* %5
%17 = add nsw i32 %16, 1
store i32 %17, i32* %5
%18 = sext i32 %16 to i64
%19 = load i64, i64* %4
%20 = add nsw i64 %19, %18
store i64 %20, i64* %4
br label %11
21: ; preds = %11
%22 = call i64 (...) @clock()
store i64 %22, i64* %7
%23 = load i64, i64* %7
%24 = load i64, i64* %2
%25 = sub nsw i64 %23, %24
%26 = sitofp i64 %25 to float
%27 = load float, float* @CLOCKS_PER_SEC
%28 = fdiv float %26, %27
%29 = fptosi float %28 to i64
%30 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i64 %29)
%31 = load i64, i64* %4
%32 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i64 %31)
ret i32 0
}

LLVM IR (-O2):
@.str = [37 x i8] c"Time elapsed single-thread C: %.2lf\0A\00"
@CLOCKS_PER_SEC = global float 0.000000e+00
@.str.1 = [15 x i8] c"Result : %lld\0A\00"
define i32 @main() {
%1 = tail call i64 (...) @clock()
%2 = tail call i64 (...) @clock()
%3 = sub nsw i64 %2, %1
%4 = sitofp i64 %3 to float
%5 = load float, float* @CLOCKS_PER_SEC
%6 = fdiv float %4, %5
%7 = fptosi float %6 to i64
%8 = tail call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i64 %7)
%9 = tail call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i64 200000010000000)
ret i32 0
}