double fakeSomeWork() {
  double x = 1;
  int i, j;
  for (i = 100; i > 0; i--) {
    for (j = 2000; j > 0; j--) {
      x = x * x + (i * j) + i * x;
    }
  }
  return x;
}


x86 assembly (clang, -O0):
<fakeSomeWork>:
push   %rbp
mov    %rsp,%rbp
movsd  0xef4(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
movl   $0x64,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jle    1188 <fakeSomeWork+0x88>
movl   $0x7d0,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jle    1175 <fakeSomeWork+0x75>
movsd  -0x8(%rbp),%xmm1
movsd  -0x8(%rbp),%xmm2
mov    -0xc(%rbp),%eax
imul   -0x10(%rbp),%eax
cvtsi2sd %eax,%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
cvtsi2sdl -0xc(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    1129 <fakeSomeWork+0x29>
jmp    117a <fakeSomeWork+0x7a>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    1118 <fakeSomeWork+0x18>
movsd  -0x8(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<fakeSomeWork>:
movsd  0xef8(%rip),%xmm0
mov    $0x64,%r8d
mov    $0x30cdc,%r9d
mov    $0xffffff38,%ecx
mov    $0x30d40,%esi
xchg   %ax,%ax
xorps  %xmm1,%xmm1
cvtsi2sd %r8d,%xmm1
mov    $0xfffff830,%edi
mov    %esi,%edx
mov    %r9d,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xorps  %xmm2,%xmm2
cvtsi2sd %edx,%xmm2
movapd %xmm1,%xmm3
mulsd  %xmm0,%xmm3
mulsd  %xmm0,%xmm0
addsd  %xmm2,%xmm0
xorps  %xmm2,%xmm2
cvtsi2sd %eax,%xmm2
addsd  %xmm3,%xmm0
movapd %xmm1,%xmm3
mulsd  %xmm0,%xmm3
mulsd  %xmm0,%xmm0
addsd  %xmm2,%xmm0
addsd  %xmm3,%xmm0
add    %ecx,%eax
add    %ecx,%edx
add    $0x2,%edi
jne    1140 <fakeSomeWork+0x40>
lea    -0x1(%r8),%eax
add    $0xfffff831,%r9d
add    $0x2,%ecx
add    $0xfffff830,%esi
cmp    $0x1,%r8d
mov    %eax,%r8d
ja     1120 <fakeSomeWork+0x20>
ret

LLVM IR (-O0):
define double @fakeSomeWork() {
%1 = alloca double
%2 = alloca i32
%3 = alloca i32
store double 1.000000e+00, double* %1
store i32 100, i32* %2
br label %4
4: ; preds = %27, %0
%5 = load i32, i32* %2
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %30
7: ; preds = %4
store i32 2000, i32* %3
br label %8
8: ; preds = %23, %7
%9 = load i32, i32* %3
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %26
11: ; preds = %8
%12 = load double, double* %1
%13 = load double, double* %1
%14 = load i32, i32* %2
%15 = load i32, i32* %3
%16 = mul nsw i32 %14, %15
%17 = sitofp i32 %16 to double
%18 = call double @llvm.fmuladd.f64(double %12, double %13, double %17)
%19 = load i32, i32* %2
%20 = sitofp i32 %19 to double
%21 = load double, double* %1
%22 = call double @llvm.fmuladd.f64(double %20, double %21, double %18)
store double %22, double* %1
br label %23
23: ; preds = %11
%24 = load i32, i32* %3
%25 = add nsw i32 %24, -1
store i32 %25, i32* %3
br label %8
26: ; preds = %8
br label %27
27: ; preds = %26
%28 = load i32, i32* %2
%29 = add nsw i32 %28, -1
store i32 %29, i32* %2
br label %4
30: ; preds = %4
%31 = load double, double* %1
ret double %31
}

LLVM IR (-O2):
define double @fakeSomeWork() {
br label %1
1: ; preds = %0, %19
%2 = phi i32 [ 100, %0 ], [ %20, %19 ]
%3 = phi double [ 1.000000e+00, %0 ], [ %16, %19 ]
%4 = sitofp i32 %2 to double
br label %5
5: ; preds = %5, %1
%6 = phi i32 [ 2000, %1 ], [ %17, %5 ]
%7 = phi double [ %3, %1 ], [ %16, %5 ]
%8 = mul nuw nsw i32 %6, %2
%9 = sitofp i32 %8 to double
%10 = tail call double @llvm.fmuladd.f64(double %7, double %7, double %9)
%11 = tail call double @llvm.fmuladd.f64(double %4, double %7, double %10)
%12 = add nsw i32 %6, -1
%13 = mul nuw nsw i32 %12, %2
%14 = sitofp i32 %13 to double
%15 = tail call double @llvm.fmuladd.f64(double %11, double %11, double %14)
%16 = tail call double @llvm.fmuladd.f64(double %4, double %11, double %15)
%17 = add nsw i32 %6, -2
%18 = icmp eq i32 %12, 1
br i1 %18, label %19, label %5
19: ; preds = %5
%20 = add nsw i32 %2, -1
%21 = icmp ugt i32 %2, 1
br i1 %21, label %1, label %22
22: ; preds = %19
ret double %16
}