// File: /workspace/github_c_makefile_star2_O3/samtools[P]htslib/kstring.c
// Function: ksplit_core
int ksplit_core(char *s, int delimiter, int *_max, int **_offsets)
{
	int i, n, max, last_char, last_start, *offsets, l;
	n = 0; max = *_max; offsets = *_offsets;
	l = strlen(s);

#define __ksplit_aux do {						\
		if (_offsets) {						\
			s[i] = 0;					\
			if (n == max) {					\
				int *tmp;				\
				max = max? max<<1 : 2;			\
				if ((tmp = (int*)realloc(offsets, sizeof(int) * max))) {  \
					offsets = tmp;			\
				} else	{				\
					free(offsets);			\
					*_offsets = NULL;		\
					return 0;			\
				}					\
			}						\
			offsets[n++] = last_start;			\
		} else ++n;						\
	} while (0)

	for (i = 0, last_char = last_start = 0; i <= l; ++i) {
		if (delimiter == 0) {
			if (isspace((int)((unsigned char) s[i])) || s[i] == 0) {
				if (isgraph(last_char))
                    __ksplit_aux; // the end of a field
			} else {
				if (isspace(last_char) || last_char == 0)
                    last_start = i;
			}
		} else {
			if (s[i] == delimiter || s[i] == 0) {
				if (last_char != 0 && last_char != delimiter) __ksplit_aux; // the end of a field
			} else {
				if (last_char == delimiter || last_char == 0) last_start = i;
			}
		}
		last_char = (int)((unsigned char)s[i]);
	}
	*_max = max; *_offsets = offsets;
	return n;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %esi, %ebp
movq %rdi, %r13
movq %rdx, 0x18(%rsp)
movl (%rdx), %eax
movl %eax, 0x4(%rsp)
movq %rcx, 0x20(%rsp)
movq (%rcx), %rax
movq %rax, 0x8(%rsp)
callq 0x41d0
movq %rax, %rsi
xorl %edx, %edx
testl %esi, %esi
js 0x9dd1
incl %esi
xorl %r15d, %r15d
xorl %edx, %edx
xorl %ebx, %ebx
xorl %r12d, %r12d
movq %rsi, 0x10(%rsp)
testl %ebp, %ebp
je 0x9d07
movsbl (%r13,%r15), %eax
testl %eax, %eax
setne %cl
cmpl %ebp, %eax
setne %al
testb %al, %cl
jne 0x9d41
testl %r12d, %r12d
sete %al
cmpl %ebp, %r12d
sete %cl
orb %al, %cl
jne 0x9dbf
movb $0x0, (%r13,%r15)
cmpl 0x4(%rsp), %edx
movq 0x8(%rsp), %r12
jne 0x9d60
leal (%rdx,%rdx), %eax
testl %edx, %edx
movl $0x2, %ecx
cmovel %ecx, %eax
movl %eax, 0x4(%rsp)
movslq %eax, %rsi
shlq $0x2, %rsi
movq %r12, %rdi
movq %rdx, %r14
callq 0x4840
movq %r14, %rdx
movq 0x10(%rsp), %rsi
testq %rax, %rax
jne 0x9db2
jmp 0x9dfa
movq %rdx, %r14
callq 0x4510
movq (%rax), %rcx
movzbl (%r13,%r15), %edx
movl %r12d, %eax
movzwl (%rcx,%rax,2), %eax
testl %edx, %edx
je 0x9d51
movzwl (%rcx,%rdx,2), %ecx
andl $0x2000, %ecx           # imm = 0x2000
jne 0x9d51
testl %r12d, %r12d
cmovel %r15d, %ebx
testl $0x2000, %eax           # imm = 0x2000
cmovnel %r15d, %ebx
jmp 0x9d56
testl %r12d, %r12d
cmovel %r15d, %ebx
cmpl %ebp, %r12d
cmovel %r15d, %ebx
jmp 0x9dbf
testw %ax, %ax
js 0x9d65
movq %r14, %rdx
movq 0x10(%rsp), %rsi
jmp 0x9dbf
movq %r12, %rax
jmp 0x9db2
movb $0x0, (%r13,%r15)
movq %r14, %rdx
cmpl 0x4(%rsp), %edx
jne 0x9da8
leal (%rdx,%rdx), %eax
testl %edx, %edx
movl $0x2, %ecx
cmovel %ecx, %eax
movl %eax, 0x4(%rsp)
movslq %eax, %rsi
shlq $0x2, %rsi
movq 0x8(%rsp), %r12
movq %r12, %rdi
callq 0x4840
movq %r14, %rdx
testq %rax, %rax
movq 0x10(%rsp), %rsi
jne 0x9db2
jmp 0x9dfa
movq 0x8(%rsp), %rax
movq 0x10(%rsp), %rsi
movslq %edx, %rcx
incl %edx
movl %ebx, (%rax,%rcx,4)
movq %rax, 0x8(%rsp)
movzbl (%r13,%r15), %r12d
incq %r15
cmpq %r15, %rsi
jne 0x9c89
movq 0x18(%rsp), %rax
movl 0x4(%rsp), %ecx
movl %ecx, (%rax)
movq 0x8(%rsp), %rcx
movq 0x20(%rsp), %rax
movq %rcx, (%rax)
movl %edx, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r12, %rdi
callq 0x45c0
xorl %ecx, %ecx
xorl %edx, %edx
jmp 0x9de1