#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 sprintf(char *, char *, double, char);
int /*<<< orphan*/ strcpy(char *, char *);
int convert_to_metric_suffix(char *buf, double value, int decimals) {
  double ltmp;
  char suffix = ' ';
  if (value < 0) {
    ltmp = value * -1;
  } else {
    ltmp = value;
  }
  if (ltmp > 0.999999e12 && ltmp < 0.999999e15) {
    ltmp = ltmp / 1e12;
    suffix = 'T';
  } else if (ltmp > 0.999999e9) {
    ltmp = ltmp / 1e9;
    suffix = 'G';
  } else if (ltmp > 0.999999e6) {
    ltmp = ltmp / 1e6;
    suffix = 'M';
  } else if (ltmp > 0.999999e3) {
    ltmp /= 1e3;
    suffix = 'K';
  } else if (ltmp > 0.999999e-3 && ltmp < 0.999999) {
    ltmp *= 1e3;
    suffix = 'm';
  } else if (ltmp > 0.999999e-6 && ltmp < 0.999999e-3) {
    ltmp *= 1e6;
    suffix = 'u';
  } else if (ltmp > 0.999999e-9 && ltmp < 0.999999e-6) {
    ltmp *= 1e9;
    suffix = 'n';
  } else if (ltmp > 0.999999e-12 && ltmp < 0.999999e-9) {
    ltmp *= 1e12;
    suffix = 'p';
  }
  if (value >= 0) {
    switch (decimals) {
    case 0:
      return sprintf(buf, "%.0f%c", ltmp, suffix);
      break;
    case 1:
      return sprintf(buf, "%.1f%c", ltmp, suffix);
      break;
    case 2:
      return sprintf(buf, "%.2f%c", ltmp, suffix);
      break;
    case 3:
      return sprintf(buf, "%.3f%c", ltmp, suffix);
      break;
    case 4:
      return sprintf(buf, "%.4f%c", ltmp, suffix);
      break;
    case 5:
      return sprintf(buf, "%.5f%c", ltmp, suffix);
      break;
    case 6:
      return sprintf(buf, "%.6f%c", ltmp, suffix);
      break;
    default:
      return sprintf(buf, "%.3f%c", ltmp, suffix);
      break;
    }
  }
  if (value < 0) {
    switch (decimals) {
    case 0:
      return sprintf(buf, "%.0f%c", ltmp * -1, suffix);
      break;
    case 1:
      return sprintf(buf, "%.1f%c", ltmp * -1, suffix);
      break;
    case 2:
      return sprintf(buf, "%.2f%c", ltmp * -1, suffix);
      break;
    default:
      return sprintf(buf, "%.3f%c", ltmp * -1, suffix);
      break;
    }
  }
  strcpy(buf, "0");
  return 1;
}


x86 assembly (clang, -O0):
<convert_to_metric_suffix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
mov    %esi,-0x1c(%rbp)
movb   $0x20,-0x29(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    115d <convert_to_metric_suffix+0x3d>
movsd  0xeb2(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    1167 <convert_to_metric_suffix+0x47>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  0xe94(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11b0 <convert_to_metric_suffix+0x90>
movsd  0xe8a(%rip),%xmm0
ucomisd -0x28(%rbp),%xmm0
jbe    11b0 <convert_to_metric_suffix+0x90>
movsd  -0x28(%rbp),%xmm0
movsd  0xeba(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movb   $0x54,-0x29(%rbp)
jmp    1384 <convert_to_metric_suffix+0x264>
movsd  -0x28(%rbp),%xmm0
movsd  0xe5b(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11e6 <convert_to_metric_suffix+0xc6>
movsd  -0x28(%rbp),%xmm0
movsd  0xe8c(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movb   $0x47,-0x29(%rbp)
jmp    137f <convert_to_metric_suffix+0x25f>
movsd  -0x28(%rbp),%xmm0
movsd  0xe2d(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    121c <convert_to_metric_suffix+0xfc>
movsd  -0x28(%rbp),%xmm0
movsd  0xe5e(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movb   $0x4d,-0x29(%rbp)
jmp    137a <convert_to_metric_suffix+0x25a>
movsd  -0x28(%rbp),%xmm0
movsd  0xdff(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1252 <convert_to_metric_suffix+0x132>
movsd  -0x28(%rbp),%xmm0
movsd  0xe30(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movb   $0x4b,-0x29(%rbp)
jmp    1375 <convert_to_metric_suffix+0x255>
movsd  -0x28(%rbp),%xmm0
movsd  0xdd1(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1297 <convert_to_metric_suffix+0x177>
movsd  0xdc7(%rip),%xmm0
ucomisd -0x28(%rbp),%xmm0
jbe    1297 <convert_to_metric_suffix+0x177>
movsd  0xdec(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movb   $0x6d,-0x29(%rbp)
jmp    1370 <convert_to_metric_suffix+0x250>
movsd  -0x28(%rbp),%xmm0
movsd  0xd9c(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    12dc <convert_to_metric_suffix+0x1bc>
movsd  0xd7a(%rip),%xmm0
ucomisd -0x28(%rbp),%xmm0
jbe    12dc <convert_to_metric_suffix+0x1bc>
movsd  0xd9f(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movb   $0x75,-0x29(%rbp)
jmp    136b <convert_to_metric_suffix+0x24b>
movsd  -0x28(%rbp),%xmm0
movsd  0xd5f(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1321 <convert_to_metric_suffix+0x201>
movsd  0xd45(%rip),%xmm0
ucomisd -0x28(%rbp),%xmm0
jbe    1321 <convert_to_metric_suffix+0x201>
movsd  0xd52(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movb   $0x6e,-0x29(%rbp)
jmp    1366 <convert_to_metric_suffix+0x246>
movsd  -0x28(%rbp),%xmm0
movsd  0xd22(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1361 <convert_to_metric_suffix+0x241>
movsd  0xd08(%rip),%xmm0
ucomisd -0x28(%rbp),%xmm0
jbe    1361 <convert_to_metric_suffix+0x241>
movsd  0xd05(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movb   $0x70,-0x29(%rbp)
jmp    1366 <convert_to_metric_suffix+0x246>
jmp    136b <convert_to_metric_suffix+0x24b>
jmp    1370 <convert_to_metric_suffix+0x250>
jmp    1375 <convert_to_metric_suffix+0x255>
jmp    137a <convert_to_metric_suffix+0x25a>
jmp    137f <convert_to_metric_suffix+0x25f>
jmp    1384 <convert_to_metric_suffix+0x264>
movsd  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     14c3 <convert_to_metric_suffix+0x3a3>
mov    -0x1c(%rbp),%eax
mov    %rax,-0x38(%rbp)
sub    $0x6,%rax
ja     14a2 <convert_to_metric_suffix+0x382>
mov    -0x38(%rbp),%rax
lea    0xcc6(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%rdi
movsd  -0x28(%rbp),%xmm0
lea    0xcc9(%rip),%rsi
movsbl -0x29(%rbp),%edx
call   1040 <sprintf@plt>
mov    %eax,-0x4(%rbp)
jmp    15c1 <convert_to_metric_suffix+0x4a1>
mov    -0x10(%rbp),%rdi
movsd  -0x28(%rbp),%xmm0
lea    0xcaf(%rip),%rsi
movsbl -0x29(%rbp),%edx
call   1040 <sprintf@plt>
mov    %eax,-0x4(%rbp)
jmp    15c1 <convert_to_metric_suffix+0x4a1>
mov    -0x10(%rbp),%rdi
movsd  -0x28(%rbp),%xmm0
lea    0xc95(%rip),%rsi
movsbl -0x29(%rbp),%edx
call   1040 <sprintf@plt>
mov    %eax,-0x4(%rbp)
jmp    15c1 <convert_to_metric_suffix+0x4a1>
mov    -0x10(%rbp),%rdi
movsd  -0x28(%rbp),%xmm0
lea    0xc7b(%rip),%rsi
movsbl -0x29(%rbp),%edx
call   1040 <sprintf@plt>
mov    %eax,-0x4(%rbp)
jmp    15c1 <convert_to_metric_suffix+0x4a1>
mov    -0x10(%rbp),%rdi
movsd  -0x28(%rbp),%xmm0
lea    0xc61(%rip),%rsi
movsbl -0x29(%rbp),%edx
call   1040 <sprintf@plt>
mov    %eax,-0x4(%rbp)
jmp    15c1 <convert_to_metric_suffix+0x4a1>
mov    -0x10(%rbp),%rdi
movsd  -0x28(%rbp),%xmm0
lea    0xc47(%rip),%rsi
movsbl -0x29(%rbp),%edx
call   1040 <sprintf@plt>
mov    %eax,-0x4(%rbp)
jmp    15c1 <convert_to_metric_suffix+0x4a1>
mov    -0x10(%rbp),%rdi
movsd  -0x28(%rbp),%xmm0
lea    0xc2d(%rip),%rsi
movsbl -0x29(%rbp),%edx
call   1040 <sprintf@plt>
mov    %eax,-0x4(%rbp)
jmp    15c1 <convert_to_metric_suffix+0x4a1>
mov    -0x10(%rbp),%rdi
movsd  -0x28(%rbp),%xmm0
lea    0xbf7(%rip),%rsi
movsbl -0x29(%rbp),%edx
call   1040 <sprintf@plt>
mov    %eax,-0x4(%rbp)
jmp    15c1 <convert_to_metric_suffix+0x4a1>
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    15aa <convert_to_metric_suffix+0x48a>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x3c(%rbp)
test   %eax,%eax
je     1506 <convert_to_metric_suffix+0x3e6>
jmp    14e4 <convert_to_metric_suffix+0x3c4>
mov    -0x3c(%rbp),%eax
sub    $0x1,%eax
je     152f <convert_to_metric_suffix+0x40f>
jmp    14f5 <convert_to_metric_suffix+0x3d5>
mov    -0x3c(%rbp),%eax
sub    $0x2,%eax
je     1558 <convert_to_metric_suffix+0x438>
jmp    1581 <convert_to_metric_suffix+0x461>
mov    -0x10(%rbp),%rdi
movsd  0xaee(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
lea    0xb76(%rip),%rsi
movsbl -0x29(%rbp),%edx
call   1040 <sprintf@plt>
mov    %eax,-0x4(%rbp)
jmp    15c1 <convert_to_metric_suffix+0x4a1>
mov    -0x10(%rbp),%rdi
movsd  0xac5(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
lea    0xb54(%rip),%rsi
movsbl -0x29(%rbp),%edx
call   1040 <sprintf@plt>
mov    %eax,-0x4(%rbp)
jmp    15c1 <convert_to_metric_suffix+0x4a1>
mov    -0x10(%rbp),%rdi
movsd  0xa9c(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
lea    0xb32(%rip),%rsi
movsbl -0x29(%rbp),%edx
call   1040 <sprintf@plt>
mov    %eax,-0x4(%rbp)
jmp    15c1 <convert_to_metric_suffix+0x4a1>
mov    -0x10(%rbp),%rdi
movsd  0xa73(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
lea    0xb10(%rip),%rsi
movsbl -0x29(%rbp),%edx
call   1040 <sprintf@plt>
mov    %eax,-0x4(%rbp)
jmp    15c1 <convert_to_metric_suffix+0x4a1>
mov    -0x10(%rbp),%rdi
lea    0xb10(%rip),%rsi
call   1030 <strcpy@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<convert_to_metric_suffix>:
push   %rax
movapd %xmm0,%xmm1
movapd 0xed3(%rip),%xmm2
xorpd  %xmm0,%xmm2
xorpd  %xmm3,%xmm3
cmpltsd %xmm3,%xmm0
andpd  %xmm0,%xmm2
andnpd %xmm1,%xmm0
orpd   %xmm2,%xmm0
ucomisd 0xec2(%rip),%xmm0
jbe    1171 <convert_to_metric_suffix+0x51>
movsd  0xec0(%rip),%xmm2
ucomisd %xmm0,%xmm2
jbe    1171 <convert_to_metric_suffix+0x51>
movsd  0xefa(%rip),%xmm2
divsd  %xmm2,%xmm0
mov    $0x54,%al
jmp    127a <convert_to_metric_suffix+0x15a>
ucomisd 0xea7(%rip),%xmm0
jbe    118e <convert_to_metric_suffix+0x6e>
movsd  0xee5(%rip),%xmm2
divsd  %xmm2,%xmm0
mov    $0x47,%al
jmp    127a <convert_to_metric_suffix+0x15a>
ucomisd 0xe92(%rip),%xmm0
jbe    11ab <convert_to_metric_suffix+0x8b>
movsd  0xed0(%rip),%xmm2
divsd  %xmm2,%xmm0
mov    $0x4d,%al
jmp    127a <convert_to_metric_suffix+0x15a>
ucomisd 0xe7d(%rip),%xmm0
jbe    11c8 <convert_to_metric_suffix+0xa8>
movsd  0xebb(%rip),%xmm2
divsd  %xmm2,%xmm0
mov    $0x4b,%al
jmp    127a <convert_to_metric_suffix+0x15a>
ucomisd 0xe68(%rip),%xmm0
jbe    11f3 <convert_to_metric_suffix+0xd3>
movsd  0xe66(%rip),%xmm2
ucomisd %xmm0,%xmm2
jbe    11f3 <convert_to_metric_suffix+0xd3>
movsd  0xe90(%rip),%xmm2
mulsd  %xmm2,%xmm0
mov    $0x6d,%al
jmp    127a <convert_to_metric_suffix+0x15a>
ucomisd 0xe4d(%rip),%xmm0
jbe    121b <convert_to_metric_suffix+0xfb>
movsd  0xe33(%rip),%xmm2
ucomisd %xmm0,%xmm2
jbe    121b <convert_to_metric_suffix+0xfb>
movsd  0xe5d(%rip),%xmm2
mulsd  %xmm2,%xmm0
mov    $0x75,%al
jmp    127a <convert_to_metric_suffix+0x15a>
ucomisd 0xe2d(%rip),%xmm0
jbe    1243 <convert_to_metric_suffix+0x123>
movsd  0xe1b(%rip),%xmm2
ucomisd %xmm0,%xmm2
jbe    1243 <convert_to_metric_suffix+0x123>
movsd  0xe2d(%rip),%xmm2
mulsd  %xmm2,%xmm0
mov    $0x6e,%al
jmp    127a <convert_to_metric_suffix+0x15a>
ucomisd 0xe0d(%rip),%xmm0
seta   %al
movsd  0xdfa(%rip),%xmm2
ucomisd %xmm0,%xmm2
seta   %cl
test   %cl,%al
je     126d <convert_to_metric_suffix+0x14d>
movsd  0xdf7(%rip),%xmm2
mulsd  %xmm2,%xmm0
mov    $0x70,%ecx
mov    $0x20,%eax
cmovne %ecx,%eax
xorpd  %xmm2,%xmm2
ucomisd %xmm2,%xmm1
jae    12a2 <convert_to_metric_suffix+0x182>
ucomisd %xmm1,%xmm2
jbe    12c9 <convert_to_metric_suffix+0x1a9>
xorpd  0xd6e(%rip),%xmm0
cmp    $0x2,%esi
je     12fc <convert_to_metric_suffix+0x1dc>
cmp    $0x1,%esi
je     12ec <convert_to_metric_suffix+0x1cc>
test   %esi,%esi
je     12b9 <convert_to_metric_suffix+0x199>
jmp    12dc <convert_to_metric_suffix+0x1bc>
cmp    $0x6,%esi
ja     12dc <convert_to_metric_suffix+0x1bc>
mov    %esi,%ecx
lea    0xdd0(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
movzbl %al,%edx
lea    0xdd9(%rip),%rsi
pop    %rax
jmp    1040 <sprintf@plt>
lea    0xdfd(%rip),%rsi
call   1030 <strcpy@plt>
mov    $0x1,%eax
pop    %rcx
ret
movzbl %al,%edx
lea    0xdcb(%rip),%rsi
pop    %rax
jmp    1040 <sprintf@plt>
movzbl %al,%edx
lea    0xdad(%rip),%rsi
pop    %rax
jmp    1040 <sprintf@plt>
movzbl %al,%edx
lea    0xda4(%rip),%rsi
pop    %rax
jmp    1040 <sprintf@plt>
movzbl %al,%edx
lea    0xda2(%rip),%rsi
pop    %rax
jmp    1040 <sprintf@plt>
movzbl %al,%edx
lea    0xd99(%rip),%rsi
pop    %rax
jmp    1040 <sprintf@plt>
movzbl %al,%edx
lea    0xd90(%rip),%rsi
pop    %rax
jmp    1040 <sprintf@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"%.0f%c\00"
@.str.1 = [7 x i8] c"%.1f%c\00"
@.str.2 = [7 x i8] c"%.2f%c\00"
@.str.3 = [7 x i8] c"%.3f%c\00"
@.str.4 = [7 x i8] c"%.4f%c\00"
@.str.5 = [7 x i8] c"%.5f%c\00"
@.str.6 = [7 x i8] c"%.6f%c\00"
@.str.7 = [2 x i8] c"0\00"
define i32 @convert_to_metric_suffix(i8* %0, double %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca double
%7 = alloca i32
%8 = alloca double
%9 = alloca i8
store i8* %0, i8** %5
store double %1, double* %6
store i32 %2, i32* %7
store i8 32, i8* %9
%10 = load double, double* %6
%11 = fcmp olt double %10, 0.000000e+00
br i1 %11, label %12, label %15
12: ; preds = %3
%13 = load double, double* %6
%14 = fmul double %13, -1.000000e+00
store double %14, double* %8
br label %17
15: ; preds = %3
%16 = load double, double* %6
store double %16, double* %8
br label %17
17: ; preds = %15, %12
%18 = load double, double* %8
%19 = fcmp ogt double %18, 9.999990e+11
br i1 %19, label %20, label %26
20: ; preds = %17
%21 = load double, double* %8
%22 = fcmp olt double %21, 9.999990e+14
br i1 %22, label %23, label %26
23: ; preds = %20
%24 = load double, double* %8
%25 = fdiv double %24, 1.000000e+12
store double %25, double* %8
store i8 84, i8* %9
br label %87
26: ; preds = %20, %17
%27 = load double, double* %8
%28 = fcmp ogt double %27, 9.999990e+08
br i1 %28, label %29, label %32
29: ; preds = %26
%30 = load double, double* %8
%31 = fdiv double %30, 1.000000e+09
store double %31, double* %8
store i8 71, i8* %9
br label %86
32: ; preds = %26
%33 = load double, double* %8
%34 = fcmp ogt double %33, 9.999990e+05
br i1 %34, label %35, label %38
35: ; preds = %32
%36 = load double, double* %8
%37 = fdiv double %36, 1.000000e+06
store double %37, double* %8
store i8 77, i8* %9
br label %85
38: ; preds = %32
%39 = load double, double* %8
%40 = fcmp ogt double %39, 9.999990e+02
br i1 %40, label %41, label %44
41: ; preds = %38
%42 = load double, double* %8
%43 = fdiv double %42, 1.000000e+03
store double %43, double* %8
store i8 75, i8* %9
br label %84
44: ; preds = %38
%45 = load double, double* %8
%46 = fcmp ogt double %45, 9.999990e-04
br i1 %46, label %47, label %53
47: ; preds = %44
%48 = load double, double* %8
%49 = fcmp olt double %48, 0x3FEFFFFDE7210BE9
br i1 %49, label %50, label %53
50: ; preds = %47
%51 = load double, double* %8
%52 = fmul double %51, 1.000000e+03
store double %52, double* %8
store i8 109, i8* %9
br label %83
53: ; preds = %47, %44
%54 = load double, double* %8
%55 = fcmp ogt double %54, 0x3EB0C6F6873C557A
br i1 %55, label %56, label %62
56: ; preds = %53
%57 = load double, double* %8
%58 = fcmp olt double %57, 9.999990e-04
br i1 %58, label %59, label %62
59: ; preds = %56
%60 = load double, double* %8
%61 = fmul double %60, 1.000000e+06
store double %61, double* %8
store i8 117, i8* %9
br label %82
62: ; preds = %56, %53
%63 = load double, double* %8
%64 = fcmp ogt double %63, 0x3E112E0AC7EBDCA6
br i1 %64, label %65, label %71
65: ; preds = %62
%66 = load double, double* %8
%67 = fcmp olt double %66, 0x3EB0C6F6873C557A
br i1 %67, label %68, label %71
68: ; preds = %65
%69 = load double, double* %8
%70 = fmul double %69, 1.000000e+09
store double %70, double* %8
store i8 110, i8* %9
br label %81
71: ; preds = %65, %62
%72 = load double, double* %8
%73 = fcmp ogt double %72, 9.999990e-13
br i1 %73, label %74, label %80
74: ; preds = %71
%75 = load double, double* %8
%76 = fcmp olt double %75, 0x3E112E0AC7EBDCA6
br i1 %76, label %77, label %80
77: ; preds = %74
%78 = load double, double* %8
%79 = fmul double %78, 1.000000e+12
store double %79, double* %8
store i8 112, i8* %9
br label %80
80: ; preds = %77, %74, %71
br label %81
81: ; preds = %80, %68
br label %82
82: ; preds = %81, %59
br label %83
83: ; preds = %82, %50
br label %84
84: ; preds = %83, %41
br label %85
85: ; preds = %84, %35
br label %86
86: ; preds = %85, %29
br label %87
87: ; preds = %86, %23
%88 = load double, double* %6
%89 = fcmp oge double %88, 0.000000e+00
br i1 %89, label %90, label %132
90: ; preds = %87
%91 = load i32, i32* %7
switch i32 %91, label %127 [
i32 0, label %92
i32 1, label %97
i32 2, label %102
i32 3, label %107
i32 4, label %112
i32 5, label %117
i32 6, label %122
]
92: ; preds = %90
%93 = load i8*, i8** %5
%94 = load double, double* %8
%95 = load i8, i8* %9
%96 = call i32 @sprintf(i8* %93, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), double %94, i8 signext %95)
store i32 %96, i32* %4
br label %164
97: ; preds = %90
%98 = load i8*, i8** %5
%99 = load double, double* %8
%100 = load i8, i8* %9
%101 = call i32 @sprintf(i8* %98, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double %99, i8 signext %100)
store i32 %101, i32* %4
br label %164
102: ; preds = %90
%103 = load i8*, i8** %5
%104 = load double, double* %8
%105 = load i8, i8* %9
%106 = call i32 @sprintf(i8* %103, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), double %104, i8 signext %105)
store i32 %106, i32* %4
br label %164
107: ; preds = %90
%108 = load i8*, i8** %5
%109 = load double, double* %8
%110 = load i8, i8* %9
%111 = call i32 @sprintf(i8* %108, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), double %109, i8 signext %110)
store i32 %111, i32* %4
br label %164
112: ; preds = %90
%113 = load i8*, i8** %5
%114 = load double, double* %8
%115 = load i8, i8* %9
%116 = call i32 @sprintf(i8* %113, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), double %114, i8 signext %115)
store i32 %116, i32* %4
br label %164
117: ; preds = %90
%118 = load i8*, i8** %5
%119 = load double, double* %8
%120 = load i8, i8* %9
%121 = call i32 @sprintf(i8* %118, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), double %119, i8 signext %120)
store i32 %121, i32* %4
br label %164
122: ; preds = %90
%123 = load i8*, i8** %5
%124 = load double, double* %8
%125 = load i8, i8* %9
%126 = call i32 @sprintf(i8* %123, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), double %124, i8 signext %125)
store i32 %126, i32* %4
br label %164
127: ; preds = %90
%128 = load i8*, i8** %5
%129 = load double, double* %8
%130 = load i8, i8* %9
%131 = call i32 @sprintf(i8* %128, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), double %129, i8 signext %130)
store i32 %131, i32* %4
br label %164
132: ; preds = %87
%133 = load double, double* %6
%134 = fcmp olt double %133, 0.000000e+00
br i1 %134, label %135, label %161
135: ; preds = %132
%136 = load i32, i32* %7
switch i32 %136, label %155 [
i32 0, label %137
i32 1, label %143
i32 2, label %149
]
137: ; preds = %135
%138 = load i8*, i8** %5
%139 = load double, double* %8
%140 = fmul double %139, -1.000000e+00
%141 = load i8, i8* %9
%142 = call i32 @sprintf(i8* %138, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), double %140, i8 signext %141)
store i32 %142, i32* %4
br label %164
143: ; preds = %135
%144 = load i8*, i8** %5
%145 = load double, double* %8
%146 = fmul double %145, -1.000000e+00
%147 = load i8, i8* %9
%148 = call i32 @sprintf(i8* %144, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double %146, i8 signext %147)
store i32 %148, i32* %4
br label %164
149: ; preds = %135
%150 = load i8*, i8** %5
%151 = load double, double* %8
%152 = fmul double %151, -1.000000e+00
%153 = load i8, i8* %9
%154 = call i32 @sprintf(i8* %150, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), double %152, i8 signext %153)
store i32 %154, i32* %4
br label %164
155: ; preds = %135
%156 = load i8*, i8** %5
%157 = load double, double* %8
%158 = fmul double %157, -1.000000e+00
%159 = load i8, i8* %9
%160 = call i32 @sprintf(i8* %156, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), double %158, i8 signext %159)
store i32 %160, i32* %4
br label %164
161: ; preds = %132
%162 = load i8*, i8** %5
%163 = call i32 @strcpy(i8* %162, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
store i32 1, i32* %4
br label %164
164: ; preds = %161, %155, %149, %143, %137, %127, %122, %117, %112, %107, %102, %97, %92
%165 = load i32, i32* %4
ret i32 %165
}

LLVM IR (-O2):
@.str = [7 x i8] c"%.0f%c\00"
@.str.1 = [7 x i8] c"%.1f%c\00"
@.str.2 = [7 x i8] c"%.2f%c\00"
@.str.3 = [7 x i8] c"%.3f%c\00"
@.str.4 = [7 x i8] c"%.4f%c\00"
@.str.5 = [7 x i8] c"%.5f%c\00"
@.str.6 = [7 x i8] c"%.6f%c\00"
@.str.7 = [2 x i8] c"0\00"
define i32 @convert_to_metric_suffix(i8* %0, double %1, i32 %2) {
%4 = fcmp olt double %1, 0.000000e+00
%5 = fneg double %1
%6 = select i1 %4, double %5, double %1
%7 = fcmp ogt double %6, 9.999990e+11
%8 = fcmp olt double %6, 9.999990e+14
%9 = and i1 %7, %8
br i1 %9, label %10, label %12
10: ; preds = %3
%11 = fdiv double %6, 1.000000e+12
br label %49
12: ; preds = %3
%13 = fcmp ogt double %6, 9.999990e+08
br i1 %13, label %14, label %16
14: ; preds = %12
%15 = fdiv double %6, 1.000000e+09
br label %49
16: ; preds = %12
%17 = fcmp ogt double %6, 9.999990e+05
br i1 %17, label %18, label %20
18: ; preds = %16
%19 = fdiv double %6, 1.000000e+06
br label %49
20: ; preds = %16
%21 = fcmp ogt double %6, 9.999990e+02
br i1 %21, label %22, label %24
22: ; preds = %20
%23 = fdiv double %6, 1.000000e+03
br label %49
24: ; preds = %20
%25 = fcmp ogt double %6, 9.999990e-04
%26 = fcmp olt double %6, 0x3FEFFFFDE7210BE9
%27 = and i1 %25, %26
br i1 %27, label %28, label %30
28: ; preds = %24
%29 = fmul double %6, 1.000000e+03
br label %49
30: ; preds = %24
%31 = fcmp ogt double %6, 0x3EB0C6F6873C557A
%32 = fcmp olt double %6, 9.999990e-04
%33 = and i1 %31, %32
br i1 %33, label %34, label %36
34: ; preds = %30
%35 = fmul double %6, 1.000000e+06
br label %49
36: ; preds = %30
%37 = fcmp ogt double %6, 0x3E112E0AC7EBDCA6
%38 = fcmp olt double %6, 0x3EB0C6F6873C557A
%39 = and i1 %37, %38
br i1 %39, label %40, label %42
40: ; preds = %36
%41 = fmul double %6, 1.000000e+09
br label %49
42: ; preds = %36
%43 = fcmp ogt double %6, 9.999990e-13
%44 = fcmp olt double %6, 0x3E112E0AC7EBDCA6
%45 = and i1 %43, %44
%46 = fmul double %6, 1.000000e+12
%47 = select i1 %45, double %46, double %6
%48 = select i1 %45, i8 112, i8 32
br label %49
49: ; preds = %42, %14, %22, %34, %40, %28, %18, %10
%50 = phi double [ %11, %10 ], [ %15, %14 ], [ %19, %18 ], [ %23, %22 ], [ %29, %28 ], [ %35, %34 ], [ %41, %40 ], [ %47, %42 ]
%51 = phi i8 [ 84, %10 ], [ 71, %14 ], [ 77, %18 ], [ 75, %22 ], [ 109, %28 ], [ 117, %34 ], [ 110, %40 ], [ %48, %42 ]
%52 = fcmp ult double %1, 0.000000e+00
br i1 %52, label %70, label %53
53: ; preds = %49
switch i32 %2, label %68 [
i32 0, label %54
i32 1, label %56
i32 2, label %58
i32 3, label %60
i32 4, label %62
i32 5, label %64
i32 6, label %66
]
54: ; preds = %53
%55 = tail call i32 @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), double %50, i8 signext %51)
br label %86
56: ; preds = %53
%57 = tail call i32 @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double %50, i8 signext %51)
br label %86
58: ; preds = %53
%59 = tail call i32 @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), double %50, i8 signext %51)
br label %86
60: ; preds = %53
%61 = tail call i32 @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), double %50, i8 signext %51)
br label %86
62: ; preds = %53
%63 = tail call i32 @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), double %50, i8 signext %51)
br label %86
64: ; preds = %53
%65 = tail call i32 @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), double %50, i8 signext %51)
br label %86
66: ; preds = %53
%67 = tail call i32 @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), double %50, i8 signext %51)
br label %86
68: ; preds = %53
%69 = tail call i32 @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), double %50, i8 signext %51)
br label %86
70: ; preds = %49
br i1 %4, label %71, label %84
71: ; preds = %70
switch i32 %2, label %81 [
i32 0, label %72
i32 1, label %75
i32 2, label %78
]
72: ; preds = %71
%73 = fneg double %50
%74 = tail call i32 @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), double %73, i8 signext %51)
br label %86
75: ; preds = %71
%76 = fneg double %50
%77 = tail call i32 @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double %76, i8 signext %51)
br label %86
78: ; preds = %71
%79 = fneg double %50
%80 = tail call i32 @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), double %79, i8 signext %51)
br label %86
81: ; preds = %71
%82 = fneg double %50
%83 = tail call i32 @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), double %82, i8 signext %51)
br label %86
84: ; preds = %70
%85 = tail call i32 @strcpy(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
br label %86
86: ; preds = %84, %81, %78, %75, %72, %68, %66, %64, %62, %60, %58, %56, %54
%87 = phi i32 [ %69, %68 ], [ %67, %66 ], [ %65, %64 ], [ %63, %62 ], [ %61, %60 ], [ %59, %58 ], [ %57, %56 ], [ %55, %54 ], [ %83, %81 ], [ %80, %78 ], [ %77, %75 ], [ %74, %72 ], [ 1, %84 ]
ret i32 %87
}