// File: /workspace/github_c_makefile_star2_O2/lh3[P]miniprot/format.c
// Function: mp_sprintf_lite
int64_t mp_sprintf_lite(kstring_t *s, const char *fmt, ...)
{
	char buf[32]; // for integer to string conversion
	const char *p, *q;
	int64_t len = 0;
	va_list ap;
	va_start(ap, fmt);
	for (q = p = fmt; *p; ++p) {
		if (*p == '%') {
			if (p > q) {
				len += p - q;
				if (s) str_copy(s, q, p);
			}
			++p;
			if (*p == 'd') {
				int c, i, l = 0;
				unsigned int x;
				c = va_arg(ap, int);
				x = c >= 0? c : -c;
				do { buf[l++] = x%10 + '0'; x /= 10; } while (x > 0);
				if (c < 0) buf[l++] = '-';
				len += l;
				if (s) {
					str_enlarge(s, l);
					for (i = l - 1; i >= 0; --i) s->s[s->l++] = buf[i];
				}
			} else if (*p == 'l' && *(p+1) == 'd') {
				int i, l = 0;
				long c;
				unsigned long x;
				c = va_arg(ap, long);
				x = c >= 0? c : -c;
				do { buf[l++] = x%10 + '0'; x /= 10; } while (x > 0);
				if (c < 0) buf[l++] = '-';
				len += l;
				if (s) {
					str_enlarge(s, l);
					for (i = l - 1; i >= 0; --i) s->s[s->l++] = buf[i];
				}
				++p;
			} else if (*p == 'u') {
				int i, l = 0;
				uint32_t x;
				x = va_arg(ap, uint32_t);
				do { buf[l++] = x%10 + '0'; x /= 10; } while (x > 0);
				len += l;
				if (s) {
					str_enlarge(s, l);
					for (i = l - 1; i >= 0; --i) s->s[s->l++] = buf[i];
				}
			} else if (*p == 's') {
				char *r = va_arg(ap, char*);
				int l;
				l = strlen(r);
				len += l;
				if (s) str_copy(s, r, r + l);
			} else if (*p == 'c') {
				++len;
				if (s) {
					str_enlarge(s, 1);
					s->s[s->l++] = va_arg(ap, int);
				}
			} else {
				fprintf(stderr, "ERROR: unrecognized type '%%%c'\n", *p);
				abort();
			}
			q = p + 1;
		}
	}
	if (p > q) {
		len += p - q;
		if (s) str_copy(s, q, p);
	}
	va_end(ap);
	if (s) s->s[s->l] = 0;
	return len;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xf8, %rsp
movq %rdi, %rbx
leaq 0x40(%rsp), %rdi
movq %rdx, 0x10(%rdi)
movq %rcx, 0x18(%rdi)
movq %r8, 0x20(%rdi)
movq %r9, 0x28(%rdi)
testb %al, %al
je 0xdd96
movaps %xmm0, 0x70(%rsp)
movaps %xmm1, 0x80(%rsp)
movaps %xmm2, 0x90(%rsp)
movaps %xmm3, 0xa0(%rsp)
movaps %xmm4, 0xb0(%rsp)
movaps %xmm5, 0xc0(%rsp)
movaps %xmm6, 0xd0(%rsp)
movaps %xmm7, 0xe0(%rsp)
movq %rdi, 0x10(%rsp)
leaq 0x130(%rsp), %rax
movq %rax, 0x8(%rsp)
movabsq $0x3000000010, %rax     # imm = 0x3000000010
movq %rax, (%rsp)
xorl %r14d, %r14d
pushq $0xa
popq %rbp
movq %rsi, %r15
movzbl (%r15), %eax
cmpl $0x25, %eax
je 0xddd5
testl %eax, %eax
jne 0xe0b2
jmp 0xe0ba
movq %r15, %r13
subq %rsi, %r13
jbe 0xddf2
addq %r14, %r13
testq %rbx, %rbx
je 0xddf5
movq %rbx, %rdi
movq %r15, %rdx
callq 0xe11c
jmp 0xddf5
movq %r14, %r13
pushq $0xa
popq %rdi
leaq 0x1(%r15), %r12
movzbl 0x1(%r15), %eax
cmpl $0x63, %eax
je 0xde66
cmpl $0x75, %eax
je 0xde46
cmpl $0x6c, %eax
je 0xde9a
cmpl $0x73, %eax
je 0xdec5
cmpl $0x64, %eax
jne 0xe0fc
movl (%rsp), %ecx
cmpq $0x28, %rcx
ja 0xdf7e
movq %rcx, %rax
addq 0x10(%rsp), %rax
addl $0x8, %ecx
movl %ecx, (%rsp)
jmp 0xdf8c
movl (%rsp), %ecx
cmpq $0x28, %rcx
ja 0xdede
movq %rcx, %rax
addq 0x10(%rsp), %rax
addl $0x8, %ecx
movl %ecx, (%rsp)
jmp 0xdeec
testq %rbx, %rbx
je 0xe0a3
movq %rbx, %rdi
pushq $0x1
popq %rsi
callq 0xe14f
movl (%rsp), %ecx
cmpq $0x28, %rcx
ja 0xe082
movq %rcx, %rax
addq 0x10(%rsp), %rax
addl $0x8, %ecx
movl %ecx, (%rsp)
jmp 0xe090
cmpb $0x64, 0x2(%r15)
jne 0xe0fc
movl (%rsp), %ecx
cmpq $0x28, %rcx
ja 0xdffb
movq %rcx, %rax
addq 0x10(%rsp), %rax
addl $0x8, %ecx
movl %ecx, (%rsp)
jmp 0xe009
movl (%rsp), %ecx
cmpq $0x28, %rcx
ja 0xdf45
movq %rcx, %rax
addq 0x10(%rsp), %rax
addl $0x8, %ecx
movl %ecx, (%rsp)
jmp 0xdf53
movq 0x8(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movl (%rax), %ecx
xorl %esi, %esi
movl %ecx, %eax
xorl %edx, %edx
divl %ebp
orb $0x30, %dl
movb %dl, 0x20(%rsp,%rsi)
incq %rsi
cmpl $0x9, %ecx
movl %eax, %ecx
ja 0xdef0
movl %esi, %r14d
testq %rbx, %rbx
je 0xe0a7
leal -0x1(%rsi), %r15d
movq %rbx, %rdi
callq 0xe14f
testl %r15d, %r15d
js 0xe0a7
movl %r15d, %eax
movb 0x20(%rsp,%rax), %al
movq (%rbx), %rcx
movq 0x10(%rbx), %rdx
leaq 0x1(%rcx), %rsi
movq %rsi, (%rbx)
movb %al, (%rdx,%rcx)
decl %r15d
jmp 0xdf1f
movq 0x8(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq (%rax), %r15
movq %r15, %rdi
callq 0x2100
movslq %eax, %r14
testq %rbx, %rbx
je 0xe0a7
leaq (%r15,%r14), %rdx
movq %rbx, %rdi
movq %r15, %rsi
callq 0xe11c
jmp 0xe0a7
movq 0x8(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movl (%rax), %esi
movl %esi, %ecx
negl %ecx
cmovsl %esi, %ecx
xorl %r15d, %r15d
movl %ecx, %eax
xorl %edx, %edx
divl %ebp
orb $0x30, %dl
movb %dl, 0x20(%rsp,%r15)
incq %r15
cmpl $0x9, %ecx
movl %eax, %ecx
ja 0xdf98
testl %esi, %esi
jns 0xdfbf
movl %r15d, %eax
incl %r15d
movb $0x2d, 0x20(%rsp,%rax)
movslq %r15d, %r14
testq %rbx, %rbx
je 0xe0a7
movq %rbx, %rdi
movl %r15d, %esi
callq 0xe14f
movl %r15d, %eax
testl %eax, %eax
jle 0xe0a7
movb 0x1f(%rsp,%rax), %cl
decq %rax
movq (%rbx), %rdx
movq 0x10(%rbx), %rsi
leaq 0x1(%rdx), %rdi
movq %rdi, (%rbx)
movb %cl, (%rsi,%rdx)
jmp 0xdfd9
movq 0x8(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
addq $0x2, %r15
movq (%rax), %rsi
movq %rsi, %rcx
negq %rcx
cmovsq %rsi, %rcx
xorl %r12d, %r12d
movq %rcx, %rax
xorl %edx, %edx
divq %rdi
orb $0x30, %dl
movb %dl, 0x20(%rsp,%r12)
incq %r12
cmpq $0x9, %rcx
movq %rax, %rcx
ja 0xe01d
testq %rsi, %rsi
jns 0xe049
movl %r12d, %eax
incl %r12d
movb $0x2d, 0x20(%rsp,%rax)
movslq %r12d, %r14
testq %rbx, %rbx
je 0xe07d
movq %rbx, %rdi
movl %r12d, %esi
callq 0xe14f
movl %r12d, %eax
testl %eax, %eax
jle 0xe07d
movb 0x1f(%rsp,%rax), %cl
decq %rax
movq (%rbx), %rdx
movq 0x10(%rbx), %rsi
leaq 0x1(%rdx), %rdi
movq %rdi, (%rbx)
movb %cl, (%rsi,%rdx)
jmp 0xe05f
movq %r15, %r12
jmp 0xe0a7
movq 0x8(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movb (%rax), %al
movq (%rbx), %rcx
movq 0x10(%rbx), %rdx
leaq 0x1(%rcx), %rsi
movq %rsi, (%rbx)
movb %al, (%rdx,%rcx)
pushq $0x1
popq %r14
addq %r13, %r14
leaq 0x1(%r12), %rsi
movq %r12, %r15
incq %r15
jmp 0xddbf
movq %r15, %rax
subq %rsi, %rax
jbe 0xe0d7
addq %rax, %r14
testq %rbx, %rbx
je 0xe0e7
movq %rbx, %rdi
movq %r15, %rdx
callq 0xe11c
jmp 0xe0dc
testq %rbx, %rbx
je 0xe0e7
movq (%rbx), %rax
movq 0x10(%rbx), %rcx
movb $0x0, (%rcx,%rax)
movq %r14, %rax
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movsbl %al, %edx
movq 0x9eea(%rip), %rax      # 0x17ff0
movq (%rax), %rdi
leaq 0x51d8(%rip), %rsi      # 0x132e8
xorl %eax, %eax
callq 0x21e0
callq 0x2060