#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*/ Grisu2(double, char *, int *, int *);
int /*<<< orphan*/ Prettify(char *, int, int);
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ isinf(double);
int /*<<< orphan*/ isnan(double);
void dtoa_milo(double value, char *buffer) {
  assert(!isnan(value));
  assert(!isinf(value));
  if (value == 0) {
    buffer[0] = '0';
    buffer[1] = '.';
    buffer[2] = '0';
    buffer[3] = '\0';
  } else {
    if (value < 0) {
      *buffer++ = '-';
      value = -value;
    }
    int length, K;
    Grisu2(value, buffer, &length, &K);
    Prettify(buffer, length, K);
  }
}


x86 assembly (clang, -O0):
<dtoa_milo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1040 <isnan@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
movsd  -0x8(%rbp),%xmm0
call   1070 <isinf@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
movsd  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11d5 <dtoa_milo+0x85>
jp     11d5 <dtoa_milo+0x85>
mov    -0x10(%rbp),%rax
movb   $0x30,(%rax)
mov    -0x10(%rbp),%rax
movb   $0x2e,0x1(%rax)
mov    -0x10(%rbp),%rax
movb   $0x30,0x2(%rax)
mov    -0x10(%rbp),%rax
movb   $0x0,0x3(%rax)
jmp    123b <dtoa_milo+0xeb>
xorps  %xmm0,%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    1216 <dtoa_milo+0xc6>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x2d,(%rax)
movsd  -0x8(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
mov    -0x10(%rbp),%rdi
lea    -0x14(%rbp),%rsi
lea    -0x18(%rbp),%rdx
call   1050 <Grisu2@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1060 <Prettify@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dtoa_milo>:
push   %rbx
sub    $0x20,%rsp
mov    %rdi,%rbx
movaps %xmm0,0x10(%rsp)
call   1040 <isnan@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1030 <assert@plt>
movaps 0x10(%rsp),%xmm0
call   1070 <isinf@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1030 <assert@plt>
movapd 0x10(%rsp),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11a0 <dtoa_milo+0x50>
jp     11a0 <dtoa_milo+0x50>
movl   $0x302e30,(%rbx)
jmp    11d7 <dtoa_milo+0x87>
ucomisd %xmm0,%xmm1
jbe    11b5 <dtoa_milo+0x65>
movb   $0x2d,(%rbx)
add    $0x1,%rbx
xorpd  0xe4b(%rip),%xmm0
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
mov    %rbx,%rdi
call   1050 <Grisu2@plt>
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%edx
mov    %rbx,%rdi
call   1060 <Prettify@plt>
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define void @dtoa_milo(double %0, i8* %1) {
%3 = alloca double
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
store double %0, double* %3
store i8* %1, i8** %4
%7 = load double, double* %3
%8 = call i32 @isnan(double %7)
%9 = icmp ne i32 %8, 0
%10 = xor i1 %9, true
%11 = zext i1 %10 to i32
%12 = call i32 @assert(i32 %11)
%13 = load double, double* %3
%14 = call i32 @isinf(double %13)
%15 = icmp ne i32 %14, 0
%16 = xor i1 %15, true
%17 = zext i1 %16 to i32
%18 = call i32 @assert(i32 %17)
%19 = load double, double* %3
%20 = fcmp oeq double %19, 0.000000e+00
br i1 %20, label %21, label %30
21: ; preds = %2
%22 = load i8*, i8** %4
%23 = getelementptr inbounds i8, i8* %22, i64 0
store i8 48, i8* %23
%24 = load i8*, i8** %4
%25 = getelementptr inbounds i8, i8* %24, i64 1
store i8 46, i8* %25
%26 = load i8*, i8** %4
%27 = getelementptr inbounds i8, i8* %26, i64 2
store i8 48, i8* %27
%28 = load i8*, i8** %4
%29 = getelementptr inbounds i8, i8* %28, i64 3
store i8 0, i8* %29
br label %46
30: ; preds = %2
%31 = load double, double* %3
%32 = fcmp olt double %31, 0.000000e+00
br i1 %32, label %33, label %38
33: ; preds = %30
%34 = load i8*, i8** %4
%35 = getelementptr inbounds i8, i8* %34, i32 1
store i8* %35, i8** %4
store i8 45, i8* %34
%36 = load double, double* %3
%37 = fneg double %36
store double %37, double* %3
br label %38
38: ; preds = %33, %30
%39 = load double, double* %3
%40 = load i8*, i8** %4
%41 = call i32 @Grisu2(double %39, i8* %40, i32* %5, i32* %6)
%42 = load i8*, i8** %4
%43 = load i32, i32* %5
%44 = load i32, i32* %6
%45 = call i32 @Prettify(i8* %42, i32 %43, i32 %44)
br label %46
46: ; preds = %38, %21
ret void
}

LLVM IR (-O2):
define void @dtoa_milo(double %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = tail call i32 @isnan(double %0)
%6 = icmp eq i32 %5, 0
%7 = zext i1 %6 to i32
%8 = tail call i32 @assert(i32 %7)
%9 = tail call i32 @isinf(double %0)
%10 = icmp eq i32 %9, 0
%11 = zext i1 %10 to i32
%12 = tail call i32 @assert(i32 %11)
%13 = fcmp oeq double %0, 0.000000e+00
br i1 %13, label %14, label %18
14: ; preds = %2
store i8 48, i8* %1
%15 = getelementptr inbounds i8, i8* %1, i64 1
store i8 46, i8* %15
%16 = getelementptr inbounds i8, i8* %1, i64 2
store i8 48, i8* %16
%17 = getelementptr inbounds i8, i8* %1, i64 3
store i8 0, i8* %17
br label %32
18: ; preds = %2
%19 = fcmp olt double %0, 0.000000e+00
br i1 %19, label %20, label %23
20: ; preds = %18
%21 = getelementptr inbounds i8, i8* %1, i64 1
store i8 45, i8* %1
%22 = fneg double %0
br label %23
23: ; preds = %20, %18
%24 = phi double [ %22, %20 ], [ %0, %18 ]
%25 = phi i8* [ %21, %20 ], [ %1, %18 ]
%26 = bitcast i32* %3 to i8*
%27 = bitcast i32* %4 to i8*
%28 = call i32 @Grisu2(double %24, i8* %25, i32* %3, i32* %4)
%29 = load i32, i32* %3
%30 = load i32, i32* %4
%31 = call i32 @Prettify(i8* %25, i32 %29, i32 %30)
br label %32
32: ; preds = %23, %14
ret void
}