// File: Alcaro[P]bridges/arlib/string.cpp
// Function: cstring::csplit(cstring, unsigned long) const
array<cstring> cstring::csplit(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));
		data = next+sep.length();
	}
	ret.append(arrayview<uint8_t>(data, dataend-data));
	return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1a0, %rsp            # imm = 0x1A0
movq %rdi, -0x150(%rbp)
movq %rdi, %rax
movq %rax, -0x148(%rbp)
movq %rdi, -0xb0(%rbp)
movq %rdx, -0xc0(%rbp)
movq %rcx, -0xb8(%rbp)
movq %rsi, -0xc8(%rbp)
movq %r8, -0xd0(%rbp)
movq -0xc8(%rbp), %rax
movq %rax, -0x140(%rbp)
movb $0x0, -0xd1(%rbp)
callq 0x27080
movq -0x140(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x138(%rbp)
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
callq 0x5cc0
movsbl %al, %eax
cmpl $0x0, %eax
jl 0x3a101
movq -0x138(%rbp), %rax
movq %rax, -0x28(%rbp)
jmp 0x3a10f
movq -0x138(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x140(%rbp), %rax
movq -0x28(%rbp), %rcx
movq %rcx, -0xe0(%rbp)
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x158(%rbp)
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
callq 0x5cc0
movsbl %al, %eax
cmpl $0x0, %eax
jl 0x3a152
movq -0x158(%rbp), %rax
movq %rax, -0x40(%rbp)
jmp 0x3a160
movq -0x158(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x140(%rbp), %rax
movq -0x40(%rbp), %rcx
movq %rcx, -0x168(%rbp)
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rax
movq %rax, -0x160(%rbp)
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rdi
callq 0x5cc0
movsbl %al, %eax
cmpl $0x0, %eax
jl 0x3a1b8
movq -0x160(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
callq 0x5cc0
movsbl %al, %eax
xorl $0xf, %eax
movzbl %al, %eax
movl %eax, -0x6c(%rbp)
jmp 0x3a1c5
movq -0x160(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x6c(%rbp)
movq -0x168(%rbp), %rax
movl -0x6c(%rbp), %ecx
addq %rcx, %rax
movq %rax, -0xe8(%rbp)
movq -0x150(%rbp), %rdi
callq 0x12a40
cmpq -0xd0(%rbp), %rax
jae 0x3a3ee
movq -0xe0(%rbp), %rax
movq %rax, -0x180(%rbp)
movq -0xe8(%rbp), %rax
movq -0xe0(%rbp), %rcx
subq %rcx, %rax
movq %rax, -0x178(%rbp)
leaq -0xc0(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
movq %rax, -0x170(%rbp)
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rdi
callq 0x5cc0
movsbl %al, %eax
cmpl $0x0, %eax
jl 0x3a250
movq -0x170(%rbp), %rax
movq %rax, -0x58(%rbp)
jmp 0x3a25e
movq -0x170(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
movq %rax, -0x190(%rbp)
leaq -0xc0(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rax
movq %rax, -0x188(%rbp)
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rdi
callq 0x5cc0
movsbl %al, %eax
cmpl $0x0, %eax
jl 0x3a2bf
movq -0x188(%rbp), %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rdi
callq 0x5cc0
movsbl %al, %eax
xorl $0xf, %eax
movzbl %al, %eax
movl %eax, -0x84(%rbp)
jmp 0x3a2cf
movq -0x188(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x84(%rbp)
movq -0x190(%rbp), %rdx
movq -0x178(%rbp), %rsi
movq -0x180(%rbp), %rdi
movl -0x84(%rbp), %eax
movl %eax, %ecx
callq 0x2d1d0
movq %rax, -0xf0(%rbp)
cmpq $0x0, -0xf0(%rbp)
jne 0x3a307
jmp 0x3a3ee
movq -0xe0(%rbp), %rsi
movq -0xf0(%rbp), %rdx
movq -0xe0(%rbp), %rax
subq %rax, %rdx
leaq -0x110(%rbp), %rdi
callq 0x5d70
movq -0x110(%rbp), %rsi
movq -0x108(%rbp), %rdx
leaq -0x100(%rbp), %rdi
callq 0x2ac10
movq -0x150(%rbp), %rdi
leaq -0x100(%rbp), %rsi
callq 0x267f0
movq -0xf0(%rbp), %rax
movq %rax, -0x1a0(%rbp)
leaq -0xc0(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0xa8(%rbp), %rax
movq %rax, -0x198(%rbp)
movq %rax, -0x98(%rbp)
movq -0x98(%rbp), %rdi
callq 0x5cc0
movsbl %al, %eax
cmpl $0x0, %eax
jl 0x3a3c2
movq -0x198(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rdi
callq 0x5cc0
movsbl %al, %eax
xorl $0xf, %eax
movzbl %al, %eax
movl %eax, -0x9c(%rbp)
jmp 0x3a3d2
movq -0x198(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x9c(%rbp)
movq -0x1a0(%rbp), %rax
movl -0x9c(%rbp), %ecx
addq %rcx, %rax
movq %rax, -0xe0(%rbp)
jmp 0x3a1d9
movq -0xe0(%rbp), %rsi
movq -0xe8(%rbp), %rdx
movq -0xe0(%rbp), %rax
subq %rax, %rdx
leaq -0x130(%rbp), %rdi
callq 0x5d70
movq -0x130(%rbp), %rsi
movq -0x128(%rbp), %rdx
leaq -0x120(%rbp), %rdi
callq 0x2ac10
movq -0x150(%rbp), %rdi
leaq -0x120(%rbp), %rsi
callq 0x267f0
movb $0x1, -0xd1(%rbp)
testb $0x1, -0xd1(%rbp)
jne 0x3a45b
movq -0x150(%rbp), %rdi
callq 0x26f60
movq -0x148(%rbp), %rax
addq $0x1a0, %rsp            # imm = 0x1A0
popq %rbp
retq
nopl (%rax,%rax)