// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/external/samtools-0.1.18/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) {												\
				max = max? max<<1 : 2;									\
				offsets = (int*)realloc(offsets, sizeof(int) * max);	\
			}															\
			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:
subq $0x58, %rsp
movq %rdi, 0x50(%rsp)
movl %esi, 0x4c(%rsp)
movq %rdx, 0x40(%rsp)
movq %rcx, 0x38(%rsp)
movl $0x0, 0x30(%rsp)
movq 0x40(%rsp), %rax
movl (%rax), %eax
movl %eax, 0x2c(%rsp)
movq 0x38(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x18(%rsp)
movq 0x50(%rsp), %rdi
callq 0x192b0
movl %eax, 0x14(%rsp)
movl $0x0, 0x34(%rsp)
movl $0x0, 0x24(%rsp)
movl $0x0, 0x28(%rsp)
movl 0x34(%rsp), %eax
cmpl 0x14(%rsp), %eax
jg 0x4f9555
cmpl $0x0, 0x4c(%rsp)
jne 0x4f9443
callq 0x197c0
movq (%rax), %rax
movq 0x50(%rsp), %rcx
movslq 0x34(%rsp), %rdx
movsbl (%rcx,%rdx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x2000, %eax           # imm = 0x2000
cmpl $0x0, %eax
jne 0x4f9364
movq 0x50(%rsp), %rax
movslq 0x34(%rsp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x0, %eax
jne 0x4f9412
callq 0x197c0
movq (%rax), %rax
movslq 0x28(%rsp), %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x8000, %eax           # imm = 0x8000
cmpl $0x0, %eax
je 0x4f9410
jmp 0x4f9385
cmpq $0x0, 0x38(%rsp)
je 0x4f9401
movq 0x50(%rsp), %rax
movslq 0x34(%rsp), %rcx
movb $0x0, (%rax,%rcx)
movl 0x30(%rsp), %eax
cmpl 0x2c(%rsp), %eax
jne 0x4f93e3
cmpl $0x0, 0x2c(%rsp)
je 0x4f93b8
movl 0x2c(%rsp), %eax
shll %eax
movl %eax, 0x10(%rsp)
jmp 0x4f93c3
movl $0x2, %eax
movl %eax, 0x10(%rsp)
jmp 0x4f93c3
movl 0x10(%rsp), %eax
movl %eax, 0x2c(%rsp)
movq 0x18(%rsp), %rdi
movslq 0x2c(%rsp), %rsi
shlq $0x2, %rsi
callq 0x19f00
movq %rax, 0x18(%rsp)
movl 0x24(%rsp), %edx
movq 0x18(%rsp), %rax
movl 0x30(%rsp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, 0x30(%rsp)
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
jmp 0x4f940c
movl 0x30(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x30(%rsp)
jmp 0x4f940e
jmp 0x4f9410
jmp 0x4f943e
callq 0x197c0
movq (%rax), %rax
movslq 0x28(%rsp), %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x2000, %eax           # imm = 0x2000
cmpl $0x0, %eax
jne 0x4f9434
cmpl $0x0, 0x28(%rsp)
jne 0x4f943c
movl 0x34(%rsp), %eax
movl %eax, 0x24(%rsp)
jmp 0x4f943e
jmp 0x4f9533
movq 0x50(%rsp), %rax
movslq 0x34(%rsp), %rcx
movsbl (%rax,%rcx), %eax
cmpl 0x4c(%rsp), %eax
je 0x4f946e
movq 0x50(%rsp), %rax
movslq 0x34(%rsp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x0, %eax
jne 0x4f9516
cmpl $0x0, 0x28(%rsp)
je 0x4f9514
movl 0x28(%rsp), %eax
cmpl 0x4c(%rsp), %eax
je 0x4f9514
jmp 0x4f9489
cmpq $0x0, 0x38(%rsp)
je 0x4f9505
movq 0x50(%rsp), %rax
movslq 0x34(%rsp), %rcx
movb $0x0, (%rax,%rcx)
movl 0x30(%rsp), %eax
cmpl 0x2c(%rsp), %eax
jne 0x4f94e7
cmpl $0x0, 0x2c(%rsp)
je 0x4f94bc
movl 0x2c(%rsp), %eax
shll %eax
movl %eax, 0xc(%rsp)
jmp 0x4f94c7
movl $0x2, %eax
movl %eax, 0xc(%rsp)
jmp 0x4f94c7
movl 0xc(%rsp), %eax
movl %eax, 0x2c(%rsp)
movq 0x18(%rsp), %rdi
movslq 0x2c(%rsp), %rsi
shlq $0x2, %rsi
callq 0x19f00
movq %rax, 0x18(%rsp)
movl 0x24(%rsp), %edx
movq 0x18(%rsp), %rax
movl 0x30(%rsp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, 0x30(%rsp)
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
jmp 0x4f9510
movl 0x30(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x30(%rsp)
jmp 0x4f9512
jmp 0x4f9514
jmp 0x4f9531
movl 0x28(%rsp), %eax
cmpl 0x4c(%rsp), %eax
je 0x4f9527
cmpl $0x0, 0x28(%rsp)
jne 0x4f952f
movl 0x34(%rsp), %eax
movl %eax, 0x24(%rsp)
jmp 0x4f9531
jmp 0x4f9533
movq 0x50(%rsp), %rax
movslq 0x34(%rsp), %rcx
movsbl (%rax,%rcx), %eax
movl %eax, 0x28(%rsp)
movl 0x34(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x34(%rsp)
jmp 0x4f930d
movl 0x2c(%rsp), %ecx
movq 0x40(%rsp), %rax
movl %ecx, (%rax)
movq 0x18(%rsp), %rcx
movq 0x38(%rsp), %rax
movq %rcx, (%rax)
movl 0x30(%rsp), %eax
addq $0x58, %rsp
retq
nopw %cs:(%rax,%rax)