// File: /workspace/github_c_makefile_star2_O2/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 $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 0x20c0
movslq %eax, %rsi
xorl %r14d, %r14d
xorl %r13d, %r13d
xorl %r12d, %r12d
xorl %edx, %edx
movq %rsi, 0x10(%rsp)
cmpq %rsi, %r14
jg 0x914c
movslq %edx, %r8
testl %ebp, %ebp
je 0x907d
movsbl (%r15,%r14), %eax
testl %eax, %eax
setne %cl
cmpl %ebp, %eax
setne %al
testb %al, %cl
jne 0x90ba
testl %r13d, %r13d
sete %al
cmpl %ebp, %r13d
sete %cl
orb %al, %cl
jne 0x913f
movb $0x0, (%r15,%r14)
movq 0x8(%rsp), %rax
cmpl %eax, %edx
jne 0x90d8
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 0x21e0
movq 0x10(%rsp), %rsi
movl 0x2c(%rsp), %edx
movq 0x20(%rsp), %r8
movl %r13d, %ecx
movq %rcx, 0x8(%rsp)
testq %rax, %rax
jne 0x90dc
jmp 0x9175
movq %r8, 0x20(%rsp)
movl %edx, %ebx
callq 0x22b0
movq (%rax), %rcx
movsbq (%r15,%r14), %rdx
movslq %r13d, %rax
movzwl (%rcx,%rax,2), %eax
testq %rdx, %rdx
je 0x90ca
movzwl (%rcx,%rdx,2), %ecx
andl $0x2000, %ecx           # imm = 0x2000
jne 0x90ca
testl %r13d, %r13d
cmovel %r14d, %r12d
testw $0x2000, %ax            # imm = 0x2000
cmovnel %r14d, %r12d
jmp 0x90cf
testl %r13d, %r13d
cmovel %r14d, %r12d
cmpl %ebp, %r13d
cmovel %r14d, %r12d
jmp 0x913f
testw %ax, %ax
js 0x90e4
movl %ebx, %edx
movq 0x10(%rsp), %rsi
jmp 0x913f
movq (%rsp), %rax
incl %edx
movl %r12d, (%rax,%r8,4)
jmp 0x913b
movb $0x0, (%r15,%r14)
movq 0x8(%rsp), %rax
cmpl %eax, %ebx
jne 0x9125
leal (%rax,%rax), %r13d
testl %eax, %eax
pushq $0x2
popq %rax
cmovel %eax, %r13d
movslq %r13d, %rsi
shlq $0x2, %rsi
movq (%rsp), %rdi
callq 0x21e0
movl %ebx, %edx
movl %r13d, %ecx
movq %rcx, 0x8(%rsp)
testq %rax, %rax
movq 0x10(%rsp), %rsi
jne 0x9130
jmp 0x917a
movl %ebx, %edx
movq (%rsp), %rax
movq 0x10(%rsp), %rsi
incl %edx
movq 0x20(%rsp), %rcx
movl %r12d, (%rax,%rcx,4)
movq %rax, (%rsp)
movsbl (%r15,%r14), %r13d
incq %r14
jmp 0x8fe3
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 0x917e
movq (%rsp), %rdi
callq 0x22c0
xorl %ecx, %ecx
xorl %edx, %edx
movq 0x18(%rsp), %rax
jmp 0x9161