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


x86 assembly (clang, -O0):
<convert_to_metric_suffix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
movb   $0x20,-0x21(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    115a <convert_to_metric_suffix+0x3a>
movsd  0xeb5(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1164 <convert_to_metric_suffix+0x44>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xe97(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     11ad <convert_to_metric_suffix+0x8d>
movsd  0xe8d(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    11ad <convert_to_metric_suffix+0x8d>
movsd  -0x20(%rbp),%xmm0
movsd  0xe6d(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movb   $0x54,-0x21(%rbp)
jmp    13ba <convert_to_metric_suffix+0x29a>
movsd  -0x20(%rbp),%xmm0
movsd  0xe5e(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     11f6 <convert_to_metric_suffix+0xd6>
movsd  0xe3c(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    11f6 <convert_to_metric_suffix+0xd6>
movsd  -0x20(%rbp),%xmm0
movsd  0xe34(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movb   $0x47,-0x21(%rbp)
jmp    13b5 <convert_to_metric_suffix+0x295>
movsd  -0x20(%rbp),%xmm0
movsd  0xe1d(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     123f <convert_to_metric_suffix+0x11f>
movsd  0xe03(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    123f <convert_to_metric_suffix+0x11f>
movsd  -0x20(%rbp),%xmm0
movsd  0xdf3(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movb   $0x4d,-0x21(%rbp)
jmp    13b0 <convert_to_metric_suffix+0x290>
movsd  -0x20(%rbp),%xmm0
movsd  0xddc(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     1288 <convert_to_metric_suffix+0x168>
movsd  0xdc2(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    1288 <convert_to_metric_suffix+0x168>
movsd  -0x20(%rbp),%xmm0
movsd  0xdb2(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movb   $0x4b,-0x21(%rbp)
jmp    13ab <convert_to_metric_suffix+0x28b>
movsd  -0x20(%rbp),%xmm0
movsd  0xd9b(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     12cd <convert_to_metric_suffix+0x1ad>
movsd  0xd91(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    12cd <convert_to_metric_suffix+0x1ad>
movsd  0xd6e(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movb   $0x6d,-0x21(%rbp)
jmp    13a6 <convert_to_metric_suffix+0x286>
movsd  -0x20(%rbp),%xmm0
movsd  0xd66(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     1312 <convert_to_metric_suffix+0x1f2>
movsd  0xd44(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    1312 <convert_to_metric_suffix+0x1f2>
movsd  0xd21(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movb   $0x75,-0x21(%rbp)
jmp    13a1 <convert_to_metric_suffix+0x281>
movsd  -0x20(%rbp),%xmm0
movsd  0xd29(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     1357 <convert_to_metric_suffix+0x237>
movsd  0xd0f(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    1357 <convert_to_metric_suffix+0x237>
movsd  0xcd4(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movb   $0x6e,-0x21(%rbp)
jmp    139c <convert_to_metric_suffix+0x27c>
movsd  -0x20(%rbp),%xmm0
movsd  0xcec(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     1397 <convert_to_metric_suffix+0x277>
movsd  0xcd2(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    1397 <convert_to_metric_suffix+0x277>
movsd  0xc7f(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movb   $0x70,-0x21(%rbp)
jmp    139c <convert_to_metric_suffix+0x27c>
jmp    13a1 <convert_to_metric_suffix+0x281>
jmp    13a6 <convert_to_metric_suffix+0x286>
jmp    13ab <convert_to_metric_suffix+0x28b>
jmp    13b0 <convert_to_metric_suffix+0x290>
jmp    13b5 <convert_to_metric_suffix+0x295>
jmp    13ba <convert_to_metric_suffix+0x29a>
movsd  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     13ed <convert_to_metric_suffix+0x2cd>
mov    -0x10(%rbp),%rdi
movsd  -0x20(%rbp),%xmm0
lea    0xc7c(%rip),%rsi
movsbl -0x21(%rbp),%edx
call   1040 <sprintf@plt>
mov    %eax,-0x4(%rbp)
jmp    143b <convert_to_metric_suffix+0x31b>
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    1424 <convert_to_metric_suffix+0x304>
mov    -0x10(%rbp),%rdi
movsd  0xbf9(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
lea    0xc45(%rip),%rsi
movsbl -0x21(%rbp),%edx
call   1040 <sprintf@plt>
mov    %eax,-0x4(%rbp)
jmp    143b <convert_to_metric_suffix+0x31b>
mov    -0x10(%rbp),%rdi
lea    0xc30(%rip),%rsi
call   1030 <strcpy@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%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
jb     1171 <convert_to_metric_suffix+0x51>
movsd  0xec0(%rip),%xmm2
ucomisd %xmm0,%xmm2
jbe    1171 <convert_to_metric_suffix+0x51>
movsd  0xeaa(%rip),%xmm2
divsd  %xmm2,%xmm0
mov    $0x54,%al
jmp    12a4 <convert_to_metric_suffix+0x184>
ucomisd 0xea7(%rip),%xmm0
jb     119c <convert_to_metric_suffix+0x7c>
movsd  0xe8d(%rip),%xmm2
ucomisd %xmm0,%xmm2
jbe    119c <convert_to_metric_suffix+0x7c>
movsd  0xe8f(%rip),%xmm2
divsd  %xmm2,%xmm0
mov    $0x47,%al
jmp    12a4 <convert_to_metric_suffix+0x184>
ucomisd 0xe84(%rip),%xmm0
jb     11c7 <convert_to_metric_suffix+0xa7>
movsd  0xe72(%rip),%xmm2
ucomisd %xmm0,%xmm2
jbe    11c7 <convert_to_metric_suffix+0xa7>
movsd  0xe6c(%rip),%xmm2
divsd  %xmm2,%xmm0
mov    $0x4d,%al
jmp    12a4 <convert_to_metric_suffix+0x184>
ucomisd 0xe61(%rip),%xmm0
jb     11f2 <convert_to_metric_suffix+0xd2>
movsd  0xe4f(%rip),%xmm2
ucomisd %xmm0,%xmm2
jbe    11f2 <convert_to_metric_suffix+0xd2>
movsd  0xe49(%rip),%xmm2
divsd  %xmm2,%xmm0
mov    $0x4b,%al
jmp    12a4 <convert_to_metric_suffix+0x184>
ucomisd 0xe3e(%rip),%xmm0
jb     121d <convert_to_metric_suffix+0xfd>
movsd  0xe3c(%rip),%xmm2
ucomisd %xmm0,%xmm2
jbe    121d <convert_to_metric_suffix+0xfd>
movsd  0xe1e(%rip),%xmm2
mulsd  %xmm2,%xmm0
mov    $0x6d,%al
jmp    12a4 <convert_to_metric_suffix+0x184>
ucomisd 0xe23(%rip),%xmm0
jb     1245 <convert_to_metric_suffix+0x125>
movsd  0xe09(%rip),%xmm2
ucomisd %xmm0,%xmm2
jbe    1245 <convert_to_metric_suffix+0x125>
movsd  0xdeb(%rip),%xmm2
mulsd  %xmm2,%xmm0
mov    $0x75,%al
jmp    12a4 <convert_to_metric_suffix+0x184>
ucomisd 0xe03(%rip),%xmm0
jb     126d <convert_to_metric_suffix+0x14d>
movsd  0xdf1(%rip),%xmm2
ucomisd %xmm0,%xmm2
jbe    126d <convert_to_metric_suffix+0x14d>
movsd  0xdbb(%rip),%xmm2
mulsd  %xmm2,%xmm0
mov    $0x6e,%al
jmp    12a4 <convert_to_metric_suffix+0x184>
ucomisd 0xde3(%rip),%xmm0
setae  %al
movsd  0xdd0(%rip),%xmm2
ucomisd %xmm0,%xmm2
seta   %cl
test   %cl,%al
je     1297 <convert_to_metric_suffix+0x177>
movsd  0xd7d(%rip),%xmm2
mulsd  %xmm2,%xmm0
mov    $0x70,%ecx
mov    $0x20,%eax
cmovne %ecx,%eax
xorpd  %xmm2,%xmm2
ucomisd %xmm2,%xmm1
jae    12bc <convert_to_metric_suffix+0x19c>
ucomisd %xmm1,%xmm2
jbe    12cc <convert_to_metric_suffix+0x1ac>
xorpd  0xd44(%rip),%xmm0
movzbl %al,%edx
lea    0xd9a(%rip),%rsi
pop    %rax
jmp    1040 <sprintf@plt>
lea    0xd94(%rip),%rsi
call   1030 <strcpy@plt>
mov    $0x1,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [7 x i8] c"%.3f%c\00"
@.str.1 = [2 x i8] c"0\00"
define i32 @convert_to_metric_suffix(i8* %0, double %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca double
%6 = alloca double
%7 = alloca i8
store i8* %0, i8** %4
store double %1, double* %5
store i8 32, i8* %7
%8 = load double, double* %5
%9 = fcmp olt double %8, 0.000000e+00
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = load double, double* %5
%12 = fmul double %11, -1.000000e+00
store double %12, double* %6
br label %15
13: ; preds = %2
%14 = load double, double* %5
store double %14, double* %6
br label %15
15: ; preds = %13, %10
%16 = load double, double* %6
%17 = fcmp oge double %16, 1.000000e+12
br i1 %17, label %18, label %24
18: ; preds = %15
%19 = load double, double* %6
%20 = fcmp olt double %19, 1.000000e+15
br i1 %20, label %21, label %24
21: ; preds = %18
%22 = load double, double* %6
%23 = fdiv double %22, 1.000000e+12
store double %23, double* %6
store i8 84, i8* %7
br label %94
24: ; preds = %18, %15
%25 = load double, double* %6
%26 = fcmp oge double %25, 1.000000e+09
br i1 %26, label %27, label %33
27: ; preds = %24
%28 = load double, double* %6
%29 = fcmp olt double %28, 1.000000e+12
br i1 %29, label %30, label %33
30: ; preds = %27
%31 = load double, double* %6
%32 = fdiv double %31, 1.000000e+09
store double %32, double* %6
store i8 71, i8* %7
br label %93
33: ; preds = %27, %24
%34 = load double, double* %6
%35 = fcmp oge double %34, 1.000000e+06
br i1 %35, label %36, label %42
36: ; preds = %33
%37 = load double, double* %6
%38 = fcmp olt double %37, 1.000000e+09
br i1 %38, label %39, label %42
39: ; preds = %36
%40 = load double, double* %6
%41 = fdiv double %40, 1.000000e+06
store double %41, double* %6
store i8 77, i8* %7
br label %92
42: ; preds = %36, %33
%43 = load double, double* %6
%44 = fcmp oge double %43, 1.000000e+03
br i1 %44, label %45, label %51
45: ; preds = %42
%46 = load double, double* %6
%47 = fcmp olt double %46, 1.000000e+06
br i1 %47, label %48, label %51
48: ; preds = %45
%49 = load double, double* %6
%50 = fdiv double %49, 1.000000e+03
store double %50, double* %6
store i8 75, i8* %7
br label %91
51: ; preds = %45, %42
%52 = load double, double* %6
%53 = fcmp oge double %52, 1.000000e-03
br i1 %53, label %54, label %60
54: ; preds = %51
%55 = load double, double* %6
%56 = fcmp olt double %55, 1.000000e+00
br i1 %56, label %57, label %60
57: ; preds = %54
%58 = load double, double* %6
%59 = fmul double %58, 1.000000e+03
store double %59, double* %6
store i8 109, i8* %7
br label %90
60: ; preds = %54, %51
%61 = load double, double* %6
%62 = fcmp oge double %61, 0x3EB0C6F7A0B5ED8D
br i1 %62, label %63, label %69
63: ; preds = %60
%64 = load double, double* %6
%65 = fcmp olt double %64, 1.000000e-03
br i1 %65, label %66, label %69
66: ; preds = %63
%67 = load double, double* %6
%68 = fmul double %67, 1.000000e+06
store double %68, double* %6
store i8 117, i8* %7
br label %89
69: ; preds = %63, %60
%70 = load double, double* %6
%71 = fcmp oge double %70, 1.000000e-09
br i1 %71, label %72, label %78
72: ; preds = %69
%73 = load double, double* %6
%74 = fcmp olt double %73, 0x3EB0C6F7A0B5ED8D
br i1 %74, label %75, label %78
75: ; preds = %72
%76 = load double, double* %6
%77 = fmul double %76, 1.000000e+09
store double %77, double* %6
store i8 110, i8* %7
br label %88
78: ; preds = %72, %69
%79 = load double, double* %6
%80 = fcmp oge double %79, 0x3D719799812DEA11
br i1 %80, label %81, label %87
81: ; preds = %78
%82 = load double, double* %6
%83 = fcmp olt double %82, 1.000000e-09
br i1 %83, label %84, label %87
84: ; preds = %81
%85 = load double, double* %6
%86 = fmul double %85, 1.000000e+12
store double %86, double* %6
store i8 112, i8* %7
br label %87
87: ; preds = %84, %81, %78
br label %88
88: ; preds = %87, %75
br label %89
89: ; preds = %88, %66
br label %90
90: ; preds = %89, %57
br label %91
91: ; preds = %90, %48
br label %92
92: ; preds = %91, %39
br label %93
93: ; preds = %92, %30
br label %94
94: ; preds = %93, %21
%95 = load double, double* %5
%96 = fcmp oge double %95, 0.000000e+00
br i1 %96, label %97, label %102
97: ; preds = %94
%98 = load i8*, i8** %4
%99 = load double, double* %6
%100 = load i8, i8* %7
%101 = call i32 @sprintf(i8* %98, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), double %99, i8 signext %100)
store i32 %101, i32* %3
br label %114
102: ; preds = %94
%103 = load double, double* %5
%104 = fcmp olt double %103, 0.000000e+00
br i1 %104, label %105, label %111
105: ; preds = %102
%106 = load i8*, i8** %4
%107 = load double, double* %6
%108 = fmul double %107, -1.000000e+00
%109 = load i8, i8* %7
%110 = call i32 @sprintf(i8* %106, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), double %108, i8 signext %109)
store i32 %110, i32* %3
br label %114
111: ; preds = %102
%112 = load i8*, i8** %4
%113 = call i32 @strcpy(i8* %112, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %114
114: ; preds = %111, %105, %97
%115 = load i32, i32* %3
ret i32 %115
}

LLVM IR (-O2):
@.str = [7 x i8] c"%.3f%c\00"
@.str.1 = [2 x i8] c"0\00"
define i32 @convert_to_metric_suffix(i8* %0, double %1) {
%3 = fcmp olt double %1, 0.000000e+00
%4 = fneg double %1
%5 = select i1 %3, double %4, double %1
%6 = fcmp oge double %5, 1.000000e+12
%7 = fcmp olt double %5, 1.000000e+15
%8 = and i1 %6, %7
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = fdiv double %5, 1.000000e+12
br label %54
11: ; preds = %2
%12 = fcmp oge double %5, 1.000000e+09
%13 = fcmp olt double %5, 1.000000e+12
%14 = and i1 %12, %13
br i1 %14, label %15, label %17
15: ; preds = %11
%16 = fdiv double %5, 1.000000e+09
br label %54
17: ; preds = %11
%18 = fcmp oge double %5, 1.000000e+06
%19 = fcmp olt double %5, 1.000000e+09
%20 = and i1 %18, %19
br i1 %20, label %21, label %23
21: ; preds = %17
%22 = fdiv double %5, 1.000000e+06
br label %54
23: ; preds = %17
%24 = fcmp oge double %5, 1.000000e+03
%25 = fcmp olt double %5, 1.000000e+06
%26 = and i1 %24, %25
br i1 %26, label %27, label %29
27: ; preds = %23
%28 = fdiv double %5, 1.000000e+03
br label %54
29: ; preds = %23
%30 = fcmp oge double %5, 1.000000e-03
%31 = fcmp olt double %5, 1.000000e+00
%32 = and i1 %30, %31
br i1 %32, label %33, label %35
33: ; preds = %29
%34 = fmul double %5, 1.000000e+03
br label %54
35: ; preds = %29
%36 = fcmp oge double %5, 0x3EB0C6F7A0B5ED8D
%37 = fcmp olt double %5, 1.000000e-03
%38 = and i1 %36, %37
br i1 %38, label %39, label %41
39: ; preds = %35
%40 = fmul double %5, 1.000000e+06
br label %54
41: ; preds = %35
%42 = fcmp oge double %5, 1.000000e-09
%43 = fcmp olt double %5, 0x3EB0C6F7A0B5ED8D
%44 = and i1 %42, %43
br i1 %44, label %45, label %47
45: ; preds = %41
%46 = fmul double %5, 1.000000e+09
br label %54
47: ; preds = %41
%48 = fcmp oge double %5, 0x3D719799812DEA11
%49 = fcmp olt double %5, 1.000000e-09
%50 = and i1 %48, %49
%51 = fmul double %5, 1.000000e+12
%52 = select i1 %50, double %51, double %5
%53 = select i1 %50, i8 112, i8 32
br label %54
54: ; preds = %47, %15, %27, %39, %45, %33, %21, %9
%55 = phi double [ %10, %9 ], [ %16, %15 ], [ %22, %21 ], [ %28, %27 ], [ %34, %33 ], [ %40, %39 ], [ %46, %45 ], [ %52, %47 ]
%56 = phi i8 [ 84, %9 ], [ 71, %15 ], [ 77, %21 ], [ 75, %27 ], [ 109, %33 ], [ 117, %39 ], [ 110, %45 ], [ %53, %47 ]
%57 = fcmp ult double %1, 0.000000e+00
br i1 %57, label %60, label %58
58: ; preds = %54
%59 = 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 %55, i8 signext %56)
br label %66
60: ; preds = %54
br i1 %3, label %61, label %64
61: ; preds = %60
%62 = fneg double %55
%63 = 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 %62, i8 signext %56)
br label %66
64: ; preds = %60
%65 = tail call i32 @strcpy(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %66
66: ; preds = %64, %61, %58
%67 = phi i32 [ %59, %58 ], [ %63, %61 ], [ 1, %64 ]
ret i32 %67
}