// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x20f0, %rsp           # imm = 0x20F0
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
callq 0x5d90
movl %eax, -0x14(%rbp)
movl $0x1, -0x18(%rbp)
movq -0x10(%rbp), %rdi
movl -0x18(%rbp), %esi
leaq -0x20(%rbp), %rdx
callq 0x20390
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
addq -0x20(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rdi
leaq -0x2050(%rbp), %rsi
callq 0x20aa0
movq -0x28(%rbp), %rax
cmpq -0x30(%rbp), %rax
jae 0x2ca67
movq -0x28(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x25, %eax
je 0x2c69d
movq -0x2040(%rbp), %rcx
movb $0x1, %al
cmpq -0x2048(%rbp), %rcx
movb %al, -0x2099(%rbp)
jb 0x2c662
leaq -0x2050(%rbp), %rdi
movl $0x1, %esi
callq 0x20630
cmpq $0x0, %rax
setne %al
movb %al, -0x2099(%rbp)
movb -0x2099(%rbp), %al
movq -0x28(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x28(%rbp)
movb (%rax), %dl
movq -0x2050(%rbp), %rax
movq -0x2040(%rbp), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, -0x2040(%rbp)
movb %dl, (%rax,%rcx)
jmp 0x2ca62
movq -0x28(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x28(%rbp)
movsbl 0x1(%rax), %eax
cmpl $0x25, %eax
jne 0x2c726
movq -0x2040(%rbp), %rcx
movb $0x1, %al
cmpq -0x2048(%rbp), %rcx
movb %al, -0x209a(%rbp)
jb 0x2c6eb
leaq -0x2050(%rbp), %rdi
movl $0x1, %esi
callq 0x20630
cmpq $0x0, %rax
setne %al
movb %al, -0x209a(%rbp)
movb -0x209a(%rbp), %al
movq -0x28(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x28(%rbp)
movb (%rax), %dl
movq -0x2050(%rbp), %rax
movq -0x2040(%rbp), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, -0x2040(%rbp)
movb %dl, (%rax,%rcx)
jmp 0x2ca60
leaq -0x2050(%rbp), %rdi
movl $0x1ac, %esi            # imm = 0x1AC
callq 0x20630
movq %rax, -0x2078(%rbp)
movl $0x0, -0x207c(%rbp)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
cmpl -0x14(%rbp), %eax
jle 0x2c769
movq -0x10(%rbp), %rdi
movl -0x18(%rbp), %esi
leaq 0x89c7(%rip), %rdx      # 0x3512b
callq 0x1fab0
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rsi
leaq -0x2070(%rbp), %rdx
callq 0x2f2b0
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq %rax, %rcx
incq %rcx
movq %rcx, -0x28(%rbp)
movsbl (%rax), %eax
addl $-0x41, %eax
movl %eax, %ecx
movq %rcx, -0x20a8(%rbp)
subl $0x37, %eax
ja 0x2ca2c
movq -0x20a8(%rbp), %rax
leaq 0xa2e3(%rip), %rcx      # 0x36a98
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x2078(%rbp), %rax
movq %rax, -0x20b8(%rbp)
leaq -0x2070(%rbp), %rax
movq %rax, -0x20b0(%rbp)
movq -0x10(%rbp), %rdi
movl -0x18(%rbp), %esi
callq 0x20550
movq -0x20b8(%rbp), %rdi
movq -0x20b0(%rbp), %rdx
movl %eax, %ecx
movl $0x1ac, %esi            # imm = 0x1AC
movb $0x0, %al
callq 0x5190
movl %eax, -0x207c(%rbp)
jmp 0x2ca4b
movq -0x10(%rbp), %rdi
movl -0x18(%rbp), %esi
callq 0x20550
movq %rax, -0x2088(%rbp)
leaq -0x2070(%rbp), %rdi
leaq 0x9c9b(%rip), %rsi      # 0x364c9
callq 0x2f490
movq -0x2078(%rbp), %rdi
leaq -0x2070(%rbp), %rdx
movq -0x2088(%rbp), %rcx
movl $0x1ac, %esi            # imm = 0x1AC
movb $0x0, %al
callq 0x5190
movl %eax, -0x207c(%rbp)
jmp 0x2ca4b
leaq -0x2070(%rbp), %rdi
leaq 0xae19(%rip), %rsi      # 0x37686
callq 0x2f490
movq -0x2078(%rbp), %rax
movq %rax, -0x20c8(%rbp)
leaq -0x2070(%rbp), %rax
movq %rax, -0x20c0(%rbp)
movq -0x10(%rbp), %rdi
movl -0x18(%rbp), %esi
callq 0x204b0
movq -0x20c8(%rbp), %rdi
movq -0x20c0(%rbp), %rdx
movl $0x1ac, %esi            # imm = 0x1AC
movb $0x1, %al
callq 0x5190
movl %eax, -0x207c(%rbp)
jmp 0x2ca4b
leaq -0x2070(%rbp), %rdi
leaq 0xadb9(%rip), %rsi      # 0x37686
callq 0x2f490
movq -0x2078(%rbp), %rax
movq %rax, -0x20d8(%rbp)
leaq -0x2070(%rbp), %rax
movq %rax, -0x20d0(%rbp)
movq -0x10(%rbp), %rdi
movl -0x18(%rbp), %esi
callq 0x204b0
movq -0x20d8(%rbp), %rdi
movq -0x20d0(%rbp), %rdx
movl $0x1ac, %esi            # imm = 0x1AC
movb $0x1, %al
callq 0x5190
movl %eax, -0x207c(%rbp)
jmp 0x2ca4b
movq -0x10(%rbp), %rdi
movl -0x18(%rbp), %edx
leaq -0x2050(%rbp), %rsi
callq 0x2f510
jmp 0x2ca4b
movq -0x10(%rbp), %rdi
movl -0x18(%rbp), %esi
leaq -0x2090(%rbp), %rdx
callq 0x21320
movq %rax, -0x2098(%rbp)
movsbl -0x206e(%rbp), %eax
cmpl $0x0, %eax
jne 0x2c96e
leaq -0x2050(%rbp), %rdi
callq 0x209f0
jmp 0x2ca2a
movq -0x2090(%rbp), %rax
movq %rax, -0x20e8(%rbp)
movq -0x2098(%rbp), %rdi
callq 0x5150
movq -0x20e8(%rbp), %rcx
movq %rax, %rdx
movb $0x1, %al
cmpq %rdx, %rcx
movb %al, -0x20d9(%rbp)
je 0x2c9be
movq -0x10(%rbp), %rdi
movl -0x18(%rbp), %esi
leaq 0xa5ea(%rip), %rdx      # 0x36f97
callq 0x1fab0
cmpl $0x0, %eax
setne %al
movb %al, -0x20d9(%rbp)
movb -0x20d9(%rbp), %al
leaq -0x2070(%rbp), %rdi
movl $0x2e, %esi
callq 0x5170
cmpq $0x0, %rax
jne 0x2c9f3
cmpq $0x64, -0x2090(%rbp)
jb 0x2c9f3
leaq -0x2050(%rbp), %rdi
callq 0x209f0
jmp 0x2ca28
movq -0x2078(%rbp), %rdi
leaq -0x2070(%rbp), %rdx
movq -0x2098(%rbp), %rcx
movl $0x1ac, %esi            # imm = 0x1AC
movb $0x0, %al
callq 0x5190
movl %eax, -0x207c(%rbp)
movq -0x10(%rbp), %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x5dc0
jmp 0x2ca2a
jmp 0x2ca4b
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rax
movsbl -0x1(%rax), %edx
leaq 0xa56e(%rip), %rsi      # 0x36fad
movb $0x0, %al
callq 0x1fbf0
movl %eax, -0x4(%rbp)
jmp 0x2ca7a
movslq -0x207c(%rbp), %rax
addq -0x2040(%rbp), %rax
movq %rax, -0x2040(%rbp)
jmp 0x2ca62
jmp 0x2c612
leaq -0x2050(%rbp), %rdi
callq 0x20940
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20f0, %rsp           # imm = 0x20F0
popq %rbp
retq
nopw %cs:(%rax,%rax)