// File: /workspace/github_c_makefile_star2_O1/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 $0x2088, %rsp           # imm = 0x2088
movq %rdi, %r15
callq 0x5d3d
movl %eax, 0x14(%rsp)
leaq 0x60(%rsp), %rbx
movq %r15, %rdi
movl $0x1, %esi
movq %rbx, %rdx
callq 0x14535
movq %rax, %r14
movq (%rbx), %rbp
movq %r15, %rbx
leaq 0x68(%rsp), %rsi
movq %r15, %rdi
callq 0x149f7
testq %rbp, %rbp
jle 0x1c848
addq %r14, %rbp
movl $0x1, %r12d
movq %rbx, 0x8(%rsp)
movq %rbp, 0x50(%rsp)
cmpb $0x25, (%r14)
jne 0x1c298
leaq 0x1(%r14), %r13
cmpb $0x25, 0x1(%r14)
jne 0x1c2d8
movq 0x78(%rsp), %rax
cmpq 0x70(%rsp), %rax
jb 0x1c28c
movl $0x1, %esi
leaq 0x68(%rsp), %rdi
callq 0x146f3
movq %r14, %rax
addq $0x2, %rax
movq %r13, %r14
jmp 0x1c2b7
movq 0x78(%rsp), %rax
cmpq 0x70(%rsp), %rax
jb 0x1c2b3
movl $0x1, %esi
leaq 0x68(%rsp), %rdi
callq 0x146f3
leaq 0x1(%r14), %rax
movb (%r14), %cl
movq 0x68(%rsp), %rdx
movq 0x78(%rsp), %rsi
leaq 0x1(%rsi), %rdi
movq %rdi, 0x78(%rsp)
movb %cl, (%rdx,%rsi)
movq %rax, %r14
jmp 0x1c4ce
movl $0x1ac, %esi            # imm = 0x1AC
leaq 0x68(%rsp), %rdi
callq 0x146f3
movq %rax, %rbp
leal 0x1(%r12), %r15d
cmpl 0x14(%rsp), %r12d
jl 0x1c308
movq %rbx, %rdi
movl %r15d, %esi
leaq 0x59b0(%rip), %rdx      # 0x21cb3
callq 0x13ea8
movb (%r13), %al
movq %r13, %r14
testb %al, %al
leaq 0x72f7(%rip), %r12      # 0x2360f
je 0x1c33d
movq %r13, %r14
movsbl %al, %esi
movl $0x6, %edx
movq %r12, %rdi
callq 0x5230
testq %rax, %rax
je 0x1c33d
movb 0x1(%r14), %al
incq %r14
testb %al, %al
jne 0x1c31d
movq %r14, %rax
subq %r13, %rax
cmpq $0x6, %rax
jb 0x1c35a
movq %rbx, %rdi
leaq 0x72c2(%rip), %rsi      # 0x23615
xorl %eax, %eax
callq 0x13f8e
callq 0x5540
movq %rax, %r12
movq (%rax), %rax
movzbl (%r14), %ecx
movzwl (%rax,%rcx,2), %ecx
shrl $0xb, %ecx
andl $0x1, %ecx
movzbl (%r14,%rcx), %edx
movzwl (%rax,%rdx,2), %edx
btl $0xb, %edx
adcq %rcx, %r14
cmpb $0x2e, (%r14)
jne 0x1c3bd
leaq 0x1(%r14), %rcx
movzbl 0x1(%r14), %edx
leaq 0x2(%r14), %rsi
xorl %edi, %edi
testb $0x8, 0x1(%rax,%rdx,2)
cmoveq %rcx, %rsi
sete %dil
negq %rdi
movzbl 0x2(%r14,%rdi), %ecx
movzwl (%rax,%rcx,2), %ecx
btl $0xb, %ecx
adcq $0x0, %rsi
movq %rsi, %r14
movzbl (%r14), %ecx
testb $0x8, 0x1(%rax,%rcx,2)
je 0x1c3d9
movq %rbx, %rdi
leaq 0x7263(%rip), %rsi      # 0x23635
xorl %eax, %eax
callq 0x13f8e
movb $0x25, 0x30(%rsp)
movq %r14, %rbx
subq %r13, %rbx
leaq 0x1(%rbx), %rdx
leaq 0x31(%rsp), %rdi
movq %r13, %rsi
callq 0x5320
movb $0x0, 0x32(%rsp,%rbx)
movzbl (%r14), %eax
cmpl $0x57, %eax
jle 0x1c460
leal -0x61(%rax), %ecx
cmpl $0x17, %ecx
movl %r15d, %r13d
ja 0x1c4dc
leaq 0x6e5f(%rip), %rdx      # 0x23278
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
movq 0x8(%rsp), %rbx
jmpq *%rcx
movq %rbx, %rdi
movl %r13d, %esi
callq 0x1465a
movq %rax, %rbx
leaq 0x30(%rsp), %r12
movq %r12, %rdi
leaq 0x6905(%rip), %rsi      # 0x22d49
callq 0x1e44f
movl $0x1ac, %esi            # imm = 0x1AC
movq %rbp, %rdi
movq %r12, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x5190
jmp 0x1c4a8
cmpl $0x41, %eax
movq 0x8(%rsp), %rbx
movl %r15d, %r13d
je 0x1c477
cmpl $0x45, %eax
je 0x1c477
cmpl $0x47, %eax
jne 0x1c4ea
leaq 0x30(%rsp), %r12
movq %r12, %rdi
leaq 0x7842(%rip), %rsi      # 0x23cc8
callq 0x1e44f
movq %rbx, %rdi
movl %r13d, %esi
callq 0x145d6
movl $0x1ac, %esi            # imm = 0x1AC
movq %rbp, %rdi
movq %r12, %rdx
movb $0x1, %al
callq 0x5190
movl %eax, %ebx
movslq %ebx, %rax
addq %rax, 0x78(%rsp)
movb $0x1, %bpl
movq 0x8(%rsp), %rbx
testb %bpl, %bpl
je 0x1c869
incq %r14
movl %r13d, %r12d
movq 0x50(%rsp), %rbp
cmpq %rbp, %r14
jb 0x1c260
jmp 0x1c848
cmpl $0x58, %eax
movq 0x8(%rsp), %rbx
je 0x1c427
movsbl %al, %edx
xorl %ebp, %ebp
movq %rbx, %rdi
leaq 0x70f4(%rip), %rsi      # 0x235ed
xorl %eax, %eax
callq 0x13f8e
movl %eax, 0x10(%rsp)
jmp 0x1c4ba
movq %rbx, %rdi
movl %r13d, %esi
callq 0x5f7f
cmpl $0x2, %eax
jb 0x1c6f7
cmpl $0x3, %eax
je 0x1c742
movq %rbx, %rdi
movl %r13d, %esi
cmpl $0x4, %eax
jne 0x1c7d8
leaq 0x58(%rsp), %rdx
callq 0x6249
movq %rax, %rbx
movq 0x58(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x78(%rsp), %rax
cmpq 0x70(%rsp), %rax
jb 0x1c564
movl $0x1, %esi
leaq 0x68(%rsp), %rdi
callq 0x146f3
movq 0x68(%rsp), %rax
movq 0x78(%rsp), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x78(%rsp)
movb $0x22, (%rax,%rcx)
cmpq $0x0, 0x28(%rsp)
je 0x1c7a4
xorl %ebp, %ebp
movzbl (%rbx,%rbp), %ecx
cmpl $0xa, %ecx
je 0x1c59c
cmpl $0x5c, %ecx
je 0x1c59c
cmpl $0x22, %ecx
jne 0x1c615
movq 0x78(%rsp), %rax
cmpq 0x70(%rsp), %rax
jb 0x1c5b7
movl $0x1, %esi
leaq 0x68(%rsp), %rdi
callq 0x146f3
movq 0x68(%rsp), %rax
movq 0x78(%rsp), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x78(%rsp)
movb $0x5c, (%rax,%rcx)
movq 0x78(%rsp), %rax
cmpq 0x70(%rsp), %rax
jb 0x1c5e9
movl $0x1, %esi
leaq 0x68(%rsp), %rdi
callq 0x146f3
movb (%rbx,%rbp), %al
movq 0x68(%rsp), %rcx
movq 0x78(%rsp), %rdx
leaq 0x1(%rdx), %rsi
movq %rsi, 0x78(%rsp)
movb %al, (%rcx,%rdx)
incq %rbp
cmpq %rbp, 0x28(%rsp)
jne 0x1c589
jmp 0x1c7a4
movq (%r12), %rax
testb $0x2, (%rax,%rcx,2)
je 0x1c5ce
movq (%r12), %rax
movzbl 0x1(%rbx,%rbp), %edx
movzwl (%rax,%rdx,2), %eax
btl $0xb, %eax
leaq 0x704f(%rip), %rdx      # 0x23686
jae 0x1c640
leaq 0x704a(%rip), %rdx      # 0x2368a
movl $0xa, %esi
leaq 0x18(%rsp), %r13
movq %r13, %rdi
xorl %eax, %eax
callq 0x5190
leaq 0x68(%rsp), %rdi
movq %r13, %rsi
callq 0x148b1
movl %r15d, %r13d
jmp 0x1c602
movq %rbx, %rdi
movl %r13d, %esi
leaq 0x18(%rsp), %rdx
callq 0x14fc6
cmpb $0x0, 0x32(%rsp)
je 0x1c6c2
movq %rax, %rbx
movq 0x18(%rsp), %r12
movq %rax, %rdi
callq 0x5150
cmpq %rax, %r12
je 0x1c6a6
movq 0x8(%rsp), %rdi
movl %r13d, %esi
leaq 0x6f36(%rip), %rdx      # 0x235d7
callq 0x13ea8
leaq 0x30(%rsp), %rdi
movl $0x2e, %esi
callq 0x5170
testq %rax, %rax
jne 0x1c715
cmpq $0x64, 0x18(%rsp)
jb 0x1c715
leaq 0x68(%rsp), %rdi
callq 0x14958
jmp 0x1c841
movq %rbx, %rdi
movl %r13d, %esi
callq 0x1465a
movl $0x1ac, %esi            # imm = 0x1AC
movq %rbp, %rdi
leaq 0x30(%rsp), %rdx
movl %eax, %ecx
xorl %eax, %eax
callq 0x5190
jmp 0x1c4a8
movq %rbx, %rdi
xorl %ebx, %ebx
movl %r13d, %esi
xorl %edx, %edx
callq 0x14fc6
leaq 0x68(%rsp), %rdi
callq 0x14958
jmp 0x1c4aa
movl $0x1ac, %esi            # imm = 0x1AC
movq %rbp, %rdi
leaq 0x30(%rsp), %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x5190
movl %eax, %ebx
movq 0x8(%rsp), %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x5d51
jmp 0x1c4aa
movl $0x1ac, %esi            # imm = 0x1AC
leaq 0x68(%rsp), %rdi
callq 0x146f3
movq %rbx, %r12
movq %rax, %rbx
movq %r12, %rdi
movl %r13d, %esi
callq 0x5fcc
movq %r12, %rdi
movl %r13d, %esi
xorl %edx, %edx
testl %eax, %eax
je 0x1c7e6
callq 0x61d3
movq %rax, %rcx
negq %rcx
leaq 0x4fc0(%rip), %rdx      # 0x21740
leaq 0x6ede(%rip), %rcx      # 0x23665
cmovoq %rcx, %rdx
movl $0x1ac, %esi            # imm = 0x1AC
movq %rbx, %rdi
movq %rax, %rcx
xorl %eax, %eax
callq 0x5190
movl %eax, %ebp
jmp 0x1c839
movq 0x78(%rsp), %rax
cmpq 0x70(%rsp), %rax
jb 0x1c7bf
movl $0x1, %esi
leaq 0x68(%rsp), %rdi
callq 0x146f3
movq 0x68(%rsp), %rax
movq 0x78(%rsp), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x78(%rsp)
movb $0x22, (%rax,%rcx)
jmp 0x1c841
leaq 0x6e8d(%rip), %rdx      # 0x2366c
callq 0x13ea8
jmp 0x1c841
callq 0x6182
movl $0x1ac, %esi            # imm = 0x1AC
movq %rbx, %rdi
leaq 0x6e68(%rip), %rdx      # 0x23662
movb $0x1, %al
callq 0x5190
movl %eax, %ebp
movslq %eax, %r12
movq %rbx, %rdi
movl $0x2e, %esi
movq %r12, %rdx
callq 0x5230
testq %rax, %rax
jne 0x1c839
callq 0x5100
movq (%rax), %rax
movsbl (%rax), %esi
movq %rbx, %rdi
movq %r12, %rdx
callq 0x5230
testq %rax, %rax
je 0x1c839
movb $0x2e, (%rax)
movslq %ebp, %rax
addq %rax, 0x78(%rsp)
xorl %ebx, %ebx
jmp 0x1c4aa
leaq 0x68(%rsp), %rdi
callq 0x148ef
movl $0x1, %eax
addq $0x2088, %rsp           # imm = 0x2088
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl 0x10(%rsp), %eax
jmp 0x1c857