// File: /workspace/github_c_makefile_star2_O0/ccxvii[P]mujs/./jsstring.c
// Function: Sp_split_regexp
static void Sp_split_regexp(js_State *J)
{
	js_Regexp *re;
	const char *text;
	int limit, len, k;
	const char *p, *a, *b, *c, *e;
	Resub m;

	text = checkstring(J, 0);
	re = js_toregexp(J, 1);
	limit = js_isdefined(J, 2) ? js_tointeger(J, 2) : 1 << 30;

	js_newarray(J);
	len = 0;

	if (limit == 0)
		return;

	e = text + strlen(text);

	/* splitting the empty string */
	if (e == text) {
		if (js_doregexec(J, re->prog, text, &m, 0)) {
			js_pushliteral(J, "");
			js_setindex(J, -2, 0);
		}
		return;
	}

	p = a = text;
	while (a < e) {
		if (js_doregexec(J, re->prog, a, &m, a > text ? REG_NOTBOL : 0))
			break; /* no match */

		b = m.sub[0].sp;
		c = m.sub[0].ep;

		/* empty string at end of last match */
		if (b == c && b == p) {
			++a;
			continue;
		}

		if (len == limit) return;
		js_pushlstring(J, p, b - p);
		js_setindex(J, -2, len++);

		for (k = 1; k < m.nsub; ++k) {
			if (len == limit) return;
			js_pushlstring(J, m.sub[k].sp, m.sub[k].ep - m.sub[k].sp);
			js_setindex(J, -2, len++);
		}

		a = p = c;
	}

	if (len == limit) return;
	js_pushstring(J, p);
	js_setindex(J, -2, len);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x170, %rsp            # imm = 0x170
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
xorl %esi, %esi
callq 0x2fae0
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15f20
movq %rax, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movl $0x2, %esi
callq 0x150d0
cmpl $0x0, %eax
je 0x306f9
movq -0x8(%rbp), %rdi
movl $0x2, %esi
callq 0x43c0
movl %eax, -0x15c(%rbp)
jmp 0x30706
movl $0x40000000, %eax       # imm = 0x40000000
movl %eax, -0x15c(%rbp)
jmp 0x30706
movl -0x15c(%rbp), %eax
movl %eax, -0x1c(%rbp)
movq -0x8(%rbp), %rdi
callq 0x13830
movl $0x0, -0x20(%rbp)
cmpl $0x0, -0x1c(%rbp)
jne 0x3072a
jmp 0x3094f
movq -0x18(%rbp), %rax
movq %rax, -0x168(%rbp)
movq -0x18(%rbp), %rdi
callq 0x31e0
movq %rax, %rcx
movq -0x168(%rbp), %rax
addq %rcx, %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
cmpq -0x18(%rbp), %rax
jne 0x307a1
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
movq -0x18(%rbp), %rdx
leaq -0x158(%rbp), %rcx
xorl %r8d, %r8d
callq 0x2fb30
cmpl $0x0, %eax
je 0x3079c
movq -0x8(%rbp), %rdi
leaq 0xc2b5(%rip), %rsi      # 0x3ca3c
callq 0x66d0
movq -0x8(%rbp), %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
xorl %edx, %edx
callq 0x13bb0
jmp 0x3094f
movq -0x18(%rbp), %rax
movq %rax, -0x38(%rbp)
movq %rax, -0x30(%rbp)
movq -0x38(%rbp), %rax
cmpq -0x50(%rbp), %rax
jae 0x30927
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
movq -0x38(%rbp), %rdx
movq -0x38(%rbp), %rcx
movq -0x18(%rbp), %r9
xorl %r8d, %r8d
movl $0x4, %eax
cmpq %r9, %rcx
cmoval %eax, %r8d
leaq -0x158(%rbp), %rcx
callq 0x2fb30
cmpl $0x0, %eax
je 0x307f7
jmp 0x30927
movq -0x150(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x148(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x40(%rbp), %rax
cmpq -0x48(%rbp), %rax
jne 0x30832
movq -0x40(%rbp), %rax
cmpq -0x30(%rbp), %rax
jne 0x30832
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x307ad
movl -0x20(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jne 0x3083f
jmp 0x3094f
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x40(%rbp), %rax
movq -0x30(%rbp), %rcx
subq %rcx, %rax
movl %eax, %edx
callq 0x13a70
movq -0x8(%rbp), %rdi
movl -0x20(%rbp), %edx
movl %edx, %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x13bb0
movl $0x1, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x158(%rbp), %eax
jge 0x30916
movl -0x20(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jne 0x30895
jmp 0x3094f
movq -0x8(%rbp), %rdi
leaq -0x158(%rbp), %rax
addq $0x8, %rax
movslq -0x24(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rsi
leaq -0x158(%rbp), %rax
addq $0x8, %rax
movslq -0x24(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
leaq -0x158(%rbp), %rcx
addq $0x8, %rcx
movslq -0x24(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
subq %rcx, %rax
movl %eax, %edx
callq 0x13a70
movq -0x8(%rbp), %rdi
movl -0x20(%rbp), %edx
movl %edx, %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x13bb0
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x30879
movq -0x48(%rbp), %rax
movq %rax, -0x30(%rbp)
movq %rax, -0x38(%rbp)
jmp 0x307ad
movl -0x20(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jne 0x30931
jmp 0x3094f
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x13880
movq -0x8(%rbp), %rdi
movl -0x20(%rbp), %edx
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x13bb0
addq $0x170, %rsp            # imm = 0x170
popq %rbp
retq
nopl (%rax,%rax)