#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 int clock_t;

/* Variables and functions */
int clock();
int /*<<< orphan*/ printf(char *, float);
scalar_t__ sqrt(float);
int main() {
  clock_t temps_initial;
  clock_t temps_final;
  float i = 1.0;
  float result;
  float temps_cpu;
  temps_initial = clock();
  for (; i <= 10000000; i++) {
    result += sqrt(i);
  }
  temps_final = clock();
  temps_cpu = (temps_final - temps_initial) * 1e-6;
  printf("temps cpu = %f\n", temps_cpu);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movss  0xeb9(%rip),%xmm0
movss  %xmm0,-0x10(%rbp)
mov    $0x0,%al
call   1030 <clock@plt>
mov    %eax,-0x8(%rbp)
movss  0xea6(%rip),%xmm0
ucomiss -0x10(%rbp),%xmm0
jb     1198 <main+0x68>
movss  -0x10(%rbp),%xmm0
call   1050 <sqrt@plt>
cvtsi2ss %rax,%xmm0
addss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  0xe77(%rip),%xmm0
addss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
jmp    1156 <main+0x26>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
sub    -0x8(%rbp),%eax
cvtsi2sd %eax,%xmm0
movsd  0xe54(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
lea    0xe43(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
xor    %eax,%eax
call   1030 <clock@plt>
mov    %eax,%ebp
mov    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xorps  %xmm0,%xmm0
cvtsi2ss %ebx,%xmm0
call   1050 <sqrt@plt>
lea    0x1(%rbx),%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
call   1050 <sqrt@plt>
lea    0x2(%rbx),%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
call   1050 <sqrt@plt>
lea    0x3(%rbx),%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
call   1050 <sqrt@plt>
lea    0x4(%rbx),%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
call   1050 <sqrt@plt>
lea    0x5(%rbx),%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
call   1050 <sqrt@plt>
lea    0x6(%rbx),%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
call   1050 <sqrt@plt>
lea    0x7(%rbx),%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
call   1050 <sqrt@plt>
add    $0x8,%ebx
cmp    $0x989681,%ebx
jne    1150 <main+0x20>
xor    %eax,%eax
call   1030 <clock@plt>
sub    %ebp,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0xe18(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
lea    0xe15(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [16 x i8] c"temps cpu = %f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca float
%5 = alloca float
%6 = alloca float
store i32 0, i32* %1
store float 1.000000e+00, float* %4
%7 = call i32 (...) @clock()
store i32 %7, i32* %2
br label %8
8: ; preds = %17, %0
%9 = load float, float* %4
%10 = fcmp ole float %9, 1.000000e+07
br i1 %10, label %11, label %20
11: ; preds = %8
%12 = load float, float* %4
%13 = call i64 @sqrt(float %12)
%14 = sitofp i64 %13 to float
%15 = load float, float* %5
%16 = fadd float %15, %14
store float %16, float* %5
br label %17
17: ; preds = %11
%18 = load float, float* %4
%19 = fadd float %18, 1.000000e+00
store float %19, float* %4
br label %8
20: ; preds = %8
%21 = call i32 (...) @clock()
store i32 %21, i32* %3
%22 = load i32, i32* %3
%23 = load i32, i32* %2
%24 = sub nsw i32 %22, %23
%25 = sitofp i32 %24 to double
%26 = fmul double %25, 0x3EB0C6F7A0B5ED8D
%27 = fptrunc double %26 to float
store float %27, float* %6
%28 = load float, float* %6
%29 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), float %28)
ret i32 0
}

LLVM IR (-O2):
@.str = [16 x i8] c"temps cpu = %f\0A\00"
define i32 @main() {
%1 = tail call i32 (...) @clock()
br label %2
2: ; preds = %2, %0
%3 = phi i32 [ 1, %0 ], [ %27, %2 ]
%4 = sitofp i32 %3 to float
%5 = tail call i64 @sqrt(float %4)
%6 = add nuw nsw i32 %3, 1
%7 = sitofp i32 %6 to float
%8 = tail call i64 @sqrt(float %7)
%9 = add nuw nsw i32 %3, 2
%10 = sitofp i32 %9 to float
%11 = tail call i64 @sqrt(float %10)
%12 = add nuw nsw i32 %3, 3
%13 = sitofp i32 %12 to float
%14 = tail call i64 @sqrt(float %13)
%15 = add nuw nsw i32 %3, 4
%16 = sitofp i32 %15 to float
%17 = tail call i64 @sqrt(float %16)
%18 = add nuw nsw i32 %3, 5
%19 = sitofp i32 %18 to float
%20 = tail call i64 @sqrt(float %19)
%21 = add nuw nsw i32 %3, 6
%22 = sitofp i32 %21 to float
%23 = tail call i64 @sqrt(float %22)
%24 = add nuw nsw i32 %3, 7
%25 = sitofp i32 %24 to float
%26 = tail call i64 @sqrt(float %25)
%27 = add nuw nsw i32 %3, 8
%28 = icmp eq i32 %27, 10000001
br i1 %28, label %29, label %2
29: ; preds = %2
%30 = tail call i32 (...) @clock()
%31 = sub nsw i32 %30, %1
%32 = sitofp i32 %31 to double
%33 = fmul double %32, 0x3EB0C6F7A0B5ED8D
%34 = fptrunc double %33 to float
%35 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), float %34)
ret i32 0
}