// File: Alcaro[P]bridges/arlib/string.cpp
// Function: cstring::cspliti(cstring, unsigned long) const
array<cstring> cstring::cspliti(cstring sep, size_t limit) const
{
	array<cstring> ret;
	const uint8_t * data = ptr();
	const uint8_t * dataend = ptr()+length();
	
	while (ret.size() < limit)
	{
		const uint8_t * next = (uint8_t*)memmem(data, dataend-data, sep.ptr(), sep.length());
		if (!next) break;
		ret.append(arrayview<uint8_t>(data, next-data+sep.length()));
		data = next+sep.length();
	}
	if (dataend != data)
		ret.append(arrayview<uint8_t>(data, dataend-data));
	return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1e0, %rsp            # imm = 0x1E0
movq %rdi, -0x170(%rbp)
movq %rdi, %rax
movq %rax, -0x168(%rbp)
movq %rdi, -0xd0(%rbp)
movq %rdx, -0xe0(%rbp)
movq %rcx, -0xd8(%rbp)
movq %rsi, -0xe8(%rbp)
movq %r8, -0xf0(%rbp)
movq -0xe8(%rbp), %rax
movq %rax, -0x160(%rbp)
movb $0x0, -0xf1(%rbp)
callq 0x27080
movq -0x160(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x158(%rbp)
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
callq 0x5cc0
movsbl %al, %eax
cmpl $0x0, %eax
jl 0x3a8c1
movq -0x158(%rbp), %rax
movq %rax, -0x30(%rbp)
jmp 0x3a8cf
movq -0x158(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x160(%rbp), %rax
movq -0x30(%rbp), %rcx
movq %rcx, -0x100(%rbp)
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x178(%rbp)
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rdi
callq 0x5cc0
movsbl %al, %eax
cmpl $0x0, %eax
jl 0x3a912
movq -0x178(%rbp), %rax
movq %rax, -0x48(%rbp)
jmp 0x3a920
movq -0x178(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x160(%rbp), %rax
movq -0x48(%rbp), %rcx
movq %rcx, -0x188(%rbp)
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rax
movq %rax, -0x180(%rbp)
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rdi
callq 0x5cc0
movsbl %al, %eax
cmpl $0x0, %eax
jl 0x3a978
movq -0x180(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
callq 0x5cc0
movsbl %al, %eax
xorl $0xf, %eax
movzbl %al, %eax
movl %eax, -0x74(%rbp)
jmp 0x3a985
movq -0x180(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x74(%rbp)
movq -0x188(%rbp), %rax
movl -0x74(%rbp), %ecx
addq %rcx, %rax
movq %rax, -0x108(%rbp)
movq -0x170(%rbp), %rdi
callq 0x12a40
cmpq -0xf0(%rbp), %rax
jae 0x3ac45
movq -0x100(%rbp), %rax
movq %rax, -0x1a0(%rbp)
movq -0x108(%rbp), %rax
movq -0x100(%rbp), %rcx
subq %rcx, %rax
movq %rax, -0x198(%rbp)
leaq -0xe0(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
movq %rax, -0x190(%rbp)
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rdi
callq 0x5cc0
movsbl %al, %eax
cmpl $0x0, %eax
jl 0x3aa10
movq -0x190(%rbp), %rax
movq %rax, -0x60(%rbp)
jmp 0x3aa1e
movq -0x190(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
movq %rax, -0x1b0(%rbp)
leaq -0xe0(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x98(%rbp), %rax
movq %rax, -0x1a8(%rbp)
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rdi
callq 0x5cc0
movsbl %al, %eax
cmpl $0x0, %eax
jl 0x3aa85
movq -0x1a8(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
callq 0x5cc0
movsbl %al, %eax
xorl $0xf, %eax
movzbl %al, %eax
movl %eax, -0x8c(%rbp)
jmp 0x3aa95
movq -0x1a8(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x8c(%rbp)
movq -0x1b0(%rbp), %rdx
movq -0x198(%rbp), %rsi
movq -0x1a0(%rbp), %rdi
movl -0x8c(%rbp), %eax
movl %eax, %ecx
callq 0x2d1d0
movq %rax, -0x110(%rbp)
cmpq $0x0, -0x110(%rbp)
jne 0x3aacd
jmp 0x3ac45
movq -0x100(%rbp), %rax
movq %rax, -0x1c8(%rbp)
movq -0x110(%rbp), %rax
movq -0x100(%rbp), %rcx
subq %rcx, %rax
movq %rax, -0x1c0(%rbp)
leaq -0xe0(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq -0xb0(%rbp), %rax
movq %rax, -0x1b8(%rbp)
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rdi
callq 0x5cc0
movsbl %al, %eax
cmpl $0x0, %eax
jl 0x3ab4f
movq -0x1b8(%rbp), %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rdi
callq 0x5cc0
movsbl %al, %eax
xorl $0xf, %eax
movzbl %al, %eax
movl %eax, -0xa4(%rbp)
jmp 0x3ab5f
movq -0x1b8(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0xa4(%rbp)
movq -0x1c8(%rbp), %rsi
movq -0x1c0(%rbp), %rdx
movl -0xa4(%rbp), %eax
addq %rax, %rdx
leaq -0x130(%rbp), %rdi
callq 0x5d70
movq -0x130(%rbp), %rsi
movq -0x128(%rbp), %rdx
leaq -0x120(%rbp), %rdi
callq 0x2ac10
movq -0x170(%rbp), %rdi
leaq -0x120(%rbp), %rsi
callq 0x267f0
movq -0x110(%rbp), %rax
movq %rax, -0x1d8(%rbp)
leaq -0xe0(%rbp), %rax
movq %rax, -0xc8(%rbp)
movq -0xc8(%rbp), %rax
movq %rax, -0x1d0(%rbp)
movq %rax, -0xb8(%rbp)
movq -0xb8(%rbp), %rdi
callq 0x5cc0
movsbl %al, %eax
cmpl $0x0, %eax
jl 0x3ac19
movq -0x1d0(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rdi
callq 0x5cc0
movsbl %al, %eax
xorl $0xf, %eax
movzbl %al, %eax
movl %eax, -0xbc(%rbp)
jmp 0x3ac29
movq -0x1d0(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0xbc(%rbp)
movq -0x1d8(%rbp), %rax
movl -0xbc(%rbp), %ecx
addq %rcx, %rax
movq %rax, -0x100(%rbp)
jmp 0x3a999
movq -0x108(%rbp), %rax
cmpq -0x100(%rbp), %rax
je 0x3aca6
movq -0x100(%rbp), %rsi
movq -0x108(%rbp), %rdx
movq -0x100(%rbp), %rax
subq %rax, %rdx
leaq -0x150(%rbp), %rdi
callq 0x5d70
movq -0x150(%rbp), %rsi
movq -0x148(%rbp), %rdx
leaq -0x140(%rbp), %rdi
callq 0x2ac10
movq -0x170(%rbp), %rdi
leaq -0x140(%rbp), %rsi
callq 0x267f0
movb $0x1, -0xf1(%rbp)
testb $0x1, -0xf1(%rbp)
jne 0x3acc2
movq -0x170(%rbp), %rdi
callq 0x26f60
movq -0x168(%rbp), %rax
addq $0x1e0, %rsp            # imm = 0x1E0
popq %rbp
retq
nopw %cs:(%rax,%rax)