#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__ expf(float);
int bench_expf() {
  int niter = 100000, i, j;
  float x = 0.5f, y = 0;
  for (i = 0; i < niter; ++i) {
    for (j = 0; j < 4; ++j) {
      x += 1e-6f;
      y += expf(x + 5 * (j & 1));
    }
  }
  if (y == 2.32132323232f)
    niter--;
  return niter;
}


x86 assembly (clang, -O0):
<bench_expf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x186a0,-0x4(%rbp)
movss  0xed9(%rip),%xmm0
movss  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11b5 <bench_expf+0xa5>
movl   $0x0,-0xc(%rbp)
cmpl   $0x4,-0xc(%rbp)
jge    11a2 <bench_expf+0x92>
movss  0xea8(%rip),%xmm0
addss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
mov    -0xc(%rbp),%eax
and    $0x1,%eax
imul   $0x5,%eax,%eax
cvtsi2ss %eax,%xmm1
addss  %xmm1,%xmm0
call   1030 <expf@plt>
cvtsi2ss %rax,%xmm0
addss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    114e <bench_expf+0x3e>
jmp    11a7 <bench_expf+0x97>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    113b <bench_expf+0x2b>
movss  -0x14(%rbp),%xmm0
movss  0xe42(%rip),%xmm1
ucomiss %xmm1,%xmm0
jne    11da <bench_expf+0xca>
jp     11da <bench_expf+0xca>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bench_expf>:
push   %rbx
sub    $0x10,%rsp
movss  0xee3(%rip),%xmm0
movss  %xmm0,0x8(%rsp)
mov    $0x186a0,%ebx
xorps  %xmm0,%xmm0
nopl   0x0(%rax,%rax,1)
movss  %xmm0,0xc(%rsp)
movss  0x8(%rsp),%xmm1
movss  0xec0(%rip),%xmm0
addss  %xmm0,%xmm1
movss  %xmm1,0x8(%rsp)
movaps %xmm1,%xmm0
xorps  %xmm1,%xmm1
addss  %xmm1,%xmm0
call   1030 <expf@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
addss  0xc(%rsp),%xmm0
movss  %xmm0,0xc(%rsp)
movss  0x8(%rsp),%xmm0
addss  0xe85(%rip),%xmm0
movss  %xmm0,0x8(%rsp)
movss  0xe7b(%rip),%xmm1
addss  %xmm1,%xmm0
call   1030 <expf@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
addss  0xc(%rsp),%xmm0
movss  %xmm0,0xc(%rsp)
movss  0x8(%rsp),%xmm0
addss  0xe4c(%rip),%xmm0
movss  %xmm0,0x8(%rsp)
addss  0xe4a(%rip),%xmm0
call   1030 <expf@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
addss  0xc(%rsp),%xmm0
movss  %xmm0,0xc(%rsp)
movss  0x8(%rsp),%xmm0
addss  0xe17(%rip),%xmm0
movss  %xmm0,0x8(%rsp)
addss  0xe0d(%rip),%xmm0
call   1030 <expf@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
addss  0xc(%rsp),%xmm0
add    $0xffffffff,%ebx
jne    1130 <bench_expf+0x20>
cmpeqss 0xdec(%rip),%xmm0
movd   %xmm0,%eax
add    $0x186a0,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @bench_expf() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca float
%5 = alloca float
store i32 100000, i32* %1
store float 5.000000e-01, float* %4
store float 0.000000e+00, float* %5
store i32 0, i32* %2
br label %6
6: ; preds = %31, %0
%7 = load i32, i32* %2
%8 = load i32, i32* %1
%9 = icmp slt i32 %7, %8
br i1 %9, label %10, label %34
10: ; preds = %6
store i32 0, i32* %3
br label %11
11: ; preds = %27, %10
%12 = load i32, i32* %3
%13 = icmp slt i32 %12, 4
br i1 %13, label %14, label %30
14: ; preds = %11
%15 = load float, float* %4
%16 = fadd float %15, 0x3EB0C6F7A0000000
store float %16, float* %4
%17 = load float, float* %4
%18 = load i32, i32* %3
%19 = and i32 %18, 1
%20 = mul nsw i32 5, %19
%21 = sitofp i32 %20 to float
%22 = fadd float %17, %21
%23 = call i64 @expf(float %22)
%24 = sitofp i64 %23 to float
%25 = load float, float* %5
%26 = fadd float %25, %24
store float %26, float* %5
br label %27
27: ; preds = %14
%28 = load i32, i32* %3
%29 = add nsw i32 %28, 1
store i32 %29, i32* %3
br label %11
30: ; preds = %11
br label %31
31: ; preds = %30
%32 = load i32, i32* %2
%33 = add nsw i32 %32, 1
store i32 %33, i32* %2
br label %6
34: ; preds = %6
%35 = load float, float* %5
%36 = fcmp oeq float %35, 0x40029211E0000000
br i1 %36, label %37, label %40
37: ; preds = %34
%38 = load i32, i32* %1
%39 = add nsw i32 %38, -1
store i32 %39, i32* %1
br label %40
40: ; preds = %37, %34
%41 = load i32, i32* %1
ret i32 %41
}

LLVM IR (-O2):
define i32 @bench_expf() {
br label %1
1: ; preds = %0, %1
%2 = phi float [ 0.000000e+00, %0 ], [ %24, %1 ]
%3 = phi float [ 5.000000e-01, %0 ], [ %20, %1 ]
%4 = phi i32 [ 0, %0 ], [ %25, %1 ]
%5 = fadd float %3, 0x3EB0C6F7A0000000
%6 = fadd float %5, 0.000000e+00
%7 = tail call i64 @expf(float %6)
%8 = sitofp i64 %7 to float
%9 = fadd float %2, %8
%10 = fadd float %5, 0x3EB0C6F7A0000000
%11 = fadd float %10, 5.000000e+00
%12 = tail call i64 @expf(float %11)
%13 = sitofp i64 %12 to float
%14 = fadd float %9, %13
%15 = fadd float %10, 0x3EB0C6F7A0000000
%16 = fadd float %15, 0.000000e+00
%17 = tail call i64 @expf(float %16)
%18 = sitofp i64 %17 to float
%19 = fadd float %14, %18
%20 = fadd float %15, 0x3EB0C6F7A0000000
%21 = fadd float %20, 5.000000e+00
%22 = tail call i64 @expf(float %21)
%23 = sitofp i64 %22 to float
%24 = fadd float %19, %23
%25 = add nuw nsw i32 %4, 1
%26 = icmp eq i32 %25, 100000
br i1 %26, label %27, label %1
27: ; preds = %1
%28 = fcmp oeq float %24, 0x40029211E0000000
%29 = select i1 %28, i32 99999, i32 100000
ret i32 %29
}