// File: /workspace/github_c_makefile_star2_O3/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, %r14
callq 0x5d39
movl %eax, 0x1c(%rsp)
leaq 0x50(%rsp), %rbx
movq %r14, %rdi
movl $0x1, %esi
movq %rbx, %rdx
callq 0x14fff
movq %rax, %rbp
movq (%rbx), %r15
leaq 0x58(%rsp), %rsi
movq %r14, %rdi
callq 0x154c8
testq %r15, %r15
jle 0x1d3f6
addq %rbp, %r15
movl $0x1, %r12d
movq %r15, (%rsp)
movb (%rbp), %al
cmpb $0x25, %al
jne 0x1cdff
leaq 0x1(%rbp), %rbx
cmpb $0x25, 0x1(%rbp)
jne 0x1ce3e
movq 0x68(%rsp), %rax
movb $0x25, %cl
cmpq 0x60(%rsp), %rax
jb 0x1cde8
movl $0x1, %esi
leaq 0x58(%rsp), %rdi
callq 0x151bd
movb (%rbx), %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 0x1ce36
movq 0x68(%rsp), %rcx
cmpq 0x60(%rsp), %rcx
jb 0x1ce22
movl $0x1, %esi
leaq 0x58(%rsp), %rdi
callq 0x151bd
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)
movl %r12d, %r13d
jmp 0x1d032
movl $0x1ac, %esi            # imm = 0x1AC
leaq 0x58(%rsp), %rdi
callq 0x151bd
movq %rax, 0x8(%rsp)
leal 0x1(%r12), %r13d
cmpl 0x1c(%rsp), %r12d
jl 0x1ce70
movq %r14, %rdi
movl %r13d, %esi
leaq 0x5eb8(%rip), %rdx      # 0x22d23
callq 0x1497c
movq %r14, %r15
movb (%rbx), %r14b
testb %r14b, %r14b
leaq 0x7847(%rip), %r12      # 0x246c7
je 0x1ceac
movq %rbx, %rbp
movsbl %r14b, %esi
movl $0x6, %edx
movq %r12, %rdi
callq 0x5220
testq %rax, %rax
je 0x1ceb2
movb 0x1(%rbp), %r14b
incq %rbp
testb %r14b, %r14b
jne 0x1ce85
xorl %r14d, %r14d
jmp 0x1ceb2
xorl %r14d, %r14d
movq %rbx, %rbp
movq %rbp, %rax
subq %rbx, %rax
cmpq $0x6, %rax
jb 0x1ced3
movq %r15, %rdi
leaq 0x7805(%rip), %rsi      # 0x246cd
xorl %eax, %eax
callq 0x14a62
movb (%rbp), %r14b
callq 0x5530
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 0x1cf38
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
movq %r15, %rdi
movzbl %cl, %ecx
testb $0x8, 0x1(%rax,%rcx,2)
je 0x1cf53
leaq 0x77a1(%rip), %rsi      # 0x246ed
xorl %eax, %eax
callq 0x14a62
movb $0x25, 0x20(%rsp)
movq %rbp, %r14
subq %rbx, %r14
leaq 0x1(%r14), %rdx
leaq 0x21(%rsp), %rdi
movq %rbx, %rsi
callq 0x5310
movb $0x0, 0x22(%rsp,%r14)
movzbl (%rbp), %eax
cmpl $0x57, %eax
jle 0x1cfd8
leal -0x61(%rax), %ecx
cmpl $0x17, %ecx
ja 0x1d043
leaq 0x7377(%rip), %rdx      # 0x24308
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
movq %r15, %r14
jmpq *%rcx
movq %r14, %rdi
movl %r13d, %esi
callq 0x15124
movq %rax, %rbx
leaq 0x20(%rsp), %r15
movq %r15, %rdi
leaq 0x6e1f(%rip), %rsi      # 0x23dd9
callq 0x1ef9e
movl $0x1ac, %esi            # imm = 0x1AC
movq 0x8(%rsp), %rdi
movq %r15, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x5180
jmp 0x1d021
cmpl $0x41, %eax
movq %r15, %r14
je 0x1cfee
cmpl $0x45, %eax
je 0x1cfee
cmpl $0x47, %eax
jne 0x1d417
leaq 0x20(%rsp), %rbx
movq %rbx, %rdi
leaq 0x7d8b(%rip), %rsi      # 0x24d88
callq 0x1ef9e
movq %r14, %rdi
movl %r13d, %esi
callq 0x150a0
movl $0x1ac, %esi            # imm = 0x1AC
movq 0x8(%rsp), %rdi
movq %rbx, %rdx
movb $0x1, %al
callq 0x5180
movl %eax, %ebx
movq (%rsp), %r15
incq %rbp
movslq %ebx, %rax
addq %rax, 0x68(%rsp)
movl %r13d, %r12d
cmpq %r15, %rbp
jb 0x1cdb3
jmp 0x1d3f6
cmpl $0x58, %eax
movq %r15, %r14
je 0x1cf9d
jmp 0x1d417
movq %r14, %rdi
movl %r13d, %esi
callq 0x15124
movl $0x1ac, %esi            # imm = 0x1AC
movq 0x8(%rsp), %rdi
leaq 0x20(%rsp), %rdx
movl %eax, %ecx
xorl %eax, %eax
callq 0x5180
jmp 0x1d021
movq %r14, %rdi
movl %r13d, %esi
leaq 0x10(%rsp), %rdx
callq 0x15ab1
cmpb $0x0, 0x22(%rsp)
je 0x1d2a6
movq %rax, %rbx
movq 0x10(%rsp), %r14
movq %rax, %rdi
callq 0x5140
cmpq %rax, %r14
je 0x1d0c0
movq %r15, %rdi
movl %r13d, %esi
leaq 0x75d9(%rip), %rdx      # 0x2468f
callq 0x1497c
movq 0x10(%rsp), %r14
leaq 0x20(%rsp), %rdi
movl $0x2e, %esi
callq 0x5160
testq %rax, %rax
jne 0x1d2b5
cmpq $0x64, %r14
jb 0x1d2b5
leaq 0x58(%rsp), %rdi
callq 0x15429
jmp 0x1d3ec
movq %r14, %rdi
movl %r13d, %esi
callq 0x608f
cmpl $0x2, %eax
jb 0x1d288
cmpl $0x3, %eax
je 0x1d2e5
cmpl $0x4, %eax
jne 0x1d37d
movq %r14, %rdi
movl %r13d, %esi
leaq 0x48(%rsp), %rdx
callq 0x6359
movq %rax, %rbx
movq 0x48(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x68(%rsp), %rax
cmpq 0x60(%rsp), %rax
jb 0x1d154
movl $0x1, %esi
leaq 0x58(%rsp), %rdi
callq 0x151bd
movq 0x68(%rsp), %rax
movq 0x58(%rsp), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x68(%rsp)
movb $0x22, (%rcx,%rax)
cmpq $0x0, 0x8(%rsp)
je 0x1d349
xorl %r14d, %r14d
movzbl (%rbx,%r14), %ecx
cmpq $0xa, %rcx
je 0x1d18a
cmpl $0x5c, %ecx
je 0x1d18a
cmpl $0x22, %ecx
jne 0x1d204
movq 0x68(%rsp), %rax
cmpq 0x60(%rsp), %rax
jb 0x1d1aa
movl $0x1, %esi
leaq 0x58(%rsp), %rdi
callq 0x151bd
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 0x1d1dc
movl $0x1, %esi
leaq 0x58(%rsp), %rdi
callq 0x151bd
movq 0x68(%rsp), %rax
movb (%rbx,%r14), %cl
movq 0x58(%rsp), %rdx
leaq 0x1(%rax), %rsi
movq %rsi, 0x68(%rsp)
movb %cl, (%rdx,%rax)
incq %r14
cmpq %r14, 0x8(%rsp)
jne 0x1d175
jmp 0x1d349
movq (%r12), %rax
testb $0x2, (%rax,%rcx,2)
jne 0x1d245
movq 0x68(%rsp), %rax
cmpq 0x60(%rsp), %rax
jb 0x1d232
movl $0x1, %esi
leaq 0x58(%rsp), %rdi
callq 0x151bd
movb (%rbx,%r14), %cl
movq 0x68(%rsp), %rax
movq 0x58(%rsp), %rdx
leaq 0x1(%rax), %rsi
movq %rsi, 0x68(%rsp)
movb %cl, (%rdx,%rax)
jmp 0x1d1f1
movzbl 0x1(%rbx,%r14), %edx
movzwl (%rax,%rdx,2), %eax
btl $0xb, %eax
leaq 0x74e4(%rip), %rdx      # 0x2473e
jae 0x1d263
leaq 0x74df(%rip), %rdx      # 0x24742
movl $0xa, %esi
leaq 0x10(%rsp), %rdi
xorl %eax, %eax
callq 0x5180
leaq 0x58(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x15382
jmp 0x1d1f1
xorl %ebx, %ebx
movq %r14, %rdi
movl %r13d, %esi
xorl %edx, %edx
callq 0x15ab1
leaq 0x58(%rsp), %rdi
callq 0x15429
jmp 0x1d023
leaq 0x58(%rsp), %rdi
callq 0x15429
jmp 0x1d38f
movl $0x1ac, %esi            # imm = 0x1AC
movq 0x8(%rsp), %rdi
leaq 0x20(%rsp), %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x5180
movl %eax, %ebx
movq %r15, %r14
movq %r15, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x5d4d
jmp 0x1d023
movl $0x1ac, %esi            # imm = 0x1AC
leaq 0x58(%rsp), %rdi
callq 0x151bd
movq %rax, %rbx
movq %r14, %rdi
movl %r13d, %esi
callq 0x60dc
movq %r14, %rdi
movl %r13d, %esi
xorl %edx, %edx
testl %eax, %eax
je 0x1d396
callq 0x62e1
movq %rax, %rcx
negq %rcx
leaq 0x544c(%rip), %rdx      # 0x22770
leaq 0x73f2(%rip), %rcx      # 0x2471d
cmovoq %rcx, %rdx
movl $0x1ac, %esi            # imm = 0x1AC
movq %rbx, %rdi
movq %rax, %rcx
xorl %eax, %eax
callq 0x5180
movslq %eax, %r14
jmp 0x1d3e7
movq 0x68(%rsp), %rax
cmpq 0x60(%rsp), %rax
jb 0x1d369
movl $0x1, %esi
leaq 0x58(%rsp), %rdi
callq 0x151bd
movq 0x68(%rsp), %rax
movq 0x58(%rsp), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x68(%rsp)
movb $0x22, (%rcx,%rax)
jmp 0x1d3ec
movq %r14, %rdi
movl %r13d, %esi
leaq 0x739a(%rip), %rdx      # 0x24724
callq 0x1497c
xorl %ebx, %ebx
jmp 0x1d023
callq 0x628e
movl $0x1ac, %esi            # imm = 0x1AC
movq %rbx, %rdi
leaq 0x7370(%rip), %rdx      # 0x2471a
movb $0x1, %al
callq 0x5180
movslq %eax, %r14
movq %rbx, %rdi
movl $0x2e, %esi
movq %r14, %rdx
callq 0x5220
testq %rax, %rax
jne 0x1d3e7
callq 0x50f0
movq (%rax), %rax
movsbl (%rax), %esi
movq %rbx, %rdi
movq %r14, %rdx
callq 0x5220
testq %rax, %rax
je 0x1d3e7
movb $0x2e, (%rax)
addq %r14, 0x68(%rsp)
xorl %ebx, %ebx
movq %r15, %r14
jmp 0x1d023
leaq 0x58(%rsp), %rdi
callq 0x153c0
movl $0x1, %eax
addq $0x2078, %rsp           # imm = 0x2078
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movsbl %al, %edx
leaq 0x7284(%rip), %rsi      # 0x246a5
movq %r14, %rdi
xorl %eax, %eax
callq 0x14a62
jmp 0x1d405