// File: /workspace/github_c_makefile_star2_O3/gplessis[P]dotdeb-redis/deps/lua/src/lstrlib.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 == LUA_TNUMBER || tr == LUA_TSTRING ||
                   tr == LUA_TFUNCTION || tr == LUA_TTABLE, 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) /* non empty match? */
      src = e;  /* skip it */
    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);  /* number of substitutions */
  return 2;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2268, %rsp           # imm = 0x2268
movq %rdi, %r15
leaq 0x28(%rsp), %rbx
movl $0x1, %esi
movq %rbx, %rdx
callq 0x10b24
movq %rax, %r14
movq %r15, %rdi
movl $0x2, %esi
xorl %edx, %edx
callq 0x10b24
movq %rax, %r13
movq %r15, %rdi
movl $0x3, %esi
callq 0x584a
movl %eax, %ebp
movq (%rbx), %rdx
incq %rdx
movq %r15, %rdi
movl $0x4, %esi
callq 0x10dbc
movq %rax, 0x8(%rsp)
movb (%r13), %al
xorl %ebx, %ebx
movb %al, 0x3(%rsp)
cmpb $0x5e, %al
sete %bl
addl $-0x3, %ebp
cmpl $0x4, %ebp
jb 0x18f23
leaq 0x3ffb(%rip), %rdx      # 0x1cf11
movq %r15, %rdi
movl $0x3, %esi
callq 0x10820
addq %rbx, %r13
leaq 0x250(%rsp), %rsi
movq %r15, %rdi
callq 0x1121c
leaq 0x30(%rsp), %rcx
movq %r15, 0x10(%rcx)
movq %r14, (%rcx)
movq 0x28(%rsp), %rax
addq %r14, %rax
movq %rax, 0x8(%rcx)
xorl %r12d, %r12d
movq 0x8(%rsp), %rbp
movq %r15, 0x20(%rsp)
movq %r13, 0x18(%rsp)
cmpl %ebp, %r12d
jge 0x19212
movl $0x0, 0x48(%rsp)
leaq 0x30(%rsp), %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x1980e
testq %rax, %rax
je 0x191ba
movq %rax, %rbx
movl %r12d, 0x4(%rsp)
movq 0x40(%rsp), %r12
movq %r12, %rdi
movl $0x3, %esi
callq 0x584a
leal -0x3(%rax), %ecx
cmpl $0x2, %ecx
jb 0x18fef
cmpl $0x5, %eax
je 0x19117
cmpl $0x6, %eax
jne 0x19136
movq %r12, %rdi
movl $0x3, %esi
callq 0x582a
leaq 0x30(%rsp), %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x19bbc
movq %r12, %rdi
movl %eax, %esi
movl $0x1, %edx
callq 0x6305
jmp 0x19136
movq %r12, %rdi
movl $0x3, %esi
leaq 0x10(%rsp), %rdx
callq 0x5a88
cmpq $0x0, 0x10(%rsp)
je 0x19103
movq %rax, %r12
movq %rbx, %rbp
subq %r14, %rbp
xorl %r13d, %r13d
movb (%r12,%r13), %al
cmpb $0x25, %al
jne 0x19078
leaq 0x1(%r13), %r15
callq 0x4580
movq (%rax), %rcx
movzbl 0x1(%r12,%r13), %eax
testb $0x8, 0x1(%rcx,%rax,2)
jne 0x190b6
movq 0x250(%rsp), %rcx
leaq 0x2268(%rsp), %rdx
cmpq %rdx, %rcx
jb 0x19068
leaq 0x250(%rsp), %rdi
callq 0x112d0
movb (%r12,%r15), %al
movq 0x250(%rsp), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x250(%rsp)
movb %al, (%rcx)
jmp 0x190f2
movq 0x250(%rsp), %rcx
leaq 0x2268(%rsp), %rdx
cmpq %rdx, %rcx
jb 0x190a6
leaq 0x250(%rsp), %rdi
callq 0x112d0
movb (%r12,%r13), %al
movq 0x250(%rsp), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x250(%rsp)
movb %al, (%rcx)
jmp 0x190f5
cmpb $0x30, %al
jne 0x190cf
leaq 0x250(%rsp), %rdi
movq %r14, %rsi
movq %rbp, %rdx
callq 0x1122f
jmp 0x190f2
movsbl %al, %esi
addl $-0x31, %esi
leaq 0x30(%rsp), %rdi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x19fb7
leaq 0x250(%rsp), %rdi
callq 0x113c6
movq %r15, %r13
incq %r13
cmpq 0x10(%rsp), %r13
jb 0x19019
movq 0x20(%rsp), %r15
movq 0x18(%rsp), %r13
movq 0x8(%rsp), %rbp
jmp 0x191ad
leaq 0x30(%rsp), %rdi
xorl %esi, %esi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x19fb7
movq %r12, %rdi
movl $0x3, %esi
callq 0x5ecf
movq %r12, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x5a62
movq %r12, %rdi
testl %eax, %eax
je 0x19185
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x58d4
testl %eax, %eax
jne 0x191a0
movq %r12, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x584a
movq %r12, %rdi
movl %eax, %esi
callq 0x5868
movq %r12, %rdi
leaq 0x3db7(%rip), %rsi      # 0x1cf30
movq %rax, %rdx
xorl %eax, %eax
callq 0x108d7
jmp 0x191a0
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x54e9
movq %rbx, %rdx
subq %r14, %rdx
movq %r12, %rdi
movq %r14, %rsi
callq 0x5c5a
leaq 0x250(%rsp), %rdi
callq 0x113c6
movl 0x4(%rsp), %r12d
incl %r12d
cmpq %r14, %rbx
ja 0x19202
cmpq 0x38(%rsp), %r14
jae 0x19212
movq 0x250(%rsp), %rax
leaq 0x2268(%rsp), %rcx
cmpq %rcx, %rax
jb 0x191eb
leaq 0x250(%rsp), %rdi
callq 0x112d0
movq 0x250(%rsp), %rax
movb (%r14), %cl
incq %r14
leaq 0x1(%rax), %rdx
movq %rdx, 0x250(%rsp)
movb %cl, (%rax)
movq %r14, %rbx
movq %rbx, %r14
cmpb $0x5e, 0x3(%rsp)
jne 0x18f60
jmp 0x19215
movq %r14, %rbx
movq 0x38(%rsp), %rdx
subq %rbx, %rdx
leaq 0x250(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x1122f
movq %r14, %rdi
callq 0x112b2
movslq %r12d, %rsi
movq %r15, %rdi
callq 0x5c40
movl $0x2, %eax
addq $0x2268, %rsp           # imm = 0x2268
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq