// File: /workspace/github_c_makefile_star2_O1/ccxvii[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 0x2c733(%rip), %rdx     # 0x403f8
cmpl $-0x1, %eax
jl 0x13cdf
cmpl 0x140(%rbx), %ecx
jge 0x13cdf
movl %ecx, %edx
shlq $0x4, %rdx
addq 0x148(%rbx), %rdx
cmpb $0x7, 0xf(%rdx)
jne 0x13d38
movq (%rdx), %rdx
cmpl $0x9, (%rdx)
jne 0x13d38
leaq 0x2c704(%rip), %rcx     # 0x403f8
cmpl $-0x2, %eax
jl 0x13d11
addl $0x2, %eax
cmpl 0x140(%rbx), %eax
jge 0x13d11
movl %eax, %ecx
shlq $0x4, %rcx
addq 0x148(%rbx), %rcx
cmpb $0x1, 0xf(%rcx)
jne 0x13eb3
movl $0x1, %r14d
movq %rbx, %rdi
movl $0x1, %esi
callq 0x15720
movq 0x8(%rax), %r15
movzwl 0x10(%rax), %ebp
jmp 0x13d99
leaq 0x2c6b9(%rip), %rdx     # 0x403f8
cmpl $-0x1, %eax
jl 0x13d59
cmpl 0x140(%rbx), %ecx
jge 0x13d59
movl %ecx, %edx
shlq $0x4, %rdx
addq 0x148(%rbx), %rdx
xorl %ebp, %ebp
cmpb $0x1, 0xf(%rdx)
jne 0x13d6a
leaq 0x1eeba(%rip), %r15     # 0x32c22
jmp 0x13d96
leaq 0x2c687(%rip), %rsi     # 0x403f8
cmpl $-0x1, %eax
jl 0x13d8b
cmpl 0x140(%rbx), %ecx
jge 0x13d8b
movl %ecx, %esi
shlq $0x4, %rsi
addq 0x148(%rbx), %rsi
movq %rbx, %rdi
callq 0x1533b
movq %rax, %r15
xorl %r14d, %r14d
movl 0x144(%rbx), %ecx
leal 0x2(%rcx), %eax
leaq 0x2c64f(%rip), %rdx     # 0x403f8
cmpl $-0x2, %ecx
jl 0x13dc3
cmpl 0x140(%rbx), %eax
jge 0x13dc3
movl %eax, %edx
shlq $0x4, %rdx
addq 0x148(%rbx), %rdx
movb (%r15), %r12b
cmpb $0x1, 0xf(%rdx)
je 0x13e55
leaq 0x2c621(%rip), %rsi     # 0x403f8
cmpl $-0x2, %ecx
jl 0x13df1
cmpl 0x140(%rbx), %eax
jge 0x13df1
movl %eax, %esi
shlq $0x4, %rsi
addq 0x148(%rbx), %rsi
movq %rbx, %rdi
callq 0x1533b
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
movzbl (%rax), %edi
cmpl $0x68, %edi
jle 0x13e15
cmpl $0x69, %edi
je 0x13e1e
cmpl $0x6d, %edi
jne 0x13e7b
incl %ecx
jmp 0x13e20
cmpl $0x67, %edi
jne 0x13e25
incl %esi
jmp 0x13e20
incl %edx
incq %rax
jmp 0x13dff
testl %edi, %edi
jne 0x13e7b
cmpl $0x2, %esi
jge 0x13e90
cmpl $0x2, %edx
jge 0x13e99
cmpl $0x2, %ecx
jge 0x13ea2
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 0x1edc3(%rip), %rax     # 0x32c22
cmoveq %rax, %r15
movq %rbx, %rdi
movq %r15, %rsi
movl %ebp, %edx
movl %r14d, %ecx
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x13250
movsbl %dil, %edx
leaq 0x20fe7(%rip), %rsi     # 0x34e6d
movq %rbx, %rdi
xorl %eax, %eax
callq 0xcc25
leaq 0x20ffc(%rip), %rsi     # 0x34e93
jmp 0x13ea9
leaq 0x21018(%rip), %rsi     # 0x34eb8
jmp 0x13ea9
leaq 0x21034(%rip), %rsi     # 0x34edd
movq %rbx, %rdi
xorl %eax, %eax
callq 0xcc25
leaq 0x20f79(%rip), %rsi     # 0x34e33
movq %rbx, %rdi
xorl %eax, %eax
callq 0xcce3