double ROUND(arg)
double arg;
{
  int rj;
  if (arg >= 2147483647 || arg <= -2147483647)
    derror(20);
  if (arg > 0) {
    rj = arg + 0.5;
    return rj;
  } else if (arg < 0) {
    rj = 0.5 - arg;
    return -rj;
  } else
    return 0;
}


x86 assembly (clang, -O0):
<ROUND>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xed6(%rip),%xmm1
ucomisd %xmm1,%xmm0
jae    1147 <ROUND+0x37>
movsd  0xecc(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     1153 <ROUND+0x43>
mov    $0x14,%edi
mov    $0x0,%al
call   1030 <derror@plt>
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    1188 <ROUND+0x78>
movsd  0xea3(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x14(%rbp)
cvtsi2sdl -0x14(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11c5 <ROUND+0xb5>
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    11bd <ROUND+0xad>
movsd  0xe72(%rip),%xmm0
subsd  -0x10(%rbp),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x14(%rbp)
xor    %eax,%eax
sub    -0x14(%rbp),%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11c5 <ROUND+0xb5>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ROUND>:
sub    $0x18,%rsp
movapd %xmm0,%xmm1
ucomisd 0xee0(%rip),%xmm0
jae    1130 <ROUND+0x20>
movsd  0xede(%rip),%xmm0
ucomisd %xmm1,%xmm0
jb     1146 <ROUND+0x36>
mov    $0x14,%edi
xor    %eax,%eax
movapd %xmm1,(%rsp)
call   1030 <derror@plt>
movapd (%rsp),%xmm1
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
jbe    1165 <ROUND+0x55>
addsd  0xeb8(%rip),%xmm1
cvttpd2dq %xmm1,%xmm0
cvtdq2pd %xmm0,%xmm0
add    $0x18,%rsp
ret
ucomisd %xmm1,%xmm0
jbe    1184 <ROUND+0x74>
movsd  0xe9d(%rip),%xmm0
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
neg    %eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define double @ROUND(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca i32
store double %0, double* %3
%5 = load double, double* %3
%6 = fcmp oge double %5, 0x41DFFFFFFFC00000
br i1 %6, label %10, label %7
7: ; preds = %1
%8 = load double, double* %3
%9 = fcmp ole double %8, 0xC1DFFFFFFFC00000
br i1 %9, label %10, label %12
10: ; preds = %7, %1
%11 = call i32 (i32, ...) bitcast (i32 (...)* @derror to i32 (i32, ...)*)(i32 20)
br label %12
12: ; preds = %10, %7
%13 = load double, double* %3
%14 = fcmp ogt double %13, 0.000000e+00
br i1 %14, label %15, label %21
15: ; preds = %12
%16 = load double, double* %3
%17 = fadd double %16, 5.000000e-01
%18 = fptosi double %17 to i32
store i32 %18, i32* %4
%19 = load i32, i32* %4
%20 = sitofp i32 %19 to double
store double %20, double* %2
br label %32
21: ; preds = %12
%22 = load double, double* %3
%23 = fcmp olt double %22, 0.000000e+00
br i1 %23, label %24, label %31
24: ; preds = %21
%25 = load double, double* %3
%26 = fsub double 5.000000e-01, %25
%27 = fptosi double %26 to i32
store i32 %27, i32* %4
%28 = load i32, i32* %4
%29 = sub nsw i32 0, %28
%30 = sitofp i32 %29 to double
store double %30, double* %2
br label %32
31: ; preds = %21
store double 0.000000e+00, double* %2
br label %32
32: ; preds = %31, %24, %15
%33 = load double, double* %2
ret double %33
}

LLVM IR (-O2):
define double @ROUND(double %0) {
%2 = fcmp oge double %0, 0x41DFFFFFFFC00000
%3 = fcmp ole double %0, 0xC1DFFFFFFFC00000
%4 = or i1 %2, %3
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = tail call i32 (i32, ...) bitcast (i32 (...)* @derror to i32 (i32, ...)*)(i32 20)
br label %7
7: ; preds = %1, %5
%8 = fcmp ogt double %0, 0.000000e+00
br i1 %8, label %9, label %13
9: ; preds = %7
%10 = fadd double %0, 5.000000e-01
%11 = fptosi double %10 to i32
%12 = sitofp i32 %11 to double
br label %20
13: ; preds = %7
%14 = fcmp olt double %0, 0.000000e+00
br i1 %14, label %15, label %20
15: ; preds = %13
%16 = fsub double 5.000000e-01, %0
%17 = fptosi double %16 to i32
%18 = sub nsw i32 0, %17
%19 = sitofp i32 %18 to double
br label %20
20: ; preds = %13, %15, %9
%21 = phi double [ %12, %9 ], [ %19, %15 ], [ 0.000000e+00, %13 ]
ret double %21
}