// File: /workspace/github_c_makefile_star2_O1/genometools[P]genometools/src/external/lua-5.1.5/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[MAX_ITEM];  /* to store the formatted item */
      if (++arg > top)
        luaL_argerror(L, arg, "no value");
      strfrmt = scanformat(L, strfrmt, form);
      switch (*strfrmt++) {
        case 'c': {
          sprintf(buff, form, (int)luaL_checknumber(L, arg));
          break;
        }
        case 'd':  case 'i': {
          addintlen(form);
          sprintf(buff, form, (LUA_INTFRM_T)luaL_checknumber(L, arg));
          break;
        }
        case 'o':  case 'u':  case 'x':  case 'X': {
          addintlen(form);
          sprintf(buff, form, (unsigned LUA_INTFRM_T)luaL_checknumber(L, arg));
          break;
        }
        case 'e':  case 'E': case 'f':
        case 'g': case 'G': {
          sprintf(buff, form, (double)luaL_checknumber(L, arg));
          break;
        }
        case 'q': {
          addquoted(L, &b, arg);
          continue;  /* skip the 'addsize' at the end */
        }
        case 's': {
          size_t l;
          const char *s = luaL_checklstring(L, arg, &l);
          if (!strchr(form, '.') && l >= 100) {
            /* no precision and string is too long to be formatted;
               keep original string */
            lua_pushvalue(L, arg);
            luaL_addvalue(&b);
            continue;  /* skip the `addsize' at the end */
          }
          else {
            sprintf(buff, form, s);
            break;
          }
        }
        default: {  /* also treat cases `pnLlh' */
          return luaL_error(L, "invalid option " LUA_QL("%%%c") " to "
                               LUA_QL("format"), *(strfrmt - 1));
        }
      }
      luaL_addlstring(&b, buff, strlen(buff));
    }
  }
  luaL_pushresult(&b);
  return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2258, %rsp           # imm = 0x2258
movq %rdi, %r15
movq 0x10(%rdi), %rax
subq 0x18(%rdi), %rax
movq %rax, 0x18(%rsp)
leaq 0x38(%rsp), %r14
movl $0x1, %esi
movq %r14, %rdx
callq 0x5b1b3
movq %rax, %rbx
movq (%r14), %r14
leaq 0x258(%rsp), %rax
movq %r15, -0x8(%rax)
movq %rax, -0x18(%rax)
movl $0x0, -0x10(%rax)
testq %r14, %r14
jle 0x6c824
shrq $0x4, 0x18(%rsp)
addq %rbx, %r14
leaq 0x2258(%rsp), %r12
movl $0x1, %r13d
leaq 0x82b1b(%rip), %rbp     # 0xeee54
movq %r14, 0x28(%rsp)
cmpb $0x25, (%rbx)
jne 0x6c37a
cmpb $0x25, 0x1(%rbx)
jne 0x6c3c2
cmpq %r12, 0x240(%rsp)
jb 0x6c371
leaq 0x240(%rsp), %rdi
callq 0x5ba5e
testl %eax, %eax
je 0x6c371
leaq 0x240(%rsp), %rdi
callq 0x5ba94
movb 0x1(%rbx), %al
addq $0x2, %rbx
jmp 0x6c3a7
cmpq %r12, 0x240(%rsp)
jb 0x6c3a2
leaq 0x240(%rsp), %rdi
callq 0x5ba5e
testl %eax, %eax
je 0x6c3a2
leaq 0x240(%rsp), %rdi
callq 0x5ba94
movb (%rbx), %al
incq %rbx
movq 0x240(%rsp), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x240(%rsp)
movb %al, (%rcx)
jmp 0x6c5ca
leal 0x1(%r13), %r14d
cmpl 0x18(%rsp), %r13d
jge 0x6c862
incq %rbx
movb (%rbx), %al
movq %rbx, %r13
testb %al, %al
je 0x6c400
movq %rbx, %r13
movsbl %al, %esi
movl $0x6, %edx
movq %rbp, %rdi
callq 0xb710
testq %rax, %rax
je 0x6c400
movb 0x1(%r13), %al
incq %r13
testb %al, %al
jne 0x6c3e0
movq %r13, %rax
subq %rbx, %rax
cmpq $0x6, %rax
jae 0x6c880
callq 0xb6e0
movq (%rax), %rax
movzbl (%r13), %ecx
movzwl (%rax,%rcx,2), %ecx
shrl $0xb, %ecx
andl $0x1, %ecx
movzbl (%r13,%rcx), %edx
movzwl (%rax,%rdx,2), %edx
btl $0xb, %edx
adcq %rcx, %r13
cmpb $0x2e, (%r13)
jne 0x6c473
leaq 0x1(%r13), %rcx
movzbl 0x1(%r13), %edx
leaq 0x2(%r13), %rsi
xorl %edi, %edi
testb $0x8, 0x1(%rax,%rdx,2)
cmoveq %rcx, %rsi
sete %dil
negq %rdi
movzbl 0x2(%r13,%rdi), %ecx
movzwl (%rax,%rcx,2), %ecx
btl $0xb, %ecx
adcq $0x0, %rsi
movq %rsi, %r13
movq %r15, %r12
movzbl (%r13), %ecx
testb $0x8, 0x1(%rax,%rcx,2)
jne 0x6c874
movb $0x25, (%rsp)
movq %r13, %r15
subq %rbx, %r15
leaq 0x1(%r15), %rdx
leaq 0x1(%rsp), %rdi
movq %rbx, %rsi
callq 0xb2d0
movb $0x0, 0x2(%rsp,%r15)
movzbl (%r13), %eax
cmpl $0x62, %eax
jle 0x6c505
leal -0x63(%rax), %ecx
cmpl $0x15, %ecx
movq %r12, %r15
leaq 0x40(%rsp), %rbx
ja 0x6c891
leaq 0x81120(%rip), %rdx     # 0xed5ec
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
movq %rsp, %r12
movq %r12, %rdi
callq 0xb260
movb -0x1(%rsp,%rax), %cl
movw $0x6c, -0x1(%rsp,%rax)
movb %cl, (%rsp,%rax)
movb $0x0, 0x1(%rsp,%rax)
movq %r15, %rdi
movl %r14d, %esi
callq 0x5b394
cvttsd2si %xmm0, %rdx
jmp 0x6c568
cmpl $0x45, %eax
movq %r12, %r15
leaq 0x40(%rsp), %rbx
je 0x6c577
cmpl $0x47, %eax
je 0x6c577
cmpl $0x58, %eax
jne 0x6c891
movq %rsp, %r12
movq %r12, %rdi
callq 0xb260
movb -0x1(%rsp,%rax), %cl
movw $0x6c, -0x1(%rsp,%rax)
movb %cl, (%rsp,%rax)
movb $0x0, 0x1(%rsp,%rax)
movq %r15, %rdi
movl %r14d, %esi
callq 0x5b394
cvttsd2si %xmm0, %rax
movq %rax, %rcx
sarq $0x3f, %rcx
subsd 0x7e253(%rip), %xmm0    # 0xea7b0
cvttsd2si %xmm0, %rdx
andq %rcx, %rdx
orq %rax, %rdx
movq %rbx, %rdi
movq %r12, %rsi
xorl %eax, %eax
callq 0xb110
jmp 0x6c58f
movq %r15, %rdi
movl %r14d, %esi
callq 0x5b394
movq %rbx, %rdi
movq %rsp, %rsi
movb $0x1, %al
callq 0xb110
leaq 0x2258(%rsp), %r12
movq %rbx, %rdi
callq 0xb260
leaq 0x240(%rsp), %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x5b99f
xorl %eax, %eax
testb $0x5, %al
jne 0x6c85e
incq %r13
movq %r13, %rbx
movl %r14d, %r13d
movq 0x28(%rsp), %r14
cmpq %r14, %rbx
jb 0x6c33e
jmp 0x6c824
movq %r15, %rdi
movl %r14d, %esi
movq %rbx, %rdx
callq 0x5b1b3
movq %rax, %rbx
leaq 0x2258(%rsp), %r12
cmpq %r12, 0x240(%rsp)
jb 0x6c619
leaq 0x240(%rsp), %rdi
callq 0x5ba5e
testl %eax, %eax
je 0x6c619
leaq 0x240(%rsp), %rdi
callq 0x5ba94
movq 0x240(%rsp), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x240(%rsp)
movb $0x22, (%rax)
subq $0x1, 0x40(%rsp)
jb 0x6c71e
movzbl (%rbx), %eax
cmpl $0xc, %eax
jle 0x6c659
cmpl $0xd, %eax
je 0x6c6e7
cmpl $0x5c, %eax
je 0x6c666
cmpl $0x22, %eax
je 0x6c666
jmp 0x6c6a5
testl %eax, %eax
je 0x6c6fd
cmpl $0xa, %eax
jne 0x6c6a5
cmpq %r12, 0x240(%rsp)
jb 0x6c68e
leaq 0x240(%rsp), %rdi
callq 0x5ba5e
testl %eax, %eax
je 0x6c68e
leaq 0x240(%rsp), %rdi
callq 0x5ba94
movq 0x240(%rsp), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x240(%rsp)
movb $0x5c, (%rax)
cmpq %r12, 0x240(%rsp)
jb 0x6c6cd
leaq 0x240(%rsp), %rdi
callq 0x5ba5e
testl %eax, %eax
je 0x6c6cd
leaq 0x240(%rsp), %rdi
callq 0x5ba94
movb (%rbx), %al
movq 0x240(%rsp), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x240(%rsp)
movb %al, (%rcx)
jmp 0x6c716
movl $0x2, %edx
leaq 0x240(%rsp), %rdi
leaq 0x827ac(%rip), %rsi     # 0xeeea7
jmp 0x6c711
movl $0x4, %edx
leaq 0x240(%rsp), %rdi
leaq 0x82799(%rip), %rsi     # 0xeeeaa
callq 0x5b99f
incq %rbx
jmp 0x6c630
cmpq %r12, 0x240(%rsp)
jb 0x6c746
leaq 0x240(%rsp), %rdi
callq 0x5ba5e
testl %eax, %eax
je 0x6c746
leaq 0x240(%rsp), %rdi
callq 0x5ba94
movq 0x240(%rsp), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x240(%rsp)
movb $0x22, (%rax)
movl $0x2, %eax
jmp 0x6c5b4
movq %r15, %rdi
movl %r14d, %esi
leaq 0x30(%rsp), %rdx
callq 0x5b1b3
movq %rax, 0x20(%rsp)
movq %rsp, %rdi
movl $0x2e, %esi
callq 0xb210
testq %rax, %rax
setne %al
cmpq $0x64, 0x30(%rsp)
setb %bl
orb %al, %bl
leaq 0x2258(%rsp), %r12
je 0x6c7e0
leaq 0x40(%rsp), %rdi
movq %rsp, %rsi
movq 0x20(%rsp), %rdx
xorl %eax, %eax
callq 0xb110
movl $0x4, %eax
jmp 0x6c812
movq %r15, %rdi
movl %r14d, %esi
callq 0x5b394
cvttsd2si %xmm0, %edx
movq %rbx, %rdi
movq %rsp, %rsi
xorl %eax, %eax
callq 0xb110
jmp 0x6c58f
movq %r15, %rdi
movl %r14d, %esi
callq 0x57945
movq 0x10(%r15), %rcx
movq (%rax), %rdx
movq %rdx, (%rcx)
movl 0x8(%rax), %eax
movl %eax, 0x8(%rcx)
addq $0x10, 0x10(%r15)
leaq 0x240(%rsp), %rdi
callq 0x5bb17
movl $0x2, %eax
testb %bl, %bl
leaq 0x40(%rsp), %rbx
jne 0x6c597
jmp 0x6c5b4
leaq 0x240(%rsp), %rbx
movq %rbx, %rdi
callq 0x5ba5e
movq 0x10(%rbx), %rdi
movl 0x8(%rbx), %esi
callq 0x59be2
movl $0x1, 0x8(%rbx)
movl $0x1, %eax
addq $0x2258, %rsp           # imm = 0x2258
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %eax, %eax
jmp 0x6c84c
leaq 0x7ade7(%rip), %rdx     # 0xe7650
movq %r15, %rdi
movl %r14d, %esi
callq 0x5aeac
leaq 0x825ff(%rip), %rsi     # 0xeee7a
movq %r12, %rdi
jmp 0x6c88a
leaq 0x825d3(%rip), %rsi     # 0xeee5a
movq %r15, %rdi
xorl %eax, %eax
callq 0x5af61
movsbl %al, %edx
leaq 0x82597(%rip), %rsi     # 0xeee32
movq %r15, %rdi
xorl %eax, %eax
callq 0x5af61