// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movl $0x0, -0x30(%rbp)
movq -0x20(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x34(%rbp)
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rdi
callq 0x20b0
movl %eax, -0x4c(%rbp)
movl $0x0, -0x2c(%rbp)
movl $0x0, -0x3c(%rbp)
movl $0x0, -0x38(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x4c(%rbp), %eax
jg 0xe3ce
cmpl $0x0, -0x14(%rbp)
jne 0xe2af
callq 0x2270
movq (%rax), %rax
movq -0x10(%rbp), %rcx
movslq -0x2c(%rbp), %rdx
movsbl (%rcx,%rdx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x2000, %eax           # imm = 0x2000
cmpl $0x0, %eax
jne 0xe1b3
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x0, %eax
jne 0xe282
callq 0x2270
movq (%rax), %rax
movslq -0x38(%rbp), %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x8000, %eax           # imm = 0x8000
cmpl $0x0, %eax
je 0xe280
jmp 0xe1d3
cmpq $0x0, -0x28(%rbp)
je 0xe273
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movb $0x0, (%rax,%rcx)
movl -0x30(%rbp), %eax
cmpl -0x34(%rbp), %eax
jne 0xe259
cmpl $0x0, -0x34(%rbp)
je 0xe202
movl -0x34(%rbp), %eax
shll %eax
movl %eax, -0x64(%rbp)
jmp 0xe20c
movl $0x2, %eax
movl %eax, -0x64(%rbp)
jmp 0xe20c
movl -0x64(%rbp), %eax
movl %eax, -0x34(%rbp)
movq -0x48(%rbp), %rdi
movslq -0x34(%rbp), %rsi
shlq $0x2, %rsi
callq 0x21c0
movq %rax, -0x58(%rbp)
cmpq $0x0, %rax
je 0xe237
movq -0x58(%rbp), %rax
movq %rax, -0x48(%rbp)
jmp 0xe257
movq -0x48(%rbp), %rdi
callq 0x2280
movq -0x28(%rbp), %rax
movq $0x0, (%rax)
movl $0x0, -0x4(%rbp)
jmp 0xe3e8
jmp 0xe259
movl -0x3c(%rbp), %edx
movq -0x48(%rbp), %rax
movl -0x30(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x30(%rbp)
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
jmp 0xe27c
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0xe27e
jmp 0xe280
jmp 0xe2aa
callq 0x2270
movq (%rax), %rax
movslq -0x38(%rbp), %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x2000, %eax           # imm = 0x2000
cmpl $0x0, %eax
jne 0xe2a2
cmpl $0x0, -0x38(%rbp)
jne 0xe2a8
movl -0x2c(%rbp), %eax
movl %eax, -0x3c(%rbp)
jmp 0xe2aa
jmp 0xe3b1
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl -0x14(%rbp), %eax
je 0xe2d5
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x0, %eax
jne 0xe399
cmpl $0x0, -0x38(%rbp)
je 0xe397
movl -0x38(%rbp), %eax
cmpl -0x14(%rbp), %eax
je 0xe397
jmp 0xe2ed
cmpq $0x0, -0x28(%rbp)
je 0xe38a
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movb $0x0, (%rax,%rcx)
movl -0x30(%rbp), %eax
cmpl -0x34(%rbp), %eax
jne 0xe370
cmpl $0x0, -0x34(%rbp)
je 0xe31c
movl -0x34(%rbp), %eax
shll %eax
movl %eax, -0x68(%rbp)
jmp 0xe326
movl $0x2, %eax
movl %eax, -0x68(%rbp)
jmp 0xe326
movl -0x68(%rbp), %eax
movl %eax, -0x34(%rbp)
movq -0x48(%rbp), %rdi
movslq -0x34(%rbp), %rsi
shlq $0x2, %rsi
callq 0x21c0
movq %rax, -0x60(%rbp)
cmpq $0x0, %rax
je 0xe351
movq -0x60(%rbp), %rax
movq %rax, -0x48(%rbp)
jmp 0xe36e
movq -0x48(%rbp), %rdi
callq 0x2280
movq -0x28(%rbp), %rax
movq $0x0, (%rax)
movl $0x0, -0x4(%rbp)
jmp 0xe3e8
jmp 0xe370
movl -0x3c(%rbp), %edx
movq -0x48(%rbp), %rax
movl -0x30(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x30(%rbp)
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
jmp 0xe393
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0xe395
jmp 0xe397
jmp 0xe3af
movl -0x38(%rbp), %eax
cmpl -0x14(%rbp), %eax
je 0xe3a7
cmpl $0x0, -0x38(%rbp)
jne 0xe3ad
movl -0x2c(%rbp), %eax
movl %eax, -0x3c(%rbp)
jmp 0xe3af
jmp 0xe3b1
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movsbl (%rax,%rcx), %eax
movl %eax, -0x38(%rbp)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0xe163
movl -0x34(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movq -0x48(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
movl -0x30(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)