#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 _qtoa(char *, int, long double, int /*<<< orphan*/);
char *qecvt_mp(long double arg, int ndigits, int *decpt, int *sign,
               char *buffer) {
  if (ndigits > 34) {
    register char *p, *e;
    *decpt = _qtoa(buffer, 34, arg, 0) + 1;
    for (p = buffer + 35, e = buffer + 1 + (ndigits > 82 ? 82 : ndigits);
         p != e;)
      *p++ = '0';
    *p++ = '\0';
  } else if (ndigits <= 0) {
    *decpt = _qtoa(buffer, 1, arg, 0) + 1;
    buffer[1] = '\0';
  } else {
    *decpt = _qtoa(buffer, ndigits, arg, 0) + 1;
  }
  *sign = buffer[0] == '-';
  return buffer + 1;
}


x86 assembly (clang, -O0):
<qecvt_mp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
fldt   0x10(%rbp)
fstpt  -0x10(%rbp)
mov    %edi,-0x14(%rbp)
mov    %rsi,-0x20(%rbp)
mov    %rdx,-0x28(%rbp)
mov    %rcx,-0x30(%rbp)
cmpl   $0x22,-0x14(%rbp)
jle    11dc <qecvt_mp+0xcc>
mov    -0x30(%rbp),%rdi
fldt   -0x10(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
mov    $0x22,%esi
xor    %edx,%edx
call   1030 <_qtoa@plt>
mov    %eax,%ecx
add    $0x1,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x30(%rbp),%rax
add    $0x23,%rax
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x48(%rbp)
cmpl   $0x52,-0x14(%rbp)
jle    1189 <qecvt_mp+0x79>
mov    $0x52,%eax
mov    %eax,-0x4c(%rbp)
jmp    118f <qecvt_mp+0x7f>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x48(%rbp),%rax
mov    -0x4c(%rbp),%ecx
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x40(%rbp)
mov    -0x38(%rbp),%rax
cmp    -0x40(%rbp),%rax
je     11c5 <qecvt_mp+0xb5>
mov    -0x38(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x38(%rbp)
movb   $0x30,(%rax)
jmp    11a0 <qecvt_mp+0x90>
mov    -0x38(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x38(%rbp)
movb   $0x0,(%rax)
jmp    123c <qecvt_mp+0x12c>
cmpl   $0x0,-0x14(%rbp)
jg     1216 <qecvt_mp+0x106>
mov    -0x30(%rbp),%rdi
fldt   -0x10(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
mov    $0x1,%esi
xor    %edx,%edx
call   1030 <_qtoa@plt>
mov    %eax,%ecx
add    $0x1,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x30(%rbp),%rax
movb   $0x0,0x1(%rax)
jmp    1237 <qecvt_mp+0x127>
mov    -0x30(%rbp),%rdi
mov    -0x14(%rbp),%esi
fldt   -0x10(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
xor    %edx,%edx
call   1030 <_qtoa@plt>
mov    %eax,%ecx
add    $0x1,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
jmp    123c <qecvt_mp+0x12c>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
sete   %al
and    $0x1,%al
movzbl %al,%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x30(%rbp),%rax
add    $0x1,%rax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<qecvt_mp>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rcx,%rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %edi,%r12d
fldt   0x40(%rsp)
cmp    $0x23,%edi
jl     117f <qecvt_mp+0x5f>
fstpt  (%rsp)
mov    %rbx,%rdi
mov    $0x22,%esi
xor    %edx,%edx
call   1040 <_qtoa@plt>
add    $0x1,%eax
mov    %eax,(%r15)
lea    0x23(%rbx),%rdi
cmp    $0x52,%r12d
mov    $0x52,%ebp
cmovb  %r12d,%ebp
lea    -0x22(%rbp),%rdx
mov    $0x30,%esi
call   1030 <memset@plt>
movb   $0x0,0x1(%rbp,%rbx,1)
jmp    11b8 <qecvt_mp+0x98>
test   %r12d,%r12d
jle    119c <qecvt_mp+0x7c>
fstpt  (%rsp)
mov    %rbx,%rdi
mov    %r12d,%esi
xor    %edx,%edx
call   1040 <_qtoa@plt>
add    $0x1,%eax
mov    %eax,(%r15)
jmp    11b8 <qecvt_mp+0x98>
fstpt  (%rsp)
mov    %rbx,%rdi
mov    $0x1,%esi
xor    %edx,%edx
call   1040 <_qtoa@plt>
add    $0x1,%eax
mov    %eax,(%r15)
movb   $0x0,0x1(%rbx)
xor    %eax,%eax
cmpb   $0x2d,(%rbx)
sete   %al
mov    %eax,(%r14)
add    $0x1,%rbx
mov    %rbx,%rax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i8* @qecvt_mp(x86_fp80 %0, i32 %1, i32* %2, i32* %3, i8* %4) {
%6 = alloca x86_fp80
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
store x86_fp80 %0, x86_fp80* %6
store i32 %1, i32* %7
store i32* %2, i32** %8
store i32* %3, i32** %9
store i8* %4, i8** %10
%13 = load i32, i32* %7
%14 = icmp sgt i32 %13, 34
br i1 %14, label %15, label %44
15: ; preds = %5
%16 = load i8*, i8** %10
%17 = load x86_fp80, x86_fp80* %6
%18 = call i32 @_qtoa(i8* %16, i32 34, x86_fp80 %17, i32 0)
%19 = add nsw i32 %18, 1
%20 = load i32*, i32** %8
store i32 %19, i32* %20
%21 = load i8*, i8** %10
%22 = getelementptr inbounds i8, i8* %21, i64 35
store i8* %22, i8** %11
%23 = load i8*, i8** %10
%24 = getelementptr inbounds i8, i8* %23, i64 1
%25 = load i32, i32* %7
%26 = icmp sgt i32 %25, 82
br i1 %26, label %27, label %28
27: ; preds = %15
br label %30
28: ; preds = %15
%29 = load i32, i32* %7
br label %30
30: ; preds = %28, %27
%31 = phi i32 [ 82, %27 ], [ %29, %28 ]
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %24, i64 %32
store i8* %33, i8** %12
br label %34
34: ; preds = %38, %30
%35 = load i8*, i8** %11
%36 = load i8*, i8** %12
%37 = icmp ne i8* %35, %36
br i1 %37, label %38, label %41
38: ; preds = %34
%39 = load i8*, i8** %11
%40 = getelementptr inbounds i8, i8* %39, i32 1
store i8* %40, i8** %11
store i8 48, i8* %39
br label %34
41: ; preds = %34
%42 = load i8*, i8** %11
%43 = getelementptr inbounds i8, i8* %42, i32 1
store i8* %43, i8** %11
store i8 0, i8* %42
br label %63
44: ; preds = %5
%45 = load i32, i32* %7
%46 = icmp sle i32 %45, 0
br i1 %46, label %47, label %55
47: ; preds = %44
%48 = load i8*, i8** %10
%49 = load x86_fp80, x86_fp80* %6
%50 = call i32 @_qtoa(i8* %48, i32 1, x86_fp80 %49, i32 0)
%51 = add nsw i32 %50, 1
%52 = load i32*, i32** %8
store i32 %51, i32* %52
%53 = load i8*, i8** %10
%54 = getelementptr inbounds i8, i8* %53, i64 1
store i8 0, i8* %54
br label %62
55: ; preds = %44
%56 = load i8*, i8** %10
%57 = load i32, i32* %7
%58 = load x86_fp80, x86_fp80* %6
%59 = call i32 @_qtoa(i8* %56, i32 %57, x86_fp80 %58, i32 0)
%60 = add nsw i32 %59, 1
%61 = load i32*, i32** %8
store i32 %60, i32* %61
br label %62
62: ; preds = %55, %47
br label %63
63: ; preds = %62, %41
%64 = load i8*, i8** %10
%65 = getelementptr inbounds i8, i8* %64, i64 0
%66 = load i8, i8* %65
%67 = sext i8 %66 to i32
%68 = icmp eq i32 %67, 45
%69 = zext i1 %68 to i32
%70 = load i32*, i32** %9
store i32 %69, i32* %70
%71 = load i8*, i8** %10
%72 = getelementptr inbounds i8, i8* %71, i64 1
ret i8* %72
}

LLVM IR (-O2):
define i8* @qecvt_mp(x86_fp80 %0, i32 %1, i32* nocapture writeonly %2, i32* nocapture writeonly %3, i8* %4) {
%6 = icmp sgt i32 %1, 34
br i1 %6, label %7, label %17
7: ; preds = %5
%8 = tail call i32 @_qtoa(i8* %4, i32 34, x86_fp80 %0, i32 0)
%9 = add nsw i32 %8, 1
store i32 %9, i32* %2
%10 = getelementptr i8, i8* %4, i64 35
%11 = icmp ult i32 %1, 82
%12 = select i1 %11, i32 %1, i32 82
%13 = add nuw nsw i32 %12, 1
%14 = zext i32 %13 to i64
%15 = getelementptr i8, i8* %4, i64 %14
%16 = add nsw i64 %14, -35
store i8 0, i8* %15
br label %26
17: ; preds = %5
%18 = icmp slt i32 %1, 1
br i1 %18, label %19, label %23
19: ; preds = %17
%20 = tail call i32 @_qtoa(i8* %4, i32 1, x86_fp80 %0, i32 0)
%21 = add nsw i32 %20, 1
store i32 %21, i32* %2
%22 = getelementptr inbounds i8, i8* %4, i64 1
store i8 0, i8* %22
br label %26
23: ; preds = %17
%24 = tail call i32 @_qtoa(i8* %4, i32 %1, x86_fp80 %0, i32 0)
%25 = add nsw i32 %24, 1
store i32 %25, i32* %2
br label %26
26: ; preds = %19, %23, %7
%27 = load i8, i8* %4
%28 = icmp eq i8 %27, 45
%29 = zext i1 %28 to i32
store i32 %29, i32* %3
%30 = getelementptr inbounds i8, i8* %4, i64 1
ret i8* %30
}