// File: /workspace/github_c_makefile_star2_O3/ArtifexSoftware[P]mujs/./jsstring.c
// Function: Sp_match
static void Sp_match(js_State *J)
{
	js_Regexp *re;
	const char *text;
	int len;
	const char *a, *b, *c, *e;
	Resub m;

	text = checkstring(J, 0);

	if (js_isregexp(J, 1))
		js_copy(J, 1);
	else if (js_isundefined(J, 1))
		js_newregexp(J, "", 0);
	else
		js_newregexp(J, js_tostring(J, 1), 0);

	re = js_toregexp(J, -1);
	if (!(re->flags & JS_REGEXP_G)) {
		js_RegExp_prototype_exec(J, re, text);
		return;
	}

	re->last = 0;

	js_newarray(J);

	len = 0;
	a = text;
	e = text + strlen(text);
	while (a <= e) {
		if (js_doregexec(J, re->prog, a, &m, a > text ? REG_NOTBOL : 0))
			break;

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

		js_pushlstring(J, b, c - b);
		js_setindex(J, -2, len++);

		a = c;
		if (c - b == 0)
			++a;
	}

	if (len == 0) {
		js_pop(J, 1);
		js_pushnull(J);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movq %rdi, %rbx
callq 0x28e6e
movq %rax, (%rsp)
movl 0x144(%rbx), %ecx
leal 0x1(%rcx), %eax
leaq 0x27b40(%rip), %rdx     # 0x403f8
cmpl $-0x1, %ecx
jl 0x188d2
cmpl 0x140(%rbx), %eax
jge 0x188d2
movl %eax, %edx
shlq $0x4, %rdx
addq 0x148(%rbx), %rdx
cmpb $0x7, 0xf(%rdx)
jne 0x188ef
movq (%rdx), %rdx
cmpl $0x9, (%rdx)
jne 0x188ef
movq %rbx, %rdi
movl $0x1, %esi
callq 0x13c1a
jmp 0x18953
cmpl $-0x1, %ecx
jl 0x18920
cmpl 0x140(%rbx), %eax
jge 0x18920
movq 0x148(%rbx), %rcx
movl %eax, %esi
movq %rsi, %rax
shlq $0x4, %rax
cmpb $0x1, 0xf(%rcx,%rax)
je 0x18929
shlq $0x4, %rsi
addq 0x148(%rbx), %rsi
jmp 0x1893c
cmpb $0x1, 0x27ae0(%rip)     # 0x40407
jne 0x18935
leaq 0x1ba86(%rip), %rsi     # 0x343b6
movq %rbx, %rdi
jmp 0x1894a
leaq 0x27abc(%rip), %rsi     # 0x403f8
movq %rbx, %rdi
callq 0x14e64
movq %rbx, %rdi
movq %rax, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x12e00
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x1524a
movq %rax, %r15
testb $0x1, 0x10(%rax)
jne 0x18989
movq %rbx, %rdi
movq %r15, %rsi
movq (%rsp), %rdx
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x12f64
movw $0x0, 0x12(%r15)
movq %rbx, %rdi
callq 0x1318e
movq (%rsp), %rdi
callq 0x3200
movq %rax, 0x8(%rsp)
testq %rax, %rax
js 0x18a22
movq (%rsp), %rdx
addq %rdx, 0x8(%rsp)
xorl %ebp, %ebp
movq (%r15), %rsi
xorl %r8d, %r8d
cmpq (%rsp), %rdx
seta %r8b
shll $0x2, %r8d
movq %rbx, %rdi
leaq 0x10(%rsp), %rcx
callq 0x28ed6
testl %eax, %eax
jne 0x18a1e
movq 0x18(%rsp), %r13
movq 0x20(%rsp), %r14
movl %r14d, %edx
subl %r13d, %edx
movq %rbx, %rdi
movq %r13, %rsi
callq 0x133b3
leal 0x1(%rbp), %r12d
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
movl %ebp, %edx
callq 0x134ed
xorl %edx, %edx
cmpq %r13, %r14
sete %dl
addq %r14, %rdx
movl %r12d, %ebp
cmpq 0x8(%rsp), %rdx
jbe 0x189b6
jmp 0x18a43
testl %ebp, %ebp
jne 0x18a43
movl 0x140(%rbx), %ecx
movl 0x144(%rbx), %eax
leal -0x1(%rcx), %edx
movl %edx, 0x140(%rbx)
cmpl %eax, %ecx
jle 0x18a55
movq %rbx, %rdi
callq 0x130d5
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %eax, 0x140(%rbx)
leaq 0x1ad3c(%rip), %rsi     # 0x3379e
movq %rbx, %rdi
xorl %eax, %eax
callq 0xc666