// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0xf0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x38(%rbp)
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rax
cmpb $0x0, (%rax)
je 0x30d55
movq -0x38(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x25, %eax
jne 0x30d42
movq -0x38(%rbp), %rax
cmpq -0x40(%rbp), %rax
jbe 0x30983
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq -0x38(%rbp), %rcx
callq 0x30780
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x64, %eax
jne 0x30ab6
movl $0x0, -0x4c(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x78(%rbp)
movl (%rax), %eax
movl %eax, -0x6c(%rbp)
cmpl $0x28, %eax
ja 0x309d1
movq -0x78(%rbp), %rcx
movl -0x6c(%rbp), %edx
movslq %edx, %rax
addq 0x10(%rcx), %rax
addl $0x8, %edx
movl %edx, (%rcx)
movq %rax, -0x80(%rbp)
jmp 0x309e8
movq -0x78(%rbp), %rcx
movq 0x8(%rcx), %rax
movq %rax, %rdx
addq $0x8, %rdx
movq %rdx, 0x8(%rcx)
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x44(%rbp)
cmpl $0x0, -0x44(%rbp)
jl 0x30a02
movl -0x44(%rbp), %eax
movl %eax, -0x84(%rbp)
jmp 0x30a0d
xorl %eax, %eax
subl -0x44(%rbp), %eax
movl %eax, -0x84(%rbp)
movl -0x84(%rbp), %eax
movl %eax, -0x50(%rbp)
movl -0x50(%rbp), %eax
movl $0xa, %ecx
xorl %edx, %edx
divl %ecx
addl $0x30, %edx
movb %dl, %cl
movl -0x4c(%rbp), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, -0x4c(%rbp)
cltq
movb %cl, -0x30(%rbp,%rax)
movl -0x50(%rbp), %eax
movl $0xa, %ecx
xorl %edx, %edx
divl %ecx
movl %eax, -0x50(%rbp)
cmpl $0x0, -0x50(%rbp)
ja 0x30a16
cmpl $0x0, -0x44(%rbp)
jge 0x30a65
movl -0x4c(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x4c(%rbp)
cltq
movb $0x2d, -0x30(%rbp,%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x4c(%rbp), %edx
callq 0x30830
movl -0x4c(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x48(%rbp)
cmpl $0x0, -0x48(%rbp)
jl 0x30ab1
movslq -0x48(%rbp), %rax
movb -0x30(%rbp,%rax), %dl
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x10(%rbp), %rsi
movl (%rsi), %ecx
movl %ecx, %edi
addl $0x1, %edi
movl %edi, (%rsi)
movl %ecx, %ecx
movb %dl, (%rax,%rcx)
movl -0x48(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0x30a7e
jmp 0x30d36
movq -0x38(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x75, %eax
jne 0x30bb8
movl $0x0, -0x58(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x90(%rbp)
movl (%rax), %eax
movl %eax, -0x88(%rbp)
cmpl $0x28, %eax
ja 0x30b07
movq -0x90(%rbp), %rcx
movl -0x88(%rbp), %edx
movslq %edx, %rax
addq 0x10(%rcx), %rax
addl $0x8, %edx
movl %edx, (%rcx)
movq %rax, -0x98(%rbp)
jmp 0x30b24
movq -0x90(%rbp), %rcx
movq 0x8(%rcx), %rax
movq %rax, %rdx
addq $0x8, %rdx
movq %rdx, 0x8(%rcx)
movq %rax, -0x98(%rbp)
movq -0x98(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
movl $0xa, %ecx
xorl %edx, %edx
divl %ecx
addl $0x30, %edx
movb %dl, %cl
movl -0x58(%rbp), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, -0x58(%rbp)
cltq
movb %cl, -0x30(%rbp,%rax)
movl -0x5c(%rbp), %eax
movl $0xa, %ecx
xorl %edx, %edx
divl %ecx
movl %eax, -0x5c(%rbp)
cmpl $0x0, -0x5c(%rbp)
ja 0x30b30
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x58(%rbp), %edx
callq 0x30830
movl -0x58(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x54(%rbp)
cmpl $0x0, -0x54(%rbp)
jl 0x30bb3
movslq -0x54(%rbp), %rax
movb -0x30(%rbp,%rax), %dl
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x10(%rbp), %rsi
movl (%rsi), %ecx
movl %ecx, %edi
addl $0x1, %edi
movl %edi, (%rsi)
movl %ecx, %ecx
movb %dl, (%rax,%rcx)
movl -0x54(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x30b80
jmp 0x30d34
movq -0x38(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x73, %eax
jne 0x30c8b
movq -0x20(%rbp), %rax
movq %rax, -0xa8(%rbp)
movl (%rax), %eax
movl %eax, -0x9c(%rbp)
cmpl $0x28, %eax
ja 0x30c02
movq -0xa8(%rbp), %rcx
movl -0x9c(%rbp), %edx
movslq %edx, %rax
addq 0x10(%rcx), %rax
addl $0x8, %edx
movl %edx, (%rcx)
movq %rax, -0xb0(%rbp)
jmp 0x30c1f
movq -0xa8(%rbp), %rcx
movq 0x8(%rcx), %rax
movq %rax, %rdx
addq $0x8, %rdx
movq %rdx, 0x8(%rcx)
movq %rax, -0xb0(%rbp)
movq -0xb0(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x68(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xc8(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq -0x68(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq -0x68(%rbp), %rax
movq %rax, -0xd0(%rbp)
movq -0x68(%rbp), %rdi
callq 0x2110
movq -0xd0(%rbp), %rcx
movq -0xc8(%rbp), %rdi
movq -0xc0(%rbp), %rsi
movq -0xb8(%rbp), %rdx
addq %rax, %rcx
callq 0x30780
jmp 0x30d32
movq -0x38(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x63, %eax
jne 0x30d2b
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl $0x1, %edx
callq 0x30830
movq -0x20(%rbp), %rax
movq %rax, -0xe0(%rbp)
movl (%rax), %eax
movl %eax, -0xd4(%rbp)
cmpl $0x28, %eax
ja 0x30ce7
movq -0xe0(%rbp), %rcx
movl -0xd4(%rbp), %edx
movslq %edx, %rax
addq 0x10(%rcx), %rax
addl $0x8, %edx
movl %edx, (%rcx)
movq %rax, -0xe8(%rbp)
jmp 0x30d04
movq -0xe0(%rbp), %rcx
movq 0x8(%rcx), %rax
movq %rax, %rdx
addq $0x8, %rdx
movq %rdx, 0x8(%rcx)
movq %rax, -0xe8(%rbp)
movq -0xe8(%rbp), %rax
movl (%rax), %eax
movb %al, %dl
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x10(%rbp), %rsi
movl (%rsi), %ecx
movl %ecx, %edi
addl $0x1, %edi
movl %edi, (%rsi)
movl %ecx, %ecx
movb %dl, (%rax,%rcx)
jmp 0x30d30
callq 0x2050
jmp 0x30d32
jmp 0x30d34
jmp 0x30d36
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0x30d44
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x30947
movq -0x38(%rbp), %rax
cmpq -0x40(%rbp), %rax
jbe 0x30d74
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq -0x38(%rbp), %rcx
callq 0x30780
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x10(%rbp), %rcx
movl (%rcx), %ecx
movb $0x0, (%rax,%rcx)
addq $0xf0, %rsp
popq %rbp
retq
nop