// File: /workspace/github_c_makefile_star2_O1/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, %r12
movq %rdx, 0x20(%rsp)
movl (%rdx), %eax
movq %rax, 0x10(%rsp)
movq %rcx, 0x18(%rsp)
movq (%rcx), %rax
movq %rax, 0x8(%rsp)
callq 0x41d0
movq %rax, %r14
testl %r14d, %r14d
js 0x9e13
incl %r14d
xorl %r13d, %r13d
movl $0x0, 0x4(%rsp)
xorl %r15d, %r15d
xorl %ebx, %ebx
testl %ebp, %ebp
je 0x9d36
movsbl (%r12,%r13), %eax
testl %eax, %eax
setne %cl
cmpl %ebp, %eax
setne %al
testb %al, %cl
jne 0x9d6d
testl %ebx, %ebx
sete %al
cmpl %ebp, %ebx
sete %cl
orb %al, %cl
jne 0x9e00
movb $0x0, (%r12,%r13)
movq 0x10(%rsp), %rax
movl 0x4(%rsp), %ecx
cmpl %eax, %ecx
movq 0x8(%rsp), %rbx
jne 0x9d1f
testl %eax, %eax
leal (%rax,%rax), %eax
movl $0x2, %ecx
cmovel %ecx, %eax
movq %rax, 0x10(%rsp)
movslq %eax, %rsi
shlq $0x2, %rsi
movq %rbx, %rdi
callq 0x4840
movq %rbx, %rcx
movq %rax, %rbx
testq %rax, %rax
jne 0x9d0f
movq %rcx, %rdi
movq %rcx, 0x8(%rsp)
callq 0x45c0
movq 0x18(%rsp), %rax
movq $0x0, (%rax)
movq 0x8(%rsp), %rax
testq %rbx, %rbx
movq %rax, %rbx
movl 0x4(%rsp), %ecx
je 0x9e47
movslq %ecx, %rax
incl %ecx
movl %ecx, 0x4(%rsp)
movq %rbx, 0x8(%rsp)
movl %r15d, (%rbx,%rax,4)
jmp 0x9e00
callq 0x4510
movq (%rax), %rcx
movzbl (%r12,%r13), %edx
movl %ebx, %eax
movzwl (%rcx,%rax,2), %eax
testl %edx, %edx
je 0x9d7e
movzwl (%rcx,%rdx,2), %ecx
andl $0x2000, %ecx           # imm = 0x2000
jne 0x9d7e
testl %ebx, %ebx
cmovel %r13d, %r15d
testl $0x2000, %eax           # imm = 0x2000
cmovnel %r13d, %r15d
jmp 0x9e00
testl %ebx, %ebx
cmovel %r13d, %r15d
cmpl %ebp, %ebx
cmovel %r13d, %r15d
jmp 0x9e00
testw %ax, %ax
jns 0x9e00
movb $0x0, (%r12,%r13)
movq 0x10(%rsp), %rax
movl 0x4(%rsp), %ecx
cmpl %eax, %ecx
jne 0x9de9
testl %eax, %eax
leal (%rax,%rax), %eax
movl $0x2, %ecx
cmovel %ecx, %eax
movq %rax, 0x10(%rsp)
movslq %eax, %rsi
shlq $0x2, %rsi
movq 0x8(%rsp), %rdi
callq 0x4840
movq %rax, %rbx
testq %rax, %rax
jne 0x9ddb
movq 0x8(%rsp), %rdi
callq 0x45c0
movq 0x18(%rsp), %rax
movq $0x0, (%rax)
movq 0x8(%rsp), %rax
testq %rbx, %rbx
movq %rax, %rdx
movl 0x4(%rsp), %ecx
jne 0x9dee
jmp 0x9e47
movq 0x8(%rsp), %rdx
movslq %ecx, %rax
incl %ecx
movl %ecx, 0x4(%rsp)
movq %rdx, 0x8(%rsp)
movl %r15d, (%rdx,%rax,4)
movzbl (%r12,%r13), %ebx
incq %r13
cmpq %r13, %r14
jne 0x9c7d
jmp 0x9e1b
movl $0x0, 0x4(%rsp)
movq 0x20(%rsp), %rax
movq 0x10(%rsp), %rcx
movl %ecx, (%rax)
movq 0x18(%rsp), %rax
movq 0x8(%rsp), %rcx
movq %rcx, (%rax)
movl 0x4(%rsp), %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %eax, %eax
jmp 0x9e38