#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*/ convert(char *, unsigned long, unsigned char);
int /*<<< orphan*/ convertLessThan1(char *, double, unsigned char,
                                    unsigned char);
double modf(double, double *);
int /*<<< orphan*/ strlen(char *);
void convertReal(char *rslt, double n, unsigned char base, unsigned char cnt) {
  double integer, fraction;
  if (n < 0) {
    *rslt++ = '-';
    n = -n;
  }
  fraction = modf(n, &integer);
  convert(rslt, (unsigned long)integer, base);
  if ('\0' == *rslt)
    *rslt++ = '0';
  else
    rslt += strlen(rslt);
  *rslt++ = '.';
  convertLessThan1(rslt, fraction, base, cnt);
  if ('\0' == *rslt) {
    *rslt++ = '0';
    *rslt = '\0';
  }
}


x86 assembly (clang, -O0):
<convertReal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %dl,%al
mov    %sil,%cl
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
mov    %cl,-0x11(%rbp)
mov    %al,-0x12(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    119d <convertReal+0x5d>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%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
lea    -0x20(%rbp),%rdi
call   1050 <modf@plt>
movsd  %xmm0,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
movsd  -0x20(%rbp),%xmm0
movsd  0xe3f(%rip),%xmm2
movaps %xmm0,%xmm1
subsd  %xmm2,%xmm1
cvttsd2si %xmm1,%rax
cvttsd2si %xmm0,%rsi
mov    %rsi,%rcx
sar    $0x3f,%rcx
and    %rcx,%rax
or     %rax,%rsi
movzbl -0x11(%rbp),%edx
call   1030 <convert@plt>
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    %ecx,%eax
jne    1210 <convertReal+0xd0>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movb   $0x30,(%rax)
jmp    1229 <convertReal+0xe9>
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movb   $0x2e,(%rax)
mov    -0x8(%rbp),%rdi
movsd  -0x28(%rbp),%xmm0
mov    -0x11(%rbp),%al
movzbl %al,%esi
movzbl -0x12(%rbp),%edx
call   1060 <convertLessThan1@plt>
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    %ecx,%eax
jne    127d <convertReal+0x13d>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movb   $0x30,(%rax)
mov    -0x8(%rbp),%rax
movb   $0x0,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<convertReal>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %edx,%r14d
mov    %esi,%ebp
mov    %rdi,%rbx
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
jbe    1169 <convertReal+0x29>
movb   $0x2d,(%rbx)
add    $0x1,%rbx
xorpd  0xe97(%rip),%xmm0
lea    0x8(%rsp),%rdi
call   1050 <modf@plt>
movsd  0x8(%rsp),%xmm1
cvttsd2si %xmm1,%rax
movsd  %xmm0,(%rsp)
mov    %rax,%rcx
sar    $0x3f,%rcx
subsd  0xe7e(%rip),%xmm1
cvttsd2si %xmm1,%rsi
and    %rcx,%rsi
or     %rax,%rsi
movzbl %bpl,%ebp
mov    %rbx,%rdi
mov    %ebp,%edx
call   1030 <convert@plt>
cmpb   $0x0,(%rbx)
je     11bf <convertReal+0x7f>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
add    %rax,%rbx
jmp    11c6 <convertReal+0x86>
movb   $0x30,(%rbx)
add    $0x1,%rbx
lea    0x1(%rbx),%rdi
movb   $0x2e,(%rbx)
movzbl %r14b,%edx
movsd  (%rsp),%xmm0
mov    %ebp,%esi
call   1060 <convertLessThan1@plt>
cmpb   $0x0,0x1(%rbx)
jne    11e9 <convertReal+0xa9>
movw   $0x30,0x1(%rbx)
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @convertReal(i8* %0, double %1, i8 zeroext %2, i8 zeroext %3) {
%5 = alloca i8*
%6 = alloca double
%7 = alloca i8
%8 = alloca i8
%9 = alloca double
%10 = alloca double
store i8* %0, i8** %5
store double %1, double* %6
store i8 %2, i8* %7
store i8 %3, i8* %8
%11 = load double, double* %6
%12 = fcmp olt double %11, 0.000000e+00
br i1 %12, label %13, label %18
13: ; preds = %4
%14 = load i8*, i8** %5
%15 = getelementptr inbounds i8, i8* %14, i32 1
store i8* %15, i8** %5
store i8 45, i8* %14
%16 = load double, double* %6
%17 = fneg double %16
store double %17, double* %6
br label %18
18: ; preds = %13, %4
%19 = load double, double* %6
%20 = call double @modf(double %19, double* %9)
store double %20, double* %10
%21 = load i8*, i8** %5
%22 = load double, double* %9
%23 = fptoui double %22 to i64
%24 = load i8, i8* %7
%25 = call i32 @convert(i8* %21, i64 %23, i8 zeroext %24)
%26 = load i8*, i8** %5
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp eq i32 0, %28
br i1 %29, label %30, label %33
30: ; preds = %18
%31 = load i8*, i8** %5
%32 = getelementptr inbounds i8, i8* %31, i32 1
store i8* %32, i8** %5
store i8 48, i8* %31
br label %39
33: ; preds = %18
%34 = load i8*, i8** %5
%35 = call i32 @strlen(i8* %34)
%36 = load i8*, i8** %5
%37 = sext i32 %35 to i64
%38 = getelementptr inbounds i8, i8* %36, i64 %37
store i8* %38, i8** %5
br label %39
39: ; preds = %33, %30
%40 = load i8*, i8** %5
%41 = getelementptr inbounds i8, i8* %40, i32 1
store i8* %41, i8** %5
store i8 46, i8* %40
%42 = load i8*, i8** %5
%43 = load double, double* %10
%44 = load i8, i8* %7
%45 = load i8, i8* %8
%46 = call i32 @convertLessThan1(i8* %42, double %43, i8 zeroext %44, i8 zeroext %45)
%47 = load i8*, i8** %5
%48 = load i8, i8* %47
%49 = sext i8 %48 to i32
%50 = icmp eq i32 0, %49
br i1 %50, label %51, label %55
51: ; preds = %39
%52 = load i8*, i8** %5
%53 = getelementptr inbounds i8, i8* %52, i32 1
store i8* %53, i8** %5
store i8 48, i8* %52
%54 = load i8*, i8** %5
store i8 0, i8* %54
br label %55
55: ; preds = %51, %39
ret void
}

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