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

/* Variables and functions */
scalar_t__ round(double);
const char *get_value_ansi_fmt(double v) {
  static const char *colors[] = {
      "102;30",  "42;30",   "42;33",  "42;93", "42;93;1", "43;92;1",
      "43;92",   "43;32",   "103;30", "43;30", "43;31",   "43;91",
      "43;91;1", "41;93;1", "41;93",  "41;33", "41",      "101",
  };
  if (v < 0) {
    v = 0;
  }
  if (v > 1) {
    v = 1;
  }
  return colors[(size_t)round(v * (sizeof(colors) / sizeof(*colors) - 1))];
}


x86 assembly (clang, -O0):
<get_value_ansi_fmt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movsd  %xmm0,-0x8(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    1133 <get_value_ansi_fmt+0x23>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xec0(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1157 <get_value_ansi_fmt+0x47>
movsd  0xeae(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  0xea9(%rip),%xmm0
mulsd  -0x8(%rbp),%xmm0
call   1030 <round@plt>
mov    %rax,%rcx
lea    0x2ebd(%rip),%rax
mov    (%rax,%rcx,8),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_value_ansi_fmt>:
push   %rax
xorpd  %xmm1,%xmm1
maxsd  %xmm0,%xmm1
movsd  0xedf(%rip),%xmm0
minsd  %xmm1,%xmm0
mulsd  0xedb(%rip),%xmm0
call   1030 <round@plt>
lea    0xed7(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
pop    %rcx
ret

LLVM IR (-O0):
@get_value_ansi_fmt.colors = internal global [18 x i8*] [i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.12, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.13, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.14, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.15, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.16, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.17, i32 0, i32 0)]
@.str = [7 x i8] c"102;30\00"
@.str.1 = [6 x i8] c"42;30\00"
@.str.2 = [6 x i8] c"42;33\00"
@.str.3 = [6 x i8] c"42;93\00"
@.str.4 = [8 x i8] c"42;93;1\00"
@.str.5 = [8 x i8] c"43;92;1\00"
@.str.6 = [6 x i8] c"43;92\00"
@.str.7 = [6 x i8] c"43;32\00"
@.str.8 = [7 x i8] c"103;30\00"
@.str.9 = [6 x i8] c"43;30\00"
@.str.10 = [6 x i8] c"43;31\00"
@.str.11 = [6 x i8] c"43;91\00"
@.str.12 = [8 x i8] c"43;91;1\00"
@.str.13 = [8 x i8] c"41;93;1\00"
@.str.14 = [6 x i8] c"41;93\00"
@.str.15 = [6 x i8] c"41;33\00"
@.str.16 = [3 x i8] c"41\00"
@.str.17 = [4 x i8] c"101\00"
define i8* @get_value_ansi_fmt(double %0) {
%2 = alloca double
store double %0, double* %2
%3 = load double, double* %2
%4 = fcmp olt double %3, 0.000000e+00
br i1 %4, label %5, label %6
5: ; preds = %1
store double 0.000000e+00, double* %2
br label %6
6: ; preds = %5, %1
%7 = load double, double* %2
%8 = fcmp ogt double %7, 1.000000e+00
br i1 %8, label %9, label %10
9: ; preds = %6
store double 1.000000e+00, double* %2
br label %10
10: ; preds = %9, %6
%11 = load double, double* %2
%12 = fmul double %11, 1.700000e+01
%13 = call i64 @round(double %12)
%14 = getelementptr inbounds [18 x i8*], [18 x i8*]* @get_value_ansi_fmt.colors, i64 0, i64 %13
%15 = load i8*, i8** %14
ret i8* %15
}

LLVM IR (-O2):
@reltable.get_value_ansi_fmt = internal unnamed_addr constant [18 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str to i64), i64 ptrtoint ([18 x i32]* @reltable.get_value_ansi_fmt to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.1 to i64), i64 ptrtoint ([18 x i32]* @reltable.get_value_ansi_fmt to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.2 to i64), i64 ptrtoint ([18 x i32]* @reltable.get_value_ansi_fmt to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.3 to i64), i64 ptrtoint ([18 x i32]* @reltable.get_value_ansi_fmt to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.4 to i64), i64 ptrtoint ([18 x i32]* @reltable.get_value_ansi_fmt to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.5 to i64), i64 ptrtoint ([18 x i32]* @reltable.get_value_ansi_fmt to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.6 to i64), i64 ptrtoint ([18 x i32]* @reltable.get_value_ansi_fmt to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.7 to i64), i64 ptrtoint ([18 x i32]* @reltable.get_value_ansi_fmt to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.8 to i64), i64 ptrtoint ([18 x i32]* @reltable.get_value_ansi_fmt to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.9 to i64), i64 ptrtoint ([18 x i32]* @reltable.get_value_ansi_fmt to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.10 to i64), i64 ptrtoint ([18 x i32]* @reltable.get_value_ansi_fmt to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.11 to i64), i64 ptrtoint ([18 x i32]* @reltable.get_value_ansi_fmt to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.12 to i64), i64 ptrtoint ([18 x i32]* @reltable.get_value_ansi_fmt to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.13 to i64), i64 ptrtoint ([18 x i32]* @reltable.get_value_ansi_fmt to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.14 to i64), i64 ptrtoint ([18 x i32]* @reltable.get_value_ansi_fmt to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.15 to i64), i64 ptrtoint ([18 x i32]* @reltable.get_value_ansi_fmt to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.16 to i64), i64 ptrtoint ([18 x i32]* @reltable.get_value_ansi_fmt to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.17 to i64), i64 ptrtoint ([18 x i32]* @reltable.get_value_ansi_fmt to i64)) to i32)]
@.str = [7 x i8] c"102;30\00"
@.str.1 = [6 x i8] c"42;30\00"
@.str.2 = [6 x i8] c"42;33\00"
@.str.3 = [6 x i8] c"42;93\00"
@.str.4 = [8 x i8] c"42;93;1\00"
@.str.5 = [8 x i8] c"43;92;1\00"
@.str.6 = [6 x i8] c"43;92\00"
@.str.7 = [6 x i8] c"43;32\00"
@.str.8 = [7 x i8] c"103;30\00"
@.str.9 = [6 x i8] c"43;30\00"
@.str.10 = [6 x i8] c"43;31\00"
@.str.11 = [6 x i8] c"43;91\00"
@.str.12 = [8 x i8] c"43;91;1\00"
@.str.13 = [8 x i8] c"41;93;1\00"
@.str.14 = [6 x i8] c"41;93\00"
@.str.15 = [6 x i8] c"41;33\00"
@.str.16 = [3 x i8] c"41\00"
@.str.17 = [4 x i8] c"101\00"
define i8* @get_value_ansi_fmt(double %0) {
%2 = fcmp olt double %0, 0.000000e+00
%3 = select i1 %2, double 0.000000e+00, double %0
%4 = fcmp ogt double %3, 1.000000e+00
%5 = select i1 %4, double 1.000000e+00, double %3
%6 = fmul double %5, 1.700000e+01
%7 = tail call i64 @round(double %6)
%8 = shl i64 %7, 2
%9 = call i8* @llvm.load.relative.i64(i8* bitcast ([18 x i32]* @reltable.get_value_ansi_fmt to i8*), i64 %8)
ret i8* %9
}