#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 */
int cvtFloatToExpString(float, char *, unsigned short);
int cvtFloatToString(float, char *, unsigned short);
int cvtFloatToCompactString(float f_value, char *pstr_value,
                            unsigned short f_precision) {
  if ((f_value < 1.e4 && f_value > 1.e-4) ||
      (f_value > -1.e4 && f_value < -1.e-4) || f_value == 0.0) {
    return (cvtFloatToString(f_value, pstr_value, f_precision));
  } else {
    return (cvtFloatToExpString(f_value, pstr_value, f_precision));
  }
}


x86 assembly (clang, -O0):
<cvtFloatToCompactString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %si,%ax
movss  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
mov    %ax,-0x12(%rbp)
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xeb7(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    116e <cvtFloatToCompactString+0x4e>
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xea4(%rip),%xmm1
ucomisd %xmm1,%xmm0
ja     11c0 <cvtFloatToCompactString+0xa0>
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe91(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11a4 <cvtFloatToCompactString+0x84>
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe7e(%rip),%xmm0
ucomisd %xmm1,%xmm0
ja     11c0 <cvtFloatToCompactString+0xa0>
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11da <cvtFloatToCompactString+0xba>
jp     11da <cvtFloatToCompactString+0xba>
movss  -0x8(%rbp),%xmm0
mov    -0x10(%rbp),%rdi
movzwl -0x12(%rbp),%esi
call   1040 <cvtFloatToString@plt>
mov    %eax,-0x4(%rbp)
jmp    11ef <cvtFloatToCompactString+0xcf>
movss  -0x8(%rbp),%xmm0
mov    -0x10(%rbp),%rdi
movzwl -0x12(%rbp),%esi
call   1030 <cvtFloatToExpString@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cvtFloatToCompactString>:
cvtss2sd %xmm0,%xmm1
movss  0xed4(%rip),%xmm2
ucomiss %xmm0,%xmm2
jbe    113b <cvtFloatToCompactString+0x1b>
ucomisd 0xecf(%rip),%xmm1
ja     116a <cvtFloatToCompactString+0x4a>
ucomiss 0xec2(%rip),%xmm0
seta   %al
movsd  0xec3(%rip),%xmm2
ucomisd %xmm1,%xmm2
seta   %cl
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    115e <cvtFloatToCompactString+0x3e>
jnp    116a <cvtFloatToCompactString+0x4a>
and    %cl,%al
jne    116a <cvtFloatToCompactString+0x4a>
movzwl %si,%esi
jmp    1030 <cvtFloatToExpString@plt>
movzwl %si,%esi
jmp    1040 <cvtFloatToString@plt>

LLVM IR (-O0):
define i32 @cvtFloatToCompactString(float %0, i8* %1, i16 zeroext %2) {
%4 = alloca i32
%5 = alloca float
%6 = alloca i8*
%7 = alloca i16
store float %0, float* %5
store i8* %1, i8** %6
store i16 %2, i16* %7
%8 = load float, float* %5
%9 = fpext float %8 to double
%10 = fcmp olt double %9, 1.000000e+04
br i1 %10, label %11, label %15
11: ; preds = %3
%12 = load float, float* %5
%13 = fpext float %12 to double
%14 = fcmp ogt double %13, 1.000000e-04
br i1 %14, label %27, label %15
15: ; preds = %11, %3
%16 = load float, float* %5
%17 = fpext float %16 to double
%18 = fcmp ogt double %17, -1.000000e+04
br i1 %18, label %19, label %23
19: ; preds = %15
%20 = load float, float* %5
%21 = fpext float %20 to double
%22 = fcmp olt double %21, -1.000000e-04
br i1 %22, label %27, label %23
23: ; preds = %19, %15
%24 = load float, float* %5
%25 = fpext float %24 to double
%26 = fcmp oeq double %25, 0.000000e+00
br i1 %26, label %27, label %32
27: ; preds = %23, %19, %11
%28 = load float, float* %5
%29 = load i8*, i8** %6
%30 = load i16, i16* %7
%31 = call i32 @cvtFloatToString(float %28, i8* %29, i16 zeroext %30)
store i32 %31, i32* %4
br label %37
32: ; preds = %23
%33 = load float, float* %5
%34 = load i8*, i8** %6
%35 = load i16, i16* %7
%36 = call i32 @cvtFloatToExpString(float %33, i8* %34, i16 zeroext %35)
store i32 %36, i32* %4
br label %37
37: ; preds = %32, %27
%38 = load i32, i32* %4
ret i32 %38
}

LLVM IR (-O2):
define i32 @cvtFloatToCompactString(float %0, i8* %1, i16 zeroext %2) {
%4 = fpext float %0 to double
%5 = fcmp olt float %0, 1.000000e+04
%6 = fcmp ogt double %4, 1.000000e-04
%7 = and i1 %5, %6
br i1 %7, label %14, label %8
8: ; preds = %3
%9 = fcmp ogt float %0, -1.000000e+04
%10 = fcmp olt double %4, -1.000000e-04
%11 = and i1 %9, %10
%12 = fcmp oeq float %0, 0.000000e+00
%13 = or i1 %12, %11
br i1 %13, label %14, label %16
14: ; preds = %8, %3
%15 = tail call i32 @cvtFloatToString(float %0, i8* %1, i16 zeroext %2)
br label %18
16: ; preds = %8
%17 = tail call i32 @cvtFloatToExpString(float %0, i8* %1, i16 zeroext %2)
br label %18
18: ; preds = %16, %14
%19 = phi i32 [ %15, %14 ], [ %17, %16 ]
ret i32 %19
}