#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 */
double fabs(double);
scalar_t__ floor(double);
int /*<<< orphan*/ getChar(char);
void convertLessThan1(char *rslt, double n, unsigned char base,
                      unsigned char cnt) {
  while (cnt--) {
    if (fabs(n) < 0.0001)
      break;
    n *= base;
    *rslt++ = getChar((char)(int)floor(n));
    n -= floor(n);
  }
  *rslt = '\0';
}


x86 assembly (clang, -O0):
<convertLessThan1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dl,%al
mov    %sil,%cl
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
mov    %cl,-0x11(%rbp)
mov    %al,-0x12(%rbp)
mov    -0x12(%rbp),%al
mov    %al,%cl
add    $0xff,%cl
mov    %cl,-0x12(%rbp)
cmp    $0x0,%al
je     11cf <convertLessThan1+0xaf>
movsd  -0x10(%rbp),%xmm1
movaps 0xeb5(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xe99(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1176 <convertLessThan1+0x56>
jmp    11cf <convertLessThan1+0xaf>
movzbl -0x11(%rbp),%eax
cvtsi2sd %eax,%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1040 <floor@plt>
movsbl %al,%edi
call   1030 <getChar@plt>
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x8(%rbp)
mov    %cl,(%rax)
movsd  -0x10(%rbp),%xmm0
call   1040 <floor@plt>
cvtsi2sd %rax,%xmm1
movsd  -0x10(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    113c <convertLessThan1+0x1c>
mov    -0x8(%rbp),%rax
movb   $0x0,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<convertLessThan1>:
push   %rbp
push   %rbx
sub    $0x28,%rsp
mov    %rdi,%rbx
test   %edx,%edx
je     11cf <convertLessThan1+0xaf>
movapd 0xec7(%rip),%xmm1
andpd  %xmm0,%xmm1
movsd  0xecb(%rip),%xmm2
ucomisd %xmm1,%xmm2
ja     11cf <convertLessThan1+0xaf>
mov    %edx,%ebp
movzbl %sil,%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
movsd  %xmm1,0x8(%rsp)
add    $0xff,%bpl
cs nopw 0x0(%rax,%rax,1)
mulsd  0x8(%rsp),%xmm0
movapd %xmm0,0x10(%rsp)
call   1040 <floor@plt>
movsbl %al,%edi
call   1030 <getChar@plt>
mov    %al,(%rbx)
add    $0x1,%rbx
movaps 0x10(%rsp),%xmm0
call   1040 <floor@plt>
sub    $0x1,%bpl
jb     11cf <convertLessThan1+0xaf>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movapd 0x10(%rsp),%xmm2
subsd  %xmm0,%xmm2
movapd %xmm2,%xmm0
andpd  0xe43(%rip),%xmm0
movsd  0xe4b(%rip),%xmm1
ucomisd %xmm0,%xmm1
movapd %xmm2,%xmm0
jbe    1170 <convertLessThan1+0x50>
movb   $0x0,(%rbx)
add    $0x28,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define void @convertLessThan1(i8* %0, double %1, i8 zeroext %2, i8 zeroext %3) {
%5 = alloca i8*
%6 = alloca double
%7 = alloca i8
%8 = alloca i8
store i8* %0, i8** %5
store double %1, double* %6
store i8 %2, i8* %7
store i8 %3, i8* %8
br label %9
9: ; preds = %18, %4
%10 = load i8, i8* %8
%11 = add i8 %10, -1
store i8 %11, i8* %8
%12 = icmp ne i8 %10, 0
br i1 %12, label %13, label %37
13: ; preds = %9
%14 = load double, double* %6
%15 = call double @llvm.fabs.f64(double %14)
%16 = fcmp olt double %15, 1.000000e-04
br i1 %16, label %17, label %18
17: ; preds = %13
br label %37
18: ; preds = %13
%19 = load i8, i8* %7
%20 = zext i8 %19 to i32
%21 = sitofp i32 %20 to double
%22 = load double, double* %6
%23 = fmul double %22, %21
store double %23, double* %6
%24 = load double, double* %6
%25 = call i64 @floor(double %24)
%26 = trunc i64 %25 to i32
%27 = trunc i32 %26 to i8
%28 = call i32 @getChar(i8 signext %27)
%29 = trunc i32 %28 to i8
%30 = load i8*, i8** %5
%31 = getelementptr inbounds i8, i8* %30, i32 1
store i8* %31, i8** %5
store i8 %29, i8* %30
%32 = load double, double* %6
%33 = call i64 @floor(double %32)
%34 = sitofp i64 %33 to double
%35 = load double, double* %6
%36 = fsub double %35, %34
store double %36, double* %6
br label %9
37: ; preds = %17, %9
%38 = load i8*, i8** %5
store i8 0, i8* %38
ret void
}

LLVM IR (-O2):
define void @convertLessThan1(i8* nocapture writeonly %0, double %1, i8 zeroext %2, i8 zeroext %3) {
%5 = icmp eq i8 %3, 0
%6 = tail call double @llvm.fabs.f64(double %1)
%7 = fcmp olt double %6, 1.000000e-04
%8 = select i1 %5, i1 true, i1 %7
br i1 %8, label %29, label %9
9: ; preds = %4
%10 = uitofp i8 %2 to double
br label %11
11: ; preds = %9, %11
%12 = phi i8 [ %3, %9 ], [ %15, %11 ]
%13 = phi i8* [ %0, %9 ], [ %21, %11 ]
%14 = phi double [ %1, %9 ], [ %24, %11 ]
%15 = add i8 %12, -1
%16 = fmul double %14, %10
%17 = tail call i64 @floor(double %16)
%18 = trunc i64 %17 to i8
%19 = tail call i32 @getChar(i8 signext %18)
%20 = trunc i32 %19 to i8
%21 = getelementptr inbounds i8, i8* %13, i64 1
store i8 %20, i8* %13
%22 = tail call i64 @floor(double %16)
%23 = sitofp i64 %22 to double
%24 = fsub double %16, %23
%25 = icmp eq i8 %15, 0
%26 = tail call double @llvm.fabs.f64(double %24)
%27 = fcmp olt double %26, 1.000000e-04
%28 = select i1 %25, i1 true, i1 %27
br i1 %28, label %29, label %11
29: ; preds = %11, %4
%30 = phi i8* [ %0, %4 ], [ %21, %11 ]
store i8 0, i8* %30
ret void
}