#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 */
scalar_t__ isInteger(float);
float Round(float num) {
  int hold = 0;
  num *= 10000;
  if (isInteger(num))
    return (float)num / 10000.0;
  if (num > 0.0)
    hold = (int)(num + 0.5);
  else
    hold = (int)(num - 0.5);
  return (float)hold / 10000.0;
}


x86 assembly (clang, -O0):
<Round>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movss  %xmm0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movss  0xed4(%rip),%xmm0
mulss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0x8(%rbp),%xmm0
call   1030 <isInteger@plt>
cmp    $0x0,%rax
je     116d <Round+0x5d>
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xeb5(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    11de <Round+0xce>
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    11a4 <Round+0x94>
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe74(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0xc(%rbp)
jmp    11c0 <Round+0xb0>
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe53(%rip),%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0xc(%rbp)
cvtsi2ssl -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe3f(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Round>:
sub    $0x18,%rsp
mulss  0xee4(%rip),%xmm0
movaps %xmm0,(%rsp)
call   1030 <isInteger@plt>
test   %rax,%rax
je     1130 <Round+0x20>
movaps (%rsp),%xmm0
jmp    1159 <Round+0x49>
xorps  %xmm0,%xmm0
xor    %eax,%eax
movaps (%rsp),%xmm1
ucomiss %xmm0,%xmm1
seta   %al
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
lea    0xebb(%rip),%rcx
addsd  (%rcx,%rax,8),%xmm0
cvttpd2dq %xmm0,%xmm0
cvtdq2ps %xmm0,%xmm0
divss  0xe9f(%rip),%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define float @Round(float %0) {
%2 = alloca float
%3 = alloca float
%4 = alloca i32
store float %0, float* %3
store i32 0, i32* %4
%5 = load float, float* %3
%6 = fmul float %5, 1.000000e+04
store float %6, float* %3
%7 = load float, float* %3
%8 = call i64 @isInteger(float %7)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %15
10: ; preds = %1
%11 = load float, float* %3
%12 = fpext float %11 to double
%13 = fdiv double %12, 1.000000e+04
%14 = fptrunc double %13 to float
store float %14, float* %2
br label %35
15: ; preds = %1
%16 = load float, float* %3
%17 = fpext float %16 to double
%18 = fcmp ogt double %17, 0.000000e+00
br i1 %18, label %19, label %24
19: ; preds = %15
%20 = load float, float* %3
%21 = fpext float %20 to double
%22 = fadd double %21, 5.000000e-01
%23 = fptosi double %22 to i32
store i32 %23, i32* %4
br label %29
24: ; preds = %15
%25 = load float, float* %3
%26 = fpext float %25 to double
%27 = fsub double %26, 5.000000e-01
%28 = fptosi double %27 to i32
store i32 %28, i32* %4
br label %29
29: ; preds = %24, %19
%30 = load i32, i32* %4
%31 = sitofp i32 %30 to float
%32 = fpext float %31 to double
%33 = fdiv double %32, 1.000000e+04
%34 = fptrunc double %33 to float
store float %34, float* %2
br label %35
35: ; preds = %29, %10
%36 = load float, float* %2
ret float %36
}

LLVM IR (-O2):
define float @Round(float %0) {
%2 = fmul float %0, 1.000000e+04
%3 = tail call i64 @isInteger(float %2)
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %12
5: ; preds = %1
%6 = fpext float %2 to double
%7 = fcmp ogt float %2, 0.000000e+00
%8 = select i1 %7, double 5.000000e-01, double -5.000000e-01
%9 = fadd double %8, %6
%10 = fptosi double %9 to i32
%11 = sitofp i32 %10 to float
br label %12
12: ; preds = %1, %5
%13 = phi float [ %11, %5 ], [ %2, %1 ]
%14 = fdiv float %13, 1.000000e+04
ret float %14
}