// File: /workspace/github_c_makefile_star2_O2/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 $0x38, %rsp
movl %esi, %ebp
movq %rdi, %r15
movq %rdx, 0x30(%rsp)
movl (%rdx), %eax
movq %rax, 0x8(%rsp)
movq %rcx, 0x18(%rsp)
movq (%rcx), %rax
movq %rax, (%rsp)
callq 0x41d0
movslq %eax, %rsi
xorl %r14d, %r14d
xorl %r13d, %r13d
xorl %r12d, %r12d
xorl %edx, %edx
movq %rsi, 0x10(%rsp)
cmpq %rsi, %r14
jg 0x8f81
movslq %edx, %r8
testl %ebp, %ebp
je 0x8eb3
movsbl (%r15,%r14), %eax
testl %eax, %eax
setne %cl
cmpl %ebp, %eax
setne %al
testb %al, %cl
jne 0x8eef
testl %r13d, %r13d
sete %al
cmpl %ebp, %r13d
sete %cl
orb %al, %cl
jne 0x8f74
movb $0x0, (%r15,%r14)
movq 0x8(%rsp), %rax
cmpl %eax, %edx
jne 0x8f0d
leal (%rax,%rax), %r13d
testl %eax, %eax
pushq $0x2
popq %rax
cmovel %eax, %r13d
movslq %r13d, %rsi
shlq $0x2, %rsi
movq (%rsp), %rdi
movq %rdi, %rbx
movq %r8, 0x20(%rsp)
movl %edx, 0x2c(%rsp)
callq 0x4840
movq 0x10(%rsp), %rsi
movl 0x2c(%rsp), %edx
movq 0x20(%rsp), %r8
movl %r13d, %ecx
movq %rcx, 0x8(%rsp)
testq %rax, %rax
jne 0x8f11
jmp 0x8faa
movq %r8, 0x20(%rsp)
movl %edx, %ebx
callq 0x4510
movq (%rax), %rcx
movzbl (%r15,%r14), %edx
movl %r13d, %eax
movzwl (%rcx,%rax,2), %eax
testl %edx, %edx
je 0x8eff
movzwl (%rcx,%rdx,2), %ecx
andl $0x2000, %ecx           # imm = 0x2000
jne 0x8eff
testl %r13d, %r13d
cmovel %r14d, %r12d
testw $0x2000, %ax            # imm = 0x2000
cmovnel %r14d, %r12d
jmp 0x8f04
testl %r13d, %r13d
cmovel %r14d, %r12d
cmpl %ebp, %r13d
cmovel %r14d, %r12d
jmp 0x8f74
testw %ax, %ax
js 0x8f19
movl %ebx, %edx
movq 0x10(%rsp), %rsi
jmp 0x8f74
movq (%rsp), %rax
incl %edx
movl %r12d, (%rax,%r8,4)
jmp 0x8f70
movb $0x0, (%r15,%r14)
movq 0x8(%rsp), %rax
cmpl %eax, %ebx
jne 0x8f5a
leal (%rax,%rax), %r13d
testl %eax, %eax
pushq $0x2
popq %rax
cmovel %eax, %r13d
movslq %r13d, %rsi
shlq $0x2, %rsi
movq (%rsp), %rdi
callq 0x4840
movl %ebx, %edx
movl %r13d, %ecx
movq %rcx, 0x8(%rsp)
testq %rax, %rax
movq 0x10(%rsp), %rsi
jne 0x8f65
jmp 0x8faf
movl %ebx, %edx
movq (%rsp), %rax
movq 0x10(%rsp), %rsi
incl %edx
movq 0x20(%rsp), %rcx
movl %r12d, (%rax,%rcx,4)
movq %rax, (%rsp)
movzbl (%r15,%r14), %r13d
incq %r14
jmp 0x8e19
movq 0x30(%rsp), %rax
movq 0x8(%rsp), %rcx
movl %ecx, (%rax)
movq 0x18(%rsp), %rax
movq (%rsp), %rcx
movq %rcx, (%rax)
movl %edx, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
jmp 0x8fb3
movq (%rsp), %rdi
callq 0x45c0
xorl %ecx, %ecx
xorl %edx, %edx
movq 0x18(%rsp), %rax
jmp 0x8f96