// File: /workspace/github_cpp_makefile_star2_O2/cqbqdd11519[P]DockerClient/rapidjson/include/rapidjson/internal/dtoa.h
// Function: rapidjson::internal::Prettify(char*, int, int, int)
inline char* Prettify(char* buffer, int length, int k, int maxDecimalPlaces) {
    const int kk = length + k;  // 10^(kk-1) <= v < 10^kk

    if (0 <= k && kk <= 21) {
        // 1234e7 -> 12340000000
        for (int i = length; i < kk; i++)
            buffer[i] = '0';
        buffer[kk] = '.';
        buffer[kk + 1] = '0';
        return &buffer[kk + 2];
    }
    else if (0 < kk && kk <= 21) {
        // 1234e-2 -> 12.34
        std::memmove(&buffer[kk + 1], &buffer[kk], static_cast<size_t>(length - kk));
        buffer[kk] = '.';
        if (0 > k + maxDecimalPlaces) {
            // When maxDecimalPlaces = 2, 1.2345 -> 1.23, 1.102 -> 1.1
            // Remove extra trailing zeros (at least one) after truncation.
            for (int i = kk + maxDecimalPlaces; i > kk + 1; i--)
                if (buffer[i] != '0')
                    return &buffer[i + 1];
            return &buffer[kk + 2]; // Reserve one zero
        }
        else
            return &buffer[length + 1];
    }
    else if (-6 < kk && kk <= 0) {
        // 1234e-6 -> 0.001234
        const int offset = 2 - kk;
        std::memmove(&buffer[offset], &buffer[0], static_cast<size_t>(length));
        buffer[0] = '0';
        buffer[1] = '.';
        for (int i = 2; i < offset; i++)
            buffer[i] = '0';
        if (length - kk > maxDecimalPlaces) {
            // When maxDecimalPlaces = 2, 0.123 -> 0.12, 0.102 -> 0.1
            // Remove extra trailing zeros (at least one) after truncation.
            for (int i = maxDecimalPlaces + 1; i > 2; i--)
                if (buffer[i] != '0')
                    return &buffer[i + 1];
            return &buffer[3]; // Reserve one zero
        }
        else
            return &buffer[length + offset];
    }
    else if (kk < -maxDecimalPlaces) {
        // Truncate to zero
        buffer[0] = '0';
        buffer[1] = '.';
        buffer[2] = '0';
        return &buffer[3];
    }
    else if (length == 1) {
        // 1e30
        buffer[1] = 'e';
        return WriteExponent(kk - 1, &buffer[2]);
    }
    else {
        // 1234e30 -> 1.234e33
        std::memmove(&buffer[2], &buffer[1], static_cast<size_t>(length - 1));
        buffer[1] = '.';
        buffer[length + 1] = 'e';
        return WriteExponent(kk - 1, &buffer[0 + length + 2]);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %ecx, %r15d
movl %edx, %r12d
movl %esi, %r14d
movq %rdi, %rbx
leal (%r12,%r14), %r13d
testl %edx, %edx
setns %al
cmpl $0x16, %r13d
setl %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0xd346
movslq %r14d, %rcx
movslq %r13d, %rax
cmpq %rax, %rcx
jge 0xd334
movb $0x30, (%rbx,%rcx)
incq %rcx
jmp 0xd326
addq %rax, %rbx
addq $0x2, %rbx
movw $0x302e, -0x2(%rbx)     # imm = 0x302E
jmp 0xd465
leal -0x1(%r13), %edi
cmpl $0x14, %edi
ja 0xd390
movl %r13d, %esi
leaq (%rbx,%rsi), %rdi
incq %rdi
movq %rdi, -0x30(%rbp)
addq %rbx, %rsi
movl %r12d, %eax
negl %eax
movslq %eax, %rdx
movq %rsi, -0x38(%rbp)
callq 0x9b00
movq -0x30(%rbp), %rax
movb $0x2e, -0x1(%rax)
addl %r15d, %r12d
js 0xd414
movslq %r14d, %rax
addq %rax, %rbx
incq %rbx
jmp 0xd465
movq %r14, -0x30(%rbp)
leal 0x5(%r13), %eax
cmpl $0x5, %eax
ja 0xd3fd
pushq $0x2
popq %r14
subl %r13d, %r14d
leaq (%rbx,%r14), %rdi
movslq -0x30(%rbp), %rdx
movq %rbx, %rsi
callq 0x9b00
movw $0x2e30, (%rbx)         # imm = 0x2E30
pushq $0x2
popq %rax
cmpq %r14, %rax
jae 0xd3ca
movb $0x30, (%rbx,%rax)
incq %rax
jmp 0xd3bc
negl %r12d
cmpl %r15d, %r12d
jle 0xd433
incl %r15d
movl %r15d, %eax
cmpl $0x3, %r15d
jl 0xd3f0
movl %eax, %ecx
leal -0x1(%rax), %r15d
cmpb $0x30, (%rbx,%rcx)
je 0xd3d5
addq %rbx, %rcx
incq %rcx
addq $0x3, %rbx
cmpl $0x3, %eax
cmovgeq %rcx, %rbx
jmp 0xd465
negl %r15d
cmpl %r15d, %r13d
jge 0xd43f
movw $0x2e30, (%rbx)         # imm = 0x2E30
movb $0x30, 0x2(%rbx)
addq $0x3, %rbx
jmp 0xd465
leal 0x1(%r13), %eax
addl %r13d, %r15d
movslq %r15d, %rcx
movq -0x38(%rbp), %rsi
cmpl %eax, %ecx
jle 0xd456
movl %ecx, %edx
cmpb $0x30, (%rbx,%rdx)
jne 0xd45f
decq %rcx
jmp 0xd422
addl -0x30(%rbp), %r14d
movslq %r14d, %rax
addq %rax, %rbx
jmp 0xd465
movq -0x30(%rbp), %r14
cmpl $0x1, %r14d
jne 0xd477
movb $0x65, 0x1(%rbx)
addq $0x2, %rbx
movq %rbx, %rsi
jmp 0xd4a4
addq $0x2, %rsi
movq %rsi, %rbx
jmp 0xd465
addq %rcx, %rbx
incq %rbx
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %edi, %r15d
leaq 0x2(%rbx), %rdi
leaq 0x1(%rbx), %rsi
leal -0x1(%r14), %eax
movslq %eax, %rdx
callq 0x9b00
movb $0x2e, 0x1(%rbx)
movslq %r14d, %rax
leaq (%rbx,%rax), %rsi
addq $0x2, %rsi
movb $0x65, -0x1(%rsi)
movl %r15d, %edi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x9d10
nop