#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 */
int /*<<< orphan*/ printf(char *, float);
int main() {
  const size_t n = 256 * 20;
  size_t i = 0;
  float res = .0f;
  for (i = 0; i < n; ++i) {
    res = res + (float)i * 0.0001 * (float)i * 0.0001;
  }
  printf("%f\n", res);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x1400,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
movq   $0x0,-0x18(%rbp)
cmpq   $0x1400,-0x18(%rbp)
jae    11e4 <main+0xd4>
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x18(%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,-0x24(%rbp)
test   %rax,%rax
movss  %xmm0,-0x20(%rbp)
js     1198 <main+0x88>
movss  -0x24(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
movsd  -0x30(%rbp),%xmm1
movss  -0x20(%rbp),%xmm2
cvtss2sd %xmm2,%xmm0
movsd  0xe52(%rip),%xmm3
mulsd  %xmm3,%xmm0
cvtss2sd %xmm2,%xmm2
mulsd  %xmm2,%xmm0
movsd  0xe3e(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    113f <main+0x2f>
movss  -0x1c(%rbp),%xmm0
lea    0xe18(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
xorps  %xmm0,%xmm0
xor    %eax,%eax
movsd  0xee2(%rip),%xmm1
jmp    117b <main+0x6b>
xorps  %xmm3,%xmm3
cvtsi2ss %rcx,%xmm3
cvtss2sd %xmm0,%xmm0
cvtss2sd %xmm2,%xmm2
movaps %xmm2,%xmm4
mulsd  %xmm1,%xmm4
mulsd  %xmm2,%xmm4
mulsd  %xmm1,%xmm4
addsd  %xmm0,%xmm4
xorps  %xmm0,%xmm0
cvtsd2ss %xmm4,%xmm0
cvtss2sd %xmm0,%xmm0
xorps  %xmm2,%xmm2
cvtss2sd %xmm3,%xmm2
movaps %xmm2,%xmm3
mulsd  %xmm1,%xmm3
mulsd  %xmm2,%xmm3
mulsd  %xmm1,%xmm3
addsd  %xmm0,%xmm3
xorps  %xmm0,%xmm0
cvtsd2ss %xmm3,%xmm0
add    $0x2,%rax
cmp    $0x1400,%rax
je     11d4 <main+0xc4>
test   %rax,%rax
js     1190 <main+0x80>
xorps  %xmm2,%xmm2
cvtsi2ss %rax,%xmm2
jmp    11aa <main+0x9a>
nopw   0x0(%rax,%rax,1)
mov    %rax,%rcx
shr    %rcx
mov    %eax,%edx
and    $0x1,%edx
or     %rcx,%rdx
xorps  %xmm2,%xmm2
cvtsi2ss %rdx,%xmm2
addss  %xmm2,%xmm2
mov    %rax,%rcx
add    $0x1,%rcx
jns    1120 <main+0x10>
mov    %rcx,%rdx
shr    %rdx
and    $0x1,%ecx
or     %rdx,%rcx
xorps  %xmm3,%xmm3
cvtsi2ss %rcx,%xmm3
addss  %xmm3,%xmm3
jmp    1128 <main+0x18>
lea    0xe2d(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca float
store i32 0, i32* %1
store i64 5120, i64* %2
store i64 0, i64* %3
store float 0.000000e+00, float* %4
store i64 0, i64* %3
br label %5
5: ; preds = %21, %0
%6 = load i64, i64* %3
%7 = icmp ult i64 %6, 5120
br i1 %7, label %8, label %24
8: ; preds = %5
%9 = load float, float* %4
%10 = fpext float %9 to double
%11 = load i64, i64* %3
%12 = uitofp i64 %11 to float
%13 = fpext float %12 to double
%14 = fmul double %13, 1.000000e-04
%15 = load i64, i64* %3
%16 = uitofp i64 %15 to float
%17 = fpext float %16 to double
%18 = fmul double %14, %17
%19 = call double @llvm.fmuladd.f64(double %18, double 1.000000e-04, double %10)
%20 = fptrunc double %19 to float
store float %20, float* %4
br label %21
21: ; preds = %8
%22 = load i64, i64* %3
%23 = add i64 %22, 1
store i64 %23, i64* %3
br label %5
24: ; preds = %5
%25 = load float, float* %4
%26 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), float %25)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%f\0A\00"
define i32 @main() {
br label %1
1: ; preds = %1, %0
%2 = phi float [ 0.000000e+00, %0 ], [ %18, %1 ]
%3 = phi i64 [ 0, %0 ], [ %19, %1 ]
%4 = fpext float %2 to double
%5 = uitofp i64 %3 to float
%6 = fpext float %5 to double
%7 = fmul double %6, 1.000000e-04
%8 = fmul double %7, %6
%9 = tail call double @llvm.fmuladd.f64(double %8, double 1.000000e-04, double %4)
%10 = fptrunc double %9 to float
%11 = or i64 %3, 1
%12 = fpext float %10 to double
%13 = uitofp i64 %11 to float
%14 = fpext float %13 to double
%15 = fmul double %14, 1.000000e-04
%16 = fmul double %15, %14
%17 = tail call double @llvm.fmuladd.f64(double %16, double 1.000000e-04, double %12)
%18 = fptrunc double %17 to float
%19 = add nuw nsw i64 %3, 2
%20 = icmp eq i64 %19, 5120
br i1 %20, label %21, label %1
21: ; preds = %1
%22 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), float %18)
ret i32 0
}