// File: /workspace/github_c_makefile_star2_O2/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
pushq $0x1
popq %rsi
leaq 0x30(%rsp), %rbx
movq %rbx, %rdx
callq 0x9b97
movq %rax, %r14
pushq $0x2
popq %rsi
movq %r15, %rdi
xorl %edx, %edx
callq 0x9b97
movq %rax, %r13
pushq $0x3
popq %rsi
movq %r15, %rdi
callq 0x965e
movl %eax, %ebp
movq (%rbx), %rdx
incq %rdx
pushq $0x4
popq %rsi
movq %r15, %rdi
callq 0x9c2f
movq %rax, 0x10(%rsp)
movb (%r13), %cl
xorl %eax, %eax
movb %cl, 0xf(%rsp)
cmpb $0x5e, %cl
sete %cl
addl $-0x3, %ebp
cmpl $0x4, %ebp
jae 0x1060e
movb %cl, %al
addq %rax, %r13
leaq 0x278(%rsp), %rax
movq %r15, -0x8(%rax)
movq %rax, -0x18(%rax)
andl $0x0, -0x10(%rax)
leaq 0x40(%rsp), %rcx
movq %r15, 0x18(%rsp)
movq %r15, 0x10(%rcx)
movq %r14, (%rcx)
movq 0x30(%rsp), %rax
addq %r14, %rax
movq %rax, 0x8(%rcx)
pushq $0x3
popq %rbp
xorl %r15d, %r15d
movq 0x10(%rsp), %r12
movq %r13, 0x20(%rsp)
cmpl %r12d, %r15d
jge 0x1057e
andl $0x0, 0x58(%rsp)
leaq 0x40(%rsp), %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x10afa
testq %rax, %rax
je 0x10526
movq %rax, %rbx
movq 0x50(%rsp), %r12
movq %r12, %rdi
movl %ebp, %esi
callq 0x965e
leal -0x3(%rax), %ecx
cmpl $0x2, %ecx
jb 0x10374
cmpl $0x5, %eax
je 0x10491
cmpl $0x6, %eax
pushq $-0x1
popq %rbp
jne 0x104d1
movq %r12, %rdi
pushq $0x3
popq %rsi
callq 0x8917
leaq 0x40(%rsp), %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x10e94
movq %r12, %rdi
movl %eax, %esi
pushq $0x1
popq %rdx
callq 0x85eb
jmp 0x104d1
movq %r15, 0x28(%rsp)
movq %r12, %rdi
movl %ebp, %esi
leaq 0x38(%rsp), %rdx
callq 0x3b4c
movq %rax, %r12
movq %rbx, %r15
subq %r14, %r15
xorl %ebp, %ebp
cmpq 0x38(%rsp), %rbp
jae 0x10482
movb (%r12,%rbp), %al
cmpb $0x25, %al
jne 0x103fd
leaq 0x1(%rbp), %r13
callq 0x32e0
movq (%rax), %rcx
movzbl 0x1(%r12,%rbp), %eax
testb $0x8, 0x1(%rcx,%rax,2)
jne 0x1043b
movq 0x260(%rsp), %rcx
leaq 0x2278(%rsp), %rdx
cmpq %rdx, %rcx
jb 0x103ed
leaq 0x260(%rsp), %rdi
callq 0xe979
movb (%r12,%r13), %al
movq 0x260(%rsp), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x260(%rsp)
movb %al, (%rcx)
jmp 0x10477
movq 0x260(%rsp), %rcx
leaq 0x2278(%rsp), %rdx
cmpq %rdx, %rcx
jb 0x1042b
leaq 0x260(%rsp), %rdi
callq 0xe979
movb (%r12,%rbp), %al
movq 0x260(%rsp), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x260(%rsp)
movb %al, (%rcx)
jmp 0x1047a
cmpb $0x30, %al
jne 0x10454
leaq 0x260(%rsp), %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0xe7bc
jmp 0x10477
movsbl %al, %esi
addl $-0x31, %esi
leaq 0x40(%rsp), %rdi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x11241
leaq 0x260(%rsp), %rdi
callq 0xe82a
movq %r13, %rbp
incq %rbp
jmp 0x10393
movq 0x28(%rsp), %r15
movq 0x20(%rsp), %r13
jmp 0x10516
leaq 0x40(%rsp), %rdi
xorl %esi, %esi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x11241
movq 0x10(%r12), %rcx
movq 0x18(%r12), %rsi
addq $0x20, %rsi
cmpq %rcx, %rsi
leaq 0x1f85(%rip), %rax      # 0x12440
cmovaeq %rax, %rsi
addq $-0x10, %rcx
movq %r12, %rdi
movq %rcx, %rdx
callq 0x6b95
pushq $-0x1
popq %rbp
movq %r12, %rdi
movl %ebp, %esi
callq 0x9522
testl %eax, %eax
je 0x104f2
movq %r12, %rdi
movl %ebp, %esi
callq 0x9c99
testl %eax, %eax
jne 0x10509
jmp 0x105d7
addq $-0x10, 0x10(%r12)
movq %rbx, %rdx
subq %r14, %rdx
movq %r12, %rdi
movq %r14, %rsi
callq 0x8937
leaq 0x260(%rsp), %rdi
callq 0xe82a
movq 0x10(%rsp), %r12
incl %r15d
cmpq %r14, %rbx
pushq $0x3
popq %rbp
ja 0x1056e
cmpq 0x48(%rsp), %r14
jae 0x1057e
movq 0x260(%rsp), %rax
leaq 0x2278(%rsp), %rcx
cmpq %rcx, %rax
jb 0x10557
leaq 0x260(%rsp), %rdi
callq 0xe979
movq 0x260(%rsp), %rax
movb (%r14), %cl
incq %r14
leaq 0x1(%rax), %rdx
movq %rdx, 0x260(%rsp)
movb %cl, (%rax)
movq %r14, %rbx
movq %rbx, %r14
cmpb $0x5e, 0xf(%rsp)
jne 0x102f1
jmp 0x10581
movq %r14, %rbx
movq 0x48(%rsp), %rdx
subq %rbx, %rdx
leaq 0x260(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0xe7bc
movq %r14, %rdi
callq 0xe80c
movq 0x18(%rsp), %rcx
movq 0x10(%rcx), %rax
cvtsi2sd %r15d, %xmm0
movsd %xmm0, (%rax)
movl $0x3, 0x8(%rax)
addq $0x10, 0x10(%rcx)
pushq $0x2
popq %rax
addq $0x2278, %rsp           # imm = 0x2278
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $-0x1
popq %rsi
movq %r12, %rdi
callq 0x965e
cmpl $-0x1, %eax
jne 0x105f0
leaq 0x2470(%rip), %rdx      # 0x12a5e
jmp 0x105fd
cltq
leaq 0xa267(%rip), %rcx      # 0x1a860
movq (%rcx,%rax,8), %rdx
leaq 0x2c51(%rip), %rsi      # 0x13255
movq %r12, %rdi
xorl %eax, %eax
callq 0x9546
leaq 0x2c21(%rip), %rdx      # 0x13236
pushq $0x3
popq %rsi
movq %r15, %rdi
callq 0x967a