// File: /workspace/github_c_makefile_star2_O1/bhk[P]tooltree/lua/../opensource/lua-5.2.3/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 = luaL_prepbuffsize(&b, MAX_ITEM);  /* to put formatted item */
      int nb = 0;  /* number of bytes in added item */
      if (++arg > top)
        luaL_argerror(L, arg, "no value");
      strfrmt = scanformat(L, strfrmt, form);
      switch (*strfrmt++) {
        case 'c': {
          nb = sprintf(buff, form, luaL_checkint(L, arg));
          break;
        }
        case 'd': case 'i': {
          lua_Number n = luaL_checknumber(L, arg);
          LUA_INTFRM_T ni = (LUA_INTFRM_T)n;
          lua_Number diff = n - (lua_Number)ni;
          luaL_argcheck(L, -1 < diff && diff < 1, arg,
                        "not a number in proper range");
          addlenmod(form, LUA_INTFRMLEN);
          nb = sprintf(buff, form, ni);
          break;
        }
        case 'o': case 'u': case 'x': case 'X': {
          lua_Number n = luaL_checknumber(L, arg);
          unsigned LUA_INTFRM_T ni = (unsigned LUA_INTFRM_T)n;
          lua_Number diff = n - (lua_Number)ni;
          luaL_argcheck(L, -1 < diff && diff < 1, arg,
                        "not a non-negative number in proper range");
          addlenmod(form, LUA_INTFRMLEN);
          nb = sprintf(buff, form, ni);
          break;
        }
        case 'e': case 'E': case 'f':
#if defined(LUA_USE_AFORMAT)
        case 'a': case 'A':
#endif
        case 'g': case 'G': {
          addlenmod(form, LUA_FLTFRMLEN);
          nb = sprintf(buff, form, (LUA_FLTFRM_T)luaL_checknumber(L, arg));
          break;
        }
        case 'q': {
          addquoted(L, &b, arg);
          break;
        }
        case 's': {
          size_t l;
          const char *s = luaL_tolstring(L, arg, &l);
          if (!strchr(form, '.') && l >= 100) {
            /* no precision and string is too long to be formatted;
               keep original string */
            luaL_addvalue(&b);
            break;
          }
          else {
            nb = sprintf(buff, form, s);
            lua_pop(L, 1);  /* remove result from 'luaL_tolstring' */
            break;
          }
        }
        default: {  /* also treat cases `pnLlh' */
          return luaL_error(L, "invalid option " LUA_QL("%%%c") " to "
                               LUA_QL("format"), *(strfrmt - 1));
        }
      }
      luaL_addsize(&b, nb);
    }
  }
  luaL_pushresult(&b);
  return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2088, %rsp           # imm = 0x2088
movq %rdi, %r15
callq 0x7683
movl %eax, 0x44(%rsp)
leaq 0x60(%rsp), %r14
movq %r15, %rdi
movl $0x1, %esi
movq %r14, %rdx
callq 0x9559
movq %rax, %rbx
movq (%r14), %r13
leaq 0x68(%rsp), %rsi
movq %r15, 0x10(%rsp)
movq %r15, %rdi
callq 0x999b
testq %r13, %r13
jle 0x15502
addq %rbx, %r13
movl $0x1, %r12d
leaq 0x68(%rsp), %rbp
leaq 0xca50(%rip), %r15      # 0x21a0b
cmpb $0x25, (%rbx)
jne 0x14fef
leaq 0x1(%rbx), %r14
cmpb $0x25, 0x1(%rbx)
jne 0x1502c
movq 0x78(%rsp), %rax
cmpq 0x70(%rsp), %rax
jb 0x14fe3
movl $0x1, %esi
movq %rbp, %rdi
callq 0x97c0
movq %rbx, %rax
addq $0x2, %rax
movq %r14, %rbx
jmp 0x1500c
movq 0x78(%rsp), %rax
cmpq 0x70(%rsp), %rax
jb 0x15008
movl $0x1, %esi
movq %rbp, %rdi
callq 0x97c0
leaq 0x1(%rbx), %rax
movb (%rbx), %cl
movq 0x68(%rsp), %rdx
movq 0x78(%rsp), %rsi
leaq 0x1(%rsi), %rdi
movq %rdi, 0x78(%rsp)
movb %cl, (%rdx,%rsi)
movq %rax, %rbx
jmp 0x152d3
movl $0x200, %esi            # imm = 0x200
movq %rbp, %rdi
callq 0x97c0
movq %rax, 0x18(%rsp)
leal 0x1(%r12), %eax
movl %eax, 0xc(%rsp)
cmpl 0x44(%rsp), %r12d
jl 0x15063
movq 0x10(%rsp), %rdi
movl 0xc(%rsp), %esi
leaq 0xc93b(%rip), %rdx      # 0x21999
callq 0x8f3e
movb (%r14), %al
movq %r14, %rbx
testb %al, %al
je 0x1508f
movq %r14, %rbx
movsbl %al, %esi
movl $0x6, %edx
movq %r15, %rdi
callq 0x6270
testq %rax, %rax
je 0x1508f
movb 0x1(%rbx), %al
incq %rbx
testb %al, %al
jne 0x15070
movq %rbx, %rax
subq %r14, %rax
cmpq $0x6, %rax
jb 0x150ae
movq 0x10(%rsp), %rdi
leaq 0xc96a(%rip), %rsi      # 0x21a11
xorl %eax, %eax
callq 0x9024
callq 0x65f0
movq %rax, %r12
movq (%rax), %rax
movzbl (%rbx), %ecx
movzwl (%rax,%rcx,2), %ecx
shrl $0xb, %ecx
andl $0x1, %ecx
movzbl (%rbx,%rcx), %edx
movzwl (%rax,%rdx,2), %edx
btl $0xb, %edx
adcq %rcx, %rbx
cmpb $0x2e, (%rbx)
jne 0x1510c
leaq 0x1(%rbx), %rcx
movzbl 0x1(%rbx), %edx
leaq 0x2(%rbx), %rsi
xorl %edi, %edi
testb $0x8, 0x1(%rax,%rdx,2)
cmoveq %rcx, %rsi
sete %dil
negq %rdi
movzbl 0x2(%rbx,%rdi), %ecx
movzwl (%rax,%rcx,2), %ecx
btl $0xb, %ecx
adcq $0x0, %rsi
movq %rsi, %rbx
movzbl (%rbx), %ecx
testb $0x8, 0x1(%rax,%rcx,2)
je 0x15129
movq 0x10(%rsp), %rdi
leaq 0xc90f(%rip), %rsi      # 0x21a31
xorl %eax, %eax
callq 0x9024
movb $0x25, 0x20(%rsp)
movq %rbx, %rbp
subq %r14, %rbp
leaq 0x1(%rbp), %rdx
leaq 0x21(%rsp), %rdi
movq %r14, %rsi
callq 0x6360
movb $0x0, 0x22(%rsp,%rbp)
movzbl (%rbx), %eax
cmpl $0x62, %eax
jle 0x151b9
leal -0x63(%rax), %ecx
cmpl $0x15, %ecx
ja 0x154b7
leaq 0xc5bb(%rip), %rdx      # 0x21720
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
movq 0x10(%rsp), %rdi
movl 0xc(%rsp), %esi
callq 0x9650
cvttsd2si %xmm0, %r14
cvtsi2sd %r14, %xmm1
subsd %xmm1, %xmm0
andpd 0xbace(%rip), %xmm0     # 0x20c60
movsd 0xbabe(%rip), %xmm1     # 0x20c58
ucomisd %xmm0, %xmm1
ja 0x15255
movq 0x10(%rsp), %rdi
movl 0xc(%rsp), %esi
leaq 0xc7ee(%rip), %rdx      # 0x219a2
jmp 0x15250
cmpl $0x45, %eax
je 0x1527d
cmpl $0x47, %eax
je 0x1527d
cmpl $0x58, %eax
jne 0x154b7
movq 0x10(%rsp), %rdi
movl 0xc(%rsp), %esi
callq 0x9650
cvttsd2si %xmm0, %rax
movq %rax, %rcx
sarq $0x3f, %rcx
movapd %xmm0, %xmm1
subsd 0xc4fe(%rip), %xmm1     # 0x216f8
cvttsd2si %xmm1, %r14
andq %rcx, %r14
orq %rax, %r14
movq %r14, %xmm1
punpckldq 0xc4ee(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0xc4f6(%rip), %xmm1     # 0x21710
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
addsd %xmm1, %xmm2
subsd %xmm2, %xmm0
andpd 0xba2e(%rip), %xmm0     # 0x20c60
movsd 0xba1e(%rip), %xmm1     # 0x20c58
ucomisd %xmm0, %xmm1
ja 0x15255
movq 0x10(%rsp), %rdi
movl 0xc(%rsp), %esi
leaq 0xc76f(%rip), %rdx      # 0x219bf
callq 0x8f3e
leaq 0x20(%rsp), %r12
movq %r12, %rdi
leaq 0xb227(%rip), %rsi      # 0x2048b
callq 0x1689b
movq 0x18(%rsp), %rdi
movq %r12, %rsi
movq %r14, %rdx
xorl %eax, %eax
callq 0x6530
jmp 0x152ae
leaq 0x20(%rsp), %r14
movq %r14, %rdi
leaq 0xbccb(%rip), %rsi      # 0x20f57
callq 0x1689b
movq 0x10(%rsp), %rdi
movl 0xc(%rsp), %esi
callq 0x9650
movq 0x18(%rsp), %rdi
movq %r14, %rsi
movb $0x1, %al
callq 0x6530
movl %eax, %ebp
movslq %ebp, %rax
addq %rax, 0x78(%rsp)
movb $0x1, %bpl
testb %bpl, %bpl
je 0x15523
incq %rbx
movl 0xc(%rsp), %eax
movl %eax, %r12d
leaq 0x68(%rsp), %rbp
cmpq %r13, %rbx
jb 0x14fbb
jmp 0x15502
movq 0x10(%rsp), %rdi
movl 0xc(%rsp), %esi
callq 0x96d4
movq 0x18(%rsp), %rdi
leaq 0x20(%rsp), %rsi
movl %eax, %edx
xorl %eax, %eax
callq 0x6530
jmp 0x152ae
movq 0x10(%rsp), %rdi
movl 0xc(%rsp), %esi
leaq 0x50(%rsp), %rdx
callq 0x9f37
movq %rax, %r14
leaq 0x20(%rsp), %rdi
movl $0x2e, %esi
callq 0x6190
testq %rax, %rax
jne 0x154d8
cmpq $0x64, 0x50(%rsp)
jb 0x154d8
leaq 0x68(%rsp), %rdi
callq 0x9918
jmp 0x154b0
movq 0x10(%rsp), %rdi
movl 0xc(%rsp), %esi
leaq 0x48(%rsp), %rdx
callq 0x9559
movq %rax, %r14
movq 0x78(%rsp), %rax
cmpq 0x70(%rsp), %rax
jb 0x1537e
movl $0x1, %esi
leaq 0x68(%rsp), %rdi
callq 0x97c0
movq 0x68(%rsp), %rax
movq 0x78(%rsp), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x78(%rsp)
movb $0x22, (%rax,%rcx)
subq $0x1, 0x48(%rsp)
jb 0x1547e
movzbl (%r14), %eax
cmpl $0x21, %eax
jg 0x153b9
testl %eax, %eax
je 0x15435
cmpl $0xa, %eax
je 0x153c3
jmp 0x1542b
cmpl $0x5c, %eax
je 0x153c3
cmpl $0x22, %eax
jne 0x1542b
movq 0x78(%rsp), %rax
cmpq 0x70(%rsp), %rax
jb 0x153de
movl $0x1, %esi
leaq 0x68(%rsp), %rdi
callq 0x97c0
movq 0x68(%rsp), %rax
movq 0x78(%rsp), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x78(%rsp)
movb $0x5c, (%rax,%rcx)
movq 0x78(%rsp), %rax
cmpq 0x70(%rsp), %rax
jb 0x15410
movl $0x1, %esi
leaq 0x68(%rsp), %rdi
callq 0x97c0
movb (%r14), %al
movq 0x68(%rsp), %rcx
movq 0x78(%rsp), %rdx
leaq 0x1(%rdx), %rsi
movq %rsi, 0x78(%rsp)
movb %al, (%rcx,%rdx)
jmp 0x15476
movq (%r12), %rcx
testb $0x2, (%rcx,%rax,2)
je 0x153f5
movq (%r12), %rax
movzbl 0x1(%r14), %ecx
movzwl (%rax,%rcx,2), %eax
btl $0xb, %eax
leaq 0xc611(%rip), %rsi      # 0x21a5e
jae 0x15456
leaq 0xc60c(%rip), %rsi      # 0x21a62
movzbl (%r14), %edx
leaq 0x50(%rsp), %rbp
movq %rbp, %rdi
xorl %eax, %eax
callq 0x6530
leaq 0x68(%rsp), %rdi
movq %rbp, %rsi
callq 0x9897
incq %r14
jmp 0x15395
movq 0x78(%rsp), %rax
cmpq 0x70(%rsp), %rax
jb 0x15499
movl $0x1, %esi
leaq 0x68(%rsp), %rdi
callq 0x97c0
movq 0x68(%rsp), %rax
movq 0x78(%rsp), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x78(%rsp)
movb $0x22, (%rax,%rcx)
xorl %ebp, %ebp
jmp 0x152b0
movsbl %al, %edx
xorl %ebp, %ebp
movq 0x10(%rsp), %rdi
leaq 0xc521(%rip), %rsi      # 0x219e9
xorl %eax, %eax
callq 0x9024
movl %eax, 0x40(%rsp)
jmp 0x152bb
movq 0x18(%rsp), %rdi
leaq 0x20(%rsp), %rsi
movq %r14, %rdx
xorl %eax, %eax
callq 0x6530
movl %eax, %ebp
movq 0x10(%rsp), %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x7697
jmp 0x152b0
leaq 0x68(%rsp), %rdi
callq 0x98d0
movl $0x1, %eax
addq $0x2088, %rsp           # imm = 0x2088
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl 0x40(%rsp), %eax
jmp 0x15511