// File: /workspace/github_c_makefile_star2_O2/gplessis[P]dotdeb-redis/deps/lua/src/lstrlib.c
// Function: str_format
static int str_format (lua_State *L) {
  int top = lua_gettop(L);
  int arg = 1;
  size_t sfl;
  const char *strfrmt = luaL_checklstring(L, arg, &sfl);
  const char *strfrmt_end = strfrmt+sfl;
  luaL_Buffer b;
  luaL_buffinit(L, &b);
  while (strfrmt < strfrmt_end) {
    if (*strfrmt != L_ESC)
      luaL_addchar(&b, *strfrmt++);
    else if (*++strfrmt == L_ESC)
      luaL_addchar(&b, *strfrmt++);  /* %% */
    else { /* format item */
      char form[MAX_FORMAT];  /* to store the format (`%...') */
      char buff[MAX_ITEM];  /* to store the formatted item */
      if (++arg > top)
        luaL_argerror(L, arg, "no value");
      strfrmt = scanformat(L, strfrmt, form);
      switch (*strfrmt++) {
        case 'c': {
          sprintf(buff, form, (int)luaL_checknumber(L, arg));
          break;
        }
        case 'd':  case 'i': {
          addintlen(form);
          sprintf(buff, form, (LUA_INTFRM_T)luaL_checknumber(L, arg));
          break;
        }
        case 'o':  case 'u':  case 'x':  case 'X': {
          addintlen(form);
          sprintf(buff, form, (unsigned LUA_INTFRM_T)luaL_checknumber(L, arg));
          break;
        }
        case 'e':  case 'E': case 'f':
        case 'g': case 'G': {
          sprintf(buff, form, (double)luaL_checknumber(L, arg));
          break;
        }
        case 'q': {
          addquoted(L, &b, arg);
          continue;  /* skip the 'addsize' at the end */
        }
        case 's': {
          size_t l;
          const char *s = luaL_checklstring(L, arg, &l);
          if (!strchr(form, '.') && l >= 100) {
            /* no precision and string is too long to be formatted;
               keep original string */
            lua_pushvalue(L, arg);
            luaL_addvalue(&b);
            continue;  /* skip the `addsize' at the end */
          }
          else {
            sprintf(buff, form, s);
            break;
          }
        }
        default: {  /* also treat cases `pnLlh' */
          return luaL_error(L, "invalid option " LUA_QL("%%%c") " to "
                               LUA_QL("format"), *(strfrmt - 1));
        }
      }
      luaL_addlstring(&b, buff, strlen(buff));
    }
  }
  luaL_pushresult(&b);
  return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2258, %rsp           # imm = 0x2258
movq %rdi, %r15
callq 0x51ef
movl %eax, 0x34(%rsp)
pushq $0x1
popq %r13
leaq 0x38(%rsp), %r14
movq %r15, %rdi
movl %r13d, %esi
movq %r14, %rdx
callq 0xf6c0
movq %rax, %r12
movq %rax, %rbx
addq (%r14), %rbx
leaq 0x240(%rsp), %r14
movq %r15, 0x8(%rsp)
movq %r15, %rdi
movq %r14, %rsi
callq 0xfd2b
leaq 0x2258(%rsp), %rbp
cmpq %rbx, %r12
jae 0x16fd3
movb (%r12), %al
cmpb $0x25, %al
jne 0x16bb5
leaq 0x1(%r12), %r15
cmpb $0x25, 0x1(%r12)
jne 0x16bec
movq 0x240(%rsp), %rax
movb $0x25, %cl
cmpq %rbp, %rax
jb 0x16ba1
movq %r14, %rdi
callq 0xfdd0
movb (%r15), %cl
movq 0x240(%rsp), %rax
addq $0x2, %r12
leaq 0x1(%rax), %rdx
movq %rdx, 0x240(%rsp)
movb %cl, (%rax)
jmp 0x16b61
movq 0x240(%rsp), %rcx
cmpq %rbp, %rcx
jb 0x16bd6
movq %r14, %rdi
callq 0xfdd0
movb (%r12), %al
movq 0x240(%rsp), %rcx
incq %r12
leaq 0x1(%rcx), %rdx
movq %rdx, 0x240(%rsp)
movb %al, (%rcx)
jmp 0x16b61
leal 0x1(%r13), %eax
movl %eax, 0x4(%rsp)
cmpl 0x34(%rsp), %r13d
jl 0x16c10
movq 0x8(%rsp), %rdi
movl 0x4(%rsp), %esi
leaq 0x2759(%rip), %rdx      # 0x19364
callq 0xf3d4
pushq $0x3
popq %r14
movq %r15, %r12
movsbl (%r12), %r13d
testl %r13d, %r13d
je 0x16c40
leaq 0x4238(%rip), %rdi      # 0x1ae60
movl %r13d, %esi
pushq $0x6
popq %rdx
callq 0x4210
testq %rax, %rax
je 0x16c40
incq %r12
incq %r14
jmp 0x16c17
addq $-0x3, %r14
cmpq $0x6, %r14
jb 0x16c61
movq 0x8(%rsp), %rdi
leaq 0x4210(%rip), %rsi      # 0x1ae66
xorl %eax, %eax
callq 0xf48b
movb (%r12), %r13b
callq 0x4570
movq (%rax), %rax
movzbl %r13b, %ecx
movzwl (%rax,%rcx,2), %edx
shrl $0xb, %edx
andl $0x1, %edx
movzbl (%r12,%rdx), %ecx
movzwl (%rax,%rcx,2), %ecx
shrl $0xb, %ecx
andl $0x1, %ecx
addq %rdx, %rcx
movb (%r12,%rcx), %dl
cmpb $0x2e, %dl
jne 0x16cc1
leaq (%r12,%rcx), %rdx
incq %rdx
movzbl (%rdx), %esi
testb $0x8, 0x1(%rax,%rsi,2)
leaq 0x2(%r12,%rcx), %r12
cmoveq %rdx, %r12
movzbl (%r12), %ecx
movzwl (%rax,%rcx,2), %ecx
btl $0xb, %ecx
adcq $0x0, %r12
movb (%r12), %dl
jmp 0x16cc4
addq %rcx, %r12
leaq 0x40(%rsp), %r13
movzbl %dl, %ecx
testb $0x8, 0x1(%rax,%rcx,2)
je 0x16ce6
movq 0x8(%rsp), %rdi
leaq 0x41a7(%rip), %rsi      # 0x1ae86
xorl %eax, %eax
callq 0xf48b
movb $0x25, 0x10(%rsp)
movq %r12, %r14
subq %r15, %r14
leaq 0x1(%r14), %rdx
leaq 0x11(%rsp), %rdi
movq %r15, %rsi
callq 0x4090
movb $0x0, 0x12(%rsp,%r14)
movzbl (%r12), %eax
incq %r12
leal -0x63(%rax), %ecx
cmpl $0x15, %ecx
ja 0x16d52
leaq 0x3f21(%rip), %rdx      # 0x1ac40
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
leaq 0x240(%rsp), %r14
jmpq *%rcx
leaq 0x10(%rsp), %r15
movq %r15, %rdi
callq 0x18186
movq 0x8(%rsp), %rdi
movl 0x4(%rsp), %esi
callq 0xf87d
cvttsd2si %xmm0, %rdx
jmp 0x16da7
cmpl $0x45, %eax
leaq 0x240(%rsp), %r14
je 0x16db6
cmpl $0x47, %eax
je 0x16db6
cmpl $0x58, %eax
jne 0x16ff5
leaq 0x10(%rsp), %r15
movq %r15, %rdi
callq 0x18186
movq 0x8(%rsp), %rdi
movl 0x4(%rsp), %esi
callq 0xf87d
cvttsd2si %xmm0, %rax
movq %rax, %rcx
sarq $0x3f, %rcx
subsd 0x3e9c(%rip), %xmm0     # 0x1ac38
cvttsd2si %xmm0, %rdx
andq %rcx, %rdx
orq %rax, %rdx
movq %r13, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x44b0
jmp 0x16dd3
movq 0x8(%rsp), %rdi
movl 0x4(%rsp), %esi
callq 0xf87d
movq %r13, %rdi
leaq 0x10(%rsp), %rsi
movb $0x1, %al
callq 0x44b0
movq %r13, %rdi
callq 0x4140
movq %r14, %rdi
movq %r13, %rsi
movq %rax, %rdx
callq 0xfd3b
movl 0x4(%rsp), %r13d
jmp 0x16b61
movq 0x8(%rsp), %rdi
movl 0x4(%rsp), %esi
leaq 0x28(%rsp), %rdx
callq 0xf6c0
movq %rax, %r15
movq 0x240(%rsp), %rax
cmpq %rbp, %rax
jb 0x16e26
movq %r14, %rdi
callq 0xfdd0
movq 0x240(%rsp), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x240(%rsp)
movb $0x22, (%rax)
leaq 0x407a(%rip), %r13      # 0x1aeb6
subq $0x1, 0x28(%rsp)
jb 0x16f18
movzbl (%r15), %eax
testl %eax, %eax
je 0x16f02
cmpl $0xa, %eax
je 0x16e68
cmpl $0xd, %eax
je 0x16ec4
cmpl $0x5c, %eax
je 0x16e68
cmpl $0x22, %eax
jne 0x16ed2
movq 0x240(%rsp), %rax
cmpq %rbp, %rax
jb 0x16e85
movq %r14, %rdi
callq 0xfdd0
movq 0x240(%rsp), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x240(%rsp)
movb $0x5c, (%rax)
movq 0x240(%rsp), %rax
cmpq %rbp, %rax
jb 0x16eb1
movq %r14, %rdi
callq 0xfdd0
movq 0x240(%rsp), %rax
movb (%r15), %cl
leaq 0x1(%rax), %rdx
movq %rdx, 0x240(%rsp)
movb %cl, (%rax)
jmp 0x16f10
movq %r14, %rdi
leaq 0x3fe5(%rip), %rsi      # 0x1aeb3
pushq $0x2
jmp 0x16f0a
movq 0x240(%rsp), %rcx
cmpq %rbp, %rcx
jb 0x16ef2
movq %r14, %rdi
callq 0xfdd0
movb (%r15), %al
movq 0x240(%rsp), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x240(%rsp)
movb %al, (%rcx)
jmp 0x16f10
movq %r14, %rdi
movq %r13, %rsi
pushq $0x4
popq %rdx
callq 0xfd3b
incq %r15
jmp 0x16e3c
movq 0x240(%rsp), %rax
cmpq %rbp, %rax
jb 0x16f35
movq %r14, %rdi
callq 0xfdd0
movq 0x240(%rsp), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x240(%rsp)
movb $0x22, (%rax)
movl 0x4(%rsp), %r13d
jmp 0x16b61
movq 0x8(%rsp), %rdi
movl 0x4(%rsp), %esi
leaq 0x28(%rsp), %rdx
callq 0xf6c0
movq %rax, %r15
leaq 0x10(%rsp), %rdi
pushq $0x2e
popq %rsi
callq 0x4160
testq %rax, %rax
jne 0x16fc3
cmpq $0x63, 0x28(%rsp)
jbe 0x16fc3
movq 0x8(%rsp), %rdi
movl 0x4(%rsp), %r13d
movl %r13d, %esi
callq 0x541c
movq %r14, %rdi
callq 0xfebf
jmp 0x16b61
movq 0x8(%rsp), %rdi
movl 0x4(%rsp), %esi
callq 0xf87d
cvttsd2si %xmm0, %edx
movq %r13, %rdi
leaq 0x10(%rsp), %rsi
xorl %eax, %eax
callq 0x44b0
jmp 0x16dd3
movq %r13, %rdi
leaq 0x10(%rsp), %rsi
movq %r15, %rdx
jmp 0x16dad
leaq 0x240(%rsp), %rdi
callq 0xfdb2
pushq $0x1
popq %rax
addq $0x2258, %rsp           # imm = 0x2258
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movsbl %al, %edx
leaq 0x3e3f(%rip), %rsi      # 0x1ae3e
movq 0x8(%rsp), %rdi
xorl %eax, %eax
callq 0xf48b
jmp 0x16fe3