// File: /workspace/github_c_makefile_star2_O3/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 $0x2068, %rsp           # imm = 0x2068
movq %rdi, %r14
callq 0x7674
movl %eax, 0x24(%rsp)
leaq 0x40(%rsp), %rbx
movq %r14, %rdi
movl $0x1, %esi
movq %rbx, %rdx
callq 0x9690
movq %rax, %rbp
movq (%rbx), %rax
leaq 0x48(%rsp), %rsi
movq %r14, (%rsp)
movq %r14, %rdi
movq %rax, %r14
callq 0x9ad7
testq %r14, %r14
jle 0x1562b
addq %rbp, %r14
movl $0x1, %r12d
movb (%rbp), %al
cmpb $0x25, %al
jne 0x15107
leaq 0x1(%rbp), %rbx
cmpb $0x25, 0x1(%rbp)
jne 0x15146
movq 0x58(%rsp), %rax
movb $0x25, %cl
cmpq 0x50(%rsp), %rax
jb 0x150f0
movl $0x1, %esi
leaq 0x48(%rsp), %rdi
callq 0x98f7
movb (%rbx), %cl
movq 0x58(%rsp), %rax
addq $0x2, %rbp
movq 0x48(%rsp), %rdx
leaq 0x1(%rax), %rsi
movq %rsi, 0x58(%rsp)
movb %cl, (%rdx,%rax)
jmp 0x1513e
movq 0x58(%rsp), %rcx
cmpq 0x50(%rsp), %rcx
jb 0x1512a
movl $0x1, %esi
leaq 0x48(%rsp), %rdi
callq 0x98f7
movb (%rbp), %al
movq 0x58(%rsp), %rcx
incq %rbp
movq 0x48(%rsp), %rdx
leaq 0x1(%rcx), %rsi
movq %rsi, 0x58(%rsp)
movb %al, (%rdx,%rcx)
movl %r12d, %r13d
jmp 0x153ee
movq %r14, %r15
movl $0x200, %esi            # imm = 0x200
leaq 0x48(%rsp), %rdi
callq 0x98f7
movq %rax, 0x8(%rsp)
leal 0x1(%r12), %r13d
cmpl 0x24(%rsp), %r12d
jl 0x1517c
movq (%rsp), %rdi
movl %r13d, %esi
leaq 0xc81a(%rip), %rdx      # 0x21991
callq 0x905e
movb (%rbx), %r14b
testb %r14b, %r14b
leaq 0xc87a(%rip), %r12      # 0x21a03
je 0x151b5
movq %rbx, %rbp
movsbl %r14b, %esi
movl $0x6, %edx
movq %r12, %rdi
callq 0x6270
testq %rax, %rax
je 0x151bb
movb 0x1(%rbp), %r14b
incq %rbp
testb %r14b, %r14b
jne 0x1518e
xorl %r14d, %r14d
jmp 0x151bb
xorl %r14d, %r14d
movq %rbx, %rbp
movq %rbp, %rax
subq %rbx, %rax
cmpq $0x6, %rax
jb 0x151dd
movq (%rsp), %rdi
leaq 0xc837(%rip), %rsi      # 0x21a09
xorl %eax, %eax
callq 0x9144
movb (%rbp), %r14b
callq 0x65f0
movq %rax, %r12
movq (%rax), %rax
movzbl %r14b, %ecx
movzwl (%rax,%rcx,2), %ecx
shrl $0xb, %ecx
andl $0x1, %ecx
movzbl (%rbp,%rcx), %edx
movzwl (%rax,%rdx,2), %edx
btl $0xb, %edx
adcq %rcx, %rbp
movb (%rbp), %cl
cmpb $0x2e, %cl
jne 0x15242
leaq 0x1(%rbp), %rcx
movzbl 0x1(%rbp), %edx
xorl %esi, %esi
testb $0x8, 0x1(%rax,%rdx,2)
leaq 0x2(%rbp), %rdx
sete %sil
cmoveq %rcx, %rdx
negq %rsi
movzbl 0x2(%rbp,%rsi), %ecx
movzwl (%rax,%rcx,2), %ecx
btl $0xb, %ecx
adcq $0x0, %rdx
movb (%rdx), %cl
movq %rdx, %rbp
movzbl %cl, %ecx
testb $0x8, 0x1(%rax,%rcx,2)
je 0x1525e
movq (%rsp), %rdi
leaq 0xc7d2(%rip), %rsi      # 0x21a29
xorl %eax, %eax
callq 0x9144
movb $0x25, 0x10(%rsp)
movq %rbp, %r14
subq %rbx, %r14
leaq 0x1(%r14), %rdx
leaq 0x11(%rsp), %rdi
movq %rbx, %rsi
callq 0x6360
movb $0x0, 0x12(%rsp,%r14)
movzbl (%rbp), %eax
cmpl $0x62, %eax
jle 0x152ef
leal -0x63(%rax), %ecx
cmpl $0x15, %ecx
ja 0x1564c
movq %r15, %r14
leaq 0xc491(%rip), %rdx      # 0x21730
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
movq (%rsp), %rdi
movl %r13d, %esi
callq 0x9787
cvttsd2si %xmm0, %rbx
cvtsi2sd %rbx, %xmm1
subsd %xmm1, %xmm0
andpd 0xb996(%rip), %xmm0     # 0x20c60
movsd 0xb986(%rip), %xmm1     # 0x20c58
ucomisd %xmm0, %xmm1
ja 0x1538a
movq (%rsp), %rdi
movl %r13d, %esi
leaq 0xc6b0(%rip), %rdx      # 0x2199a
jmp 0x15385
cmpl $0x45, %eax
movq %r15, %r14
je 0x153b2
cmpl $0x47, %eax
je 0x153b2
cmpl $0x58, %eax
jne 0x1564c
movq (%rsp), %rdi
movl %r13d, %esi
callq 0x9787
cvttsd2si %xmm0, %rax
movq %rax, %rcx
sarq $0x3f, %rcx
movapd %xmm0, %xmm1
subsd 0xc3d7(%rip), %xmm1     # 0x21708
cvttsd2si %xmm1, %rbx
andq %rcx, %rbx
orq %rax, %rbx
movq %rbx, %xmm1
punpckldq 0xc3c7(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0xc3cf(%rip), %xmm1     # 0x21720
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
addsd %xmm1, %xmm2
subsd %xmm2, %xmm0
andpd 0xb8f7(%rip), %xmm0     # 0x20c60
movsd 0xb8e7(%rip), %xmm1     # 0x20c58
ucomisd %xmm0, %xmm1
ja 0x1538a
movq (%rsp), %rdi
movl %r13d, %esi
leaq 0xc632(%rip), %rdx      # 0x219b7
callq 0x905e
leaq 0x10(%rsp), %r15
movq %r15, %rdi
leaq 0xb122(%rip), %rsi      # 0x204bb
callq 0x16978
movq 0x8(%rsp), %rdi
movq %r15, %rsi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x6530
jmp 0x153e1
leaq 0x10(%rsp), %rbx
movq %rbx, %rdi
leaq 0xbb96(%rip), %rsi      # 0x20f57
callq 0x16978
movq (%rsp), %rdi
movl %r13d, %esi
callq 0x9787
movq 0x8(%rsp), %rdi
movq %rbx, %rsi
movb $0x1, %al
callq 0x6530
movl %eax, %ebx
incq %rbp
movslq %ebx, %rax
addq %rax, 0x58(%rsp)
movl %r13d, %r12d
cmpq %r14, %rbp
jb 0x150bb
jmp 0x1562b
movq (%rsp), %rdi
movl %r13d, %esi
leaq 0x30(%rsp), %rdx
callq 0xa08b
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
movl $0x2e, %esi
callq 0x6190
testq %rax, %rax
jne 0x15602
cmpq $0x64, 0x30(%rsp)
jb 0x15602
leaq 0x48(%rsp), %rdi
callq 0x9a54
jmp 0x155fb
movq (%rsp), %rdi
movl %r13d, %esi
callq 0x980b
movq 0x8(%rsp), %rdi
leaq 0x10(%rsp), %rsi
movl %eax, %edx
xorl %eax, %eax
callq 0x6530
jmp 0x153e1
movq (%rsp), %rdi
movl %r13d, %esi
leaq 0x28(%rsp), %rdx
callq 0x9690
movq %rax, %rbx
movq 0x58(%rsp), %rax
cmpq 0x50(%rsp), %rax
jb 0x1549e
movl $0x1, %esi
leaq 0x48(%rsp), %rdi
callq 0x98f7
movq 0x58(%rsp), %rax
movq 0x48(%rsp), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x58(%rsp)
movb $0x22, (%rcx,%rax)
subq $0x1, 0x28(%rsp)
jb 0x155c9
movb (%rbx), %al
movzbl %al, %edx
cmpl $0x21, %edx
jg 0x154d5
testl %edx, %edx
je 0x15585
cmpl $0xa, %edx
je 0x154df
jmp 0x15546
cmpl $0x22, %edx
je 0x154df
cmpl $0x5c, %edx
jne 0x15546
movq 0x58(%rsp), %rax
cmpq 0x50(%rsp), %rax
jb 0x154ff
movl $0x1, %esi
leaq 0x48(%rsp), %rdi
callq 0x98f7
movq 0x58(%rsp), %rax
movq 0x48(%rsp), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x58(%rsp)
movb $0x5c, (%rcx,%rax)
movq 0x58(%rsp), %rax
cmpq 0x50(%rsp), %rax
jb 0x15531
movl $0x1, %esi
leaq 0x48(%rsp), %rdi
callq 0x98f7
movq 0x58(%rsp), %rax
movb (%rbx), %cl
movq 0x48(%rsp), %rdx
leaq 0x1(%rax), %rsi
movq %rsi, 0x58(%rsp)
movb %cl, (%rdx,%rax)
jmp 0x155c1
movq (%r12), %rcx
testb $0x2, (%rcx,%rdx,2)
jne 0x15589
movq 0x58(%rsp), %rcx
cmpq 0x50(%rsp), %rcx
jb 0x15572
movl $0x1, %esi
leaq 0x48(%rsp), %rdi
callq 0x98f7
movb (%rbx), %al
movq 0x58(%rsp), %rcx
movq 0x48(%rsp), %rdx
leaq 0x1(%rcx), %rsi
movq %rsi, 0x58(%rsp)
movb %al, (%rdx,%rcx)
jmp 0x155c1
movq (%r12), %rcx
movzbl 0x1(%rbx), %eax
movzwl (%rcx,%rax,2), %eax
btl $0xb, %eax
leaq 0xc4ba(%rip), %rsi      # 0x21a56
jae 0x155a5
leaq 0xc4b5(%rip), %rsi      # 0x21a5a
leaq 0x30(%rsp), %r15
movq %r15, %rdi
xorl %eax, %eax
callq 0x6530
leaq 0x48(%rsp), %rdi
movq %r15, %rsi
callq 0x99d3
incq %rbx
jmp 0x154b0
movq 0x58(%rsp), %rax
cmpq 0x50(%rsp), %rax
jb 0x155e9
movl $0x1, %esi
leaq 0x48(%rsp), %rdi
callq 0x98f7
movq 0x58(%rsp), %rax
movq 0x48(%rsp), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x58(%rsp)
movb $0x22, (%rcx,%rax)
xorl %ebx, %ebx
jmp 0x153e3
movq 0x8(%rsp), %rdi
leaq 0x10(%rsp), %rsi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x6530
movl %eax, %ebx
movq (%rsp), %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x7688
jmp 0x153e3
leaq 0x48(%rsp), %rdi
callq 0x9a0c
movl $0x1, %eax
addq $0x2068, %rsp           # imm = 0x2068
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movsbl %al, %edx
leaq 0xc38b(%rip), %rsi      # 0x219e1
movq (%rsp), %rdi
xorl %eax, %eax
callq 0x9144
jmp 0x1563a