// File: /workspace/github_c_makefile_star2_O2/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 0x66345
movq %r15, %rdi
callq 0xc103
testb %al, %al
jne 0x664ea
movq %r14, %rdi
movl %r12d, %esi
callq 0x37b59
cmpl $0x5, %eax
je 0x664c0
movq %r14, %rdi
movl %r12d, %esi
callq 0x37b59
cmpl $0x1, %eax
jne 0x66381
movq %r14, %rdi
movl %r12d, %esi
callq 0x37f77
testl %eax, %eax
je 0x663a8
leaq 0x8e6d3(%rip), %rsi     # 0xf4a52
jmp 0x663af
movq %r14, %rdi
movl %r12d, %esi
callq 0x37bad
testl %eax, %eax
je 0x663c6
movq %r14, %rdi
movl %r12d, %esi
callq 0x37f19
pushq $0xa
popq %rsi
movq %rbx, %rdi
callq 0x141d7
jmp 0x663b7
leaq 0x77b60(%rip), %rsi     # 0xddf0f
movq %rbx, %rdi
callq 0x13dd3
xorl %r15d, %r15d
movl %r15d, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %r14, %rdi
movl %r12d, %esi
callq 0x37c2b
testl %eax, %eax
je 0x6648b
xorl %r15d, %r15d
movq %r14, %rdi
movl %r12d, %esi
xorl %edx, %edx
callq 0x37f9b
movq %rax, %r12
leaq 0x65ca9(%rip), %rdx     # 0xcc09c
movq %r14, %rdi
movl $0xffffd8ee, %esi       # imm = 0xFFFFD8EE
callq 0x38a63
leaq 0x63d8f(%rip), %rsi     # 0xca196
pushq $0x6
popq %rdx
movq %r14, %rdi
callq 0x3828a
pushq $-0x2
popq %rsi
movq %r14, %rdi
callq 0x3894c
leaq 0x77b3b(%rip), %rsi     # 0xddf5f
movq %r14, %rdi
callq 0x38431
movq %r14, %rdi
movq %r12, %rsi
callq 0x38431
pushq $0x2
popq %rsi
pushq $0x1
popq %rdx
movq %r14, %rdi
callq 0x39262
pushq $-0x1
popq %rsi
movq %r14, %rdi
xorl %edx, %edx
callq 0x37f9b
movq %rax, %r12
pushq $-0x3
popq %rsi
movq %r14, %rdi
callq 0x377fa
testb %bpl, %bpl
je 0x664b0
leaq 0x77af6(%rip), %rsi     # 0xddf62
movq %rbx, %rdi
callq 0x13dd3
movq %rbx, %rdi
movq %r12, %rsi
callq 0x13dd3
leaq 0x70896(%rip), %rsi     # 0xd6d1c
movq %rbx, %rdi
jmp 0x664b6
pushq $-0x3
popq %rsi
movq %r14, %rdi
callq 0x377fa
leaq 0x77ac7(%rip), %rsi     # 0xddf64
movq %r15, %rdi
xorl %eax, %eax
callq 0xc007
pushq $-0x1
popq %r15
jmp 0x663ba
movq %rbx, %rdi
movq %r12, %rsi
callq 0x13dd3
jmp 0x663ba
movq 0xc7af1(%rip), %rax     # 0x12dfb8
movq (%rax), %rdi
leaq 0x63b95(%rip), %rsi     # 0xca066
leaq 0x77a70(%rip), %rdx     # 0xddf48
leaq 0x77a5b(%rip), %rcx     # 0xddf3a
leaq 0x778b7(%rip), %r8      # 0xddd9d
pushq $0x20
jmp 0x66512
movq 0xc7ac7(%rip), %rax     # 0x12dfb8
movq (%rax), %rdi
leaq 0x63b6b(%rip), %rsi     # 0xca066
leaq 0x64157(%rip), %rdx     # 0xca659
leaq 0x77a31(%rip), %rcx     # 0xddf3a
leaq 0x7788d(%rip), %r8      # 0xddd9d
pushq $0x1f
popq %r9
xorl %eax, %eax
callq 0xb8c0
callq 0xb300