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

/* Variables and functions */
int fabs(double);
int floor(int);
int log(int);
double pow(double, int);
int /*<<< orphan*/ sprintf(char *, char *, int);
void number_format_args(double number, const char **format, const char **suffix,
                        double *scale, double step_size) {
  static const char *fmt[] = {"%.2f%s", "%.1f%s", "%.0f%s"};
  static char suffix_buf[32];
  int mag, rad;
  if (!number) {
    *format = "%.0f";
    *suffix = "";
    *scale = 1.0;
    return;
  }
  if (fabs(number) < 1) {
    static const char *suffixes[] = {"m", "µ", "n", "p", "f", "a", "z", "y"};
    mag = -floor(log(fabs(number)) / log(10) + 1);
    rad = 2 - (mag % 3);
    mag /= 3;
    if (mag > sizeof(suffixes) / sizeof(suffixes[0]) - 1) {
      sprintf(suffix_buf, "E-%u", mag * 3);
      *suffix = suffix_buf;
    } else
      *suffix = suffixes[mag];
    *scale = pow(1000, mag + 1);
  } else {
    mag = floor(log(fabs(number)) / log(10));
    rad = mag % 3;
    mag /= 3;
    if (!mag) {
      *format = fmt[rad];
      *suffix = "";
      *scale = 1.0;
    } else {
      static const char *suffixes[] = {"k", "M", "G", "T", "P", "E", "Z", "Y"};
      if (mag > sizeof(suffixes) / sizeof(suffixes[0])) {
        sprintf(suffix_buf, "E+%u", mag * 3);
        *suffix = suffix_buf;
      } else
        *suffix = suffixes[mag - 1];
      *scale = pow(1000.0, -mag);
    }
  }
  if (step_size) {
    step_size *= *scale;
    if (step_size < 0.01)
      *format = "%.3f%s";
    else if (step_size < 0.1)
      *format = "%.2f%s";
    else if (step_size < 1.0)
      *format = "%.1f%s";
    else
      *format = "%.f%s";
  } else
    *format = fmt[rad];
}


x86 assembly (clang, -O0):
<number_format_args>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movsd  %xmm1,-0x28(%rbp)
movsd  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11b7 <number_format_args+0x67>
jp     11b7 <number_format_args+0x67>
mov    -0x10(%rbp),%rax
lea    0xea4(%rip),%rcx
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
lea    0xeba(%rip),%rcx
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rax
movsd  0xe52(%rip),%xmm0
movsd  %xmm0,(%rax)
jmp    1469 <number_format_args+0x319>
movsd  -0x8(%rbp),%xmm0
call   1030 <fabs@plt>
cmp    $0x1,%eax
jge    1294 <number_format_args+0x144>
movsd  -0x8(%rbp),%xmm0
call   1030 <fabs@plt>
mov    %eax,%edi
call   1040 <log@plt>
mov    %eax,-0x34(%rbp)
mov    $0xa,%edi
call   1040 <log@plt>
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
cltd
idiv   %ecx
mov    %eax,%edi
add    $0x1,%edi
call   1070 <floor@plt>
mov    %eax,%ecx
xor    %eax,%eax
sub    %ecx,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    $0x2,%eax
sub    %edx,%eax
mov    %eax,-0x30(%rbp)
mov    -0x2c(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %eax,-0x2c(%rbp)
movslq -0x2c(%rbp),%rax
cmp    $0x7,%rax
jbe    125e <number_format_args+0x10e>
imul   $0x3,-0x2c(%rbp),%edx
lea    0x2ec1(%rip),%rdi
lea    0xe03(%rip),%rsi
call   1060 <sprintf@plt>
mov    -0x18(%rbp),%rax
lea    0x2eaa(%rip),%rcx
mov    %rcx,(%rax)
jmp    1274 <number_format_args+0x124>
movslq -0x2c(%rbp),%rcx
lea    0x2e07(%rip),%rax
mov    (%rax,%rcx,8),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x2c(%rbp),%edi
add    $0x1,%edi
movsd  0xd86(%rip),%xmm0
call   1050 <pow@plt>
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    1395 <number_format_args+0x245>
movsd  -0x8(%rbp),%xmm0
call   1030 <fabs@plt>
mov    %eax,%edi
call   1040 <log@plt>
mov    %eax,-0x38(%rbp)
mov    $0xa,%edi
call   1040 <log@plt>
mov    %eax,%ecx
mov    -0x38(%rbp),%eax
cltd
idiv   %ecx
mov    %eax,%edi
call   1070 <floor@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %edx,-0x30(%rbp)
mov    -0x2c(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jne    1323 <number_format_args+0x1d3>
movslq -0x30(%rbp),%rcx
lea    0x2d5b(%rip),%rax
mov    (%rax,%rcx,8),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
lea    0xd4e(%rip),%rcx
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rax
movsd  0xce6(%rip),%xmm0
movsd  %xmm0,(%rax)
jmp    1390 <number_format_args+0x240>
movslq -0x2c(%rbp),%rax
cmp    $0x8,%rax
jbe    135b <number_format_args+0x20b>
imul   $0x3,-0x2c(%rbp),%edx
lea    0x2dc4(%rip),%rdi
lea    0xd1b(%rip),%rsi
call   1060 <sprintf@plt>
mov    -0x18(%rbp),%rax
lea    0x2dad(%rip),%rcx
mov    %rcx,(%rax)
jmp    1376 <number_format_args+0x226>
mov    -0x2c(%rbp),%eax
sub    $0x1,%eax
movslq %eax,%rcx
lea    0x2d45(%rip),%rax
mov    (%rax,%rcx,8),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
xor    %edi,%edi
sub    -0x2c(%rbp),%edi
movsd  0xc85(%rip),%xmm0
call   1050 <pow@plt>
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    1395 <number_format_args+0x245>
movsd  -0x28(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    13b2 <number_format_args+0x262>
jp     13b2 <number_format_args+0x262>
jmp    1453 <number_format_args+0x303>
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xc44(%rip),%xmm0
ucomisd -0x28(%rbp),%xmm0
jbe    13ea <number_format_args+0x29a>
mov    -0x10(%rbp),%rax
lea    0xc81(%rip),%rcx
mov    %rcx,(%rax)
jmp    144e <number_format_args+0x2fe>
movsd  0xc26(%rip),%xmm0
ucomisd -0x28(%rbp),%xmm0
jbe    1410 <number_format_args+0x2c0>
mov    -0x10(%rbp),%rax
lea    0xc18(%rip),%rcx
mov    %rcx,(%rax)
jmp    1449 <number_format_args+0x2f9>
movsd  0xbe8(%rip),%xmm0
ucomisd -0x28(%rbp),%xmm0
jbe    1436 <number_format_args+0x2e6>
mov    -0x10(%rbp),%rax
lea    0xbf9(%rip),%rcx
mov    %rcx,(%rax)
jmp    1444 <number_format_args+0x2f4>
mov    -0x10(%rbp),%rax
lea    0xc29(%rip),%rcx
mov    %rcx,(%rax)
jmp    1449 <number_format_args+0x2f9>
jmp    144e <number_format_args+0x2fe>
jmp    1469 <number_format_args+0x319>
movslq -0x30(%rbp),%rcx
lea    0x2bf2(%rip),%rax
mov    (%rax,%rcx,8),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<number_format_args>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%r14
xorpd  %xmm2,%xmm2
ucomisd %xmm2,%xmm0
jne    1177 <number_format_args+0x27>
jnp    11fb <number_format_args+0xab>
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,0x10(%rsp)
call   1030 <fabs@plt>
mov    %eax,%ebx
movsd  0x10(%rsp),%xmm0
call   1030 <fabs@plt>
mov    %eax,%edi
call   1040 <log@plt>
mov    %eax,%ebp
mov    $0xa,%edi
call   1040 <log@plt>
mov    %eax,%ecx
mov    %ebp,%eax
cltd
idiv   %ecx
test   %ebx,%ebx
jle    1222 <number_format_args+0xd2>
mov    %eax,%edi
call   1070 <floor@plt>
cltq
imul   $0x55555556,%rax,%rbx
mov    %rbx,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rbx
add    %ecx,%ebx
lea    (%rbx,%rbx,2),%ecx
mov    %eax,%ebp
sub    %ecx,%ebp
add    $0x2,%eax
cmp    $0x4,%eax
ja     1285 <number_format_args+0x135>
lea    0xebb(%rip),%rax
mov    %rax,(%r12)
movsd  0xe12(%rip),%xmm0
jmp    12ff <number_format_args+0x1af>
lea    0xe7f(%rip),%rax
mov    %rax,(%r14)
lea    0xe99(%rip),%rax
mov    %rax,(%r12)
movabs $0x3ff0000000000000,%rax
mov    %rax,(%r15)
jmp    137c <number_format_args+0x22c>
mov    %r14,0x10(%rsp)
add    $0x1,%eax
mov    %eax,%edi
call   1070 <floor@plt>
movslq %eax,%rbp
imul   $0x55555556,%rbp,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
add    %ecx,%eax
lea    (%rax,%rax,2),%r14d
neg    %r14d
imul   $0x55555555,%rbp,%rbx
shr    $0x20,%rbx
sub    %ebp,%ebx
mov    %ebx,%eax
shr    $0x1f,%eax
sar    %ebx
add    %eax,%ebx
cmp    $0x8,%ebx
jb     12a5 <number_format_args+0x155>
lea    (%rbx,%rbx,2),%edx
lea    0x2dec(%rip),%r13
lea    0xe1a(%rip),%rsi
mov    %r13,%rdi
call   1060 <sprintf@plt>
jmp    12b5 <number_format_args+0x165>
cmp    $0x9,%ebx
jb     12d8 <number_format_args+0x188>
lea    (%rbx,%rbx,2),%edx
lea    0x2dcc(%rip),%r13
lea    0xe0f(%rip),%rsi
mov    %r13,%rdi
call   1060 <sprintf@plt>
jmp    12ea <number_format_args+0x19a>
mov    %ebx,%eax
lea    0xd7e(%rip),%rcx
movslq (%rcx,%rax,4),%r13
add    %rcx,%r13
add    %r14d,%ebp
add    $0x2,%ebp
mov    %r13,(%r12)
add    $0x1,%ebx
movsd  0xd36(%rip),%xmm0
mov    %ebx,%edi
call   1050 <pow@plt>
mov    0x10(%rsp),%r14
jmp    12ff <number_format_args+0x1af>
movslq %ebx,%rax
lea    0xd6a(%rip),%rcx
movslq -0x4(%rcx,%rax,4),%r13
add    %rcx,%r13
mov    %r13,(%r12)
neg    %ebx
movsd  0xd08(%rip),%xmm0
mov    %ebx,%edi
call   1050 <pow@plt>
movsd  0x8(%rsp),%xmm2
movsd  %xmm0,(%r15)
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm2
jne    1316 <number_format_args+0x1c6>
jnp    1331 <number_format_args+0x1e1>
mulsd  %xmm2,%xmm0
movsd  0xcee(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    1344 <number_format_args+0x1f4>
lea    0xd80(%rip),%rax
jmp    1379 <number_format_args+0x229>
movslq %ebp,%rax
lea    0xce5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    1379 <number_format_args+0x229>
movsd  0xccc(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    135b <number_format_args+0x20b>
lea    0xd13(%rip),%rax
jmp    1379 <number_format_args+0x229>
movsd  0xca5(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    1372 <number_format_args+0x222>
lea    0xd03(%rip),%rax
jmp    1379 <number_format_args+0x229>
lea    0xd3d(%rip),%rax
mov    %rax,(%r14)
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@number_format_args.fmt = internal global [3 x i8*] [i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i32 0, i32 0)]
@.str = [7 x i8] c"%.2f%s\00"
@.str.1 = [7 x i8] c"%.1f%s\00"
@.str.2 = [7 x i8] c"%.0f%s\00"
@number_format_args.suffix_buf = internal global [32 x i8] zeroinitializer
@.str.3 = [5 x i8] c"%.0f\00"
@.str.4 = [1 x i8] zeroinitializer
@number_format_args.suffixes = internal global [8 x i8*] [i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i32 0, i32 0)]
@.str.5 = [2 x i8] c"m\00"
@.str.6 = [3 x i8] c"\C2\B5\00"
@.str.7 = [2 x i8] c"n\00"
@.str.8 = [2 x i8] c"p\00"
@.str.9 = [2 x i8] c"f\00"
@.str.10 = [2 x i8] c"a\00"
@.str.11 = [2 x i8] c"z\00"
@.str.12 = [2 x i8] c"y\00"
@.str.13 = [5 x i8] c"E-%u\00"
@number_format_args.suffixes.14 = internal global [8 x i8*] [i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.15, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.16, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.17, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.18, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.19, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.20, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.21, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.22, i32 0, i32 0)]
@.str.15 = [2 x i8] c"k\00"
@.str.16 = [2 x i8] c"M\00"
@.str.17 = [2 x i8] c"G\00"
@.str.18 = [2 x i8] c"T\00"
@.str.19 = [2 x i8] c"P\00"
@.str.20 = [2 x i8] c"E\00"
@.str.21 = [2 x i8] c"Z\00"
@.str.22 = [2 x i8] c"Y\00"
@.str.23 = [5 x i8] c"E+%u\00"
@.str.24 = [7 x i8] c"%.3f%s\00"
@.str.25 = [6 x i8] c"%.f%s\00"
define void @number_format_args(double %0, i8** %1, i8** %2, double* %3, double %4) {
%6 = alloca double
%7 = alloca i8**
%8 = alloca i8**
%9 = alloca double*
%10 = alloca double
%11 = alloca i32
%12 = alloca i32
store double %0, double* %6
store i8** %1, i8*** %7
store i8** %2, i8*** %8
store double* %3, double** %9
store double %4, double* %10
%13 = load double, double* %6
%14 = fcmp une double %13, 0.000000e+00
br i1 %14, label %19, label %15
15: ; preds = %5
%16 = load i8**, i8*** %7
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8** %16
%17 = load i8**, i8*** %8
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0), i8** %17
%18 = load double*, double** %9
store double 1.000000e+00, double* %18
br label %132
19: ; preds = %5
%20 = load double, double* %6
%21 = call i32 @fabs(double %20)
%22 = icmp slt i32 %21, 1
br i1 %22, label %23, label %56
23: ; preds = %19
%24 = load double, double* %6
%25 = call i32 @fabs(double %24)
%26 = call i32 @log(i32 %25)
%27 = call i32 @log(i32 10)
%28 = sdiv i32 %26, %27
%29 = add nsw i32 %28, 1
%30 = call i32 @floor(i32 %29)
%31 = sub nsw i32 0, %30
store i32 %31, i32* %11
%32 = load i32, i32* %11
%33 = srem i32 %32, 3
%34 = sub nsw i32 2, %33
store i32 %34, i32* %12
%35 = load i32, i32* %11
%36 = sdiv i32 %35, 3
store i32 %36, i32* %11
%37 = load i32, i32* %11
%38 = sext i32 %37 to i64
%39 = icmp ugt i64 %38, 7
br i1 %39, label %40, label %45
40: ; preds = %23
%41 = load i32, i32* %11
%42 = mul nsw i32 %41, 3
%43 = call i32 @sprintf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @number_format_args.suffix_buf, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.13, i64 0, i64 0), i32 %42)
%44 = load i8**, i8*** %8
store i8* getelementptr inbounds ([32 x i8], [32 x i8]* @number_format_args.suffix_buf, i64 0, i64 0), i8** %44
br label %51
45: ; preds = %23
%46 = load i32, i32* %11
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [8 x i8*], [8 x i8*]* @number_format_args.suffixes, i64 0, i64 %47
%49 = load i8*, i8** %48
%50 = load i8**, i8*** %8
store i8* %49, i8** %50
br label %51
51: ; preds = %45, %40
%52 = load i32, i32* %11
%53 = add nsw i32 %52, 1
%54 = call double @pow(double 1.000000e+03, i32 %53)
%55 = load double*, double** %9
store double %54, double* %55
br label %99
56: ; preds = %19
%57 = load double, double* %6
%58 = call i32 @fabs(double %57)
%59 = call i32 @log(i32 %58)
%60 = call i32 @log(i32 10)
%61 = sdiv i32 %59, %60
%62 = call i32 @floor(i32 %61)
store i32 %62, i32* %11
%63 = load i32, i32* %11
%64 = srem i32 %63, 3
store i32 %64, i32* %12
%65 = load i32, i32* %11
%66 = sdiv i32 %65, 3
store i32 %66, i32* %11
%67 = load i32, i32* %11
%68 = icmp ne i32 %67, 0
br i1 %68, label %77, label %69
69: ; preds = %56
%70 = load i32, i32* %12
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds [3 x i8*], [3 x i8*]* @number_format_args.fmt, i64 0, i64 %71
%73 = load i8*, i8** %72
%74 = load i8**, i8*** %7
store i8* %73, i8** %74
%75 = load i8**, i8*** %8
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0), i8** %75
%76 = load double*, double** %9
store double 1.000000e+00, double* %76
br label %98
77: ; preds = %56
%78 = load i32, i32* %11
%79 = sext i32 %78 to i64
%80 = icmp ugt i64 %79, 8
br i1 %80, label %81, label %86
81: ; preds = %77
%82 = load i32, i32* %11
%83 = mul nsw i32 %82, 3
%84 = call i32 @sprintf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @number_format_args.suffix_buf, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.23, i64 0, i64 0), i32 %83)
%85 = load i8**, i8*** %8
store i8* getelementptr inbounds ([32 x i8], [32 x i8]* @number_format_args.suffix_buf, i64 0, i64 0), i8** %85
br label %93
86: ; preds = %77
%87 = load i32, i32* %11
%88 = sub nsw i32 %87, 1
%89 = sext i32 %88 to i64
%90 = getelementptr inbounds [8 x i8*], [8 x i8*]* @number_format_args.suffixes.14, i64 0, i64 %89
%91 = load i8*, i8** %90
%92 = load i8**, i8*** %8
store i8* %91, i8** %92
br label %93
93: ; preds = %86, %81
%94 = load i32, i32* %11
%95 = sub nsw i32 0, %94
%96 = call double @pow(double 1.000000e+03, i32 %95)
%97 = load double*, double** %9
store double %96, double* %97
br label %98
98: ; preds = %93, %69
br label %99
99: ; preds = %98, %51
%100 = load double, double* %10
%101 = fcmp une double %100, 0.000000e+00
br i1 %101, label %102, label %126
102: ; preds = %99
%103 = load double*, double** %9
%104 = load double, double* %103
%105 = load double, double* %10
%106 = fmul double %105, %104
store double %106, double* %10
%107 = load double, double* %10
%108 = fcmp olt double %107, 1.000000e-02
br i1 %108, label %109, label %111
109: ; preds = %102
%110 = load i8**, i8*** %7
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.24, i64 0, i64 0), i8** %110
br label %125
111: ; preds = %102
%112 = load double, double* %10
%113 = fcmp olt double %112, 1.000000e-01
br i1 %113, label %114, label %116
114: ; preds = %111
%115 = load i8**, i8*** %7
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8** %115
br label %124
116: ; preds = %111
%117 = load double, double* %10
%118 = fcmp olt double %117, 1.000000e+00
br i1 %118, label %119, label %121
119: ; preds = %116
%120 = load i8**, i8*** %7
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8** %120
br label %123
121: ; preds = %116
%122 = load i8**, i8*** %7
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.25, i64 0, i64 0), i8** %122
br label %123
123: ; preds = %121, %119
br label %124
124: ; preds = %123, %114
br label %125
125: ; preds = %124, %109
br label %132
126: ; preds = %99
%127 = load i32, i32* %12
%128 = sext i32 %127 to i64
%129 = getelementptr inbounds [3 x i8*], [3 x i8*]* @number_format_args.fmt, i64 0, i64 %128
%130 = load i8*, i8** %129
%131 = load i8**, i8*** %7
store i8* %130, i8** %131
br label %132
132: ; preds = %15, %126, %125
ret void
}

LLVM IR (-O2):
@reltable.number_format_args = internal unnamed_addr constant [3 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str to i64), i64 ptrtoint ([3 x i32]* @reltable.number_format_args to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.1 to i64), i64 ptrtoint ([3 x i32]* @reltable.number_format_args to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.2 to i64), i64 ptrtoint ([3 x i32]* @reltable.number_format_args to i64)) to i32)]
@.str = [7 x i8] c"%.2f%s\00"
@.str.1 = [7 x i8] c"%.1f%s\00"
@.str.2 = [7 x i8] c"%.0f%s\00"
@number_format_args.suffix_buf = internal global [32 x i8] zeroinitializer
@.str.3 = [5 x i8] c"%.0f\00"
@.str.4 = [1 x i8] zeroinitializer
@reltable.number_format_args.26 = internal unnamed_addr constant [8 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([2 x i8]* @.str.5 to i64), i64 ptrtoint ([8 x i32]* @reltable.number_format_args.26 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.6 to i64), i64 ptrtoint ([8 x i32]* @reltable.number_format_args.26 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([2 x i8]* @.str.7 to i64), i64 ptrtoint ([8 x i32]* @reltable.number_format_args.26 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([2 x i8]* @.str.8 to i64), i64 ptrtoint ([8 x i32]* @reltable.number_format_args.26 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([2 x i8]* @.str.9 to i64), i64 ptrtoint ([8 x i32]* @reltable.number_format_args.26 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([2 x i8]* @.str.10 to i64), i64 ptrtoint ([8 x i32]* @reltable.number_format_args.26 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([2 x i8]* @.str.11 to i64), i64 ptrtoint ([8 x i32]* @reltable.number_format_args.26 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([2 x i8]* @.str.12 to i64), i64 ptrtoint ([8 x i32]* @reltable.number_format_args.26 to i64)) to i32)]
@.str.5 = [2 x i8] c"m\00"
@.str.6 = [3 x i8] c"\C2\B5\00"
@.str.7 = [2 x i8] c"n\00"
@.str.8 = [2 x i8] c"p\00"
@.str.9 = [2 x i8] c"f\00"
@.str.10 = [2 x i8] c"a\00"
@.str.11 = [2 x i8] c"z\00"
@.str.12 = [2 x i8] c"y\00"
@.str.13 = [5 x i8] c"E-%u\00"
@reltable.number_format_args.27 = internal unnamed_addr constant [8 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([2 x i8]* @.str.15 to i64), i64 ptrtoint ([8 x i32]* @reltable.number_format_args.27 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([2 x i8]* @.str.16 to i64), i64 ptrtoint ([8 x i32]* @reltable.number_format_args.27 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([2 x i8]* @.str.17 to i64), i64 ptrtoint ([8 x i32]* @reltable.number_format_args.27 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([2 x i8]* @.str.18 to i64), i64 ptrtoint ([8 x i32]* @reltable.number_format_args.27 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([2 x i8]* @.str.19 to i64), i64 ptrtoint ([8 x i32]* @reltable.number_format_args.27 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([2 x i8]* @.str.20 to i64), i64 ptrtoint ([8 x i32]* @reltable.number_format_args.27 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([2 x i8]* @.str.21 to i64), i64 ptrtoint ([8 x i32]* @reltable.number_format_args.27 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([2 x i8]* @.str.22 to i64), i64 ptrtoint ([8 x i32]* @reltable.number_format_args.27 to i64)) to i32)]
@.str.15 = [2 x i8] c"k\00"
@.str.16 = [2 x i8] c"M\00"
@.str.17 = [2 x i8] c"G\00"
@.str.18 = [2 x i8] c"T\00"
@.str.19 = [2 x i8] c"P\00"
@.str.20 = [2 x i8] c"E\00"
@.str.21 = [2 x i8] c"Z\00"
@.str.22 = [2 x i8] c"Y\00"
@.str.23 = [5 x i8] c"E+%u\00"
@.str.24 = [7 x i8] c"%.3f%s\00"
@.str.25 = [6 x i8] c"%.f%s\00"
define void @number_format_args(double %0, i8** nocapture writeonly %1, i8** nocapture writeonly %2, double* nocapture %3, double %4) {
%6 = fcmp une double %0, 0.000000e+00
br i1 %6, label %8, label %7
7: ; preds = %5
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8** %1
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0), i8** %2
store double 1.000000e+00, double* %3
br label %73
8: ; preds = %5
%9 = tail call i32 @fabs(double %0)
%10 = icmp slt i32 %9, 1
%11 = tail call i32 @fabs(double %0)
%12 = tail call i32 @log(i32 %11)
%13 = tail call i32 @log(i32 10)
%14 = sdiv i32 %12, %13
br i1 %10, label %15, label %33
15: ; preds = %8
%16 = add nsw i32 %14, 1
%17 = tail call i32 @floor(i32 %16)
%18 = srem i32 %17, 3
%19 = add nsw i32 %18, 2
%20 = sdiv i32 %17, -3
%21 = icmp ugt i32 %20, 7
br i1 %21, label %22, label %25
22: ; preds = %15
%23 = mul nsw i32 %20, 3
%24 = tail call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @number_format_args.suffix_buf, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.13, i64 0, i64 0), i32 %23)
br label %29
25: ; preds = %15
%26 = zext i32 %20 to i64
%27 = shl i64 %26, 2
%28 = call i8* @llvm.load.relative.i64(i8* bitcast ([8 x i32]* @reltable.number_format_args.26 to i8*), i64 %27)
br label %29
29: ; preds = %25, %22
%30 = phi i8* [ %28, %25 ], [ getelementptr inbounds ([32 x i8], [32 x i8]* @number_format_args.suffix_buf, i64 0, i64 0), %22 ]
store i8* %30, i8** %2
%31 = add nsw i32 %20, 1
%32 = tail call double @pow(double 1.000000e+03, i32 %31)
br label %54
33: ; preds = %8
%34 = tail call i32 @floor(i32 %14)
%35 = srem i32 %34, 3
%36 = sdiv i32 %34, 3
%37 = add i32 %34, 2
%38 = icmp ult i32 %37, 5
br i1 %38, label %39, label %40
39: ; preds = %33
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0), i8** %2
br label %54
40: ; preds = %33
%41 = icmp ugt i32 %36, 8
br i1 %41, label %42, label %45
42: ; preds = %40
%43 = mul nsw i32 %36, 3
%44 = tail call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @number_format_args.suffix_buf, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.23, i64 0, i64 0), i32 %43)
br label %50
45: ; preds = %40
%46 = add nsw i32 %36, -1
%47 = sext i32 %46 to i64
%48 = shl i64 %47, 2
%49 = call i8* @llvm.load.relative.i64(i8* bitcast ([8 x i32]* @reltable.number_format_args.27 to i8*), i64 %48)
br label %50
50: ; preds = %45, %42
%51 = phi i8* [ %49, %45 ], [ getelementptr inbounds ([32 x i8], [32 x i8]* @number_format_args.suffix_buf, i64 0, i64 0), %42 ]
store i8* %51, i8** %2
%52 = sub nsw i32 0, %36
%53 = tail call double @pow(double 1.000000e+03, i32 %52)
br label %54
54: ; preds = %39, %50, %29
%55 = phi double [ 1.000000e+00, %39 ], [ %53, %50 ], [ %32, %29 ]
%56 = phi i32 [ %35, %39 ], [ %35, %50 ], [ %19, %29 ]
store double %55, double* %3
%57 = fcmp une double %4, 0.000000e+00
br i1 %57, label %58, label %69
58: ; preds = %54
%59 = fmul double %55, %4
%60 = fcmp olt double %59, 1.000000e-02
br i1 %60, label %61, label %62
61: ; preds = %58
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.24, i64 0, i64 0), i8** %1
br label %73
62: ; preds = %58
%63 = fcmp olt double %59, 1.000000e-01
br i1 %63, label %64, label %65
64: ; preds = %62
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8** %1
br label %73
65: ; preds = %62
%66 = fcmp olt double %59, 1.000000e+00
br i1 %66, label %67, label %68
67: ; preds = %65
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8** %1
br label %73
68: ; preds = %65
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.25, i64 0, i64 0), i8** %1
br label %73
69: ; preds = %54
%70 = sext i32 %56 to i64
%71 = shl i64 %70, 2
%72 = call i8* @llvm.load.relative.i64(i8* bitcast ([3 x i32]* @reltable.number_format_args to i8*), i64 %71)
store i8* %72, i8** %1
br label %73
73: ; preds = %69, %64, %68, %67, %61, %7
ret void
}