#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 /*<<< orphan*/ sprintf(char *, char *, ...);
void format_db(char *buf, const float val) {
  if (val > 99) {
    sprintf(buf, "++++");
  } else if (val > -10) {
    sprintf(buf, "%+.1f", val);
  } else if (val > -99.9) {
    sprintf(buf, "%.0f ", val);
  } else {
    sprintf(buf, " -\u221E ");
  }
}


x86 assembly (clang, -O0):
<format_db>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
movss  0xed2(%rip),%xmm1
ucomiss %xmm1,%xmm0
jbe    114e <format_db+0x3e>
mov    -0x8(%rbp),%rdi
lea    0xece(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    11db <format_db+0xcb>
movss  -0xc(%rbp),%xmm0
movss  0xea9(%rip),%xmm1
ucomiss %xmm1,%xmm0
jbe    1184 <format_db+0x74>
mov    -0x8(%rbp),%rdi
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe9d(%rip),%rsi
mov    $0x1,%al
call   1030 <sprintf@plt>
jmp    11d6 <format_db+0xc6>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe73(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11bf <format_db+0xaf>
mov    -0x8(%rbp),%rdi
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe68(%rip),%rsi
mov    $0x1,%al
call   1030 <sprintf@plt>
jmp    11d1 <format_db+0xc1>
mov    -0x8(%rbp),%rdi
lea    0xe57(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    11d6 <format_db+0xc6>
jmp    11db <format_db+0xcb>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<format_db>:
ucomiss 0xee9(%rip),%xmm0
jbe    1124 <format_db+0x14>
movb   $0x0,0x4(%rdi)
movl   $0x2b2b2b2b,(%rdi)
ret
ucomiss 0xed9(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
jbe    113f <format_db+0x2f>
lea    0xedd(%rip),%rsi
mov    $0x1,%al
jmp    1030 <sprintf@plt>
ucomisd 0xec1(%rip),%xmm0
jbe    1157 <format_db+0x47>
lea    0xecb(%rip),%rsi
mov    $0x1,%al
jmp    1030 <sprintf@plt>
movl   $0x209e88,0x3(%rdi)
movl   $0x88e22d20,(%rdi)
ret

LLVM IR (-O0):
@.str = [5 x i8] c"++++\00"
@.str.1 = [6 x i8] c"%+.1f\00"
@.str.2 = [6 x i8] c"%.0f \00"
@.str.3 = [7 x i8] c" -\E2\88\9E \00"
define void @format_db(i8* %0, float %1) {
%3 = alloca i8*
%4 = alloca float
store i8* %0, i8** %3
store float %1, float* %4
%5 = load float, float* %4
%6 = fcmp ogt float %5, 9.900000e+01
br i1 %6, label %7, label %10
7: ; preds = %2
%8 = load i8*, i8** %3
%9 = call i32 (i8*, i8*, ...) @sprintf(i8* %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %32
10: ; preds = %2
%11 = load float, float* %4
%12 = fcmp ogt float %11, -1.000000e+01
br i1 %12, label %13, label %18
13: ; preds = %10
%14 = load i8*, i8** %3
%15 = load float, float* %4
%16 = fpext float %15 to double
%17 = call i32 (i8*, i8*, ...) @sprintf(i8* %14, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), double %16)
br label %31
18: ; preds = %10
%19 = load float, float* %4
%20 = fpext float %19 to double
%21 = fcmp ogt double %20, -9.990000e+01
br i1 %21, label %22, label %27
22: ; preds = %18
%23 = load i8*, i8** %3
%24 = load float, float* %4
%25 = fpext float %24 to double
%26 = call i32 (i8*, i8*, ...) @sprintf(i8* %23, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double %25)
br label %30
27: ; preds = %18
%28 = load i8*, i8** %3
%29 = call i32 (i8*, i8*, ...) @sprintf(i8* %28, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
br label %30
30: ; preds = %27, %22
br label %31
31: ; preds = %30, %13
br label %32
32: ; preds = %31, %7
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"++++\00"
@.str.1 = [6 x i8] c"%+.1f\00"
@.str.2 = [6 x i8] c"%.0f \00"
@.str.3 = [7 x i8] c" -\E2\88\9E \00"
define void @format_db(i8* nocapture writeonly %0, float %1) {
%3 = fcmp ogt float %1, 9.900000e+01
br i1 %3, label %4, label %5
4: ; preds = %2
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(5) %0, i8* align 1 dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64 5, i1 false)
br label %15
5: ; preds = %2
%6 = fcmp ogt float %1, -1.000000e+01
%7 = fpext float %1 to double
br i1 %6, label %8, label %10
8: ; preds = %5
%9 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), double %7)
br label %15
10: ; preds = %5
%11 = fcmp ogt double %7, -9.990000e+01
br i1 %11, label %12, label %14
12: ; preds = %10
%13 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double %7)
br label %15
14: ; preds = %10
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(7) %0, i8* align 1 dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i64 7, i1 false)
br label %15
15: ; preds = %8, %14, %12, %4
ret void
}