// File: /workspace/github_c_makefile_star2_O2/lh3[P]minigraph/gfa-io.c
// Function: gfa_aux_format
int gfa_aux_format(int l_aux, const uint8_t *aux, char **t, int *max)
{
	kstring_t str;
	const uint8_t *s = aux;
	str.l = 0, str.s = *t, str.m = *max;
	while (s < aux + l_aux) {
		uint8_t type, key[2];
		key[0] = s[0]; key[1] = s[1];
		s += 2; type = *s++;
		kputc('\t', &str); kputsn((char*)key, 2, &str); kputc(':', &str);
		if (type == 'A') { kputsn("A:", 2, &str); kputc(*s, &str); ++s; }
		else if (type == 'i') { kputsn("i:", 2, &str); kputw(*(int32_t*)s, &str); s += 4; }
		else if (type == 'f') { ksprintf(&str, "f:%g", *(float*)s); s += 4; }
		else if (type == 'Z') { kputc(type, &str); kputc(':', &str); while (*s) kputc(*s++, &str); ++s; }
		else if (type == 'B') {
			uint8_t sub_type = *(s++);
			int32_t i, n;
			memcpy(&n, s, 4);
			s += 4; // no point to the start of the array
			kputsn("B:", 2, &str); kputc(sub_type, &str); // write the typing
			for (i = 0; i < n; ++i) { // FIXME: for better performance, put the loop after "if"
				kputc(',', &str);
				if ('c' == sub_type)      { kputw(*(int8_t*)s, &str); ++s; }
				else if ('C' == sub_type) { kputw(*(uint8_t*)s, &str); ++s; }
				else if ('s' == sub_type) { kputw(*(int16_t*)s, &str); s += 2; }
				else if ('S' == sub_type) { kputw(*(uint16_t*)s, &str); s += 2; }
				else if ('i' == sub_type) { kputw(*(int32_t*)s, &str); s += 4; }
				else if ('I' == sub_type) { kputuw(*(uint32_t*)s, &str); s += 4; }
				else if ('f' == sub_type) { ksprintf(&str, "%g", *(float*)s); s += 4; }
			}
		}
	}
	*t = str.s, *max = str.m;
	return str.l;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rsi, %rbx
leaq 0x10(%rsp), %r15
andq $0x0, (%r15)
movq %rdx, 0x28(%rsp)
movq (%rdx), %rax
movq %rax, 0x10(%r15)
movq %rcx, 0x30(%rsp)
movslq (%rcx), %rax
movq %rax, 0x8(%r15)
movslq %edi, %r14
addq %rsi, %r14
pushq $0x9
popq %r13
movq %r14, 0x38(%rsp)
cmpq %r14, %rbx
jae 0x5f5c
movb (%rbx), %al
movb %al, 0xa(%rsp)
movb 0x1(%rbx), %al
movb %al, 0xb(%rsp)
movzbl 0x2(%rbx), %ebp
movl %r13d, %edi
movq %r15, %rsi
callq 0x5f87
leaq 0xa(%rsp), %rdi
pushq $0x2
popq %rsi
movq %r15, %rdx
callq 0x600a
pushq $0x3a
popq %rdi
movq %r15, %rsi
callq 0x5f87
cmpl $0x69, %ebp
je 0x5f30
cmpl $0x42, %ebp
je 0x5d43
leaq 0x3(%rbx), %r12
cmpl $0x5a, %ebp
je 0x5f0c
cmpl $0x66, %ebp
je 0x5ef4
cmpl $0x41, %ebp
jne 0x5f54
leaq 0x1d719(%rip), %rdi     # 0x2343c
pushq $0x2
popq %rsi
movq %r15, %rdx
callq 0x600a
movzbl 0x3(%rbx), %edi
movq %r15, %rsi
callq 0x5f87
addq $0x4, %rbx
jmp 0x5f51
movzbl 0x3(%rbx), %ebp
movl 0x4(%rbx), %r14d
addq $0x8, %rbx
leaq 0x1d6f1(%rip), %rdi     # 0x23447
pushq $0x2
popq %rsi
movq %r15, %rdx
callq 0x600a
movl %ebp, %edi
movq %r15, %rsi
callq 0x5f87
xorl %r13d, %r13d
testl %r14d, %r14d
cmovlel %r13d, %r14d
movl %r14d, 0xc(%rsp)
movq %rbx, %r12
pushq $0x2c
popq %rbx
pushq $0xa
popq %r14
cmpl 0xc(%rsp), %r13d
je 0x5ee9
movl %ebx, %edi
movq %r15, %rsi
callq 0x5f87
cmpl $0x43, %ebp
je 0x5dff
cmpl $0x49, %ebp
je 0x5e2a
cmpl $0x53, %ebp
je 0x5e14
cmpl $0x73, %ebp
je 0x5dcb
cmpl $0x66, %ebp
je 0x5de3
cmpl $0x69, %ebp
je 0x5dd2
cmpl $0x63, %ebp
jne 0x5ee1
movsbl (%r12), %edi
jmp 0x5e04
movswl (%r12), %edi
jmp 0x5e19
movl (%r12), %edi
movq %r15, %rsi
callq 0x609e
jmp 0x5edd
cvtss2sd (%r12), %xmm0
movq %r15, %rdi
leaq 0x1d651(%rip), %rsi     # 0x23444
movb $0x1, %al
callq 0x617c
jmp 0x5edd
movzbl (%r12), %edi
movq %r15, %rsi
callq 0x609e
incq %r12
jmp 0x5ee1
movzwl (%r12), %edi
movq %r15, %rsi
callq 0x609e
addq $0x2, %r12
jmp 0x5ee1
movl (%r12), %eax
testl %eax, %eax
je 0x5ed2
xorl %ebx, %ebx
testl %eax, %eax
je 0x5e4d
xorl %edx, %edx
divl %r14d
orb $0x30, %dl
movb %dl, 0x40(%rsp,%rbx)
incq %rbx
jmp 0x5e38
movq 0x10(%rsp), %r14
movq 0x20(%rsp), %rax
leal 0x1(%rbx), %ecx
addq %r14, %rcx
cmpq 0x18(%rsp), %rcx
jb 0x5eba
movq %rcx, %rdx
shrq %rdx
orq %rcx, %rdx
movq %rdx, %rcx
shrq $0x2, %rcx
orq %rdx, %rcx
movq %rcx, %rdx
shrq $0x4, %rdx
orq %rcx, %rdx
movq %rdx, %rcx
shrq $0x8, %rcx
orq %rdx, %rcx
movq %rcx, %rsi
shrq $0x10, %rsi
orq %rcx, %rsi
incq %rsi
movq %rsi, 0x18(%rsp)
movq %rax, %rdi
callq 0x22b0
movq %rax, 0x20(%rsp)
jmp 0x5eba
movb 0x3f(%rsp,%rbx), %cl
decq %rbx
movb %cl, (%rax,%r14)
incq %r14
testq %rbx, %rbx
jg 0x5eac
movq %r14, 0x10(%rsp)
movb $0x0, (%rax,%r14)
pushq $0x2c
popq %rbx
pushq $0xa
popq %r14
jmp 0x5edd
pushq $0x30
popq %rdi
movq %r15, %rsi
callq 0x5f87
addq $0x4, %r12
incl %r13d
jmp 0x5d84
movq 0x38(%rsp), %r14
pushq $0x9
popq %r13
jmp 0x5f54
cvtss2sd 0x3(%rbx), %xmm0
movq %r15, %rdi
leaq 0x1d53f(%rip), %rsi     # 0x23442
movb $0x1, %al
callq 0x617c
jmp 0x5f4d
pushq $0x5a
popq %rdi
movq %r15, %rsi
callq 0x5f87
pushq $0x3a
popq %rdi
movq %r15, %rsi
callq 0x5f87
movzbl (%r12), %edi
incq %r12
testl %edi, %edi
jne 0x5f1a
jmp 0x5f54
leaq 0x1d508(%rip), %rdi     # 0x2343f
pushq $0x2
popq %rsi
movq %r15, %rdx
callq 0x600a
movl 0x3(%rbx), %edi
movq %r15, %rsi
callq 0x609e
addq $0x7, %rbx
movq %rbx, %r12
movq %r12, %rbx
jmp 0x5caf
movq 0x20(%rsp), %rax
movq 0x28(%rsp), %rcx
movq %rax, (%rcx)
movl 0x18(%rsp), %eax
movq 0x30(%rsp), %rcx
movl %eax, (%rcx)
movl 0x10(%rsp), %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq