// File: /workspace/github_cpp_makefile_star2_O1/karel-brinda[P]ococo/ext/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(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 = 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 0x4230
movq %rax, %r14
testl %r14d, %r14d
js 0x432da
incl %r14d
xorl %r13d, %r13d
movl $0x0, 0x4(%rsp)
xorl %r15d, %r15d
xorl %ebx, %ebx
testl %ebp, %ebp
je 0x431fb
movsbl (%r12,%r13), %eax
testl %eax, %eax
setne %cl
cmpl %ebp, %eax
setne %al
testb %al, %cl
jne 0x43234
testl %ebx, %ebx
sete %al
cmpl %ebp, %ebx
sete %cl
orb %al, %cl
jne 0x432c7
movb $0x0, (%r12,%r13)
movq 0x10(%rsp), %rax
movl 0x4(%rsp), %ecx
cmpl %eax, %ecx
movq 0x8(%rsp), %rbx
jne 0x431e4
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 0x48d0
movq %rbx, %rcx
movq %rax, %rbx
testq %rax, %rax
jne 0x431d4
movq %rcx, %rdi
movq %rcx, 0x8(%rsp)
callq 0x4610
movq 0x18(%rsp), %rax
movq $0x0, (%rax)
movq 0x8(%rsp), %rax
testq %rbx, %rbx
movq %rax, %rbx
movl 0x4(%rsp), %ecx
je 0x4330e
movslq %ecx, %rax
incl %ecx
movl %ecx, 0x4(%rsp)
movq %rbx, 0x8(%rsp)
movl %r15d, (%rbx,%rax,4)
jmp 0x432c7
callq 0x4580
movq (%rax), %rcx
movsbq (%r12,%r13), %rdx
movslq %ebx, %rax
movzwl (%rcx,%rax,2), %eax
testq %rdx, %rdx
je 0x43245
movzwl (%rcx,%rdx,2), %ecx
andl $0x2000, %ecx           # imm = 0x2000
jne 0x43245
testl %ebx, %ebx
cmovel %r13d, %r15d
testl $0x2000, %eax           # imm = 0x2000
cmovnel %r13d, %r15d
jmp 0x432c7
testl %ebx, %ebx
cmovel %r13d, %r15d
cmpl %ebp, %ebx
cmovel %r13d, %r15d
jmp 0x432c7
testw %ax, %ax
jns 0x432c7
movb $0x0, (%r12,%r13)
movq 0x10(%rsp), %rax
movl 0x4(%rsp), %ecx
cmpl %eax, %ecx
jne 0x432b0
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 0x48d0
movq %rax, %rbx
testq %rax, %rax
jne 0x432a2
movq 0x8(%rsp), %rdi
callq 0x4610
movq 0x18(%rsp), %rax
movq $0x0, (%rax)
movq 0x8(%rsp), %rax
testq %rbx, %rbx
movq %rax, %rdx
movl 0x4(%rsp), %ecx
jne 0x432b5
jmp 0x4330e
movq 0x8(%rsp), %rdx
movslq %ecx, %rax
incl %ecx
movl %ecx, 0x4(%rsp)
movq %rdx, 0x8(%rsp)
movl %r15d, (%rdx,%rax,4)
movsbl (%r12,%r13), %ebx
incq %r13
cmpq %r13, %r14
jne 0x43142
jmp 0x432e2
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 0x432ff