// File: /workspace/github_c_makefile_star2_O3/mattn[P]orelang/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, %r13
movq %rdx, 0x18(%rsp)
movl (%rdx), %eax
movl %eax, 0x4(%rsp)
movq %rcx, 0x20(%rsp)
movq (%rcx), %rax
movq %rax, 0x8(%rsp)
callq 0x20c0
movq %rax, %rsi
xorl %edx, %edx
testl %esi, %esi
js 0xb471
incl %esi
xorl %r15d, %r15d
xorl %edx, %edx
xorl %ebx, %ebx
xorl %r12d, %r12d
movq %rsi, 0x10(%rsp)
testl %ebp, %ebp
je 0xb3a6
movsbl (%r13,%r15), %eax
testl %eax, %eax
setne %cl
cmpl %ebp, %eax
setne %al
testb %al, %cl
jne 0xb3e1
testl %r12d, %r12d
sete %al
cmpl %ebp, %r12d
sete %cl
orb %al, %cl
jne 0xb45f
movb $0x0, (%r13,%r15)
cmpl 0x4(%rsp), %edx
movq 0x8(%rsp), %r12
jne 0xb400
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 0x21e0
movq %r14, %rdx
movq 0x10(%rsp), %rsi
testq %rax, %rax
jne 0xb452
jmp 0xb49a
movq %rdx, %r14
callq 0x22b0
movq (%rax), %rcx
movsbq (%r13,%r15), %rdx
movslq %r12d, %rax
movzwl (%rcx,%rax,2), %eax
testq %rdx, %rdx
je 0xb3f1
movzwl (%rcx,%rdx,2), %ecx
andl $0x2000, %ecx           # imm = 0x2000
jne 0xb3f1
testl %r12d, %r12d
cmovel %r15d, %ebx
testl $0x2000, %eax           # imm = 0x2000
cmovnel %r15d, %ebx
jmp 0xb3f6
testl %r12d, %r12d
cmovel %r15d, %ebx
cmpl %ebp, %r12d
cmovel %r15d, %ebx
jmp 0xb45f
testw %ax, %ax
js 0xb405
movq %r14, %rdx
movq 0x10(%rsp), %rsi
jmp 0xb45f
movq %r12, %rax
jmp 0xb452
movb $0x0, (%r13,%r15)
movq %r14, %rdx
cmpl 0x4(%rsp), %edx
jne 0xb448
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 0x21e0
movq %r14, %rdx
testq %rax, %rax
movq 0x10(%rsp), %rsi
jne 0xb452
jmp 0xb49a
movq 0x8(%rsp), %rax
movq 0x10(%rsp), %rsi
movslq %edx, %rcx
incl %edx
movl %ebx, (%rax,%rcx,4)
movq %rax, 0x8(%rsp)
movsbl (%r13,%r15), %r12d
incq %r15
cmpq %r15, %rsi
jne 0xb328
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 0x22c0
xorl %ecx, %ecx
xorl %edx, %edx
jmp 0xb481