// File: /workspace/github_c_makefile_star2_O3/ArtifexSoftware[P]mujs/./jsregexp.c
// Function: jsB_new_RegExp
static void jsB_new_RegExp(js_State *J)
{
	js_Regexp *old;
	const char *pattern;
	int flags;
	int is_clone = 0;

	if (js_isregexp(J, 1)) {
		if (js_isdefined(J, 2))
			js_typeerror(J, "cannot supply flags when creating one RegExp from another");
		old = js_toregexp(J, 1);
		pattern = old->source;
		flags = old->flags;
		is_clone = 1;
	} else if (js_isundefined(J, 1)) {
		pattern = "(?:)";
		flags = 0;
	} else {
		pattern = js_tostring(J, 1);
		flags = 0;
	}

	if (strlen(pattern) == 0)
		pattern = "(?:)";

	if (js_isdefined(J, 2)) {
		const char *s = js_tostring(J, 2);
		int g = 0, i = 0, m = 0;
		while (*s) {
			if (*s == 'g') ++g;
			else if (*s == 'i') ++i;
			else if (*s == 'm') ++m;
			else js_syntaxerror(J, "invalid regular expression flag: '%c'", *s);
			++s;
		}
		if (g > 1) js_syntaxerror(J, "invalid regular expression flag: 'g'");
		if (i > 1) js_syntaxerror(J, "invalid regular expression flag: 'i'");
		if (m > 1) js_syntaxerror(J, "invalid regular expression flag: 'm'");
		if (g) flags |= JS_REGEXP_G;
		if (i) flags |= JS_REGEXP_I;
		if (m) flags |= JS_REGEXP_M;
	}

	js_newregexpx(J, pattern, flags, is_clone);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdi, %rbx
movl 0x144(%rdi), %eax
leal 0x1(%rax), %ecx
leaq 0x2cb76(%rip), %rdx     # 0x403f8
cmpl $-0x1, %eax
jl 0x1389c
cmpl 0x140(%rbx), %ecx
jge 0x1389c
movl %ecx, %edx
shlq $0x4, %rdx
addq 0x148(%rbx), %rdx
cmpb $0x7, 0xf(%rdx)
jne 0x138f5
movq (%rdx), %rdx
cmpl $0x9, (%rdx)
jne 0x138f5
leaq 0x2cb47(%rip), %rcx     # 0x403f8
cmpl $-0x2, %eax
jl 0x138ce
addl $0x2, %eax
cmpl 0x140(%rbx), %eax
jge 0x138ce
movl %eax, %ecx
shlq $0x4, %rcx
addq 0x148(%rbx), %rcx
cmpb $0x1, 0xf(%rcx)
jne 0x13a64
movl $0x1, %r15d
movq %rbx, %rdi
movl $0x1, %esi
callq 0x1524a
movq 0x8(%rax), %r14
movzwl 0x10(%rax), %ebp
jmp 0x13951
cmpl $-0x1, %eax
jl 0x13926
cmpl 0x140(%rbx), %ecx
jge 0x13926
movq 0x148(%rbx), %rax
movl %ecx, %esi
movq %rsi, %rcx
shlq $0x4, %rcx
cmpb $0x1, 0xf(%rax,%rcx)
je 0x1392f
shlq $0x4, %rsi
addq 0x148(%rbx), %rsi
jmp 0x13941
cmpb $0x1, 0x2cada(%rip)     # 0x40407
jne 0x1393a
xorl %ebp, %ebp
leaq 0x1f31a(%rip), %r14     # 0x32c52
jmp 0x1394e
leaq 0x2cab7(%rip), %rsi     # 0x403f8
movq %rbx, %rdi
callq 0x14e64
movq %rax, %r14
xorl %ebp, %ebp
xorl %r15d, %r15d
movb (%r14), %r12b
movl 0x144(%rbx), %eax
cmpl $-0x2, %eax
jl 0x13992
addl $0x2, %eax
cmpl 0x140(%rbx), %eax
jge 0x13992
movq 0x148(%rbx), %rcx
movl %eax, %esi
movq %rsi, %rax
shlq $0x4, %rax
cmpb $0x1, 0xf(%rcx,%rax)
je 0x13a06
shlq $0x4, %rsi
addq 0x148(%rbx), %rsi
jmp 0x139a2
cmpb $0x1, 0x2ca6e(%rip)     # 0x40407
je 0x13a06
leaq 0x2ca56(%rip), %rsi     # 0x403f8
movq %rbx, %rdi
callq 0x14e64
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
movzbl (%rax), %edi
cmpl $0x68, %edi
jle 0x139c6
cmpl $0x69, %edi
je 0x139cf
cmpl $0x6d, %edi
jne 0x13a2c
incl %ecx
jmp 0x139d1
cmpl $0x67, %edi
jne 0x139d6
incl %esi
jmp 0x139d1
incl %edx
incq %rax
jmp 0x139b0
testl %edi, %edi
jne 0x13a2c
cmpl $0x2, %esi
jge 0x13a41
cmpl $0x2, %edx
jge 0x13a4a
cmpl $0x2, %ecx
jge 0x13a53
xorl %eax, %eax
testl %esi, %esi
setne %al
orl %eax, %ebp
movl %ebp, %eax
orl $0x2, %eax
testl %edx, %edx
cmovel %ebp, %eax
movl %eax, %ebp
orl $0x4, %ebp
testl %ecx, %ecx
cmovel %eax, %ebp
testb %r12b, %r12b
leaq 0x1f242(%rip), %rax     # 0x32c52
cmoveq %rax, %r14
movq %rbx, %rdi
movq %r14, %rsi
movl %ebp, %edx
movl %r15d, %ecx
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x12e00
movsbl %dil, %edx
leaq 0x21466(%rip), %rsi     # 0x34e9d
movq %rbx, %rdi
xorl %eax, %eax
callq 0xc952
leaq 0x2147b(%rip), %rsi     # 0x34ec3
jmp 0x13a5a
leaq 0x21497(%rip), %rsi     # 0x34ee8
jmp 0x13a5a
leaq 0x214b3(%rip), %rsi     # 0x34f0d
movq %rbx, %rdi
xorl %eax, %eax
callq 0xc952
leaq 0x213f8(%rip), %rsi     # 0x34e63
movq %rbx, %rdi
xorl %eax, %eax
callq 0xca10