// File: /workspace/github_c_makefile_star2_O0/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:
subq $0x2278, %rsp           # imm = 0x2278
movq %rdi, 0x2270(%rsp)
movq 0x2270(%rsp), %rdi
movl $0x1, %esi
leaq 0x2268(%rsp), %rdx
callq 0x11450
movq %rax, 0x2260(%rsp)
movq 0x2270(%rsp), %rdi
movl $0x2, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x11450
movq %rax, 0x2258(%rsp)
movq 0x2270(%rsp), %rdi
movl $0x3, %esi
callq 0x10930
movl %eax, 0x2254(%rsp)
movq 0x2270(%rsp), %rdi
movq 0x2268(%rsp), %rdx
addq $0x1, %rdx
movl $0x4, %esi
callq 0x115b0
movl %eax, 0x2250(%rsp)
movq 0x2258(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x5e, %eax
jne 0x1e1ec
movq 0x2258(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x2258(%rsp)
movl $0x1, %eax
movl %eax, 0x4(%rsp)
jmp 0x1e1f4
xorl %eax, %eax
movl %eax, 0x4(%rsp)
jmp 0x1e1f4
movl 0x4(%rsp), %eax
movl %eax, 0x224c(%rsp)
movl $0x0, 0x2248(%rsp)
movb $0x1, %al
cmpl $0x3, 0x2254(%rsp)
movb %al, 0x3(%rsp)
je 0x1e26d
movb $0x1, %al
cmpl $0x4, 0x2254(%rsp)
movb %al, 0x3(%rsp)
je 0x1e26d
movb $0x1, %al
cmpl $0x6, 0x2254(%rsp)
movb %al, 0x3(%rsp)
je 0x1e26d
movb $0x1, %al
cmpl $0x5, 0x2254(%rsp)
movb %al, 0x3(%rsp)
je 0x1e26d
movq 0x2270(%rsp), %rdi
movl $0x3, %esi
leaq 0x5187(%rip), %rdx      # 0x233e5
callq 0x10980
cmpl $0x0, %eax
setne %al
movb %al, 0x3(%rsp)
movb 0x3(%rsp), %al
movq 0x2270(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x1b5c0
movq 0x2270(%rsp), %rax
movq %rax, 0x2038(%rsp)
movq 0x2260(%rsp), %rax
movq %rax, 0x2028(%rsp)
movq 0x2260(%rsp), %rax
addq 0x2268(%rsp), %rax
movq %rax, 0x2030(%rsp)
movl 0x2248(%rsp), %eax
cmpl 0x2250(%rsp), %eax
jge 0x1e3e8
movl $0x0, 0x2040(%rsp)
movq 0x2260(%rsp), %rsi
movq 0x2258(%rsp), %rdx
leaq 0x2028(%rsp), %rdi
callq 0x1eca0
movq %rax, 0x8(%rsp)
cmpq $0x0, 0x8(%rsp)
je 0x1e334
movl 0x2248(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2248(%rsp)
movq 0x2260(%rsp), %rdx
movq 0x8(%rsp), %rcx
leaq 0x2028(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x203e0
cmpq $0x0, 0x8(%rsp)
je 0x1e35a
movq 0x8(%rsp), %rax
cmpq 0x2260(%rsp), %rax
jbe 0x1e35a
movq 0x8(%rsp), %rax
movq %rax, 0x2260(%rsp)
jmp 0x1e3d7
movq 0x2260(%rsp), %rax
cmpq 0x2030(%rsp), %rax
jae 0x1e3d3
movq 0x10(%rsp), %rcx
leaq 0x10(%rsp), %rdx
addq $0x18, %rdx
addq $0x2000, %rdx           # imm = 0x2000
movb $0x1, %al
cmpq %rdx, %rcx
movb %al, 0x2(%rsp)
jb 0x1e3a1
leaq 0x10(%rsp), %rdi
callq 0x1b990
cmpq $0x0, %rax
setne %al
movb %al, 0x2(%rsp)
movb 0x2(%rsp), %al
movq 0x2260(%rsp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, 0x2260(%rsp)
movb (%rax), %cl
movq 0x10(%rsp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, 0x10(%rsp)
movb %cl, (%rax)
jmp 0x1e3d5
jmp 0x1e3e8
jmp 0x1e3d7
cmpl $0x0, 0x224c(%rsp)
je 0x1e3e3
jmp 0x1e3e8
jmp 0x1e2bb
movq 0x2260(%rsp), %rsi
movq 0x2030(%rsp), %rdx
movq 0x2260(%rsp), %rax
subq %rax, %rdx
leaq 0x10(%rsp), %rdi
callq 0x1b690
leaq 0x10(%rsp), %rdi
callq 0x1b730
movq 0x2270(%rsp), %rdi
movslq 0x2248(%rsp), %rsi
callq 0x1ab20
movl $0x2, %eax
addq $0x2278, %rsp           # imm = 0x2278
retq
nopl (%rax)