#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 scalar_t__ value;
typedef int /*<<< orphan*/ val;

/* Variables and functions */
int /*<<< orphan*/ Cvar_Set(char const *, char *);
int /*<<< orphan*/ Q_snprintfz(char *, int, char *, float);
void Cvar_SetValue(const char *var_name, float value) {
  char val[32];
  if (value == ((value) < 0 ? ((int)((value)-0.5f)) : ((int)((value) + 0.5f))))
    Q_snprintfz(
        val, sizeof(val), "%i",
        ((value) < 0 ? ((int)((value)-0.5f)) : ((int)((value) + 0.5f))));
  else
    Q_snprintfz(val, sizeof(val), "%f", value);
  Cvar_Set(var_name, val);
}


x86 assembly (clang, -O0):
<Cvar_SetValue>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x34(%rbp)
xorps  %xmm0,%xmm0
ucomiss -0xc(%rbp),%xmm0
jbe    1165 <Cvar_SetValue+0x45>
movss  -0xc(%rbp),%xmm0
movss  0xeab(%rip),%xmm1
subss  %xmm1,%xmm0
cvttss2si %xmm0,%eax
mov    %eax,-0x38(%rbp)
jmp    1179 <Cvar_SetValue+0x59>
movss  0xe93(%rip),%xmm0
addss  -0xc(%rbp),%xmm0
cvttss2si %xmm0,%eax
mov    %eax,-0x38(%rbp)
movss  -0x34(%rbp),%xmm0
mov    -0x38(%rbp),%eax
cvtsi2ss %eax,%xmm1
ucomiss %xmm1,%xmm0
jne    11fb <Cvar_SetValue+0xdb>
jp     11fb <Cvar_SetValue+0xdb>
lea    -0x30(%rbp),%rax
mov    %rax,-0x40(%rbp)
xorps  %xmm0,%xmm0
ucomiss -0xc(%rbp),%xmm0
jbe    11c6 <Cvar_SetValue+0xa6>
movss  -0xc(%rbp),%xmm0
movss  0xe4a(%rip),%xmm1
subss  %xmm1,%xmm0
cvttss2si %xmm0,%eax
mov    %eax,-0x44(%rbp)
jmp    11da <Cvar_SetValue+0xba>
movss  0xe32(%rip),%xmm0
addss  -0xc(%rbp),%xmm0
cvttss2si %xmm0,%eax
mov    %eax,-0x44(%rbp)
mov    -0x40(%rbp),%rdi
mov    -0x44(%rbp),%eax
cvtsi2ss %eax,%xmm0
mov    $0x20,%esi
lea    0xe13(%rip),%rdx
call   1040 <Q_snprintfz@plt>
jmp    1215 <Cvar_SetValue+0xf5>
lea    -0x30(%rbp),%rdi
movss  -0xc(%rbp),%xmm0
mov    $0x20,%esi
lea    0xdf7(%rip),%rdx
call   1040 <Q_snprintfz@plt>
mov    -0x8(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1030 <Cvar_Set@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Cvar_SetValue>:
push   %rbx
sub    $0x20,%rsp
xorps  %xmm1,%xmm1
xor    %eax,%eax
ucomiss %xmm0,%xmm1
seta   %al
mov    %rdi,%rbx
lea    0xec6(%rip),%rcx
movss  (%rcx,%rax,4),%xmm1
addss  %xmm0,%xmm1
cvttps2dq %xmm1,%xmm1
cvtdq2ps %xmm1,%xmm1
ucomiss %xmm0,%xmm1
jne    1165 <Cvar_SetValue+0x45>
jp     1165 <Cvar_SetValue+0x45>
lea    0xeb0(%rip),%rdx
mov    %rsp,%rdi
mov    $0x20,%esi
movaps %xmm1,%xmm0
jmp    1174 <Cvar_SetValue+0x54>
lea    0xe9f(%rip),%rdx
mov    %rsp,%rdi
mov    $0x20,%esi
call   1040 <Q_snprintfz@plt>
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1030 <Cvar_Set@plt>
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%i\00"
@.str.1 = [3 x i8] c"%f\00"
define void @Cvar_SetValue(i8* %0, float %1) {
%3 = alloca i8*
%4 = alloca float
%5 = alloca [32 x i8]
store i8* %0, i8** %3
store float %1, float* %4
%6 = load float, float* %4
%7 = load float, float* %4
%8 = fcmp olt float %7, 0.000000e+00
br i1 %8, label %9, label %13
9: ; preds = %2
%10 = load float, float* %4
%11 = fsub float %10, 5.000000e-01
%12 = fptosi float %11 to i32
br label %17
13: ; preds = %2
%14 = load float, float* %4
%15 = fadd float %14, 5.000000e-01
%16 = fptosi float %15 to i32
br label %17
17: ; preds = %13, %9
%18 = phi i32 [ %12, %9 ], [ %16, %13 ]
%19 = sitofp i32 %18 to float
%20 = fcmp oeq float %6, %19
br i1 %20, label %21, label %37
21: ; preds = %17
%22 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%23 = load float, float* %4
%24 = fcmp olt float %23, 0.000000e+00
br i1 %24, label %25, label %29
25: ; preds = %21
%26 = load float, float* %4
%27 = fsub float %26, 5.000000e-01
%28 = fptosi float %27 to i32
br label %33
29: ; preds = %21
%30 = load float, float* %4
%31 = fadd float %30, 5.000000e-01
%32 = fptosi float %31 to i32
br label %33
33: ; preds = %29, %25
%34 = phi i32 [ %28, %25 ], [ %32, %29 ]
%35 = sitofp i32 %34 to float
%36 = call i32 @Q_snprintfz(i8* %22, i32 32, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float %35)
br label %41
37: ; preds = %17
%38 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%39 = load float, float* %4
%40 = call i32 @Q_snprintfz(i8* %38, i32 32, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float %39)
br label %41
41: ; preds = %37, %33
%42 = load i8*, i8** %3
%43 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%44 = call i32 @Cvar_Set(i8* %42, i8* %43)
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%i\00"
@.str.1 = [3 x i8] c"%f\00"
define void @Cvar_SetValue(i8* %0, float %1) {
%3 = alloca [32 x i8]
%4 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%5 = fcmp olt float %1, 0.000000e+00
%6 = select i1 %5, float -5.000000e-01, float 5.000000e-01
%7 = fadd float %6, %1
%8 = fptosi float %7 to i32
%9 = sitofp i32 %8 to float
%10 = fcmp oeq float %9, %1
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = call i32 @Q_snprintfz(i8* %4, i32 32, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float %9)
br label %15
13: ; preds = %2
%14 = call i32 @Q_snprintfz(i8* %4, i32 32, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float %1)
br label %15
15: ; preds = %13, %11
%16 = call i32 @Cvar_Set(i8* %0, i8* %4)
ret void
}