#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*/ tr_snprintf(char *, size_t, char *, double);
int /*<<< orphan*/ tr_strlcpy(char *, char *, size_t);
char *tr_strlratio(char *buf, double ratio, size_t buflen) {
  if ((int)ratio == -1)
    tr_strlcpy(buf, ("None"), buflen);
  else if ((int)ratio == -2)
    tr_strlcpy(buf, "Inf", buflen);
  else if (ratio < 10.0)
    tr_snprintf(buf, buflen, "%.2f", ratio);
  else if (ratio < 100.0)
    tr_snprintf(buf, buflen, "%.1f", ratio);
  else
    tr_snprintf(buf, buflen, "%.0f", ratio);
  return buf;
}


x86 assembly (clang, -O0):
<tr_strlratio>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cvttsd2si -0x10(%rbp),%eax
cmp    $0xffffffff,%eax
jne    115c <tr_strlratio+0x3c>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xebe(%rip),%rsi
call   1030 <tr_strlcpy@plt>
jmp    120d <tr_strlratio+0xed>
cvttsd2si -0x10(%rbp),%eax
cmp    $0xfffffffe,%eax
jne    1183 <tr_strlratio+0x63>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe9c(%rip),%rsi
call   1030 <tr_strlcpy@plt>
jmp    1208 <tr_strlratio+0xe8>
movsd  0xe75(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    11b4 <tr_strlratio+0x94>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
movsd  -0x10(%rbp),%xmm0
lea    0xe6f(%rip),%rdx
call   1040 <tr_snprintf@plt>
jmp    1203 <tr_strlratio+0xe3>
movsd  0xe4c(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    11e5 <tr_strlratio+0xc5>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
movsd  -0x10(%rbp),%xmm0
lea    0xe43(%rip),%rdx
call   1040 <tr_snprintf@plt>
jmp    11fe <tr_strlratio+0xde>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
movsd  -0x10(%rbp),%xmm0
lea    0xe2a(%rip),%rdx
call   1040 <tr_snprintf@plt>
jmp    1203 <tr_strlratio+0xe3>
jmp    1208 <tr_strlratio+0xe8>
jmp    120d <tr_strlratio+0xed>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tr_strlratio>:
push   %rbx
mov    %rsi,%rax
mov    %rdi,%rbx
cvttsd2si %xmm0,%ecx
cmp    $0xfffffffe,%ecx
je     113e <tr_strlratio+0x1e>
cmp    $0xffffffff,%ecx
jne    1152 <tr_strlratio+0x32>
lea    0xed4(%rip),%rsi
jmp    1145 <tr_strlratio+0x25>
lea    0xed0(%rip),%rsi
mov    %rbx,%rdi
mov    %rax,%rdx
call   1030 <tr_strlcpy@plt>
jmp    1192 <tr_strlratio+0x72>
movsd  0xea6(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    1169 <tr_strlratio+0x49>
lea    0xeb2(%rip),%rdx
jmp    1187 <tr_strlratio+0x67>
movsd  0xe97(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    1180 <tr_strlratio+0x60>
lea    0xea0(%rip),%rdx
jmp    1187 <tr_strlratio+0x67>
lea    0xe9c(%rip),%rdx
mov    %rbx,%rdi
mov    %rax,%rsi
call   1040 <tr_snprintf@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"None\00"
@.str.1 = [4 x i8] c"Inf\00"
@.str.2 = [5 x i8] c"%.2f\00"
@.str.3 = [5 x i8] c"%.1f\00"
@.str.4 = [5 x i8] c"%.0f\00"
define i8* @tr_strlratio(i8* %0, double %1, i64 %2) {
%4 = alloca i8*
%5 = alloca double
%6 = alloca i64
store i8* %0, i8** %4
store double %1, double* %5
store i64 %2, i64* %6
%7 = load double, double* %5
%8 = fptosi double %7 to i32
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %14
10: ; preds = %3
%11 = load i8*, i8** %4
%12 = load i64, i64* %6
%13 = call i32 @tr_strlcpy(i8* %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64 %12)
br label %46
14: ; preds = %3
%15 = load double, double* %5
%16 = fptosi double %15 to i32
%17 = icmp eq i32 %16, -2
br i1 %17, label %18, label %22
18: ; preds = %14
%19 = load i8*, i8** %4
%20 = load i64, i64* %6
%21 = call i32 @tr_strlcpy(i8* %19, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64 %20)
br label %45
22: ; preds = %14
%23 = load double, double* %5
%24 = fcmp olt double %23, 1.000000e+01
br i1 %24, label %25, label %30
25: ; preds = %22
%26 = load i8*, i8** %4
%27 = load i64, i64* %6
%28 = load double, double* %5
%29 = call i32 @tr_snprintf(i8* %26, i64 %27, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), double %28)
br label %44
30: ; preds = %22
%31 = load double, double* %5
%32 = fcmp olt double %31, 1.000000e+02
br i1 %32, label %33, label %38
33: ; preds = %30
%34 = load i8*, i8** %4
%35 = load i64, i64* %6
%36 = load double, double* %5
%37 = call i32 @tr_snprintf(i8* %34, i64 %35, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), double %36)
br label %43
38: ; preds = %30
%39 = load i8*, i8** %4
%40 = load i64, i64* %6
%41 = load double, double* %5
%42 = call i32 @tr_snprintf(i8* %39, i64 %40, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), double %41)
br label %43
43: ; preds = %38, %33
br label %44
44: ; preds = %43, %25
br label %45
45: ; preds = %44, %18
br label %46
46: ; preds = %45, %10
%47 = load i8*, i8** %4
ret i8* %47
}

LLVM IR (-O2):
@.str = [5 x i8] c"None\00"
@.str.1 = [4 x i8] c"Inf\00"
@.str.2 = [5 x i8] c"%.2f\00"
@.str.3 = [5 x i8] c"%.1f\00"
@.str.4 = [5 x i8] c"%.0f\00"
define i8* @tr_strlratio(i8* returned %0, double %1, i64 %2) {
%4 = fptosi double %1 to i32
switch i32 %4, label %9 [
i32 -1, label %5
i32 -2, label %7
]
5: ; preds = %3
%6 = tail call i32 @tr_strlcpy(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64 %2)
br label %19
7: ; preds = %3
%8 = tail call i32 @tr_strlcpy(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64 %2)
br label %19
9: ; preds = %3
%10 = fcmp olt double %1, 1.000000e+01
br i1 %10, label %11, label %13
11: ; preds = %9
%12 = tail call i32 @tr_snprintf(i8* %0, i64 %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), double %1)
br label %19
13: ; preds = %9
%14 = fcmp olt double %1, 1.000000e+02
br i1 %14, label %15, label %17
15: ; preds = %13
%16 = tail call i32 @tr_snprintf(i8* %0, i64 %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), double %1)
br label %19
17: ; preds = %13
%18 = tail call i32 @tr_snprintf(i8* %0, i64 %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), double %1)
br label %19
19: ; preds = %7, %15, %17, %11, %5
ret i8* %0
}