// File: /workspace/github_c_makefile_star2_O2/lh3[P]minigraph/format.c
// Function: mg_sprintf_core
void mg_sprintf_core(void *km, kstring_t *s, const char *fmt, va_list ap)
{
	char buf[16]; // for integer to string conversion
	const char *p, *q;
	for (q = p = fmt; *p; ++p) {
		if (*p == '%') {
			if (p > q) str_copy(km, 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++] = '-';
				str_enlarge(km, s, l);
				for (i = l - 1; i >= 0; --i) s->s[s->l++] = buf[i];
			} 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);
				str_enlarge(km, 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*);
				str_copy(km, s, r, r + strlen(r));
			} else if (*p == 'c') {
				str_enlarge(km, s, 1);
				s->s[s->l++] = va_arg(ap, int);
			} else abort();
			q = p + 1;
		}
	}
	if (p > q) str_copy(km, s, q, p);
	s->s[s->l] = 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rcx, %r12
movq %rsi, %rbx
movq %rdi, %r14
pushq $0xa
popq %rbp
movq %rdx, %r15
movzbl (%r15), %eax
cmpl $0x25, %eax
je 0x1bc86
testl %eax, %eax
jne 0x1be0c
jmp 0x1be6b
cmpq %rdx, %r15
jbe 0x1bc99
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rcx
callq 0x1bbd6
movzbl 0x1(%r15), %eax
cmpl $0x63, %eax
je 0x1bcf3
cmpl $0x75, %eax
je 0x1bd23
cmpl $0x73, %eax
je 0x1bcd8
cmpl $0x64, %eax
jne 0x1be97
movl (%r12), %ecx
cmpq $0x28, %rcx
ja 0x1bd75
movq %rcx, %rax
addq 0x10(%r12), %rax
addl $0x8, %ecx
movl %ecx, (%r12)
jmp 0x1bd83
movl (%r12), %ecx
cmpq $0x28, %rcx
ja 0x1bd45
movq %rcx, %rax
addq 0x10(%r12), %rax
addl $0x8, %ecx
movl %ecx, (%r12)
jmp 0x1bd53
movq %r14, %rdi
movq %rbx, %rsi
pushq $0x1
popq %rdx
callq 0x1bc0b
movl (%r12), %ecx
cmpq $0x28, %rcx
ja 0x1bde0
movq %rcx, %rax
addq 0x10(%r12), %rax
addl $0x8, %ecx
movl %ecx, (%r12)
jmp 0x1bdee
movl (%r12), %ecx
cmpq $0x28, %rcx
ja 0x1be14
movq %rcx, %rax
addq 0x10(%r12), %rax
addl $0x8, %ecx
movl %ecx, (%r12)
jmp 0x1be22
movq 0x8(%r12), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%r12)
movq (%rax), %r13
movq %r13, %rdi
callq 0x2110
leaq (%rax,%r13), %rcx
movq %r14, %rdi
movq %rbx, %rsi
movq %r13, %rdx
callq 0x1bbd6
jmp 0x1bdfe
movq 0x8(%r12), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%r12)
movl (%rax), %esi
movl %esi, %ecx
negl %ecx
cmovsl %esi, %ecx
xorl %r13d, %r13d
movl %ecx, %eax
xorl %edx, %edx
divl %ebp
orb $0x30, %dl
movb %dl, (%rsp,%r13)
incq %r13
cmpl $0x9, %ecx
movl %eax, %ecx
ja 0x1bd8f
testl %esi, %esi
jns 0x1bdb4
movl %r13d, %eax
incl %r13d
movb $0x2d, (%rsp,%rax)
movq %r14, %rdi
movq %rbx, %rsi
movl %r13d, %edx
callq 0x1bc0b
movl %r13d, %eax
testl %eax, %eax
jle 0x1bdfe
movb -0x1(%rsp,%rax), %cl
decq %rax
movq 0x8(%rbx), %rdx
movl (%rbx), %esi
leal 0x1(%rsi), %edi
movl %edi, (%rbx)
movb %cl, (%rdx,%rsi)
jmp 0x1bdc5
movq 0x8(%r12), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%r12)
movb (%rax), %al
movq 0x8(%rbx), %rcx
movl (%rbx), %edx
leal 0x1(%rdx), %esi
movl %esi, (%rbx)
movb %al, (%rcx,%rdx)
leaq 0x1(%r15), %rax
addq $0x2, %r15
movq %r15, %rdx
movq %rax, %r15
incq %r15
jmp 0x1bc70
movq 0x8(%r12), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%r12)
movl (%rax), %esi
xorl %ecx, %ecx
movl %esi, %eax
xorl %edx, %edx
divl %ebp
orb $0x30, %dl
movb %dl, (%rsp,%rcx)
incq %rcx
cmpl $0x9, %esi
movl %eax, %esi
ja 0x1be26
leal -0x1(%rcx), %r13d
movq %r14, %rdi
movq %rbx, %rsi
movl %ecx, %edx
callq 0x1bc0b
testl %r13d, %r13d
js 0x1bdfe
movl %r13d, %eax
movb (%rsp,%rax), %al
movq 0x8(%rbx), %rcx
movl (%rbx), %edx
leal 0x1(%rdx), %esi
movl %esi, (%rbx)
movb %al, (%rcx,%rdx)
decl %r13d
jmp 0x1be4d
cmpq %rdx, %r15
jbe 0x1be7e
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rcx
callq 0x1bbd6
movq 0x8(%rbx), %rax
movl (%rbx), %ecx
movb $0x0, (%rax,%rcx)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x2050