// File: /workspace/github_c_makefile_star2_O2/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 $0x2078, %rsp           # imm = 0x2078
movq %rdi, %r12
callq 0x7423
movl %eax, %r14d
pushq $0x1
popq %r15
leaq 0x50(%rsp), %rbx
movq %r12, %rdi
movl %r15d, %esi
movq %rbx, %rdx
callq 0x9264
movq %rax, %rbp
movq %rax, %r13
addq (%rbx), %r13
leaq 0x58(%rsp), %rsi
movq %r12, %rdi
callq 0x9657
movl %r15d, %ebx
cmpq %r13, %rbp
jae 0x141c7
movb (%rbp), %al
cmpb $0x25, %al
jne 0x13cb8
leaq 0x1(%rbp), %r15
cmpb $0x25, 0x1(%rbp)
jne 0x13cf2
movq 0x68(%rsp), %rax
movb $0x25, %cl
cmpq 0x60(%rsp), %rax
jb 0x13ca1
leaq 0x58(%rsp), %rdi
pushq $0x1
popq %rsi
callq 0x94ad
movb (%r15), %cl
movq 0x68(%rsp), %rax
addq $0x2, %rbp
movq 0x58(%rsp), %rdx
leaq 0x1(%rax), %rsi
movq %rsi, 0x68(%rsp)
movb %cl, (%rdx,%rax)
jmp 0x13c64
movq 0x68(%rsp), %rcx
cmpq 0x60(%rsp), %rcx
jb 0x13cd9
leaq 0x58(%rsp), %rdi
pushq $0x1
popq %rsi
callq 0x94ad
movb (%rbp), %al
movq 0x68(%rsp), %rcx
incq %rbp
movq 0x58(%rsp), %rdx
leaq 0x1(%rcx), %rsi
movq %rsi, 0x68(%rsp)
movb %al, (%rdx,%rcx)
jmp 0x13c64
movl $0x200, %esi            # imm = 0x200
leaq 0x58(%rsp), %rdi
callq 0x94ad
movq %rax, 0x8(%rsp)
leal 0x1(%rbx), %eax
movl %eax, 0x4(%rsp)
movl %r14d, 0x2c(%rsp)
cmpl %r14d, %ebx
jl 0x13d2a
movq %r12, %rdi
movl 0x4(%rsp), %esi
leaq 0xbc54(%rip), %rdx      # 0x1f979
callq 0x8c84
movq %r12, %r14
pushq $0x3
popq %r12
movq %r15, %rbp
movsbl (%rbp), %ebx
testl %ebx, %ebx
je 0x13d5a
leaq 0xbca8(%rip), %rdi      # 0x1f9eb
movl %ebx, %esi
pushq $0x6
popq %rdx
callq 0x6260
testq %rax, %rax
je 0x13d5a
incq %rbp
incq %r12
jmp 0x13d34
addq $-0x3, %r12
cmpq $0x6, %r12
movq %r14, %r12
jb 0x13d7b
movq %r12, %rdi
leaq 0xbc80(%rip), %rsi      # 0x1f9f1
xorl %eax, %eax
callq 0x8d68
movb (%rbp), %bl
callq 0x65e0
movq %rax, 0x30(%rsp)
movq (%rax), %rax
movzbl %bl, %ecx
movzwl (%rax,%rcx,2), %edx
shrl $0xb, %edx
andl $0x1, %edx
movzbl (%rbp,%rdx), %ecx
movzwl (%rax,%rcx,2), %ecx
shrl $0xb, %ecx
andl $0x1, %ecx
addq %rdx, %rcx
movb (%rbp,%rcx), %dl
cmpb $0x2e, %dl
movl 0x2c(%rsp), %r14d
jne 0x13de2
leaq (%rcx,%rbp), %rdx
incq %rdx
movzbl (%rdx), %esi
testb $0x8, 0x1(%rax,%rsi,2)
leaq 0x2(%rbp,%rcx), %rbp
cmoveq %rdx, %rbp
movzbl (%rbp), %ecx
movzwl (%rax,%rcx,2), %ecx
btl $0xb, %ecx
adcq $0x0, %rbp
movb (%rbp), %dl
jmp 0x13de5
addq %rcx, %rbp
movzbl %dl, %ecx
testb $0x8, 0x1(%rax,%rcx,2)
je 0x13e00
movq %r12, %rdi
leaq 0xbc18(%rip), %rsi      # 0x1fa11
xorl %eax, %eax
callq 0x8d68
movb $0x25, 0x10(%rsp)
movq %rbp, %rbx
subq %r15, %rbx
leaq 0x1(%rbx), %rdx
leaq 0x11(%rsp), %rdi
movq %r15, %rsi
callq 0x6350
movb $0x0, 0x12(%rsp,%rbx)
movzbl (%rbp), %eax
leal -0x63(%rax), %ecx
cmpl $0x15, %ecx
ja 0x13ea7
leaq 0xb8cc(%rip), %rdx      # 0x1f700
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
movl 0x4(%rsp), %r15d
jmpq *%rcx
movq %r12, %rdi
movl %r15d, %esi
callq 0x9364
cvttsd2si %xmm0, %rbx
cvtsi2sd %rbx, %xmm1
subsd %xmm1, %xmm0
andpd 0xadcd(%rip), %xmm0     # 0x1ec30
movsd 0xadbd(%rip), %xmm1     # 0x1ec28
ucomisd %xmm0, %xmm1
ja 0x13e83
movq %r12, %rdi
movl %r15d, %esi
leaq 0xbb04(%rip), %rdx      # 0x1f982
callq 0x8c84
leaq 0x10(%rsp), %r15
movq %r15, %rdi
leaq 0xa5f9(%rip), %rsi      # 0x1e48b
callq 0x15483
movq 0x8(%rsp), %rdi
movq %r15, %rsi
movq %rbx, %rdx
jmp 0x13f62
cmpl $0x45, %eax
movl 0x4(%rsp), %r15d
je 0x13f6b
cmpl $0x47, %eax
je 0x13f6b
cmpl $0x58, %eax
jne 0x141e6
movq %r12, %rdi
movl %r15d, %esi
callq 0x9364
cvttsd2si %xmm0, %rax
movq %rax, %rcx
sarq $0x3f, %rcx
movapd %xmm0, %xmm1
subsd 0xb7ee(%rip), %xmm1     # 0x1f6d8
cvttsd2si %xmm1, %r15
andq %rcx, %r15
orq %rax, %r15
movq %r15, %xmm1
punpckldq 0xb7de(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0xb7e6(%rip), %xmm1     # 0x1f6f0
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
addsd %xmm1, %xmm2
subsd %xmm2, %xmm0
andpd 0xad0e(%rip), %xmm0     # 0x1ec30
movsd 0xacfe(%rip), %xmm1     # 0x1ec28
ucomisd %xmm0, %xmm1
ja 0x13f43
movq %r12, %rdi
movl 0x4(%rsp), %esi
leaq 0xba61(%rip), %rdx      # 0x1f99f
callq 0x8c84
leaq 0x10(%rsp), %rbx
movq %rbx, %rdi
leaq 0xa539(%rip), %rsi      # 0x1e48b
callq 0x15483
movq 0x8(%rsp), %rdi
movq %rbx, %rsi
movq %r15, %rdx
xorl %eax, %eax
callq 0x6520
jmp 0x13f99
leaq 0x10(%rsp), %rbx
movq %rbx, %rdi
leaq 0xafad(%rip), %rsi      # 0x1ef27
callq 0x15483
movq %r12, %rdi
movl %r15d, %esi
callq 0x9364
movq 0x8(%rsp), %rdi
movq %rbx, %rsi
movb $0x1, %al
callq 0x6520
movl %eax, %r15d
incq %rbp
movslq %r15d, %rax
addq %rax, 0x68(%rsp)
movl 0x4(%rsp), %r15d
jmp 0x13c61
movq %r12, %rdi
movl %r15d, %esi
leaq 0x48(%rsp), %rdx
callq 0x9264
movq %rax, %r15
movq 0x68(%rsp), %rax
cmpq 0x60(%rsp), %rax
jb 0x13fe2
leaq 0x58(%rsp), %rdi
pushq $0x1
popq %rsi
callq 0x94ad
movq 0x68(%rsp), %rax
movq 0x58(%rsp), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x68(%rsp)
movb $0x22, (%rcx,%rax)
subq $0x1, 0x48(%rsp)
jb 0x1410c
movzbl (%r15), %edx
cmpq $0x5c, %rdx
je 0x14025
cmpl $0xa, %edx
je 0x14025
cmpl $0x22, %edx
je 0x14025
testl %edx, %edx
jne 0x14089
movq 0x30(%rsp), %rax
movq (%rax), %rax
jmp 0x140cb
movq 0x68(%rsp), %rax
cmpq 0x60(%rsp), %rax
jb 0x14043
leaq 0x58(%rsp), %rdi
pushq $0x1
popq %rsi
callq 0x94ad
movq 0x68(%rsp), %rax
movq 0x58(%rsp), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x68(%rsp)
movb $0x5c, (%rcx,%rax)
movq 0x68(%rsp), %rax
cmpq 0x60(%rsp), %rax
jb 0x14073
leaq 0x58(%rsp), %rdi
pushq $0x1
popq %rsi
callq 0x94ad
movq 0x68(%rsp), %rax
movb (%r15), %cl
movq 0x58(%rsp), %rdx
leaq 0x1(%rax), %rsi
movq %rsi, 0x68(%rsp)
movb %cl, (%rdx,%rax)
jmp 0x14104
movq 0x30(%rsp), %rax
movq (%rax), %rax
testb $0x2, (%rax,%rdx,2)
jne 0x140cb
movq 0x68(%rsp), %rax
cmpq 0x60(%rsp), %rax
jb 0x140b8
leaq 0x58(%rsp), %rdi
pushq $0x1
popq %rsi
callq 0x94ad
movb (%r15), %dl
movq 0x68(%rsp), %rax
movq 0x58(%rsp), %rcx
leaq 0x1(%rax), %rsi
movq %rsi, 0x68(%rsp)
movb %dl, (%rcx,%rax)
jmp 0x14104
movzbl 0x1(%r15), %ecx
movzwl (%rax,%rcx,2), %eax
btl $0xb, %eax
leaq 0xb95f(%rip), %rsi      # 0x1fa3e
jae 0x140e8
leaq 0xb95a(%rip), %rsi      # 0x1fa42
leaq 0x38(%rsp), %rbx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x6520
leaq 0x58(%rsp), %rdi
movq %rbx, %rsi
callq 0x9587
incq %r15
jmp 0x13ff4
movq 0x68(%rsp), %rax
cmpq 0x60(%rsp), %rax
jb 0x1412a
leaq 0x58(%rsp), %rdi
pushq $0x1
popq %rsi
callq 0x94ad
movq 0x68(%rsp), %rax
movq 0x58(%rsp), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x68(%rsp)
movb $0x22, (%rcx,%rax)
jmp 0x14175
movq %r12, %rdi
movl %r15d, %esi
leaq 0x38(%rsp), %rdx
callq 0x9bc6
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
pushq $0x2e
popq %rsi
callq 0x6190
testq %rax, %rax
jne 0x141a0
cmpq $0x64, 0x38(%rsp)
jb 0x141a0
leaq 0x58(%rsp), %rdi
callq 0x95f4
xorl %r15d, %r15d
jmp 0x13f9c
movq %r12, %rdi
movl %r15d, %esi
callq 0x93db
movq 0x8(%rsp), %rdi
leaq 0x10(%rsp), %rsi
movl %eax, %edx
xorl %eax, %eax
callq 0x6520
jmp 0x13f99
movq 0x8(%rsp), %rdi
leaq 0x10(%rsp), %rsi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x6520
movl %eax, %r15d
movq %r12, %rdi
pushq $-0x2
popq %rsi
callq 0x7437
jmp 0x13f9c
leaq 0x58(%rsp), %rdi
callq 0x95ae
pushq $0x1
popq %rax
addq $0x2078, %rsp           # imm = 0x2078
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movsbl %al, %edx
leaq 0xb7d9(%rip), %rsi      # 0x1f9c9
movq %r12, %rdi
xorl %eax, %eax
callq 0x8d68
jmp 0x141d4