// File: /workspace/github_c_makefile_star2_O1/zenkj[P]luajit-arm64/src/host/minilua.c
// Function: str_gsub
static int str_gsub(lua_State*L){
size_t srcl;
const char*src=luaL_checklstring(L,1,&srcl);
const char*p=luaL_checkstring(L,2);
int tr=lua_type(L,3);
int max_s=luaL_optint(L,4,srcl+1);
int anchor=(*p=='^')?(p++,1):0;
int n=0;
MatchState ms;
luaL_Buffer b;
luaL_argcheck(L,tr==3||tr==4||
tr==6||tr==5,3,
"string/function/table expected");
luaL_buffinit(L,&b);
ms.L=L;
ms.src_init=src;
ms.src_end=src+srcl;
while(n<max_s){
const char*e;
ms.level=0;
e=match(&ms,src,p);
if(e){
n++;
add_value(&ms,&b,src,e);
}
if(e&&e>src)
src=e;
else if(src<ms.src_end)
luaL_addchar(&b,*src++);
else break;
if(anchor)break;
}
luaL_addlstring(&b,src,ms.src_end-src);
luaL_pushresult(&b);
lua_pushinteger(L,n);
return 2;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2278, %rsp           # imm = 0x2278
movq %rdi, %r15
leaq 0x18(%rsp), %rdx
movl $0x1, %esi
callq 0xa6a8
movq %rax, %rbx
xorl %r14d, %r14d
movq %r15, %rdi
movl $0x2, %esi
xorl %edx, %edx
callq 0xa6a8
movq %rax, %r13
movq 0x18(%r15), %rax
leaq 0x20(%rax), %rcx
cmpq 0x10(%r15), %rcx
setae %dl
leaq 0x2524(%rip), %rsi      # 0x14420
cmpq %rsi, %rcx
sete %cl
orb %dl, %cl
jne 0x11f13
movl 0x28(%rax), %eax
addl $-0x3, %eax
cmpl $0x4, %eax
setb %r14b
movq 0x18(%rsp), %rdx
incq %rdx
movq %r15, %rdi
movl $0x4, %esi
callq 0xa737
movq %rax, 0x38(%rsp)
movb (%r13), %al
xorl %ecx, %ecx
cmpb $0x5e, %al
sete %dl
testb %r14b, %r14b
je 0x12356
movb %dl, %cl
addq %rcx, %r13
cmpb $0x5e, %al
setne %bpl
leaq 0x278(%rsp), %rax
movq %r15, -0x8(%rax)
movq %rax, -0x18(%rax)
movl $0x0, -0x10(%rax)
leaq 0x40(%rsp), %rcx
movq %r15, 0x28(%rsp)
movq %r15, 0x10(%rcx)
movq %rbx, (%rcx)
movq 0x18(%rsp), %rax
addq %rbx, %rax
movq %rax, 0x8(%rcx)
movq $0x0, 0x10(%rsp)
leaq 0x2490(%rip), %r15      # 0x14420
movq %r13, 0x30(%rsp)
movb %bpl, 0xf(%rsp)
movq 0x38(%rsp), %rax
cmpl %eax, 0x10(%rsp)
jge 0x122b2
movl $0x0, 0x58(%rsp)
leaq 0x40(%rsp), %rdi
movq %rbx, %rsi
movq %r13, %rdx
callq 0x1292a
movq %rax, %r14
testq %rax, %rax
je 0x12235
movq 0x50(%rsp), %r12
movq 0x10(%r12), %rax
movq 0x18(%r12), %rcx
addq $0x20, %rcx
cmpq %rax, %rcx
cmovaeq %r15, %rcx
cmpq %r15, %rcx
je 0x11ff1
movl 0x8(%rcx), %edx
jmp 0x11ff6
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movq 0x10(%rsp), %rsi
incl %esi
movq %rsi, 0x10(%rsp)
leal -0x3(%rdx), %esi
cmpl $0x2, %esi
jb 0x1205e
cmpl $0x5, %edx
je 0x121a5
cmpl $0x6, %edx
jne 0x121db
movq (%rcx), %rdx
movq %rdx, (%rax)
movl 0x8(%rcx), %ecx
movl %ecx, 0x8(%rax)
addq $0x10, 0x10(%r12)
leaq 0x40(%rsp), %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x12d64
notl %eax
movslq %eax, %rsi
shlq $0x4, %rsi
addq 0x10(%r12), %rsi
movq %r12, %rdi
movl $0x1, %edx
callq 0x523c
jmp 0x121db
movq %r12, %rdi
movl $0x3, %esi
leaq 0x20(%rsp), %rdx
callq 0x3c5a
cmpq $0x0, 0x20(%rsp)
je 0x12194
movq %rax, %r12
movq %r14, %r13
subq %rbx, %r13
xorl %r15d, %r15d
cmpb $0x25, (%r12,%r15)
jne 0x120fb
leaq 0x1(%r15), %rbp
callq 0x32f0
movq (%rax), %rcx
movzbl 0x1(%r12,%r15), %eax
testb $0x8, 0x1(%rcx,%rax,2)
jne 0x12147
leaq 0x2278(%rsp), %rax
cmpq %rax, 0x260(%rsp)
jb 0x120dc
leaq 0x260(%rsp), %rdi
callq 0x1008f
testl %eax, %eax
je 0x120dc
leaq 0x260(%rsp), %rdi
callq 0x100c5
movb (%r12,%rbp), %al
movq 0x260(%rsp), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x260(%rsp)
movb %al, (%rcx)
jmp 0x12183
leaq 0x2278(%rsp), %rax
cmpq %rax, 0x260(%rsp)
jb 0x1212b
leaq 0x260(%rsp), %rdi
callq 0x1008f
testl %eax, %eax
je 0x1212b
leaq 0x260(%rsp), %rdi
callq 0x100c5
movb (%r12,%r15), %al
movq 0x260(%rsp), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x260(%rsp)
movb %al, (%rcx)
jmp 0x12186
cmpb $0x30, %al
jne 0x12160
leaq 0x260(%rsp), %rdi
movq %rbx, %rsi
movq %r13, %rdx
callq 0xffb1
jmp 0x12183
movsbl %al, %esi
addl $-0x31, %esi
leaq 0x40(%rsp), %rdi
movq %rbx, %rdx
movq %r14, %rcx
callq 0x1311b
leaq 0x260(%rsp), %rdi
callq 0x1000d
movq %rbp, %r15
incq %r15
cmpq 0x20(%rsp), %r15
jb 0x12088
movq 0x30(%rsp), %r13
leaq 0x2280(%rip), %r15      # 0x14420
jmp 0x12230
leaq 0x40(%rsp), %rdi
xorl %esi, %esi
movq %rbx, %rdx
movq %r14, %rcx
callq 0x1311b
movq 0x10(%r12), %rcx
movq 0x18(%r12), %rsi
addq $0x20, %rsi
cmpq %rcx, %rsi
cmovaeq %r15, %rsi
addq $-0x10, %rcx
movq %r12, %rdi
movq %rcx, %rdx
callq 0x6e8f
movq 0x10(%r12), %rcx
movslq -0x8(%rcx), %rax
addq $-0x10, %rcx
testq %rax, %rax
je 0x1220d
cmpl $0x1, %eax
jne 0x121f7
cmpl $0x0, (%rcx)
je 0x1220d
cmpq %r15, %rcx
je 0x12321
leal -0x5(%rax), %edx
cmpl $-0x3, %edx
ja 0x12223
jmp 0x12321
movq %rcx, 0x10(%r12)
movq %r14, %rdx
subq %rbx, %rdx
movq %r12, %rdi
movq %rbx, %rsi
callq 0x90a1
leaq 0x260(%rsp), %rdi
callq 0x1000d
movb 0xf(%rsp), %bpl
testq %r14, %r14
setne %cl
cmpq %rbx, %r14
seta %dl
movl %ebp, %eax
testb %dl, %cl
jne 0x122a5
cmpq 0x48(%rsp), %rbx
jae 0x122a0
leaq 0x2278(%rsp), %rax
cmpq %rax, 0x260(%rsp)
jb 0x1227e
leaq 0x260(%rsp), %rdi
callq 0x1008f
testl %eax, %eax
je 0x1227e
leaq 0x260(%rsp), %rdi
callq 0x100c5
movb (%rbx), %al
incq %rbx
movq 0x260(%rsp), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x260(%rsp)
movb %al, (%rcx)
movq %rbx, %r14
movl %ebp, %eax
jmp 0x122a5
xorl %eax, %eax
movq %rbx, %r14
movq %r14, %rbx
testb %al, %al
jne 0x11f9a
jmp 0x122b5
movq %rbx, %r14
movq 0x48(%rsp), %rdx
subq %r14, %rdx
leaq 0x260(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq 0xffb1
movq %rbx, %rdi
callq 0x1008f
movq 0x10(%rbx), %rdi
movl 0x8(%rbx), %esi
callq 0xa57b
movl $0x1, 0x8(%rbx)
movq 0x28(%rsp), %rcx
movq 0x10(%rcx), %rax
cvtsi2sdl 0x10(%rsp), %xmm0
movsd %xmm0, (%rax)
movl $0x3, 0x8(%rax)
addq $0x10, 0x10(%rcx)
movl $0x2, %eax
addq $0x2278, %rsp           # imm = 0x2278
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpq %r15, %rcx
sete %cl
cmpl $-0x1, %eax
sete %dl
orb %cl, %dl
je 0x1233a
leaq 0x26fe(%rip), %rdx      # 0x14a36
jmp 0x12345
leaq 0x851f(%rip), %rcx      # 0x1a860
movq (%rcx,%rax,8), %rdx
leaq 0x2ee1(%rip), %rsi      # 0x1522d
movq %r12, %rdi
xorl %eax, %eax
callq 0xa049
leaq 0x2eb1(%rip), %rdx      # 0x1520e
movq %r15, %rdi
movl $0x3, %esi
callq 0xa173