#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*/ sprintf(char *, char const *, double);
int /*<<< orphan*/ wcsutil_locale_to_dot(char *);
void wcsutil_double2str(char *buf, const char *format, double value) {
  char *bp, *cp;
  sprintf(buf, format, value);
  wcsutil_locale_to_dot(buf);
  bp = buf;
  while (*bp) {
    if (*bp != ' ') {
      if (*bp == '.')
        return;
      if (*bp == 'e')
        return;
      if (*bp == 'E')
        return;
    }
    bp++;
  }
  bp = buf;
  if (*bp == ' ') {
    cp = buf + 1;
    if (*cp == ' ')
      cp++;
    while (*cp) {
      *bp = *cp;
      bp++;
      cp++;
    }
    *bp = '.';
    bp++;
    if (bp < cp)
      *bp = '0';
  }
}


x86 assembly (clang, -O0):
<wcsutil_double2str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
movsd  -0x18(%rbp),%xmm0
call   1040 <sprintf@plt>
mov    -0x8(%rbp),%rdi
call   1030 <wcsutil_locale_to_dot@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmpb   $0x0,(%rax)
je     11ca <wcsutil_double2str+0xaa>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
je     11b9 <wcsutil_double2str+0x99>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    118a <wcsutil_double2str+0x6a>
jmp    1272 <wcsutil_double2str+0x152>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x65,%eax
jne    119f <wcsutil_double2str+0x7f>
jmp    1272 <wcsutil_double2str+0x152>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x45,%eax
jne    11b4 <wcsutil_double2str+0x94>
jmp    1272 <wcsutil_double2str+0x152>
jmp    11b9 <wcsutil_double2str+0x99>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1158 <wcsutil_double2str+0x38>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jne    1272 <wcsutil_double2str+0x152>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jne    120a <wcsutil_double2str+0xea>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    120f <wcsutil_double2str+0xef>
mov    -0x28(%rbp),%rax
cmpb   $0x0,(%rax)
je     1245 <wcsutil_double2str+0x125>
mov    -0x28(%rbp),%rax
mov    (%rax),%cl
mov    -0x20(%rbp),%rax
mov    %cl,(%rax)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    120f <wcsutil_double2str+0xef>
mov    -0x20(%rbp),%rax
movb   $0x2e,(%rax)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x28(%rbp),%rax
jae    126d <wcsutil_double2str+0x14d>
mov    -0x20(%rbp),%rax
movb   $0x30,(%rax)
jmp    1272 <wcsutil_double2str+0x152>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wcsutil_double2str>:
push   %rbx
mov    %rdi,%rbx
call   1040 <sprintf@plt>
mov    %rbx,%rdi
call   1030 <wcsutil_locale_to_dot@plt>
movabs $0x80000000800001,%rax
mov    %rbx,%rcx
xchg   %ax,%ax
movzbl (%rcx),%edx
lea    -0x2e(%rdx),%esi
cmp    $0x37,%sil
ja     1156 <wcsutil_double2str+0x36>
movzbl %sil,%esi
bt     %rsi,%rax
jb     11b1 <wcsutil_double2str+0x91>
test   %dl,%dl
je     1160 <wcsutil_double2str+0x40>
add    $0x1,%rcx
jmp    1140 <wcsutil_double2str+0x20>
cmpb   $0x20,(%rbx)
jne    11b1 <wcsutil_double2str+0x91>
lea    0x1(%rbx),%rax
lea    0x2(%rbx),%rcx
xor    %edx,%edx
cmpb   $0x20,0x1(%rbx)
sete   %dl
cmove  %rcx,%rax
mov    0x1(%rdx,%rbx,1),%cl
test   %cl,%cl
je     11a2 <wcsutil_double2str+0x82>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %cl,(%rbx)
add    $0x1,%rbx
movzbl 0x1(%rax),%ecx
add    $0x1,%rax
test   %cl,%cl
jne    1190 <wcsutil_double2str+0x70>
movb   $0x2e,(%rbx)
add    $0x1,%rbx
cmp    %rax,%rbx
jae    11b1 <wcsutil_double2str+0x91>
movb   $0x30,(%rbx)
pop    %rbx
ret

LLVM IR (-O0):
define void @wcsutil_double2str(i8* %0, i8* %1, double %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca double
%7 = alloca i8*
%8 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store double %2, double* %6
%9 = load i8*, i8** %4
%10 = load i8*, i8** %5
%11 = load double, double* %6
%12 = call i32 @sprintf(i8* %9, i8* %10, double %11)
%13 = load i8*, i8** %4
%14 = call i32 @wcsutil_locale_to_dot(i8* %13)
%15 = load i8*, i8** %4
store i8* %15, i8** %7
br label %16
16: ; preds = %44, %3
%17 = load i8*, i8** %7
%18 = load i8, i8* %17
%19 = icmp ne i8 %18, 0
br i1 %19, label %20, label %47
20: ; preds = %16
%21 = load i8*, i8** %7
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp ne i32 %23, 32
br i1 %24, label %25, label %44
25: ; preds = %20
%26 = load i8*, i8** %7
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %28, 46
br i1 %29, label %30, label %31
30: ; preds = %25
br label %86
31: ; preds = %25
%32 = load i8*, i8** %7
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = icmp eq i32 %34, 101
br i1 %35, label %36, label %37
36: ; preds = %31
br label %86
37: ; preds = %31
%38 = load i8*, i8** %7
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = icmp eq i32 %40, 69
br i1 %41, label %42, label %43
42: ; preds = %37
br label %86
43: ; preds = %37
br label %44
44: ; preds = %43, %20
%45 = load i8*, i8** %7
%46 = getelementptr inbounds i8, i8* %45, i32 1
store i8* %46, i8** %7
br label %16
47: ; preds = %16
%48 = load i8*, i8** %4
store i8* %48, i8** %7
%49 = load i8*, i8** %7
%50 = load i8, i8* %49
%51 = sext i8 %50 to i32
%52 = icmp eq i32 %51, 32
br i1 %52, label %53, label %86
53: ; preds = %47
%54 = load i8*, i8** %4
%55 = getelementptr inbounds i8, i8* %54, i64 1
store i8* %55, i8** %8
%56 = load i8*, i8** %8
%57 = load i8, i8* %56
%58 = sext i8 %57 to i32
%59 = icmp eq i32 %58, 32
br i1 %59, label %60, label %63
60: ; preds = %53
%61 = load i8*, i8** %8
%62 = getelementptr inbounds i8, i8* %61, i32 1
store i8* %62, i8** %8
br label %63
63: ; preds = %60, %53
br label %64
64: ; preds = %68, %63
%65 = load i8*, i8** %8
%66 = load i8, i8* %65
%67 = icmp ne i8 %66, 0
br i1 %67, label %68, label %76
68: ; preds = %64
%69 = load i8*, i8** %8
%70 = load i8, i8* %69
%71 = load i8*, i8** %7
store i8 %70, i8* %71
%72 = load i8*, i8** %7
%73 = getelementptr inbounds i8, i8* %72, i32 1
store i8* %73, i8** %7
%74 = load i8*, i8** %8
%75 = getelementptr inbounds i8, i8* %74, i32 1
store i8* %75, i8** %8
br label %64
76: ; preds = %64
%77 = load i8*, i8** %7
store i8 46, i8* %77
%78 = load i8*, i8** %7
%79 = getelementptr inbounds i8, i8* %78, i32 1
store i8* %79, i8** %7
%80 = load i8*, i8** %7
%81 = load i8*, i8** %8
%82 = icmp ult i8* %80, %81
br i1 %82, label %83, label %85
83: ; preds = %76
%84 = load i8*, i8** %7
store i8 48, i8* %84
br label %85
85: ; preds = %83, %76
br label %86
86: ; preds = %30, %36, %42, %85, %47
ret void
}

LLVM IR (-O2):
define void @wcsutil_double2str(i8* %0, i8* nocapture %1, double %2) {
%4 = tail call i32 @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) %1, double %2)
%5 = tail call i32 @wcsutil_locale_to_dot(i8* %0)
br label %6
6: ; preds = %9, %3
%7 = phi i8* [ %0, %3 ], [ %10, %9 ]
%8 = load i8, i8* %7
switch i8 %8, label %9 [
i8 0, label %11
i8 69, label %36
i8 46, label %36
i8 101, label %36
]
9: ; preds = %6
%10 = getelementptr inbounds i8, i8* %7, i64 1
br label %6
11: ; preds = %6
%12 = load i8, i8* %0
%13 = icmp eq i8 %12, 32
br i1 %13, label %14, label %36
14: ; preds = %11
%15 = getelementptr inbounds i8, i8* %0, i64 1
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 32
%18 = getelementptr inbounds i8, i8* %0, i64 2
%19 = select i1 %17, i8* %18, i8* %15
%20 = load i8, i8* %19
%21 = icmp eq i8 %20, 0
br i1 %21, label %30, label %22
22: ; preds = %14, %22
%23 = phi i8 [ %28, %22 ], [ %20, %14 ]
%24 = phi i8* [ %27, %22 ], [ %19, %14 ]
%25 = phi i8* [ %26, %22 ], [ %0, %14 ]
store i8 %23, i8* %25
%26 = getelementptr inbounds i8, i8* %25, i64 1
%27 = getelementptr inbounds i8, i8* %24, i64 1
%28 = load i8, i8* %27
%29 = icmp eq i8 %28, 0
br i1 %29, label %30, label %22
30: ; preds = %22, %14
%31 = phi i8* [ %0, %14 ], [ %26, %22 ]
%32 = phi i8* [ %19, %14 ], [ %27, %22 ]
store i8 46, i8* %31
%33 = getelementptr inbounds i8, i8* %31, i64 1
%34 = icmp ult i8* %33, %32
br i1 %34, label %35, label %36
35: ; preds = %30
store i8 48, i8* %33
br label %36
36: ; preds = %6, %6, %6, %11, %35, %30
ret void
}