// File: /workspace/github_c_makefile_star2_O2/tylerneylon[P]APIsWithLua/lua/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 = l_sprintf(buff, MAX_ITEM, form, (int)luaL_checkinteger(L, arg));
          break;
        }
        case 'd': case 'i':
        case 'o': case 'u': case 'x': case 'X': {
          lua_Integer n = luaL_checkinteger(L, arg);
          addlenmod(form, LUA_INTEGER_FRMLEN);
          nb = l_sprintf(buff, MAX_ITEM, form, n);
          break;
        }
        case 'a': case 'A':
          addlenmod(form, LUA_NUMBER_FRMLEN);
          nb = lua_number2strx(L, buff, MAX_ITEM, form,
                                  luaL_checknumber(L, arg));
          break;
        case 'e': case 'E': case 'f':
        case 'g': case 'G': {
          addlenmod(form, LUA_NUMBER_FRMLEN);
          nb = l_sprintf(buff, MAX_ITEM, form, luaL_checknumber(L, arg));
          break;
        }
        case 'q': {
          addliteral(L, &b, arg);
          break;
        }
        case 's': {
          size_t l;
          const char *s = luaL_tolstring(L, arg, &l);
          if (form[2] == '\0')  /* no modifiers? */
            luaL_addvalue(&b);  /* keep entire string */
          else {
            luaL_argcheck(L, l == strlen(s), arg, "string contains zeros");
            if (!strchr(form, '.') && l >= 100) {
              /* no precision and string is too long to be formatted */
              luaL_addvalue(&b);  /* keep entire string */
            }
            else {  /* format the string into 'buff' */
              nb = l_sprintf(buff, MAX_ITEM, form, s);
              lua_pop(L, 1);  /* remove result from 'luaL_tolstring' */
            }
          }
          break;
        }
        default: {  /* also treat cases 'pnLlh' */
          return luaL_error(L, "invalid option '%%%c' to 'format'",
                               *(strfrmt - 1));
        }
      }
      lua_assert(nb < MAX_ITEM);
      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 0x5b1d
movl %eax, %r14d
pushq $0x1
popq %r15
leaq 0x50(%rsp), %rbx
movq %r12, %rdi
movl %r15d, %esi
movq %rbx, %rdx
callq 0x13131
movq %rax, %rbp
movq %rax, %r13
addq (%rbx), %r13
leaq 0x58(%rsp), %rsi
movq %r12, %rdi
callq 0x13589
movl %r15d, %ebx
cmpq %r13, %rbp
jae 0x1ad09
movb (%rbp), %al
cmpb $0x25, %al
jne 0x1a77d
leaq 0x1(%rbp), %r15
cmpb $0x25, 0x1(%rbp)
jne 0x1a7b7
movq 0x68(%rsp), %rax
movb $0x25, %cl
cmpq 0x60(%rsp), %rax
jb 0x1a766
leaq 0x58(%rsp), %rdi
pushq $0x1
popq %rsi
callq 0x132de
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 0x1a729
movq 0x68(%rsp), %rcx
cmpq 0x60(%rsp), %rcx
jb 0x1a79e
leaq 0x58(%rsp), %rdi
pushq $0x1
popq %rsi
callq 0x132de
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 0x1a729
movl $0x1ac, %esi            # imm = 0x1AC
leaq 0x58(%rsp), %rdi
callq 0x132de
movq %rax, 0x8(%rsp)
leal 0x1(%rbx), %eax
movl %eax, 0x4(%rsp)
movl %r14d, 0x1c(%rsp)
cmpl %r14d, %ebx
jl 0x1a7ef
movq %r12, %rdi
movl 0x4(%rsp), %esi
leaq 0x5561(%rip), %rdx      # 0x1fd4b
callq 0x12af2
movq %r12, %r14
pushq $0x3
popq %r12
movq %r15, %rbp
movsbl (%rbp), %ebx
testl %ebx, %ebx
je 0x1a81f
leaq 0x6f27(%rip), %rdi      # 0x2172f
movl %ebx, %esi
pushq $0x6
popq %rdx
callq 0x5210
testq %rax, %rax
je 0x1a81f
incq %rbp
incq %r12
jmp 0x1a7f9
addq $-0x3, %r12
cmpq $0x6, %r12
movq %r14, %r12
jb 0x1a840
movq %r12, %rdi
leaq 0x6eff(%rip), %rsi      # 0x21735
xorl %eax, %eax
callq 0x12bd6
movb (%rbp), %bl
callq 0x5520
movq %rax, 0x40(%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 0x1c(%rsp), %r14d
jne 0x1a8a7
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 0x1a8aa
addq %rcx, %rbp
movzbl %dl, %ecx
testb $0x8, 0x1(%rax,%rcx,2)
je 0x1a8c5
movq %r12, %rdi
leaq 0x6e97(%rip), %rsi      # 0x21755
xorl %eax, %eax
callq 0x12bd6
movb $0x25, 0x20(%rsp)
movq %rbp, %rbx
subq %r15, %rbx
leaq 0x1(%rbx), %rdx
leaq 0x21(%rsp), %rdi
movq %r15, %rsi
callq 0x5300
movb $0x0, 0x22(%rsp,%rbx)
movzbl (%rbp), %eax
leal -0x61(%rax), %ecx
cmpl $0x17, %ecx
ja 0x1a942
leaq 0x6a9f(%rip), %rdx      # 0x21398
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
movl 0x4(%rsp), %r15d
jmpq *%rcx
movq %r12, %rdi
movl %r15d, %esi
callq 0x13252
movq %rax, %rbx
leaq 0x20(%rsp), %r15
movq %r15, %rdi
leaq 0x6545(%rip), %rsi      # 0x20e69
callq 0x1c739
movl $0x1ac, %esi            # imm = 0x1AC
movq 0x8(%rsp), %rdi
movq %r15, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x5180
jmp 0x1a993
cmpl $0x41, %eax
movl 0x4(%rsp), %r15d
je 0x1a960
cmpl $0x45, %eax
je 0x1a960
cmpl $0x47, %eax
je 0x1a960
cmpl $0x58, %eax
je 0x1a907
jmp 0x1ad28
leaq 0x20(%rsp), %rbx
movq %rbx, %rdi
leaq 0x7479(%rip), %rsi      # 0x21de8
callq 0x1c739
movq %r12, %rdi
movl %r15d, %esi
callq 0x131db
movl $0x1ac, %esi            # imm = 0x1AC
movq 0x8(%rsp), %rdi
movq %rbx, %rdx
movb $0x1, %al
callq 0x5180
movl %eax, %r15d
incq %rbp
movslq %r15d, %rax
addq %rax, 0x68(%rsp)
movl 0x4(%rsp), %r15d
jmp 0x1a726
movq %r12, %rdi
movl %r15d, %esi
callq 0x5d12
cmpl $0x2, %eax
jb 0x1abc2
cmpl $0x3, %eax
je 0x1ac0d
movq %r12, %rdi
movl %r15d, %esi
cmpl $0x4, %eax
jne 0x1ac9f
leaq 0x48(%rsp), %rdx
callq 0x5fca
movq %rax, %r15
movq 0x48(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x68(%rsp), %rax
cmpq 0x60(%rsp), %rax
jb 0x1aa0c
leaq 0x58(%rsp), %rdi
pushq $0x1
popq %rsi
callq 0x132de
movq 0x68(%rsp), %rax
movq 0x58(%rsp), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x68(%rsp)
movb $0x22, (%rcx,%rax)
xorl %ebx, %ebx
cmpq %rbx, 0x8(%rsp)
je 0x1ac6d
movzbl (%r15,%rbx), %ecx
cmpq $0xa, %rcx
je 0x1aa40
cmpl $0x5c, %ecx
je 0x1aa40
cmpl $0x22, %ecx
jne 0x1aaab
movq 0x68(%rsp), %rax
cmpq 0x60(%rsp), %rax
jb 0x1aa5e
leaq 0x58(%rsp), %rdi
pushq $0x1
popq %rsi
callq 0x132de
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 0x1aa8e
leaq 0x58(%rsp), %rdi
pushq $0x1
popq %rsi
callq 0x132de
movq 0x68(%rsp), %rax
movb (%r15,%rbx), %cl
movq 0x58(%rsp), %rdx
leaq 0x1(%rax), %rsi
movq %rsi, 0x68(%rsp)
movb %cl, (%rdx,%rax)
incq %rbx
jmp 0x1aa20
movq 0x40(%rsp), %rax
movq (%rax), %rax
testb $0x2, (%rax,%rcx,2)
jne 0x1aaee
movq 0x68(%rsp), %rax
cmpq 0x60(%rsp), %rax
jb 0x1aadb
leaq 0x58(%rsp), %rdi
pushq $0x1
popq %rsi
callq 0x132de
movb (%r15,%rbx), %cl
movq 0x68(%rsp), %rax
movq 0x58(%rsp), %rdx
leaq 0x1(%rax), %rsi
movq %rsi, 0x68(%rsp)
movb %cl, (%rdx,%rax)
jmp 0x1aaa3
movzbl 0x1(%r15,%rbx), %edx
movzwl (%rax,%rdx,2), %eax
btl $0xb, %eax
leaq 0x6ca3(%rip), %rdx      # 0x217a6
jae 0x1ab0c
leaq 0x6c9e(%rip), %rdx      # 0x217aa
leaq 0x10(%rsp), %rdi
pushq $0xa
popq %rsi
xorl %eax, %eax
callq 0x5180
leaq 0x58(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x13493
jmp 0x1aaa3
movq %r12, %rdi
movl %r15d, %esi
leaq 0x10(%rsp), %rdx
callq 0x13b27
cmpb $0x0, 0x22(%rsp)
je 0x1ab8b
movq %rax, %r15
movq 0x10(%rsp), %rbx
movq %rax, %rdi
callq 0x5140
cmpq %rax, %rbx
je 0x1ab73
movq %r12, %rdi
movl 0x4(%rsp), %esi
leaq 0x6b8e(%rip), %rdx      # 0x216f7
callq 0x12af2
movq 0x10(%rsp), %rbx
leaq 0x20(%rsp), %rdi
pushq $0x2e
popq %rsi
callq 0x5160
testq %rax, %rax
jne 0x1abe1
cmpq $0x64, %rbx
jb 0x1abe1
leaq 0x58(%rsp), %rdi
callq 0x13515
jmp 0x1ad01
movq %r12, %rdi
movl %r15d, %esi
callq 0x13252
movl $0x1ac, %esi            # imm = 0x1AC
movq 0x8(%rsp), %rdi
leaq 0x20(%rsp), %rdx
movl %eax, %ecx
xorl %eax, %eax
callq 0x5180
jmp 0x1a993
movl %r15d, %esi
xorl %r15d, %r15d
movq %r12, %rdi
xorl %edx, %edx
callq 0x13b27
leaq 0x58(%rsp), %rdi
callq 0x13515
jmp 0x1a996
movl $0x1ac, %esi            # imm = 0x1AC
movq 0x8(%rsp), %rdi
leaq 0x20(%rsp), %rdx
movq %r15, %rcx
xorl %eax, %eax
callq 0x5180
movl %eax, %r15d
movq %r12, %rdi
pushq $-0x2
popq %rsi
callq 0x5b31
jmp 0x1a996
movl $0x1ac, %esi            # imm = 0x1AC
leaq 0x58(%rsp), %rdi
callq 0x132de
movq %rax, %rbx
movq %r12, %rdi
movl %r15d, %esi
callq 0x5d5d
movq %r12, %rdi
movl %r15d, %esi
xorl %edx, %edx
testl %eax, %eax
je 0x1acad
callq 0x5f59
movq %rax, %rcx
negq %rcx
leaq 0x4b48(%rip), %rdx      # 0x1f790
leaq 0x6b36(%rip), %rcx      # 0x21785
cmovoq %rcx, %rdx
movl $0x1ac, %esi            # imm = 0x1AC
movq %rbx, %rdi
movq %rax, %rcx
xorl %eax, %eax
callq 0x5180
movslq %eax, %r15
jmp 0x1acfc
movq 0x68(%rsp), %rax
cmpq 0x60(%rsp), %rax
jb 0x1ac8b
leaq 0x58(%rsp), %rdi
pushq $0x1
popq %rsi
callq 0x132de
movq 0x68(%rsp), %rax
movq 0x58(%rsp), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x68(%rsp)
movb $0x22, (%rcx,%rax)
jmp 0x1ad01
leaq 0x6ae6(%rip), %rdx      # 0x2178c
callq 0x12af2
jmp 0x1ad01
callq 0x5f0b
movl $0x1ac, %esi            # imm = 0x1AC
movq %rbx, %rdi
leaq 0x6ac1(%rip), %rdx      # 0x21782
movb $0x1, %al
callq 0x5180
movslq %eax, %r15
movq %rbx, %rdi
pushq $0x2e
popq %rsi
movq %r15, %rdx
callq 0x5210
testq %rax, %rax
jne 0x1acfc
callq 0x50f0
movq (%rax), %rax
movsbl (%rax), %esi
movq %rbx, %rdi
movq %r15, %rdx
callq 0x5210
testq %rax, %rax
je 0x1acfc
movb $0x2e, (%rax)
addq %r15, 0x68(%rsp)
xorl %r15d, %r15d
jmp 0x1a996
leaq 0x58(%rsp), %rdi
callq 0x134ba
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 0x69db(%rip), %rsi      # 0x2170d
movq %r12, %rdi
xorl %eax, %eax
callq 0x12bd6
jmp 0x1ad16