// File: /workspace/github_c_makefile_star2_O1/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 %rsi, %r15
movq %rdi, %rbx
leaq 0x40(%rsp), %rsi
movq %rdx, 0x10(%rsi)
movq %rcx, 0x18(%rsi)
movq %r8, 0x20(%rsi)
movq %r9, 0x28(%rsi)
testb %al, %al
je 0xf59d
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 %rsi, 0x10(%rsp)
leaq 0x130(%rsp), %rax
movq %rax, 0x8(%rsp)
movabsq $0x3000000010, %rax     # imm = 0x3000000010
movq %rax, (%rsp)
xorl %r14d, %r14d
movl $0xcccccccd, %ebp       # imm = 0xCCCCCCCD
movabsq $-0x3333333333333333, %r8 # imm = 0xCCCCCCCCCCCCCCCD
movq %r15, %r12
movzbl (%r12), %eax
cmpl $0x25, %eax
je 0xf5e9
testl %eax, %eax
jne 0xfbaa
jmp 0xfbb2
movq %r12, %r13
subq %r15, %r13
jbe 0xf685
addq %r13, %r14
testq %rbx, %rbx
je 0xf685
movq (%rbx), %rax
movslq %r13d, %rcx
leaq (%rax,%rcx), %rdx
incq %rdx
cmpq 0x8(%rbx), %rdx
jbe 0xf666
addq %rcx, %rax
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x10, %rcx
orq %rax, %rcx
movq %rcx, %rsi
shrq $0x20, %rsi
orq %rcx, %rsi
incq %rsi
movq %rsi, 0x8(%rbx)
movq 0x10(%rbx), %rdi
callq 0x2230
movq %rax, 0x10(%rbx)
movq 0x10(%rbx), %rdi
addq (%rbx), %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x21e0
addq %r13, (%rbx)
movabsq $-0x3333333333333333, %r8 # imm = 0xCCCCCCCCCCCCCCCD
leaq 0x1(%r12), %r13
movzbl 0x1(%r12), %edi
cmpl $0x6b, %edi
jle 0xf6cc
cmpl $0x6c, %edi
je 0xf71e
cmpl $0x73, %edi
je 0xf6fe
cmpl $0x75, %edi
jne 0xfc62
movl (%rsp), %ecx
cmpq $0x28, %rcx
ja 0xf74a
movq %rcx, %rax
addq 0x10(%rsp), %rax
addl $0x8, %ecx
movl %ecx, (%rsp)
jmp 0xf758
cmpl $0x63, %edi
je 0xf8e5
cmpl $0x64, %edi
jne 0xfc62
movl (%rsp), %ecx
cmpq $0x28, %rcx
ja 0xf97d
movq %rcx, %rax
addq 0x10(%rsp), %rax
addl $0x8, %ecx
movl %ecx, (%rsp)
jmp 0xf98b
movl (%rsp), %ecx
cmpq $0x28, %rcx
ja 0xf82d
movq %rcx, %rax
addq 0x10(%rsp), %rax
addl $0x8, %ecx
movl %ecx, (%rsp)
jmp 0xf83b
cmpb $0x64, 0x2(%r12)
jne 0xf8dc
movl (%rsp), %ecx
cmpq $0x28, %rcx
ja 0xfa9d
movq %rcx, %rax
addq 0x10(%rsp), %rax
addl $0x8, %ecx
movl %ecx, (%rsp)
jmp 0xfaab
movq 0x8(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movl (%rax), %ecx
movl $0x1, %edx
xorl %eax, %eax
movq %rdx, %r12
movl %ecx, %esi
imulq %rbp, %rsi
shrq $0x23, %rsi
leal (%rsi,%rsi), %edx
leal (%rdx,%rdx,4), %edx
movl %ecx, %edi
subl %edx, %edi
orb $0x30, %dil
movb %dil, 0x20(%rsp,%rax)
incq %rax
leaq 0x1(%r12), %rdx
cmpl $0x9, %ecx
movl %esi, %ecx
ja 0xf761
movl %eax, %r15d
testq %rbx, %rbx
je 0xfba0
movq (%rbx), %rcx
movl %eax, %eax
leaq (%rcx,%rax), %rdx
incq %rdx
cmpq 0x8(%rbx), %rdx
jbe 0xf80a
addq %rax, %rcx
movq %rcx, %rax
shrq %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x2, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x4, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x8, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x10, %rax
orq %rcx, %rax
movq %rax, %rsi
shrq $0x20, %rsi
orq %rax, %rsi
incq %rsi
movq %rsi, 0x8(%rbx)
movq 0x10(%rbx), %rdi
callq 0x2230
movabsq $-0x3333333333333333, %r8 # imm = 0xCCCCCCCCCCCCCCCD
movq %rax, 0x10(%rbx)
movb 0x1f(%rsp,%r12), %al
movq (%rbx), %rcx
movq 0x10(%rbx), %rdx
leaq 0x1(%rcx), %rsi
movq %rsi, (%rbx)
movb %al, (%rdx,%rcx)
decq %r12
testq %r12, %r12
jg 0xf80a
jmp 0xfba0
movq 0x8(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq (%rax), %r12
movq %r12, %rdi
callq 0x2100
movslq %eax, %r15
testq %rbx, %rbx
je 0xf8cd
shlq $0x20, %rax
movq (%rbx), %rcx
sarq $0x20, %rax
leaq (%rcx,%rax), %rdx
incq %rdx
cmpq 0x8(%rbx), %rdx
jbe 0xf8b8
addq %rax, %rcx
movq %rcx, %rax
shrq %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x2, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x4, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x8, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x10, %rax
orq %rcx, %rax
movq %rax, %rsi
shrq $0x20, %rsi
orq %rax, %rsi
incq %rsi
movq %rsi, 0x8(%rbx)
movq 0x10(%rbx), %rdi
callq 0x2230
movq %rax, 0x10(%rbx)
movq 0x10(%rbx), %rdi
addq (%rbx), %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x21e0
addq %r15, (%rbx)
movabsq $-0x3333333333333333, %r8 # imm = 0xCCCCCCCCCCCCCCCD
jmp 0xfba0
cmpl $0x63, %edi
jne 0xf69e
movl $0x1, %r15d
testq %rbx, %rbx
je 0xfba0
movq (%rbx), %rax
leaq 0x2(%rax), %rcx
cmpq 0x8(%rbx), %rcx
jbe 0xf95d
incq %rax
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x10, %rcx
orq %rax, %rcx
movq %rcx, %rsi
shrq $0x20, %rsi
orq %rcx, %rsi
incq %rsi
movq %rsi, 0x8(%rbx)
movq 0x10(%rbx), %rdi
callq 0x2230
movabsq $-0x3333333333333333, %r8 # imm = 0xCCCCCCCCCCCCCCCD
movq %rax, 0x10(%rbx)
movl (%rsp), %ecx
cmpq $0x28, %rcx
ja 0xfa77
movq %rcx, %rax
addq 0x10(%rsp), %rax
addl $0x8, %ecx
movl %ecx, (%rsp)
jmp 0xfa85
movq 0x8(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movl (%rax), %eax
movl %eax, %ecx
negl %ecx
cmovsl %eax, %ecx
xorl %r12d, %r12d
movl %ecx, %edx
imulq %rbp, %rdx
shrq $0x23, %rdx
leal (%rdx,%rdx), %esi
leal (%rsi,%rsi,4), %esi
movl %ecx, %edi
subl %esi, %edi
orb $0x30, %dil
movb %dil, 0x20(%rsp,%r12)
incq %r12
cmpl $0x9, %ecx
movl %edx, %ecx
ja 0xf997
testl %eax, %eax
jns 0xf9cd
movl %r12d, %eax
incl %r12d
movb $0x2d, 0x20(%rsp,%rax)
movslq %r12d, %r15
testq %rbx, %rbx
je 0xfba0
movq (%rbx), %rax
leaq (%rax,%r15), %rcx
incq %rcx
cmpq 0x8(%rbx), %rcx
jbe 0xfa45
addq %r15, %rax
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x10, %rcx
orq %rax, %rcx
movq %rcx, %rsi
shrq $0x20, %rsi
orq %rcx, %rsi
incq %rsi
movq %rsi, 0x8(%rbx)
movq 0x10(%rbx), %rdi
callq 0x2230
movabsq $-0x3333333333333333, %r8 # imm = 0xCCCCCCCCCCCCCCCD
movq %rax, 0x10(%rbx)
movl %r12d, %eax
incl %r12d
leaq 0x1f(%rsp), %rcx
addq %rcx, %rax
movb (%rax), %cl
movq (%rbx), %rdx
movq 0x10(%rbx), %rsi
leaq 0x1(%rdx), %rdi
movq %rdi, (%rbx)
movb %cl, (%rsi,%rdx)
decl %r12d
decq %rax
cmpl $0x1, %r12d
jg 0xfa53
jmp 0xfba0
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)
jmp 0xfba0
movq 0x8(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
addq $0x2, %r12
movq (%rax), %rsi
movq %rsi, %rcx
negq %rcx
cmovsq %rsi, %rcx
xorl %r13d, %r13d
movq %rcx, %rax
mulq %r8
shrq $0x3, %rdx
leal (%rdx,%rdx), %eax
leal (%rax,%rax,4), %eax
movl %ecx, %edi
subl %eax, %edi
orb $0x30, %dil
movb %dil, 0x20(%rsp,%r13)
incq %r13
cmpq $0x9, %rcx
movq %rdx, %rcx
ja 0xfabf
testq %rsi, %rsi
jns 0xfaf8
movl %r13d, %eax
incl %r13d
movb $0x2d, 0x20(%rsp,%rax)
movslq %r13d, %r15
testq %rbx, %rbx
je 0xfb9d
movq (%rbx), %rax
leaq (%rax,%r15), %rcx
incq %rcx
cmpq 0x8(%rbx), %rcx
jbe 0xfb70
addq %r15, %rax
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x10, %rcx
orq %rax, %rcx
movq %rcx, %rsi
shrq $0x20, %rsi
orq %rcx, %rsi
incq %rsi
movq %rsi, 0x8(%rbx)
movq 0x10(%rbx), %rdi
callq 0x2230
movabsq $-0x3333333333333333, %r8 # imm = 0xCCCCCCCCCCCCCCCD
movq %rax, 0x10(%rbx)
movl %r13d, %eax
incl %r13d
leaq 0x1f(%rsp), %rcx
addq %rcx, %rax
movb (%rax), %cl
movq (%rbx), %rdx
movq 0x10(%rbx), %rsi
leaq 0x1(%rdx), %rdi
movq %rdi, (%rbx)
movb %cl, (%rsi,%rdx)
decl %r13d
decq %rax
cmpl $0x1, %r13d
jg 0xfb7e
movq %r12, %r13
addq %r15, %r14
leaq 0x1(%r13), %r15
movq %r13, %r12
incq %r12
jmp 0xf5d2
subq %r15, %r12
jbe 0xfc3d
addq %r12, %r14
testq %rbx, %rbx
je 0xfc3d
movq (%rbx), %rax
movslq %r12d, %rcx
leaq (%rax,%rcx), %rdx
incq %rdx
cmpq 0x8(%rbx), %rdx
jbe 0xfc28
addq %rcx, %rax
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x10, %rcx
orq %rax, %rcx
movq %rcx, %rsi
shrq $0x20, %rsi
orq %rcx, %rsi
incq %rsi
movq %rsi, 0x8(%rbx)
movq 0x10(%rbx), %rdi
callq 0x2230
movq %rax, 0x10(%rbx)
movq 0x10(%rbx), %rdi
addq (%rbx), %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x21e0
addq %r12, (%rbx)
testq %rbx, %rbx
je 0xfc4d
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
callq 0x2d33