// File: /workspace/github_cpp_makefile_star2_O1/Alcaro[P]bridges/arlib/string.cpp
// Function: cstring::crspliti(cstring, unsigned long) const
array<cstring> cstring::crspliti(cstring sep, size_t limit) const
{
	array<cstring> ret;
	const uint8_t * datastart = ptr();
	const uint8_t * data = ptr()+length();
	
	const uint8_t * sepp = sep.ptr();
	size_t sepl = sep.length();
	
	size_t outlen = 0;
	while (outlen < limit)
	{
		if (datastart+sepl > data) break;
		const uint8_t * next = data-sepl;
		while (memcmp(next, sepp, sepl) != 0)
		{
			if (datastart==next) goto done;
			next--;
		}
		size_t len = data - (next+sepl) + (data == ptr()+length() ? 0 : sepl);
		if (len)
			ret.insert(0, arrayview<uint8_t>(next+sepl, len));
		outlen++;
		data = next;
	}
done:
	size_t len = data - datastart + (data == ptr()+length() ? 0 : sepl);
	if (len)
		ret.insert(0, arrayview<uint8_t>(datastart, len));
	return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdx, %r13
movq %rsi, %r15
leaq 0x48(%rsp), %rax
movq %rdx, (%rax)
movq %rcx, 0x8(%rax)
xorps %xmm0, %xmm0
movq %rdi, (%rsp)
movups %xmm0, (%rdi)
movzbl 0xf(%rsi), %ecx
movl %ecx, %ebx
xorl $0xf, %ebx
testb %cl, %cl
movq (%rsi), %r14
cmovnsq %rsi, %r14
cmovsl 0x8(%rsi), %ebx
movq %r8, 0x30(%rsp)
addq %r14, %rbx
movzbl 0xf(%rax), %ecx
movl %ecx, %r12d
xorl $0xf, %r12d
testb %cl, %cl
cmovnsq %rax, %r13
cmovsl 0x8(%rax), %r12d
leaq (%r14,%r12), %rax
movq %rax, 0x28(%rsp)
movq %r12, %rax
negq %rax
movq %rax, 0x20(%rsp)
xorl %ecx, %ecx
cmpq 0x30(%rsp), %rcx
jae 0x1a26a
cmpq %rbx, 0x28(%rsp)
ja 0x1a26a
movq %rcx, 0x8(%rsp)
movq 0x20(%rsp), %rax
leaq (%rbx,%rax), %rbp
movq %rbp, %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0x3380
testl %eax, %eax
je 0x1a1be
cmpq %r14, %rbp
je 0x1a24f
decq %rbp
jmp 0x1a19e
leaq (%r12,%rbp), %rsi
movq %rbx, %rax
subq %rsi, %rax
movzbl 0xf(%r15), %ecx
movl %ecx, %edx
xorl $0xf, %edx
testb %cl, %cl
movq (%r15), %rcx
cmovsl 0x8(%r15), %edx
cmovnsq %r15, %rcx
addq %rcx, %rdx
cmpq %rdx, %rbx
movl $0x0, %edx
cmovneq %r12, %rdx
addq %rax, %rdx
je 0x1a240
leaq 0x38(%rsp), %rdi
xorl %ecx, %ecx
callq 0x5040
movups 0x38(%rsp), %xmm0
movaps %xmm0, 0x10(%rsp)
movq (%rsp), %rbx
movq 0x8(%rbx), %rsi
incq %rsi
movq %rbx, %rdi
callq 0x124e8
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
leaq 0x10(%rsi), %rdi
shlq $0x4, %rdx
addq $-0x10, %rdx
callq 0x3600
movq (%rbx), %rax
movaps 0x10(%rsp), %xmm0
movups %xmm0, (%rax)
movq 0x8(%rsp), %rcx
incq %rcx
xorl %eax, %eax
movq %rbp, %rbx
jmp 0x1a259
movl $0x6, %eax
movq 0x8(%rsp), %rcx
testl %eax, %eax
je 0x1a17a
cmpl $0x6, %eax
jne 0x1a2ef
movq %rbx, %rax
subq %r14, %rax
movzbl 0xf(%r15), %ecx
movl %ecx, %edx
xorl $0xf, %edx
testb %cl, %cl
movq (%r15), %rcx
cmovsl 0x8(%r15), %edx
cmovnsq %r15, %rcx
addq %rcx, %rdx
xorl %ecx, %ecx
cmpq %rdx, %rbx
cmoveq %rcx, %r12
addq %rax, %r12
movq (%rsp), %rbx
je 0x1a2fb
leaq 0x38(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
movq %r12, %rdx
xorl %ecx, %ecx
callq 0x5040
movups (%r15), %xmm0
movaps %xmm0, 0x10(%rsp)
movq 0x8(%rbx), %rsi
incq %rsi
movq %rbx, %rdi
callq 0x124e8
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
leaq 0x10(%rsi), %rdi
shlq $0x4, %rdx
addq $-0x10, %rdx
callq 0x3600
movq (%rbx), %rax
movaps 0x10(%rsp), %xmm0
movups %xmm0, (%rax)
jmp 0x1a2fb
movq (%rsp), %rbx
movq (%rbx), %rdi
callq 0x3430
movq %rbx, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop