#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 */
typedef int uint64_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, double, double, int);
double rounder(double val, double min, double abstol) {
  uint64_t enc = (((uint64_t)(((double)(val - min)) / abstol)) + 1) >> 1;
  double result = (enc * abstol * 2.0) + min;
  printf("%.2f -> %.2f -> %lld \n", val, result, enc);
}


x86 assembly (clang, -O0):
<rounder>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
divsd  -0x20(%rbp),%xmm0
cvttsd2si %xmm0,%eax
add    $0x1,%eax
sar    $0x1,%eax
mov    %eax,-0x24(%rbp)
cvtsi2sdl -0x24(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
addsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
mov    -0x24(%rbp),%esi
lea    0xe8d(%rip),%rdi
call   1030 <printf@plt>
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rounder>:
movapd %xmm0,%xmm3
subsd  %xmm1,%xmm3
divsd  %xmm2,%xmm3
cvttsd2si %xmm3,%esi
add    $0x1,%esi
sar    %esi
xorps  %xmm3,%xmm3
cvtsi2sd %esi,%xmm3
mulsd  %xmm2,%xmm3
addsd  %xmm3,%xmm3
addsd  %xmm3,%xmm1
lea    0xec1(%rip),%rdi
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [23 x i8] c"%.2f -> %.2f -> %lld \0A\00"
define double @rounder(double %0, double %1, double %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca i32
%9 = alloca double
store double %0, double* %5
store double %1, double* %6
store double %2, double* %7
%10 = load double, double* %5
%11 = load double, double* %6
%12 = fsub double %10, %11
%13 = load double, double* %7
%14 = fdiv double %12, %13
%15 = fptosi double %14 to i32
%16 = add nsw i32 %15, 1
%17 = ashr i32 %16, 1
store i32 %17, i32* %8
%18 = load i32, i32* %8
%19 = sitofp i32 %18 to double
%20 = load double, double* %7
%21 = fmul double %19, %20
%22 = load double, double* %6
%23 = call double @llvm.fmuladd.f64(double %21, double 2.000000e+00, double %22)
store double %23, double* %9
%24 = load double, double* %5
%25 = load double, double* %9
%26 = load i32, i32* %8
%27 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), double %24, double %25, i32 %26)
%28 = load double, double* %4
ret double %28
}

LLVM IR (-O2):
@.str = [23 x i8] c"%.2f -> %.2f -> %lld \0A\00"
define double @rounder(double %0, double %1, double %2) {
%4 = fsub double %0, %1
%5 = fdiv double %4, %2
%6 = fptosi double %5 to i32
%7 = add nsw i32 %6, 1
%8 = ashr i32 %7, 1
%9 = sitofp i32 %8 to double
%10 = fmul double %9, %2
%11 = tail call double @llvm.fmuladd.f64(double %10, double 2.000000e+00, double %1)
%12 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), double %0, double %11, i32 %8)
ret double undef
}