#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 */
struct polynomial_function {
  int dummy;
};

/* Variables and functions */
float fabsf(scalar_t__);
scalar_t__ get_value(struct polynomial_function *, float);
float sum_of_diffs(struct polynomial_function *f, float a, float b, float h) {
  float result = 0.0;
  for (float i = a; i < b; i += h) {
    result += fabsf(get_value(f, i + h) - get_value(f, i)) * h;
  }
  return result;
}


x86 assembly (clang, -O0):
<sum_of_diffs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movss  %xmm0,-0xc(%rbp)
movss  %xmm1,-0x10(%rbp)
movss  %xmm2,-0x14(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x1c(%rbp),%xmm1
movss  -0x10(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    11bc <sum_of_diffs+0x9c>
mov    -0x8(%rbp),%rdi
movss  -0x1c(%rbp),%xmm0
addss  -0x14(%rbp),%xmm0
call   1040 <get_value@plt>
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
movss  -0x1c(%rbp),%xmm0
call   1040 <get_value@plt>
mov    -0x28(%rbp),%rdi
sub    %rax,%rdi
call   1030 <fabsf@plt>
movss  -0x14(%rbp),%xmm2
movss  -0x18(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x14(%rbp),%xmm0
addss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
jmp    114d <sum_of_diffs+0x2d>
movss  -0x18(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sum_of_diffs>:
push   %r14
push   %rbx
sub    $0x18,%rsp
movaps %xmm0,%xmm4
xorps  %xmm0,%xmm0
ucomiss %xmm4,%xmm1
jbe    11c1 <sum_of_diffs+0xa1>
mov    %rdi,%r14
xorps  %xmm0,%xmm0
movaps %xmm4,%xmm3
movss  %xmm2,0xc(%rsp)
movss  %xmm1,0x8(%rsp)
nopl   0x0(%rax,%rax,1)
movss  %xmm4,0x10(%rsp)
movss  %xmm0,0x4(%rsp)
addss  %xmm2,%xmm3
movss  %xmm3,0x14(%rsp)
mov    %r14,%rdi
movaps %xmm3,%xmm0
call   1040 <get_value@plt>
mov    %rax,%rbx
mov    %r14,%rdi
movss  0x10(%rsp),%xmm0
call   1040 <get_value@plt>
sub    %rax,%rbx
mov    %rbx,%rdi
call   1030 <fabsf@plt>
movss  0x8(%rsp),%xmm1
movss  0xc(%rsp),%xmm2
mulss  %xmm2,%xmm0
movss  0x4(%rsp),%xmm3
addss  %xmm0,%xmm3
movss  %xmm3,0x4(%rsp)
movss  0x14(%rsp),%xmm3
movss  0x4(%rsp),%xmm0
ucomiss %xmm3,%xmm1
movaps %xmm3,%xmm4
ja     1150 <sum_of_diffs+0x30>
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.polynomial_function = type { i32 }
define float @sum_of_diffs(%struct.polynomial_function* %0, float %1, float %2, float %3) {
%5 = alloca %struct.polynomial_function*
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca float
store %struct.polynomial_function* %0, %struct.polynomial_function** %5
store float %1, float* %6
store float %2, float* %7
store float %3, float* %8
store float 0.000000e+00, float* %9
%11 = load float, float* %6
store float %11, float* %10
br label %12
12: ; preds = %30, %4
%13 = load float, float* %10
%14 = load float, float* %7
%15 = fcmp olt float %13, %14
br i1 %15, label %16, label %34
16: ; preds = %12
%17 = load %struct.polynomial_function*, %struct.polynomial_function** %5
%18 = load float, float* %10
%19 = load float, float* %8
%20 = fadd float %18, %19
%21 = call i64 @get_value(%struct.polynomial_function* %17, float %20)
%22 = load %struct.polynomial_function*, %struct.polynomial_function** %5
%23 = load float, float* %10
%24 = call i64 @get_value(%struct.polynomial_function* %22, float %23)
%25 = sub nsw i64 %21, %24
%26 = call float @fabsf(i64 %25)
%27 = load float, float* %8
%28 = load float, float* %9
%29 = call float @llvm.fmuladd.f32(float %26, float %27, float %28)
store float %29, float* %9
br label %30
30: ; preds = %16
%31 = load float, float* %8
%32 = load float, float* %10
%33 = fadd float %32, %31
store float %33, float* %10
br label %12
34: ; preds = %12
%35 = load float, float* %9
ret float %35
}

LLVM IR (-O2):
%struct.polynomial_function = type { i32 }
define float @sum_of_diffs(%struct.polynomial_function* %0, float %1, float %2, float %3) {
%5 = fcmp olt float %1, %2
br i1 %5, label %8, label %6
6: ; preds = %8, %4
%7 = phi float [ 0.000000e+00, %4 ], [ %16, %8 ]
ret float %7
8: ; preds = %4, %8
%9 = phi float [ %11, %8 ], [ %1, %4 ]
%10 = phi float [ %16, %8 ], [ 0.000000e+00, %4 ]
%11 = fadd float %9, %3
%12 = tail call i64 @get_value(%struct.polynomial_function* %0, float %11)
%13 = tail call i64 @get_value(%struct.polynomial_function* %0, float %9)
%14 = sub nsw i64 %12, %13
%15 = tail call float @fabsf(i64 %14)
%16 = tail call float @llvm.fmuladd.f32(float %15, float %3, float %10)
%17 = fcmp olt float %11, %2
br i1 %17, label %8, label %6
}