#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 /*<<< orphan*/ val;

/* Variables and functions */
int /*<<< orphan*/ Com_sprintf(char *, int, char *, float);
int /*<<< orphan*/ Cvar_SetSafe(char const *, char *);
scalar_t__ Q_isintegral(float);
void Cvar_SetValueSafe(const char *var_name, float value) {
  char val[32];
  if (Q_isintegral(value))
    Com_sprintf(val, sizeof(val), "%i", (int)value);
  else
    Com_sprintf(val, sizeof(val), "%f", value);
  Cvar_SetSafe(var_name, val);
}


x86 assembly (clang, -O0):
<Cvar_SetValueSafe>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
call   1050 <Q_isintegral@plt>
cmp    $0x0,%rax
je     1178 <Cvar_SetValueSafe+0x48>
lea    -0x30(%rbp),%rdi
cvttss2si -0xc(%rbp),%eax
cvtsi2ss %eax,%xmm0
mov    $0x20,%esi
lea    0xe92(%rip),%rdx
call   1040 <Com_sprintf@plt>
jmp    1192 <Cvar_SetValueSafe+0x62>
lea    -0x30(%rbp),%rdi
movss  -0xc(%rbp),%xmm0
mov    $0x20,%esi
lea    0xe76(%rip),%rdx
call   1040 <Com_sprintf@plt>
mov    -0x8(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1030 <Cvar_SetSafe@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Cvar_SetValueSafe>:
push   %rbx
sub    $0x30,%rsp
mov    %rdi,%rbx
movaps %xmm0,(%rsp)
call   1050 <Q_isintegral@plt>
test   %rax,%rax
je     1161 <Cvar_SetValueSafe+0x31>
cvttps2dq (%rsp),%xmm0
cvtdq2ps %xmm0,%xmm0
lea    0xeab(%rip),%rdx
lea    0x10(%rsp),%rdi
mov    $0x20,%esi
jmp    1176 <Cvar_SetValueSafe+0x46>
lea    0xe9b(%rip),%rdx
lea    0x10(%rsp),%rdi
mov    $0x20,%esi
movaps (%rsp),%xmm0
call   1040 <Com_sprintf@plt>
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   1030 <Cvar_SetSafe@plt>
add    $0x30,%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_SetValueSafe(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 = call i64 @Q_isintegral(float %6)
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %15
9: ; preds = %2
%10 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%11 = load float, float* %4
%12 = fptosi float %11 to i32
%13 = sitofp i32 %12 to float
%14 = call i32 @Com_sprintf(i8* %10, i32 32, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float %13)
br label %19
15: ; preds = %2
%16 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%17 = load float, float* %4
%18 = call i32 @Com_sprintf(i8* %16, i32 32, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float %17)
br label %19
19: ; preds = %15, %9
%20 = load i8*, i8** %3
%21 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%22 = call i32 @Cvar_SetSafe(i8* %20, i8* %21)
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%i\00"
@.str.1 = [3 x i8] c"%f\00"
define void @Cvar_SetValueSafe(i8* %0, float %1) {
%3 = alloca [32 x i8]
%4 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%5 = tail call i64 @Q_isintegral(float %1)
%6 = icmp eq i64 %5, 0
br i1 %6, label %11, label %7
7: ; preds = %2
%8 = fptosi float %1 to i32
%9 = sitofp i32 %8 to float
%10 = call i32 @Com_sprintf(i8* %4, i32 32, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float %9)
br label %13
11: ; preds = %2
%12 = call i32 @Com_sprintf(i8* %4, i32 32, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float %1)
br label %13
13: ; preds = %11, %7
%14 = call i32 @Cvar_SetSafe(i8* %0, i8* %4)
ret void
}