// File: /workspace/github_c_makefile_star2_O0/bhk[P]tooltree/lua/../opensource/lua-5.2.3/src/lstrlib.c
// Function: str_gsub
static int str_gsub (lua_State *L) {
  size_t srcl, lp;
  const char *src = luaL_checklstring(L, 1, &srcl);
  const char *p = luaL_checklstring(L, 2, &lp);
  int tr = lua_type(L, 3);
  size_t max_s = luaL_optinteger(L, 4, srcl+1);
  int anchor = (*p == '^');
  size_t 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);
  if (anchor) {
    p++; lp--;  /* skip anchor character */
  }
  ms.L = L;
  ms.matchdepth = MAXCCALLS;
  ms.src_init = src;
  ms.src_end = src+srcl;
  ms.p_end = p + lp;
  while (n < max_s) {
    const char *e;
    ms.level = 0;
    lua_assert(ms.matchdepth == MAXCCALLS);
    e = match(&ms, src, p);
    if (e) {
      n++;
      add_value(&ms, &b, src, e, tr);
    }
    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:
subq $0x22a8, %rsp           # imm = 0x22A8
movq %rdi, 0x22a0(%rsp)
movq 0x22a0(%rsp), %rdi
movl $0x1, %esi
leaq 0x2298(%rsp), %rdx
callq 0xcd00
movq %rax, 0x2288(%rsp)
movq 0x22a0(%rsp), %rdi
movl $0x2, %esi
leaq 0x2290(%rsp), %rdx
callq 0xcd00
movq %rax, 0x2280(%rsp)
movq 0x22a0(%rsp), %rdi
movl $0x3, %esi
callq 0x9350
movl %eax, 0x227c(%rsp)
movq 0x22a0(%rsp), %rdi
movq 0x2298(%rsp), %rdx
addq $0x1, %rdx
movl $0x4, %esi
callq 0xcfe0
movq %rax, 0x2270(%rsp)
movq 0x2280(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x5e, %eax
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x226c(%rsp)
movq $0x0, 0x2260(%rsp)
movb $0x1, %al
cmpl $0x3, 0x227c(%rsp)
movb %al, 0x7(%rsp)
je 0x2173e
movb $0x1, %al
cmpl $0x4, 0x227c(%rsp)
movb %al, 0x7(%rsp)
je 0x2173e
movb $0x1, %al
cmpl $0x6, 0x227c(%rsp)
movb %al, 0x7(%rsp)
je 0x2173e
movb $0x1, %al
cmpl $0x5, 0x227c(%rsp)
movb %al, 0x7(%rsp)
je 0x2173e
movq 0x22a0(%rsp), %rdi
movl $0x3, %esi
leaq 0x155f9(%rip), %rdx     # 0x36d28
callq 0xc3a0
cmpl $0x0, %eax
setne %al
movb %al, 0x7(%rsp)
movb 0x7(%rsp), %al
movq 0x22a0(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0xd390
cmpl $0x0, 0x226c(%rsp)
je 0x21786
movq 0x2280(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x2280(%rsp)
movq 0x2290(%rsp), %rax
addq $-0x1, %rax
movq %rax, 0x2290(%rsp)
movq 0x22a0(%rsp), %rax
movq %rax, 0x2050(%rsp)
movl $0xc8, 0x2030(%rsp)
movq 0x2288(%rsp), %rax
movq %rax, 0x2038(%rsp)
movq 0x2288(%rsp), %rax
addq 0x2298(%rsp), %rax
movq %rax, 0x2040(%rsp)
movq 0x2280(%rsp), %rax
addq 0x2290(%rsp), %rax
movq %rax, 0x2048(%rsp)
movq 0x2260(%rsp), %rax
cmpq 0x2270(%rsp), %rax
jae 0x21918
movl $0x0, 0x2058(%rsp)
movq 0x2288(%rsp), %rsi
movq 0x2280(%rsp), %rdx
leaq 0x2030(%rsp), %rdi
callq 0x22530
movq %rax, 0x8(%rsp)
cmpq $0x0, 0x8(%rsp)
je 0x21867
movq 0x2260(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x2260(%rsp)
movq 0x2288(%rsp), %rdx
movq 0x8(%rsp), %rcx
movl 0x227c(%rsp), %r8d
leaq 0x2030(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x23cd0
cmpq $0x0, 0x8(%rsp)
je 0x2188d
movq 0x8(%rsp), %rax
cmpq 0x2288(%rsp), %rax
jbe 0x2188d
movq 0x8(%rsp), %rax
movq %rax, 0x2288(%rsp)
jmp 0x21907
movq 0x2288(%rsp), %rax
cmpq 0x2040(%rsp), %rax
jae 0x21903
movq 0x20(%rsp), %rcx
movb $0x1, %al
cmpq 0x18(%rsp), %rcx
movb %al, 0x6(%rsp)
jb 0x218cb
leaq 0x10(%rsp), %rdi
movl $0x1, %esi
callq 0xd080
cmpq $0x0, %rax
setne %al
movb %al, 0x6(%rsp)
movb 0x6(%rsp), %al
movq 0x2288(%rsp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, 0x2288(%rsp)
movb (%rax), %dl
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, 0x20(%rsp)
movb %dl, (%rax,%rcx)
jmp 0x21905
jmp 0x21918
jmp 0x21907
cmpl $0x0, 0x226c(%rsp)
je 0x21913
jmp 0x21918
jmp 0x217e1
movq 0x2288(%rsp), %rsi
movq 0x2040(%rsp), %rdx
movq 0x2288(%rsp), %rax
subq %rax, %rdx
leaq 0x10(%rsp), %rdi
callq 0xd1b0
leaq 0x10(%rsp), %rdi
callq 0xd260
movq 0x22a0(%rsp), %rdi
movq 0x2260(%rsp), %rsi
callq 0x9e70
movl $0x2, %eax
addq $0x22a8, %rsp           # imm = 0x22A8
retq
nopl (%rax)