// File: /workspace/github_c_makefile_star2_O0/tylerneylon[P]APIsWithLua/lua/lstrlib.c
// Function: str_unpack
static int str_unpack (lua_State *L) {
  Header h;
  const char *fmt = luaL_checkstring(L, 1);
  size_t ld;
  const char *data = luaL_checklstring(L, 2, &ld);
  size_t pos = (size_t)posrelat(luaL_optinteger(L, 3, 1), ld) - 1;
  int n = 0;  /* number of results */
  luaL_argcheck(L, pos <= ld, 3, "initial position out of string");
  initheader(L, &h);
  while (*fmt != '\0') {
    int size, ntoalign;
    KOption opt = getdetails(&h, pos, &fmt, &size, &ntoalign);
    if ((size_t)ntoalign + size > ~pos || pos + ntoalign + size > ld)
      luaL_argerror(L, 2, "data string too short");
    pos += ntoalign;  /* skip alignment */
    /* stack space for item + next position */
    luaL_checkstack(L, 2, "too many results");
    n++;
    switch (opt) {
      case Kint:
      case Kuint: {
        lua_Integer res = unpackint(L, data + pos, h.islittle, size,
                                       (opt == Kint));
        lua_pushinteger(L, res);
        break;
      }
      case Kfloat: {
        volatile Ftypes u;
        lua_Number num;
        copywithendian(u.buff, data + pos, size, h.islittle);
        if (size == sizeof(u.f)) num = (lua_Number)u.f;
        else if (size == sizeof(u.d)) num = (lua_Number)u.d;
        else num = u.n;
        lua_pushnumber(L, num);
        break;
      }
      case Kchar: {
        lua_pushlstring(L, data + pos, size);
        break;
      }
      case Kstring: {
        size_t len = (size_t)unpackint(L, data + pos, h.islittle, size, 0);
        luaL_argcheck(L, pos + len + size <= ld, 2, "data string too short");
        lua_pushlstring(L, data + pos + size, len);
        pos += len;  /* skip string */
        break;
      }
      case Kzstr: {
        size_t len = (int)strlen(data + pos);
        lua_pushlstring(L, data + pos, len);
        pos += len + 1;  /* skip string plus final '\0' */
        break;
      }
      case Kpaddalign: case Kpadding: case Knop:
        n--;  /* undo increment */
        break;
    }
    pos += size;
  }
  lua_pushinteger(L, pos + 1);  /* next position */
  return n + 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movl $0x1, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x20390
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rdi
movl $0x2, %esi
leaq -0x28(%rbp), %rdx
callq 0x20390
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
movl $0x3, %esi
movl $0x1, %edx
callq 0x205e0
movq %rax, %rdi
movq -0x28(%rbp), %rsi
callq 0x2de20
subq $0x1, %rax
movq %rax, -0x38(%rbp)
movl $0x0, -0x3c(%rbp)
movq -0x38(%rbp), %rcx
movb $0x1, %al
cmpq -0x28(%rbp), %rcx
movb %al, -0x91(%rbp)
jbe 0x2db6c
movq -0x8(%rbp), %rdi
movl $0x3, %esi
leaq 0x96c5(%rip), %rdx      # 0x37220
callq 0x1fab0
cmpl $0x0, %eax
setne %al
movb %al, -0x91(%rbp)
movb -0x91(%rbp), %al
movq -0x8(%rbp), %rdi
leaq -0x18(%rbp), %rsi
callq 0x2fdf0
movq -0x20(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x2ddf6
movq -0x38(%rbp), %rsi
leaq -0x18(%rbp), %rdi
leaq -0x20(%rbp), %rdx
leaq -0x40(%rbp), %rcx
leaq -0x44(%rbp), %r8
callq 0x2fe30
movl %eax, -0x48(%rbp)
movslq -0x44(%rbp), %rax
movslq -0x40(%rbp), %rcx
addq %rcx, %rax
movq -0x38(%rbp), %rcx
xorq $-0x1, %rcx
cmpq %rcx, %rax
ja 0x2dbdb
movq -0x38(%rbp), %rax
movslq -0x44(%rbp), %rcx
addq %rcx, %rax
movslq -0x40(%rbp), %rcx
addq %rcx, %rax
cmpq -0x28(%rbp), %rax
jbe 0x2dbf0
movq -0x8(%rbp), %rdi
movl $0x2, %esi
leaq 0x9654(%rip), %rdx      # 0x3723f
callq 0x1fab0
movslq -0x44(%rbp), %rcx
movq -0x38(%rbp), %rax
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rdi
leaq 0x964b(%rip), %rdx      # 0x37255
movl $0x2, %esi
callq 0x1f930
movl -0x3c(%rbp), %eax
incl %eax
movl %eax, -0x3c(%rbp)
movl -0x48(%rbp), %eax
movq %rax, -0xa0(%rbp)
subq $0x8, %rax
ja 0x2dde5
movq -0xa0(%rbp), %rax
leaq 0x8f5e(%rip), %rcx      # 0x36b9c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
addq -0x38(%rbp), %rsi
movl -0x10(%rbp), %edx
movl -0x40(%rbp), %ecx
cmpl $0x0, -0x48(%rbp)
sete %al
andb $0x1, %al
movzbl %al, %r8d
callq 0x30500
movq %rax, -0x50(%rbp)
movq -0x8(%rbp), %rdi
movq -0x50(%rbp), %rsi
callq 0x6be0
jmp 0x2dde5
leaq -0x78(%rbp), %rdi
movq -0x30(%rbp), %rsi
addq -0x38(%rbp), %rsi
movl -0x40(%rbp), %edx
movl -0x10(%rbp), %ecx
callq 0x30080
movslq -0x40(%rbp), %rax
cmpq $0x4, %rax
jne 0x2dcb2
movss -0x78(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x80(%rbp)
jmp 0x2dcd4
movslq -0x40(%rbp), %rax
cmpq $0x8, %rax
jne 0x2dcc8
movsd -0x78(%rbp), %xmm0
movsd %xmm0, -0x80(%rbp)
jmp 0x2dcd2
movsd -0x78(%rbp), %xmm0
movsd %xmm0, -0x80(%rbp)
jmp 0x2dcd4
movq -0x8(%rbp), %rdi
movsd -0x80(%rbp), %xmm0
callq 0x6b90
jmp 0x2dde5
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
addq -0x38(%rbp), %rsi
movslq -0x40(%rbp), %rdx
callq 0x6c20
jmp 0x2dde5
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
addq -0x38(%rbp), %rsi
movl -0x10(%rbp), %edx
movl -0x40(%rbp), %ecx
xorl %r8d, %r8d
callq 0x30500
movq %rax, -0x88(%rbp)
movq -0x38(%rbp), %rcx
addq -0x88(%rbp), %rcx
movslq -0x40(%rbp), %rax
addq %rax, %rcx
movb $0x1, %al
cmpq -0x28(%rbp), %rcx
movb %al, -0xa1(%rbp)
jbe 0x2dd63
movq -0x8(%rbp), %rdi
movl $0x2, %esi
leaq 0x94ed(%rip), %rdx      # 0x3723f
callq 0x1fab0
cmpl $0x0, %eax
setne %al
movb %al, -0xa1(%rbp)
movb -0xa1(%rbp), %al
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
addq -0x38(%rbp), %rsi
movslq -0x40(%rbp), %rax
addq %rax, %rsi
movq -0x88(%rbp), %rdx
callq 0x6c20
movq -0x88(%rbp), %rax
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
jmp 0x2dde5
movq -0x30(%rbp), %rdi
addq -0x38(%rbp), %rdi
callq 0x5150
cltq
movq %rax, -0x90(%rbp)
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
addq -0x38(%rbp), %rsi
movq -0x90(%rbp), %rdx
callq 0x6c20
movq -0x90(%rbp), %rax
addq $0x1, %rax
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
jmp 0x2dde5
movl -0x3c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x3c(%rbp)
movslq -0x40(%rbp), %rax
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
jmp 0x2db7f
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rsi
addq $0x1, %rsi
callq 0x6be0
movl -0x3c(%rbp), %eax
addl $0x1, %eax
addq $0xb0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)