#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 */
scalar_t__ sqrtfcn(float);
int benchmark() {
  float i = 0.0;
  volatile float accum = 0.0;
  for (i = 0.0; i < 10000.; i += 100.)
    accum += sqrtfcn(i);
  return (int)(accum * 1000000);
}


x86 assembly (clang, -O0):
<benchmark>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
xorps  %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x8(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xebf(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    118b <benchmark+0x7b>
movss  -0x4(%rbp),%xmm0
call   1030 <sqrtfcn@plt>
cvtsi2ss %rax,%xmm1
movss  -0x8(%rbp),%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe8f(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    1130 <benchmark+0x20>
movss  -0x8(%rbp),%xmm0
movss  0xe78(%rip),%xmm1
mulss  %xmm1,%xmm0
cvttss2si %xmm0,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<benchmark>:
push   %rbx
sub    $0x10,%rsp
movl   $0x0,0xc(%rsp)
mov    $0xffffff9c,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x64,%ebx
xorps  %xmm0,%xmm0
cvtsi2ss %ebx,%xmm0
call   1030 <sqrtfcn@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
addss  0xc(%rsp),%xmm0
movss  %xmm0,0xc(%rsp)
cmp    $0x26ac,%ebx
jb     1130 <benchmark+0x20>
movss  0xc(%rsp),%xmm0
mulss  0xe97(%rip),%xmm0
cvttss2si %xmm0,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @benchmark() {
%1 = alloca float
%2 = alloca float
store float 0.000000e+00, float* %1
store volatile float 0.000000e+00, float* %2
store float 0.000000e+00, float* %1
br label %3
3: ; preds = %13, %0
%4 = load float, float* %1
%5 = fpext float %4 to double
%6 = fcmp olt double %5, 1.000000e+04
br i1 %6, label %7, label %18
7: ; preds = %3
%8 = load float, float* %1
%9 = call i64 @sqrtfcn(float %8)
%10 = sitofp i64 %9 to float
%11 = load volatile float, float* %2
%12 = fadd float %11, %10
store volatile float %12, float* %2
br label %13
13: ; preds = %7
%14 = load float, float* %1
%15 = fpext float %14 to double
%16 = fadd double %15, 1.000000e+02
%17 = fptrunc double %16 to float
store float %17, float* %1
br label %3
18: ; preds = %3
%19 = load volatile float, float* %2
%20 = fmul float %19, 1.000000e+06
%21 = fptosi float %20 to i32
ret i32 %21
}

LLVM IR (-O2):
define i32 @benchmark() {
%1 = alloca float
%2 = bitcast float* %1 to i8*
store volatile float 0.000000e+00, float* %1
br label %3
3: ; preds = %0, %3
%4 = phi i32 [ 0, %0 ], [ %10, %3 ]
%5 = sitofp i32 %4 to float
%6 = tail call i64 @sqrtfcn(float %5)
%7 = sitofp i64 %6 to float
%8 = load volatile float, float* %1
%9 = fadd float %8, %7
store volatile float %9, float* %1
%10 = add nuw nsw i32 %4, 100
%11 = icmp ult i32 %4, 9900
br i1 %11, label %3, label %12
12: ; preds = %3
%13 = load volatile float, float* %1
%14 = fmul float %13, 1.000000e+06
%15 = fptosi float %14 to i32
ret i32 %15
}