#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 */
double ceil(double);
double floor(double);
double pow(int, double);
double roundValue(double value, int precision) {
  double temp;
  if (value < 0)
    temp = ceil(value * pow(10., (double)precision) - .5);
  else
    temp = floor(value * pow(10., (double)precision) + .5);
  value = temp / pow(10., (double)precision);
  return value;
}


x86 assembly (clang, -O0):
<roundValue>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %edi,-0xc(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    118e <roundValue+0x5e>
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
cvtsi2sdl -0xc(%rbp),%xmm0
mov    $0xa,%edi
call   1040 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  0xe8d(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1030 <ceil@plt>
movsd  %xmm0,-0x18(%rbp)
jmp    11c9 <roundValue+0x99>
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
cvtsi2sdl -0xc(%rbp),%xmm0
mov    $0xa,%edi
call   1040 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  0xe45(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1050 <floor@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
cvtsi2sdl -0xc(%rbp),%xmm0
mov    $0xa,%edi
call   1040 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<roundValue>:
sub    $0x18,%rsp
movsd  %xmm0,0x8(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sd %edi,%xmm0
mov    $0xa,%edi
movsd  %xmm0,0x10(%rsp)
call   1040 <pow@plt>
xorpd  %xmm1,%xmm1
movsd  0x8(%rsp),%xmm2
ucomisd %xmm2,%xmm1
movapd %xmm2,%xmm1
mulsd  %xmm0,%xmm1
jbe    117c <roundValue+0x4c>
addsd  0xe97(%rip),%xmm1
movapd %xmm1,%xmm0
call   1030 <ceil@plt>
jmp    118d <roundValue+0x5d>
addsd  0xe7c(%rip),%xmm1
movapd %xmm1,%xmm0
call   1050 <floor@plt>
movsd  %xmm0,0x8(%rsp)
mov    $0xa,%edi
movsd  0x10(%rsp),%xmm0
call   1040 <pow@plt>
movsd  0x8(%rsp),%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x18,%rsp
ret

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

LLVM IR (-O2):
define double @roundValue(double %0, i32 %1) {
%3 = fcmp olt double %0, 0.000000e+00
%4 = sitofp i32 %1 to double
%5 = tail call double @pow(i32 10, double %4)
br i1 %3, label %6, label %9
6: ; preds = %2
%7 = tail call double @llvm.fmuladd.f64(double %0, double %5, double -5.000000e-01)
%8 = tail call double @llvm.ceil.f64(double %7)
br label %12
9: ; preds = %2
%10 = tail call double @llvm.fmuladd.f64(double %0, double %5, double 5.000000e-01)
%11 = tail call double @llvm.floor.f64(double %10)
br label %12
12: ; preds = %9, %6
%13 = phi double [ %11, %9 ], [ %8, %6 ]
%14 = tail call double @pow(i32 10, double %4)
%15 = fdiv double %13, %14
ret double %15
}