#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);
int 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';
    return 3;
  } else {
    if (value < 0) {
      *buffer++ = '-';
      value = -value;
    }
    int length, K;
    Grisu2(value, buffer, &length, &K);
    Prettify(buffer, length, K);
    return length;
  }
}


x86 assembly (clang, -O0):
<dtoa_milo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x10(%rbp)
mov    %rdi,-0x18(%rbp)
movsd  -0x10(%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  -0x10(%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  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11dc <dtoa_milo+0x8c>
jp     11dc <dtoa_milo+0x8c>
mov    -0x18(%rbp),%rax
movb   $0x30,(%rax)
mov    -0x18(%rbp),%rax
movb   $0x2e,0x1(%rax)
mov    -0x18(%rbp),%rax
movb   $0x30,0x2(%rax)
mov    -0x18(%rbp),%rax
movb   $0x0,0x3(%rax)
movl   $0x3,-0x4(%rbp)
jmp    1248 <dtoa_milo+0xf8>
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    121d <dtoa_milo+0xcd>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movb   $0x2d,(%rax)
movsd  -0x10(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
mov    -0x18(%rbp),%rdi
lea    -0x1c(%rbp),%rsi
lea    -0x20(%rbp),%rdx
call   1050 <Grisu2@plt>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
call   1060 <Prettify@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
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    11a5 <dtoa_milo+0x55>
jp     11a5 <dtoa_milo+0x55>
movl   $0x302e30,(%rbx)
mov    $0x3,%eax
jmp    11e0 <dtoa_milo+0x90>
ucomisd %xmm0,%xmm1
jbe    11ba <dtoa_milo+0x6a>
movb   $0x2d,(%rbx)
add    $0x1,%rbx
xorpd  0xe46(%rip),%xmm0
lea    0x8(%rsp),%rsi
lea    0xc(%rsp),%rdx
mov    %rbx,%rdi
call   1050 <Grisu2@plt>
mov    0x8(%rsp),%esi
mov    0xc(%rsp),%edx
mov    %rbx,%rdi
call   1060 <Prettify@plt>
mov    0x8(%rsp),%eax
add    $0x20,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
define i32 @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 %33
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)
%32 = load i32, i32* %3
br label %33
33: ; preds = %23, %14
%34 = phi i32 [ 3, %14 ], [ %32, %23 ]
ret i32 %34
}