// File: /workspace/github_c_makefile_star2_O1/genometools[P]genometools/src/extended/luaserialize.c
// Function: format_scalar
static int format_scalar(lua_State *L, GtStr *out, int index, bool table_key,
                         GtError *err)
{
  int had_err = 0;
  gt_error_check(err);
  gt_assert(!lua_istable(L, index));
  if (lua_isboolean(L, index))
  {
    int val;
    val = lua_toboolean(L, index);
    if (val)
      gt_str_append_cstr(out, "true");
    else
      gt_str_append_cstr(out, "false");
  }
  else if (lua_isnumber(L, index))
  {
    double val;
    val = lua_tonumber(L, index);
    gt_str_append_double(out, val, 10);
  }
  else if (lua_isstring(L, index))
  {
    const char *str;
    str = lua_tostring(L, index);
    /* use Lua's own "string.format() function to escape string */
    lua_getglobal(L, "string");
    lua_pushliteral(L, "format");
    lua_gettable(L, -2);
    lua_pushstring(L, "%q");
    lua_pushstring(L, str);
    lua_call(L, 2 ,1);
    str = lua_tostring(L, -1);
    lua_pop(L,2);
    /* table keys must be enclosed in square brackets */
    if (table_key)
      gt_str_append_cstr(out, "[");
    gt_str_append_cstr(out, str);
    if (table_key)
      gt_str_append_cstr(out, "]");
  }
  else {
    lua_pop(L, 2);
    gt_error_set(err, "expected boolean, number, or string");
    had_err = -1;
  }
  return had_err;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %r8, %r15
movl %ecx, %ebp
movl %edx, %r12d
movq %rsi, %rbx
movq %rdi, %r14
testq %r8, %r8
je 0x868e4
movq %r15, %rdi
callq 0x3566a
testb %al, %al
jne 0x86a76
movq %r14, %rdi
movl %r12d, %esi
callq 0x57c5c
cmpl $0x5, %eax
je 0x86a71
movq %r14, %rdi
movl %r12d, %esi
callq 0x57c5c
cmpl $0x1, %eax
jne 0x86920
movq %r14, %rdi
movl %r12d, %esi
callq 0x5801c
testl %eax, %eax
je 0x86949
leaq 0x85054(%rip), %rsi     # 0x10b972
jmp 0x86950
movq %r14, %rdi
movl %r12d, %esi
callq 0x57cb2
testl %eax, %eax
je 0x86967
movq %r14, %rdi
movl %r12d, %esi
callq 0x57fbe
movq %rbx, %rdi
movl $0xa, %esi
callq 0x3c324
jmp 0x86958
leaq 0x6e2bf(%rip), %rsi     # 0xf4c0f
movq %rbx, %rdi
callq 0x3c067
xorl %r15d, %r15d
movl %r15d, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %r14, %rdi
movl %r12d, %esi
callq 0x57d30
testl %eax, %eax
je 0x86a38
xorl %r15d, %r15d
movq %r14, %rdi
movl %r12d, %esi
xorl %edx, %edx
callq 0x58042
movq %rax, %r12
leaq 0x5c728(%rip), %rdx     # 0xe30bc
movq %r14, %rdi
movl $0xffffd8ee, %esi       # imm = 0xFFFFD8EE
callq 0x58b98
leaq 0x5a7ee(%rip), %rsi     # 0xe1196
movl $0x6, %edx
movq %r14, %rdi
callq 0x58391
movq %r14, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x58a66
leaq 0x6e296(%rip), %rsi     # 0xf4c5f
movq %r14, %rdi
callq 0x58568
movq %r14, %rdi
movq %r12, %rsi
callq 0x58568
movq %r14, %rdi
movl $0x2, %esi
movl $0x1, %edx
callq 0x5948a
movq %r14, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %edx, %edx
callq 0x58042
movq %rax, %r12
movq %r14, %rdi
movl $0xfffffffd, %esi       # imm = 0xFFFFFFFD
callq 0x578d2
testb %bpl, %bpl
je 0x86a61
leaq 0x6e249(%rip), %rsi     # 0xf4c62
movq %rbx, %rdi
callq 0x3c067
movq %rbx, %rdi
movq %r12, %rsi
callq 0x3c067
leaq 0x67389(%rip), %rsi     # 0xeddbc
movq %rbx, %rdi
jmp 0x86a67
movq %r14, %rdi
movl $0xfffffffd, %esi       # imm = 0xFFFFFFFD
callq 0x578d2
leaq 0x6e218(%rip), %rsi     # 0xf4c64
movq %r15, %rdi
xorl %eax, %eax
callq 0x3559f
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
jmp 0x8695b
movq %rbx, %rdi
movq %r12, %rsi
callq 0x3c067
jmp 0x8695b
callq 0x1fc56
callq 0x1fc1f
nop