// File: /workspace/github_c_makefile_star2_O0/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:
subq $0x20f8, %rsp           # imm = 0x20F8
movq %rdi, 0x20e8(%rsp)
movq 0x20e8(%rsp), %rdi
callq 0x8e20
movl %eax, 0x20e4(%rsp)
movl $0x1, 0x20e0(%rsp)
movq 0x20e8(%rsp), %rdi
movl 0x20e0(%rsp), %esi
leaq 0x20d8(%rsp), %rdx
callq 0xcd00
movq %rax, 0x20d0(%rsp)
movq 0x20d0(%rsp), %rax
addq 0x20d8(%rsp), %rax
movq %rax, 0x20c8(%rsp)
movq 0x20e8(%rsp), %rdi
leaq 0xa8(%rsp), %rsi
callq 0xd390
movq 0x20d0(%rsp), %rax
cmpq 0x20c8(%rsp), %rax
jae 0x21590
movq 0x20d0(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x25, %eax
je 0x210be
movq 0xb8(%rsp), %rcx
movb $0x1, %al
cmpq 0xb0(%rsp), %rcx
movb %al, 0x3f(%rsp)
jb 0x2107a
leaq 0xa8(%rsp), %rdi
movl $0x1, %esi
callq 0xd080
cmpq $0x0, %rax
setne %al
movb %al, 0x3f(%rsp)
movb 0x3f(%rsp), %al
movq 0x20d0(%rsp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, 0x20d0(%rsp)
movb (%rax), %dl
movq 0xa8(%rsp), %rax
movq 0xb8(%rsp), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, 0xb8(%rsp)
movb %dl, (%rax,%rcx)
jmp 0x2158b
movq 0x20d0(%rsp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, 0x20d0(%rsp)
movsbl 0x1(%rax), %eax
cmpl $0x25, %eax
jne 0x21157
movq 0xb8(%rsp), %rcx
movb $0x1, %al
cmpq 0xb0(%rsp), %rcx
movb %al, 0x3e(%rsp)
jb 0x21113
leaq 0xa8(%rsp), %rdi
movl $0x1, %esi
callq 0xd080
cmpq $0x0, %rax
setne %al
movb %al, 0x3e(%rsp)
movb 0x3e(%rsp), %al
movq 0x20d0(%rsp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, 0x20d0(%rsp)
movb (%rax), %dl
movq 0xa8(%rsp), %rax
movq 0xb8(%rsp), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, 0xb8(%rsp)
movb %dl, (%rax,%rcx)
jmp 0x21589
leaq 0xa8(%rsp), %rdi
movl $0x200, %esi            # imm = 0x200
callq 0xd080
movq %rax, 0x88(%rsp)
movl $0x0, 0x84(%rsp)
movl 0x20e0(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x20e0(%rsp)
cmpl 0x20e4(%rsp), %eax
jle 0x211b1
movq 0x20e8(%rsp), %rdi
movl 0x20e0(%rsp), %esi
leaq 0x15aad(%rip), %rdx     # 0x36c59
callq 0xc3a0
movq 0x20e8(%rsp), %rdi
movq 0x20d0(%rsp), %rsi
leaq 0x90(%rsp), %rdx
callq 0x235b0
movq %rax, 0x20d0(%rsp)
movq 0x20d0(%rsp), %rax
movq %rax, %rcx
incq %rcx
movq %rcx, 0x20d0(%rsp)
movsbl (%rax), %eax
addl $-0x45, %eax
movl %eax, %ecx
movq %rcx, 0x30(%rsp)
subl $0x33, %eax
ja 0x21546
movq 0x30(%rsp), %rax
leaq 0x15702(%rip), %rcx     # 0x36910
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x88(%rsp), %rax
movq %rax, 0x20(%rsp)
leaq 0x90(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x20e8(%rsp), %rdi
movl 0x20e0(%rsp), %esi
callq 0xcf40
movq 0x20(%rsp), %rdi
movq 0x28(%rsp), %rsi
movl %eax, %edx
movb $0x0, %al
callq 0x7510
movl %eax, 0x84(%rsp)
jmp 0x21571
movq 0x20e8(%rsp), %rdi
movl 0x20e0(%rsp), %esi
callq 0xce90
movsd %xmm0, 0x78(%rsp)
cvttsd2si 0x78(%rsp), %rax
movq %rax, 0x70(%rsp)
movsd 0x78(%rsp), %xmm0
cvtsi2sdq 0x70(%rsp), %xmm1
subsd %xmm1, %xmm0
movsd %xmm0, 0x68(%rsp)
movsd 0x68(%rsp), %xmm0
movsd 0x15631(%rip), %xmm1    # 0x368e0
ucomisd %xmm1, %xmm0
jbe 0x212cb
movb $0x1, %al
movsd 0x14c69(%rip), %xmm0    # 0x35f28
ucomisd 0x68(%rsp), %xmm0
movb %al, 0x1f(%rsp)
ja 0x212f0
movq 0x20e8(%rsp), %rdi
movl 0x20e0(%rsp), %esi
leaq 0x15981(%rip), %rdx     # 0x36c62
callq 0xc3a0
cmpl $0x0, %eax
setne %al
movb %al, 0x1f(%rsp)
movb 0x1f(%rsp), %al
leaq 0x90(%rsp), %rdi
leaq 0x14208(%rip), %rsi     # 0x3550b
callq 0x237c0
movq 0x88(%rsp), %rdi
leaq 0x90(%rsp), %rsi
movq 0x70(%rsp), %rdx
movb $0x0, %al
callq 0x7510
movl %eax, 0x84(%rsp)
jmp 0x21571
movq 0x20e8(%rsp), %rdi
movl 0x20e0(%rsp), %esi
callq 0xce90
movsd %xmm0, 0x60(%rsp)
movsd 0x60(%rsp), %xmm0
movsd 0x15590(%rip), %xmm2    # 0x368e8
movaps %xmm0, %xmm1
subsd %xmm2, %xmm1
cvttsd2si %xmm1, %rcx
cvttsd2si %xmm0, %rax
movq %rax, %rdx
sarq $0x3f, %rdx
andq %rdx, %rcx
orq %rcx, %rax
movq %rax, 0x58(%rsp)
movsd 0x60(%rsp), %xmm0
movaps 0x15568(%rip), %xmm2    # 0x368f0
movq 0x58(%rsp), %xmm1
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movapd 0x15566(%rip), %xmm2    # 0x36900
subpd %xmm2, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
subsd %xmm1, %xmm0
movsd %xmm0, 0x50(%rsp)
movsd 0x50(%rsp), %xmm0
movsd 0x1551f(%rip), %xmm1    # 0x368e0
ucomisd %xmm1, %xmm0
jbe 0x213dd
movb $0x1, %al
movsd 0x14b57(%rip), %xmm0    # 0x35f28
ucomisd 0x50(%rsp), %xmm0
movb %al, 0x1e(%rsp)
ja 0x21402
movq 0x20e8(%rsp), %rdi
movl 0x20e0(%rsp), %esi
leaq 0x1588c(%rip), %rdx     # 0x36c7f
callq 0xc3a0
cmpl $0x0, %eax
setne %al
movb %al, 0x1e(%rsp)
movb 0x1e(%rsp), %al
leaq 0x90(%rsp), %rdi
leaq 0x140f6(%rip), %rsi     # 0x3550b
callq 0x237c0
movq 0x88(%rsp), %rdi
leaq 0x90(%rsp), %rsi
movq 0x58(%rsp), %rdx
movb $0x0, %al
callq 0x7510
movl %eax, 0x84(%rsp)
jmp 0x21571
leaq 0x90(%rsp), %rdi
leaq 0x14dd6(%rip), %rsi     # 0x36227
callq 0x237c0
movq 0x88(%rsp), %rax
movq %rax, 0x8(%rsp)
leaq 0x90(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x20e8(%rsp), %rdi
movl 0x20e0(%rsp), %esi
callq 0xce90
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %rsi
movb $0x1, %al
callq 0x7510
movl %eax, 0x84(%rsp)
jmp 0x21571
movq 0x20e8(%rsp), %rdi
movl 0x20e0(%rsp), %edx
leaq 0xa8(%rsp), %rsi
callq 0x23850
jmp 0x21571
movq 0x20e8(%rsp), %rdi
movl 0x20e0(%rsp), %esi
leaq 0x48(%rsp), %rdx
callq 0xdc50
movq %rax, 0x40(%rsp)
leaq 0x90(%rsp), %rdi
movl $0x2e, %esi
callq 0x7190
cmpq $0x0, %rax
jne 0x2150f
cmpq $0x64, 0x48(%rsp)
jb 0x2150f
leaq 0xa8(%rsp), %rdi
callq 0xd2f0
jmp 0x21571
movq 0x88(%rsp), %rdi
leaq 0x90(%rsp), %rsi
movq 0x40(%rsp), %rdx
movb $0x0, %al
callq 0x7510
movl %eax, 0x84(%rsp)
movq 0x20e8(%rsp), %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x8e50
jmp 0x21571
movq 0x20e8(%rsp), %rdi
movq 0x20d0(%rsp), %rax
movsbl -0x1(%rax), %edx
leaq 0x15748(%rip), %rsi     # 0x36ca9
movb $0x0, %al
callq 0xc520
movl %eax, 0x20f4(%rsp)
jmp 0x215a8
movslq 0x84(%rsp), %rax
addq 0xb8(%rsp), %rax
movq %rax, 0xb8(%rsp)
jmp 0x2158b
jmp 0x2101f
leaq 0xa8(%rsp), %rdi
callq 0xd260
movl $0x1, 0x20f4(%rsp)
movl 0x20f4(%rsp), %eax
addq $0x20f8, %rsp           # imm = 0x20F8
retq
nopw (%rax,%rax)