// File: /workspace/github_c_makefile_star2_O3/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 0x86419
movq %r15, %rdi
callq 0x34fea
testb %al, %al
jne 0x865ab
movq %r14, %rdi
movl %r12d, %esi
callq 0x56f9b
cmpl $0x5, %eax
je 0x865a6
movq %r14, %rdi
movl %r12d, %esi
callq 0x56f9b
cmpl $0x1, %eax
jne 0x86455
movq %r14, %rdi
movl %r12d, %esi
callq 0x573d2
testl %eax, %eax
je 0x8647e
leaq 0x8533f(%rip), %rsi     # 0x10b792
jmp 0x86485
movq %r14, %rdi
movl %r12d, %esi
callq 0x56ff1
testl %eax, %eax
je 0x8649c
movq %r14, %rdi
movl %r12d, %esi
callq 0x57374
movq %rbx, %rdi
movl $0xa, %esi
callq 0x3ba76
jmp 0x8648d
leaq 0x6e72a(%rip), %rsi     # 0xf4baf
movq %rbx, %rdi
callq 0x3b7af
xorl %r15d, %r15d
movl %r15d, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %r14, %rdi
movl %r12d, %esi
callq 0x5706f
testl %eax, %eax
je 0x8656d
xorl %r15d, %r15d
movq %r14, %rdi
movl %r12d, %esi
xorl %edx, %edx
callq 0x573f8
movq %rax, %r12
leaq 0x5cbd3(%rip), %rdx     # 0xe309c
movq %r14, %rdi
movl $0xffffd8ee, %esi       # imm = 0xFFFFD8EE
callq 0x57f56
leaq 0x5acb9(%rip), %rsi     # 0xe1196
movl $0x6, %edx
movq %r14, %rdi
callq 0x57747
movq %r14, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x57e45
leaq 0x6e701(%rip), %rsi     # 0xf4bff
movq %r14, %rdi
callq 0x5790a
movq %r14, %rdi
movq %r12, %rsi
callq 0x5790a
movq %r14, %rdi
movl $0x2, %esi
movl $0x1, %edx
callq 0x5881f
movq %r14, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %edx, %edx
callq 0x573f8
movq %rax, %r12
movq %r14, %rdi
movl $0xfffffffd, %esi       # imm = 0xFFFFFFFD
callq 0x56b09
testb %bpl, %bpl
je 0x86596
leaq 0x6e6b4(%rip), %rsi     # 0xf4c02
movq %rbx, %rdi
callq 0x3b7af
movq %rbx, %rdi
movq %r12, %rsi
callq 0x3b7af
leaq 0x6780c(%rip), %rsi     # 0xedd74
movq %rbx, %rdi
jmp 0x8659c
movq %r14, %rdi
movl $0xfffffffd, %esi       # imm = 0xFFFFFFFD
callq 0x56b09
leaq 0x6e683(%rip), %rsi     # 0xf4c04
movq %r15, %rdi
xorl %eax, %eax
callq 0x34f1f
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
jmp 0x86490
movq %rbx, %rdi
movq %r12, %rsi
callq 0x3b7af
jmp 0x86490
callq 0x1fbf0
callq 0x1fbb9