// File: /workspace/github_c_makefile_star2_O2/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, %r12
pushq $0x1
popq %rsi
leaq 0x20(%rsp), %rbx
movq %rbx, %rdx
callq 0xf6c0
movq %rax, %r14
pushq $0x2
popq %rsi
movq %r12, %rdi
xorl %edx, %edx
callq 0xf6c0
movq %rax, %r13
pushq $0x3
popq %rsi
movq %r12, %rdi
callq 0x543c
movl %eax, %ebp
movq (%rbx), %rdx
incq %rdx
pushq $0x4
popq %rsi
movq %r12, %rdi
callq 0xf939
movq %rax, 0x18(%rsp)
movb (%r13), %al
xorl %ebx, %ebx
movb %al, 0x3(%rsp)
cmpb $0x5e, %al
sete %bl
addl $-0x3, %ebp
cmpl $0x4, %ebp
jb 0x170ed
leaq 0x3e07(%rip), %rdx      # 0x1aee9
pushq $0x3
popq %rsi
movq %r12, %rdi
callq 0xf3d4
addq %rbx, %r13
leaq 0x250(%rsp), %rsi
movq %r12, %rdi
callq 0xfd2b
leaq 0x30(%rsp), %rcx
movq %r12, 0x10(%rcx)
movq %r14, (%rcx)
movq 0x20(%rsp), %rax
addq %r14, %rax
movq %rax, 0x8(%rcx)
pushq $0x3
popq %r15
xorl %ebp, %ebp
movq %r12, 0x10(%rsp)
movq %r13, 0x8(%rsp)
cmpl 0x18(%rsp), %ebp
jge 0x173bf
andl $0x0, 0x48(%rsp)
leaq 0x30(%rsp), %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x17967
testq %rax, %rax
je 0x17367
movq %rax, %rbx
movl %ebp, 0x4(%rsp)
movl %r15d, %ebp
movq 0x40(%rsp), %r15
movq %r15, %rdi
movl %ebp, %esi
callq 0x543c
leal -0x3(%rax), %ecx
cmpl $0x2, %ecx
jb 0x171b3
cmpl $0x5, %eax
je 0x172cc
cmpl $0x6, %eax
pushq $-0x1
popq %rbp
jne 0x172ec
movq %r15, %rdi
pushq $0x3
popq %rsi
callq 0x541c
leaq 0x30(%rsp), %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x17d10
movq %r15, %rdi
movl %eax, %esi
pushq $0x1
popq %rdx
callq 0x5eb4
jmp 0x172ec
movq %r15, %rdi
movl %ebp, %esi
leaq 0x28(%rsp), %rdx
callq 0x5665
movq %rax, %r12
movq %rbx, %r15
subq %r14, %r15
xorl %r13d, %r13d
cmpq 0x28(%rsp), %r13
jae 0x172bd
movb (%r12,%r13), %al
cmpb $0x25, %al
jne 0x17238
leaq 0x1(%r13), %rbp
callq 0x4570
movq (%rax), %rcx
movzbl 0x1(%r12,%r13), %eax
testb $0x8, 0x1(%rcx,%rax,2)
jne 0x17276
movq 0x250(%rsp), %rcx
leaq 0x2268(%rsp), %rdx
cmpq %rdx, %rcx
jb 0x17228
leaq 0x250(%rsp), %rdi
callq 0xfdd0
movb (%r12,%rbp), %al
movq 0x250(%rsp), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x250(%rsp)
movb %al, (%rcx)
jmp 0x172b2
movq 0x250(%rsp), %rcx
leaq 0x2268(%rsp), %rdx
cmpq %rdx, %rcx
jb 0x17266
leaq 0x250(%rsp), %rdi
callq 0xfdd0
movb (%r12,%r13), %al
movq 0x250(%rsp), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x250(%rsp)
movb %al, (%rcx)
jmp 0x172b5
cmpb $0x30, %al
jne 0x1728f
leaq 0x250(%rsp), %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0xfd3b
jmp 0x172b2
movsbl %al, %esi
addl $-0x31, %esi
leaq 0x30(%rsp), %rdi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x180f7
leaq 0x250(%rsp), %rdi
callq 0xfebf
movq %rbp, %r13
incq %r13
jmp 0x171ce
movq 0x10(%rsp), %r12
movq 0x8(%rsp), %r13
jmp 0x17358
leaq 0x30(%rsp), %rdi
xorl %esi, %esi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x180f7
movq %r15, %rdi
pushq $0x3
popq %rsi
callq 0x5a86
pushq $-0x1
popq %rbp
movq %r15, %rdi
movl %ebp, %esi
callq 0x5641
movq %r15, %rdi
testl %eax, %eax
je 0x17332
movl %ebp, %esi
callq 0x54c4
testl %eax, %eax
jne 0x1734b
movq %r15, %rdi
movl %ebp, %esi
callq 0x543c
movq %r15, %rdi
movl %eax, %esi
callq 0x5458
movq %r15, %rdi
leaq 0x3be2(%rip), %rsi      # 0x1af08
movq %rax, %rdx
xorl %eax, %eax
callq 0xf48b
jmp 0x1734b
pushq $-0x2
popq %rsi
callq 0x51fc
movq %rbx, %rdx
subq %r14, %rdx
movq %r15, %rdi
movq %r14, %rsi
callq 0x5819
leaq 0x250(%rsp), %rdi
callq 0xfebf
movl 0x4(%rsp), %ebp
incl %ebp
cmpq %r14, %rbx
pushq $0x3
popq %r15
ja 0x173af
cmpq 0x38(%rsp), %r14
jae 0x173bf
movq 0x250(%rsp), %rax
leaq 0x2268(%rsp), %rcx
cmpq %rcx, %rax
jb 0x17398
leaq 0x250(%rsp), %rdi
callq 0xfdd0
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 0x17128
jmp 0x173c2
movq %r14, %rbx
movq 0x38(%rsp), %rdx
subq %rbx, %rdx
leaq 0x250(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0xfd3b
movq %r14, %rdi
callq 0xfdb2
movslq %ebp, %rsi
movq %r12, %rdi
callq 0x57ff
pushq $0x2
popq %rax
addq $0x2268, %rsp           # imm = 0x2268
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq