// File: /workspace/github_c_makefile_star2_O3/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 0x10(%rsp), %rdx
movl $0x1, %esi
callq 0xb00c
movq %rax, %r14
xorl %ebx, %ebx
movq %r15, %rdi
movl $0x2, %esi
xorl %edx, %edx
callq 0xb00c
movq %rax, %r12
movq 0x18(%r15), %rax
leaq 0x20(%rax), %rcx
cmpq 0x10(%r15), %rcx
setae %dl
leaq 0x26ef(%rip), %rsi      # 0x15498
cmpq %rsi, %rcx
sete %cl
orb %dl, %cl
jne 0x12dbf
movl 0x28(%rax), %eax
addl $-0x3, %eax
cmpl $0x4, %eax
setb %bl
movq 0x10(%rsp), %rdx
incq %rdx
movq %r15, %rdi
movl $0x4, %esi
callq 0xb093
movq %rax, 0x38(%rsp)
movb (%r12), %cl
xorl %eax, %eax
movb %cl, 0x7(%rsp)
cmpb $0x5e, %cl
sete %cl
testb %bl, %bl
je 0x131df
movb %cl, %al
addq %rax, %r12
leaq 0x278(%rsp), %rax
movq %r15, -0x8(%rax)
movq %rax, -0x18(%rax)
movl $0x0, -0x10(%rax)
leaq 0x40(%rsp), %rcx
movq %r15, 0x20(%rsp)
movq %r15, 0x10(%rcx)
movq %r14, (%rcx)
movq 0x10(%rsp), %rax
addq %r14, %rax
movq %rax, 0x8(%rcx)
xorl %r15d, %r15d
leaq 0x2c2a(%rip), %rax      # 0x15a5e
movq %rax, 0x8(%rsp)
movq %r12, 0x28(%rsp)
cmpl 0x38(%rsp), %r15d
jge 0x1314c
movl $0x0, 0x58(%rsp)
leaq 0x40(%rsp), %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x1379f
testq %rax, %rax
je 0x130a2
movq %rax, %rbx
movq 0x50(%rsp), %rbp
movq 0x10(%rbp), %rax
movq 0x18(%rbp), %rcx
leaq 0x20(%rcx), %rdx
cmpq %rax, %rdx
setae %sil
leaq 0x260c(%rip), %rdi      # 0x15498
cmpq %rdi, %rdx
sete %dl
orb %sil, %dl
je 0x12ed3
movq 0x10(%rbp), %rcx
movslq -0x8(%rcx), %rax
addq $-0x10, %rcx
testq %rax, %rax
je 0x12f2d
cmpl $0x1, %eax
jne 0x12eb6
cmpl $0x0, (%rcx)
je 0x12f2d
leaq 0x25db(%rip), %rdx      # 0x15498
cmpq %rdx, %rcx
je 0x131c9
leal -0x5(%rax), %ecx
cmpl $-0x3, %ecx
ja 0x12f42
jmp 0x131b4
movl 0x28(%rcx), %edx
leal -0x3(%rdx), %esi
cmpl $0x2, %esi
jb 0x12f54
cmpl $0x5, %edx
je 0x1310c
cmpl $0x6, %edx
jne 0x12e97
movq 0x20(%rcx), %rdx
movq %rdx, (%rax)
movl 0x28(%rcx), %ecx
movl %ecx, 0x8(%rax)
addq $0x10, 0x10(%rbp)
leaq 0x40(%rsp), %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x13b8d
notl %eax
movslq %eax, %rsi
shlq $0x4, %rsi
addq 0x10(%rbp), %rsi
movq %rbp, %rdi
movl $0x1, %edx
callq 0x53b2
jmp 0x12e97
movq %rcx, 0x10(%rbp)
movq %rbx, %rdx
subq %r14, %rdx
movq %rbp, %rdi
movq %r14, %rsi
callq 0x94a5
leaq 0x260(%rsp), %rdi
callq 0x10cbf
jmp 0x1309a
movq %rbp, %rdi
movl $0x3, %esi
leaq 0x18(%rsp), %rdx
callq 0x3d8d
cmpq $0x0, 0x18(%rsp)
je 0x13095
movq %rax, %rbp
movq %rbx, %rax
subq %r14, %rax
movq %rax, 0x30(%rsp)
xorl %r12d, %r12d
cmpb $0x25, (%rbp,%r12)
jne 0x12ff9
leaq 0x1(%r12), %r13
callq 0x32f0
movq (%rax), %rcx
movzbl 0x1(%rbp,%r12), %eax
testb $0x8, 0x1(%rcx,%rax,2)
jne 0x13046
leaq 0x2278(%rsp), %rax
cmpq %rax, 0x260(%rsp)
jb 0x12fd9
leaq 0x260(%rsp), %rdi
callq 0x10d41
testl %eax, %eax
je 0x12fd9
leaq 0x260(%rsp), %rdi
callq 0x10d77
movb (%rbp,%r13), %al
movq 0x260(%rsp), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x260(%rsp)
movb %al, (%rcx)
jmp 0x13084
leaq 0x2278(%rsp), %rax
cmpq %rax, 0x260(%rsp)
jb 0x13029
leaq 0x260(%rsp), %rdi
callq 0x10d41
testl %eax, %eax
je 0x13029
leaq 0x260(%rsp), %rdi
callq 0x10d77
movb (%rbp,%r12), %al
movq 0x260(%rsp), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x260(%rsp)
movb %al, (%rcx)
jmp 0x13087
cmpb $0x30, %al
jne 0x13061
leaq 0x260(%rsp), %rdi
movq %r14, %rsi
movq 0x30(%rsp), %rdx
callq 0x10c63
jmp 0x13084
movsbl %al, %esi
addl $-0x31, %esi
leaq 0x40(%rsp), %rdi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x13f4e
leaq 0x260(%rsp), %rdi
callq 0x10cbf
movq %r13, %r12
incq %r12
cmpq 0x18(%rsp), %r12
jb 0x12f83
movq 0x28(%rsp), %r12
incl %r15d
cmpq %r14, %rbx
ja 0x130fc
cmpq 0x48(%rsp), %r14
jae 0x1314c
leaq 0x2278(%rsp), %rax
cmpq %rax, 0x260(%rsp)
jb 0x130dd
leaq 0x260(%rsp), %rdi
callq 0x10d41
testl %eax, %eax
je 0x130dd
leaq 0x260(%rsp), %rdi
callq 0x10d77
movb (%r14), %al
incq %r14
movq 0x260(%rsp), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x260(%rsp)
movb %al, (%rcx)
movq %r14, %rbx
movq %rbx, %r14
cmpb $0x5e, 0x7(%rsp)
jne 0x12e3e
jmp 0x1314f
leaq 0x40(%rsp), %rdi
xorl %esi, %esi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x13f4e
movq 0x10(%rbp), %rcx
movq 0x18(%rbp), %rsi
addq $0x20, %rsi
cmpq %rcx, %rsi
leaq 0x2364(%rip), %rax      # 0x15498
cmovaeq %rax, %rsi
addq $-0x10, %rcx
movq %rbp, %rdi
movq %rcx, %rdx
callq 0x7194
jmp 0x12e97
movq %r14, %rbx
movq 0x48(%rsp), %rdx
subq %rbx, %rdx
leaq 0x260(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x10c63
movq %r14, %rdi
callq 0x10d41
movq 0x10(%r14), %rdi
movl 0x8(%r14), %esi
callq 0xaedf
movq 0x20(%rsp), %rcx
movq 0x10(%rcx), %rax
cvtsi2sd %r15d, %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
cmpl $-0x1, %eax
je 0x131c9
leaq 0x86a0(%rip), %rcx      # 0x1b860
movq (%rcx,%rax,8), %rax
movq %rax, 0x8(%rsp)
leaq 0x3085(%rip), %rsi      # 0x16255
movq %rbp, %rdi
movq 0x8(%rsp), %rdx
xorl %eax, %eax
callq 0xa940
leaq 0x3050(%rip), %rdx      # 0x16236
movq %r15, %rdi
movl $0x3, %esi
callq 0xaa6a