// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/kstring.c
// Function: kputd
int kputd(double d, kstring_t *s) {
	int len = 0;
	char buf[21], *cp = buf+20, *ep;
	if (d == 0) {
		if (signbit(d)) {
			kputsn("-0",2,s);
			return 2;
		} else {
			kputsn("0",1,s);
			return 1;
		}
	}

	if (d < 0) {
		kputc('-',s);
		len = 1;
		d=-d;
	}
	if (!(d >= 0.0001 && d <= 999999)) {
		if (ks_resize(s, s->l + 50) < 0)
			return EOF;
		// We let stdio handle the exponent cases
		int s2 = snprintf(s->s + s->l, s->m - s->l, "%g", d);
		len += s2;
		s->l += s2;
		return len;
	}

	// Correction for rounding - rather ugly
	// Optimised for small numbers.

	uint32_t i;
	if (d<0.001)         i = rint(d*1000000000), cp -= 1;
	else if (d < 0.01)   i = rint(d*100000000),  cp -= 2;
	else if (d < 0.1)    i = rint(d*10000000),   cp -= 3;
	else if (d < 1)      i = rint(d*1000000),    cp -= 4;
	else if (d < 10)     i = rint(d*100000),     cp -= 5;
	else if (d < 100)    i = rint(d*10000),      cp -= 6;
	else if (d < 1000)   i = rint(d*1000),       cp -= 7;
	else if (d < 10000)  i = rint(d*100),        cp -= 8;
	else if (d < 100000) i = rint(d*10),         cp -= 9;
	else                 i = rint(d),            cp -= 10;

	// integer i is always 6 digits, so print it 2 at a time.
	static const char kputuw_dig2r[] =
		"00010203040506070809"
		"10111213141516171819"
		"20212223242526272829"
		"30313233343536373839"
		"40414243444546474849"
		"50515253545556575859"
		"60616263646566676869"
		"70717273747576777879"
		"80818283848586878889"
		"90919293949596979899";

	memcpy(cp-=2, &kputuw_dig2r[2*(i%100)], 2); i /= 100;
	memcpy(cp-=2, &kputuw_dig2r[2*(i%100)], 2); i /= 100;
	memcpy(cp-=2, &kputuw_dig2r[2*(i%100)], 2);

	// Except when it rounds up (d=0.009999999 is i=1000000)
	if (i >= 100)
		*--cp = '0' + (i/100);


	int p = buf+20-cp;
	if (p <= 10) { /* d < 1 */
		// 0.00123 is 123, so add leading zeros and 0.
		ep = cp+5; // 6 precision
		while (p < 10) { // aka d < 1
			*--cp = '0';
			p++;
		}
		*--cp = '.';
		*--cp = '0';
	} else {
		// 123.001 is 123001 with p==13, so move 123 down and add "."
		// Equiv to memmove(cp-1, cp, p-10); cp--;
		char *xp = --cp;
		ep = cp+6;
		while (p > 10) {
			xp[0] = xp[1];
			xp++;
			p--;
		}
		xp[0] = '.';
	}

	// Cull trailing zeros
	while (*ep == '0' && ep > cp)
		ep--;

	// End can be 1 out due to the mostly-6 but occasionally 7 (i==1) case.
	// Also code with "123." which should be "123"
	if (*ep && *ep != '.')
		ep++;
	*ep = 0;

	int sl = ep-cp;
	len += sl;
	kputsn(cp, sl, s);
	return len;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movsd %xmm0, -0x10(%rbp)
movq %rdi, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
leaq -0x40(%rbp), %rax
addq $0x14, %rax
movq %rax, -0x48(%rbp)
movsd -0x10(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0xa6d9
jp 0xa6d9
movsd -0x10(%rbp), %xmm0
movq %xmm0, %rax
cmpq $0x0, %rax
jge 0xa6b8
movq -0x18(%rbp), %rdx
leaq 0xe437e(%rip), %rdi     # 0xeea20
movl $0x2, %esi
callq 0xac60
movl $0x2, -0x4(%rbp)
jmp 0xac4f
movq -0x18(%rbp), %rdx
leaq 0xe6489(%rip), %rdi     # 0xf0b4c
movl $0x1, %esi
callq 0xac60
movl $0x1, -0x4(%rbp)
jmp 0xac4f
xorps %xmm0, %xmm0
ucomisd -0x10(%rbp), %xmm0
jbe 0xa719
movq -0x18(%rbp), %rsi
movl $0x2d, %edi
callq 0xad10
movl $0x1, -0x1c(%rbp)
movsd -0x10(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd %xmm0, -0x10(%rbp)
movsd -0x10(%rbp), %xmm0
movsd 0xe428a(%rip), %xmm1    # 0xee9b0
ucomisd %xmm1, %xmm0
jb 0xa73b
movsd 0xe4284(%rip), %xmm0    # 0xee9b8
ucomisd -0x10(%rbp), %xmm0
jae 0xa7b6
movq -0x18(%rbp), %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rsi
addq $0x32, %rsi
callq 0xad90
cmpl $0x0, %eax
jge 0xa760
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xac4f
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x18(%rbp), %rax
addq (%rax), %rdi
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rsi
movq -0x18(%rbp), %rax
subq (%rax), %rsi
movsd -0x10(%rbp), %xmm0
leaq 0xe8584(%rip), %rdx     # 0xf2d0e
movb $0x1, %al
callq 0x47e0
movl %eax, -0x54(%rbp)
movl -0x54(%rbp), %eax
addl -0x1c(%rbp), %eax
movl %eax, -0x1c(%rbp)
movslq -0x54(%rbp), %rcx
movq -0x18(%rbp), %rax
addq (%rax), %rcx
movq %rcx, (%rax)
movl -0x1c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0xac4f
movsd 0xe4202(%rip), %xmm0    # 0xee9c0
ucomisd -0x10(%rbp), %xmm0
jbe 0xa7f4
movsd -0x10(%rbp), %xmm0
movsd 0xe4246(%rip), %xmm1    # 0xeea18
mulsd %xmm1, %xmm0
callq 0x46c0
cvttsd2si %xmm0, %rax
movl %eax, -0x58(%rbp)
movq -0x48(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x48(%rbp)
jmp 0xaa0c
movsd 0xe41cc(%rip), %xmm0    # 0xee9c8
ucomisd -0x10(%rbp), %xmm0
jbe 0xa832
movsd -0x10(%rbp), %xmm0
movsd 0xe4200(%rip), %xmm1    # 0xeea10
mulsd %xmm1, %xmm0
callq 0x46c0
cvttsd2si %xmm0, %rax
movl %eax, -0x58(%rbp)
movq -0x48(%rbp), %rax
addq $-0x2, %rax
movq %rax, -0x48(%rbp)
jmp 0xaa0a
movsd 0xe4196(%rip), %xmm0    # 0xee9d0
ucomisd -0x10(%rbp), %xmm0
jbe 0xa870
movsd -0x10(%rbp), %xmm0
movsd 0xe41ba(%rip), %xmm1    # 0xeea08
mulsd %xmm1, %xmm0
callq 0x46c0
cvttsd2si %xmm0, %rax
movl %eax, -0x58(%rbp)
movq -0x48(%rbp), %rax
addq $-0x3, %rax
movq %rax, -0x48(%rbp)
jmp 0xaa08
movsd 0xe2790(%rip), %xmm0    # 0xed008
ucomisd -0x10(%rbp), %xmm0
jbe 0xa8ae
movsd -0x10(%rbp), %xmm0
movsd 0xe4174(%rip), %xmm1    # 0xeea00
mulsd %xmm1, %xmm0
callq 0x46c0
cvttsd2si %xmm0, %rax
movl %eax, -0x58(%rbp)
movq -0x48(%rbp), %rax
addq $-0x4, %rax
movq %rax, -0x48(%rbp)
jmp 0xaa06
movsd 0xe4122(%rip), %xmm0    # 0xee9d8
ucomisd -0x10(%rbp), %xmm0
jbe 0xa8ec
movsd -0x10(%rbp), %xmm0
movsd 0xe412e(%rip), %xmm1    # 0xee9f8
mulsd %xmm1, %xmm0
callq 0x46c0
cvttsd2si %xmm0, %rax
movl %eax, -0x58(%rbp)
movq -0x48(%rbp), %rax
addq $-0x5, %rax
movq %rax, -0x48(%rbp)
jmp 0xaa04
movsd 0xe40ec(%rip), %xmm0    # 0xee9e0
ucomisd -0x10(%rbp), %xmm0
jbe 0xa92a
movsd -0x10(%rbp), %xmm0
movsd 0xe40e8(%rip), %xmm1    # 0xee9f0
mulsd %xmm1, %xmm0
callq 0x46c0
cvttsd2si %xmm0, %rax
movl %eax, -0x58(%rbp)
movq -0x48(%rbp), %rax
addq $-0x6, %rax
movq %rax, -0x48(%rbp)
jmp 0xaa02
movsd 0xe40b6(%rip), %xmm0    # 0xee9e8
ucomisd -0x10(%rbp), %xmm0
jbe 0xa968
movsd -0x10(%rbp), %xmm0
movsd 0xe40a2(%rip), %xmm1    # 0xee9e8
mulsd %xmm1, %xmm0
callq 0x46c0
cvttsd2si %xmm0, %rax
movl %eax, -0x58(%rbp)
movq -0x48(%rbp), %rax
addq $-0x7, %rax
movq %rax, -0x48(%rbp)
jmp 0xaa00
movsd 0xe4080(%rip), %xmm0    # 0xee9f0
ucomisd -0x10(%rbp), %xmm0
jbe 0xa9a3
movsd -0x10(%rbp), %xmm0
movsd 0xe405c(%rip), %xmm1    # 0xee9e0
mulsd %xmm1, %xmm0
callq 0x46c0
cvttsd2si %xmm0, %rax
movl %eax, -0x58(%rbp)
movq -0x48(%rbp), %rax
addq $-0x8, %rax
movq %rax, -0x48(%rbp)
jmp 0xa9fe
movsd 0xe404d(%rip), %xmm0    # 0xee9f8
ucomisd -0x10(%rbp), %xmm0
jbe 0xa9de
movsd -0x10(%rbp), %xmm0
movsd 0xe4019(%rip), %xmm1    # 0xee9d8
mulsd %xmm1, %xmm0
callq 0x46c0
cvttsd2si %xmm0, %rax
movl %eax, -0x58(%rbp)
movq -0x48(%rbp), %rax
addq $-0x9, %rax
movq %rax, -0x48(%rbp)
jmp 0xa9fc
movsd -0x10(%rbp), %xmm0
callq 0x46c0
cvttsd2si %xmm0, %rax
movl %eax, -0x58(%rbp)
movq -0x48(%rbp), %rax
addq $-0xa, %rax
movq %rax, -0x48(%rbp)
jmp 0xa9fe
jmp 0xaa00
jmp 0xaa02
jmp 0xaa04
jmp 0xaa06
jmp 0xaa08
jmp 0xaa0a
jmp 0xaa0c
movq -0x48(%rbp), %rax
movq %rax, -0x88(%rbp)
addq $-0x2, %rax
movq %rax, -0x48(%rbp)
movl -0x58(%rbp), %eax
movl $0x64, %ecx
xorl %edx, %edx
divl %ecx
movq -0x88(%rbp), %rax
shll %edx
movl %edx, %ecx
movl %ecx, %edx
leaq 0xe3ff1(%rip), %rcx     # 0xeea30
movw (%rcx,%rdx), %cx
movw %cx, -0x2(%rax)
movl -0x58(%rbp), %eax
movl $0x64, %ecx
xorl %edx, %edx
divl %ecx
movl %eax, -0x58(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x80(%rbp)
addq $-0x2, %rax
movq %rax, -0x48(%rbp)
movl -0x58(%rbp), %eax
movl $0x64, %ecx
xorl %edx, %edx
divl %ecx
movq -0x80(%rbp), %rax
shll %edx
movl %edx, %ecx
movl %ecx, %edx
leaq 0xe3fad(%rip), %rcx     # 0xeea30
movw (%rcx,%rdx), %cx
movw %cx, -0x2(%rax)
movl -0x58(%rbp), %eax
movl $0x64, %ecx
xorl %edx, %edx
divl %ecx
movl %eax, -0x58(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x78(%rbp)
addq $-0x2, %rax
movq %rax, -0x48(%rbp)
movl -0x58(%rbp), %eax
movl $0x64, %ecx
xorl %edx, %edx
divl %ecx
movq -0x78(%rbp), %rax
shll %edx
movl %edx, %ecx
movl %ecx, %edx
leaq 0xe3f69(%rip), %rcx     # 0xeea30
movw (%rcx,%rdx), %cx
movw %cx, -0x2(%rax)
cmpl $0x64, -0x58(%rbp)
jb 0xaaf8
movl -0x58(%rbp), %eax
movl $0x64, %ecx
xorl %edx, %edx
divl %ecx
addl $0x30, %eax
movb %al, %cl
movq -0x48(%rbp), %rax
movq %rax, %rdx
addq $-0x1, %rdx
movq %rdx, -0x48(%rbp)
movb %cl, -0x1(%rax)
leaq -0x40(%rbp), %rax
addq $0x14, %rax
movq -0x48(%rbp), %rcx
subq %rcx, %rax
movl %eax, -0x5c(%rbp)
cmpl $0xa, -0x5c(%rbp)
jg 0xab68
movq -0x48(%rbp), %rax
addq $0x5, %rax
movq %rax, -0x50(%rbp)
cmpl $0xa, -0x5c(%rbp)
jge 0xab40
movq -0x48(%rbp), %rax
movq %rax, %rcx
addq $-0x1, %rcx
movq %rcx, -0x48(%rbp)
movb $0x30, -0x1(%rax)
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0xab1c
movq -0x48(%rbp), %rax
movq %rax, %rcx
addq $-0x1, %rcx
movq %rcx, -0x48(%rbp)
movb $0x2e, -0x1(%rax)
movq -0x48(%rbp), %rax
movq %rax, %rcx
addq $-0x1, %rcx
movq %rcx, -0x48(%rbp)
movb $0x30, -0x1(%rax)
jmp 0xabb5
movq -0x48(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x48(%rbp)
movq %rax, -0x68(%rbp)
movq -0x48(%rbp), %rax
addq $0x6, %rax
movq %rax, -0x50(%rbp)
cmpl $0xa, -0x5c(%rbp)
jle 0xabae
movq -0x68(%rbp), %rax
movb 0x1(%rax), %cl
movq -0x68(%rbp), %rax
movb %cl, (%rax)
movq -0x68(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x68(%rbp)
movl -0x5c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0xab84
movq -0x68(%rbp), %rax
movb $0x2e, (%rax)
jmp 0xabb7
movq -0x50(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x30, %ecx
movb %al, -0x89(%rbp)
jne 0xabdc
movq -0x50(%rbp), %rax
cmpq -0x48(%rbp), %rax
seta %al
movb %al, -0x89(%rbp)
movb -0x89(%rbp), %al
testb $0x1, %al
jne 0xabe8
jmp 0xabf6
movq -0x50(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x50(%rbp)
jmp 0xabb7
movq -0x50(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0xac1a
movq -0x50(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2e, %eax
je 0xac1a
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movb $0x0, (%rax)
movq -0x50(%rbp), %rax
movq -0x48(%rbp), %rcx
subq %rcx, %rax
movl %eax, -0x6c(%rbp)
movl -0x6c(%rbp), %eax
addl -0x1c(%rbp), %eax
movl %eax, -0x1c(%rbp)
movq -0x48(%rbp), %rdi
movslq -0x6c(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0xac60
movl -0x1c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x90, %rsp
popq %rbp
retq
nopl (%rax,%rax)