// File: 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
movq %rsp, %rbp
subq $0x250, %rsp            # imm = 0x250
movq %rdi, -0x1c8(%rbp)
movq %rdi, %rax
movq %rax, -0x1c0(%rbp)
movq %rdi, -0x100(%rbp)
movq %rdx, -0x110(%rbp)
movq %rcx, -0x108(%rbp)
movq %rsi, -0x118(%rbp)
movq %r8, -0x120(%rbp)
movq -0x118(%rbp), %rax
movq %rax, -0x1b8(%rbp)
movb $0x0, -0x121(%rbp)
callq 0x27080
movq -0x1b8(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x1b0(%rbp)
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
callq 0x5cc0
movsbl %al, %eax
cmpl $0x0, %eax
jl 0x3ad71
movq -0x1b0(%rbp), %rax
movq %rax, -0x30(%rbp)
jmp 0x3ad7f
movq -0x1b0(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x1b8(%rbp), %rax
movq -0x30(%rbp), %rcx
movq %rcx, -0x130(%rbp)
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x1d0(%rbp)
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rdi
callq 0x5cc0
movsbl %al, %eax
cmpl $0x0, %eax
jl 0x3adc2
movq -0x1d0(%rbp), %rax
movq %rax, -0x48(%rbp)
jmp 0x3add0
movq -0x1d0(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x1b8(%rbp), %rax
movq -0x48(%rbp), %rcx
movq %rcx, -0x1e0(%rbp)
movq %rax, -0xb0(%rbp)
movq -0xb0(%rbp), %rax
movq %rax, -0x1d8(%rbp)
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rdi
callq 0x5cc0
movsbl %al, %eax
cmpl $0x0, %eax
jl 0x3ae37
movq -0x1d8(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
callq 0x5cc0
movsbl %al, %eax
xorl $0xf, %eax
movzbl %al, %eax
movl %eax, -0xa4(%rbp)
jmp 0x3ae47
movq -0x1d8(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0xa4(%rbp)
movq -0x1e0(%rbp), %rax
movl -0xa4(%rbp), %ecx
addq %rcx, %rax
movq %rax, -0x138(%rbp)
leaq -0x110(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
movq %rax, -0x1e8(%rbp)
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rdi
callq 0x5cc0
movsbl %al, %eax
cmpl $0x0, %eax
jl 0x3ae96
movq -0x1e8(%rbp), %rax
movq %rax, -0x60(%rbp)
jmp 0x3aea4
movq -0x1e8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
movq %rax, -0x140(%rbp)
leaq -0x110(%rbp), %rax
movq %rax, -0xc8(%rbp)
movq -0xc8(%rbp), %rax
movq %rax, -0x1f0(%rbp)
movq %rax, -0xb8(%rbp)
movq -0xb8(%rbp), %rdi
callq 0x5cc0
movsbl %al, %eax
cmpl $0x0, %eax
jl 0x3af0b
movq -0x1f0(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
callq 0x5cc0
movsbl %al, %eax
xorl $0xf, %eax
movzbl %al, %eax
movl %eax, -0xbc(%rbp)
jmp 0x3af1b
movq -0x1f0(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0xbc(%rbp)
movl -0xbc(%rbp), %eax
movq %rax, -0x148(%rbp)
movq $0x0, -0x150(%rbp)
movq -0x150(%rbp), %rax
cmpq -0x120(%rbp), %rax
jae 0x3b17d
movq -0x130(%rbp), %rax
addq -0x148(%rbp), %rax
cmpq -0x138(%rbp), %rax
jbe 0x3af63
jmp 0x3b17d
movq -0x138(%rbp), %rax
xorl %ecx, %ecx
subq -0x148(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x158(%rbp)
movq -0x158(%rbp), %rdi
movq -0x140(%rbp), %rsi
movq -0x148(%rbp), %rdx
callq 0x4100
cmpl $0x0, %eax
je 0x3afc5
movq -0x130(%rbp), %rax
cmpq -0x158(%rbp), %rax
jne 0x3afb1
jmp 0x3b17f
movq -0x158(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x158(%rbp)
jmp 0x3af7d
movq -0x1b8(%rbp), %rax
movq -0x138(%rbp), %rcx
movq -0x158(%rbp), %rdx
addq -0x148(%rbp), %rdx
subq %rdx, %rcx
movq %rcx, -0x208(%rbp)
movq -0x138(%rbp), %rcx
movq %rcx, -0x200(%rbp)
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rax
movq %rax, -0x1f8(%rbp)
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rdi
callq 0x5cc0
movsbl %al, %eax
cmpl $0x0, %eax
jl 0x3b02a
movq -0x1f8(%rbp), %rax
movq %rax, -0x78(%rbp)
jmp 0x3b038
movq -0x1f8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x78(%rbp)
movq -0x1b8(%rbp), %rax
movq -0x78(%rbp), %rcx
movq %rcx, -0x218(%rbp)
movq %rax, -0xe0(%rbp)
movq -0xe0(%rbp), %rax
movq %rax, -0x210(%rbp)
movq %rax, -0xd0(%rbp)
movq -0xd0(%rbp), %rdi
callq 0x5cc0
movsbl %al, %eax
cmpl $0x0, %eax
jl 0x3b09f
movq -0x210(%rbp), %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rdi
callq 0x5cc0
movsbl %al, %eax
xorl $0xf, %eax
movzbl %al, %eax
movl %eax, -0xd4(%rbp)
jmp 0x3b0af
movq -0x210(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0xd4(%rbp)
movq -0x200(%rbp), %rax
movq -0x218(%rbp), %rcx
movl -0xd4(%rbp), %edx
addq %rdx, %rcx
cmpq %rcx, %rax
jne 0x3b0d6
xorl %eax, %eax
movq %rax, -0x220(%rbp)
jmp 0x3b0e4
movq -0x148(%rbp), %rax
movq %rax, -0x220(%rbp)
movq -0x208(%rbp), %rax
movq -0x220(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x160(%rbp)
cmpq $0x0, -0x160(%rbp)
je 0x3b158
movq -0x158(%rbp), %rsi
addq -0x148(%rbp), %rsi
movq -0x160(%rbp), %rdx
leaq -0x180(%rbp), %rdi
callq 0x5d70
movq -0x180(%rbp), %rsi
movq -0x178(%rbp), %rdx
leaq -0x170(%rbp), %rdi
callq 0x2ac10
movq -0x1c8(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
leaq -0x170(%rbp), %rdx
callq 0x26600
movq -0x150(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x150(%rbp)
movq -0x158(%rbp), %rax
movq %rax, -0x138(%rbp)
jmp 0x3af33
jmp 0x3b17f
movq -0x1b8(%rbp), %rax
movq -0x138(%rbp), %rcx
movq -0x130(%rbp), %rdx
subq %rdx, %rcx
movq %rcx, -0x238(%rbp)
movq -0x138(%rbp), %rcx
movq %rcx, -0x230(%rbp)
movq %rax, -0x98(%rbp)
movq -0x98(%rbp), %rax
movq %rax, -0x228(%rbp)
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rdi
callq 0x5cc0
movsbl %al, %eax
cmpl $0x0, %eax
jl 0x3b1ec
movq -0x228(%rbp), %rax
movq %rax, -0x90(%rbp)
jmp 0x3b1fd
movq -0x228(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x90(%rbp)
movq -0x1b8(%rbp), %rax
movq -0x90(%rbp), %rcx
movq %rcx, -0x248(%rbp)
movq %rax, -0xf8(%rbp)
movq -0xf8(%rbp), %rax
movq %rax, -0x240(%rbp)
movq %rax, -0xe8(%rbp)
movq -0xe8(%rbp), %rdi
callq 0x5cc0
movsbl %al, %eax
cmpl $0x0, %eax
jl 0x3b267
movq -0x240(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rdi
callq 0x5cc0
movsbl %al, %eax
xorl $0xf, %eax
movzbl %al, %eax
movl %eax, -0xec(%rbp)
jmp 0x3b277
movq -0x240(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0xec(%rbp)
movq -0x230(%rbp), %rax
movq -0x248(%rbp), %rcx
movl -0xec(%rbp), %edx
addq %rdx, %rcx
cmpq %rcx, %rax
jne 0x3b29e
xorl %eax, %eax
movq %rax, -0x250(%rbp)
jmp 0x3b2ac
movq -0x148(%rbp), %rax
movq %rax, -0x250(%rbp)
movq -0x238(%rbp), %rax
movq -0x250(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x188(%rbp)
cmpq $0x0, -0x188(%rbp)
je 0x3b319
movq -0x130(%rbp), %rsi
movq -0x188(%rbp), %rdx
leaq -0x1a8(%rbp), %rdi
callq 0x5d70
movq -0x1a8(%rbp), %rsi
movq -0x1a0(%rbp), %rdx
leaq -0x198(%rbp), %rdi
callq 0x2ac10
movq -0x1c8(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
leaq -0x198(%rbp), %rdx
callq 0x26600
movb $0x1, -0x121(%rbp)
testb $0x1, -0x121(%rbp)
jne 0x3b335
movq -0x1c8(%rbp), %rdi
callq 0x26f60
movq -0x1c0(%rbp), %rax
addq $0x250, %rsp            # imm = 0x250
popq %rbp
retq
nopw %cs:(%rax,%rax)