#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 get_range_size(int, int);
int absolute_value_from_relative_part_factor(int range_begin, int range_end,
                                             double relative_part_factor) {
  int range_size = get_range_size(range_begin, range_end);
  float round_factor = 0.5;
  if (relative_part_factor < 0)
    round_factor = -0.5;
  return range_begin +
         (int)((relative_part_factor * range_size) + round_factor);
}


x86 assembly (clang, -O0):
<absolute_value_from_relative_part_factor>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1030 <get_range_size@plt>
mov    %eax,-0x14(%rbp)
movss  0xec7(%rip),%xmm0
movss  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    1159 <absolute_value_from_relative_part_factor+0x49>
movss  0xeb0(%rip),%xmm0
movss  %xmm0,-0x18(%rbp)
mov    -0x4(%rbp),%eax
movsd  -0x10(%rbp),%xmm0
cvtsi2sdl -0x14(%rbp),%xmm2
movss  -0x18(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%ecx
add    %ecx,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<absolute_value_from_relative_part_factor>:
push   %rbp
push   %rbx
push   %rax
movsd  %xmm0,(%rsp)
mov    %edi,%ebp
xorpd  %xmm1,%xmm1
xor    %ebx,%ebx
ucomisd %xmm0,%xmm1
seta   %bl
call   1030 <get_range_size@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  (%rsp),%xmm0
lea    0xec1(%rip),%rax
addsd  (%rax,%rbx,8),%xmm0
cvttsd2si %xmm0,%eax
add    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @absolute_value_from_relative_part_factor(i32 %0, i32 %1, double %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca double
%7 = alloca i32
%8 = alloca float
store i32 %0, i32* %4
store i32 %1, i32* %5
store double %2, double* %6
%9 = load i32, i32* %4
%10 = load i32, i32* %5
%11 = call i32 @get_range_size(i32 %9, i32 %10)
store i32 %11, i32* %7
store float 5.000000e-01, float* %8
%12 = load double, double* %6
%13 = fcmp olt double %12, 0.000000e+00
br i1 %13, label %14, label %15
14: ; preds = %3
store float -5.000000e-01, float* %8
br label %15
15: ; preds = %14, %3
%16 = load i32, i32* %4
%17 = load double, double* %6
%18 = load i32, i32* %7
%19 = sitofp i32 %18 to double
%20 = load float, float* %8
%21 = fpext float %20 to double
%22 = call double @llvm.fmuladd.f64(double %17, double %19, double %21)
%23 = fptosi double %22 to i32
%24 = add nsw i32 %16, %23
ret i32 %24
}

LLVM IR (-O2):
define i32 @absolute_value_from_relative_part_factor(i32 %0, i32 %1, double %2) {
%4 = tail call i32 @get_range_size(i32 %0, i32 %1)
%5 = fcmp olt double %2, 0.000000e+00
%6 = select i1 %5, double -5.000000e-01, double 5.000000e-01
%7 = sitofp i32 %4 to double
%8 = tail call double @llvm.fmuladd.f64(double %2, double %7, double %6)
%9 = fptosi double %8 to i32
%10 = add nsw i32 %9, %0
ret i32 %10
}