// File: /workspace/github_c_makefile_star2_O3/gplessis[P]dotdeb-redis/deps/lua/src/lua_struct.c
// Function: b_pack
static int b_pack (lua_State *L) {
  luaL_Buffer b;
  const char *fmt = luaL_checkstring(L, 1);
  Header h;
  int arg = 2;
  size_t totalsize = 0;
  defaultoptions(&h);
  lua_pushnil(L);  /* mark to separate arguments from string buffer */
  luaL_buffinit(L, &b);
  while (*fmt != '\0') {
    int opt = *fmt++;
    size_t size = optsize(L, opt, &fmt);
    int toalign = gettoalign(totalsize, &h, opt, size);
    totalsize += toalign;
    while (toalign-- > 0) luaL_addchar(&b, '\0');
    switch (opt) {
      case 'b': case 'B': case 'h': case 'H':
      case 'l': case 'L': case 'T': case 'i': case 'I': {  /* integer types */
        putinteger(L, &b, arg++, h.endian, size);
        break;
      }
      case 'x': {
        luaL_addchar(&b, '\0');
        break;
      }
      case 'f': {
        float f = (float)luaL_checknumber(L, arg++);
        correctbytes((char *)&f, size, h.endian);
        luaL_addlstring(&b, (char *)&f, size);
        break;
      }
      case 'd': {
        double d = luaL_checknumber(L, arg++);
        correctbytes((char *)&d, size, h.endian);
        luaL_addlstring(&b, (char *)&d, size);
        break;
      }
      case 'c': case 's': {
        size_t l;
        const char *s = luaL_checklstring(L, arg++, &l);
        if (size == 0) size = l;
        luaL_argcheck(L, l >= (size_t)size, arg, "string too short");
        luaL_addlstring(&b, s, size);
        if (opt == 's') {
          luaL_addchar(&b, '\0');  /* add zero at the end */
          size++;
        }
        break;
      }
      default: controloptions(L, opt, &fmt, &h);
    }
    totalsize += size;
  }
  luaL_pushresult(&b);
  return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2068, %rsp           # imm = 0x2068
movq %rdi, %rbx
movl $0x1, %esi
xorl %edx, %edx
callq 0x91394
movq %rax, %r12
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, 0x18(%rsp)
movq %rbx, %rdi
callq 0x86487
leaq 0x50(%rsp), %rsi
movq %rbx, 0x10(%rsp)
movq %rbx, %rdi
callq 0x91a8c
movb (%r12), %r13b
testb %r13b, %r13b
je 0x98afe
movl $0x2, %eax
movq %rax, 0x8(%rsp)
leaq 0x2068(%rsp), %r14
xorl %ebx, %ebx
incq %r12
movq %r12, 0x48(%rsp)
movsbl %r13b, %r12d
movq 0x10(%rsp), %rdi
movl %r12d, %esi
leaq 0x48(%rsp), %rdx
callq 0x99012
movq %rax, %rbp
testq %rax, %rax
sete %al
cmpb $0x63, %r12b
sete %cl
orb %al, %cl
jne 0x9884e
movslq 0x1c(%rsp), %r15
cmpq %rbp, %r15
cmovaeq %rbp, %r15
leaq -0x1(%r15), %rax
movq %rax, %rcx
andq %rbx, %rcx
subq %rcx, %r15
andq %rax, %r15
movl %r15d, %eax
addq %rax, %rbx
testl %r15d, %r15d
jle 0x9884e
incl %r15d
movq 0x50(%rsp), %rax
cmpq %r14, %rax
jb 0x98839
leaq 0x50(%rsp), %rdi
callq 0x91b40
movq 0x50(%rsp), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x50(%rsp)
movb $0x0, (%rax)
decl %r15d
cmpl $0x1, %r15d
ja 0x98820
movzbl %r13b, %eax
cmpl $0x53, %eax
jle 0x98902
leal -0x62(%rax), %ecx
cmpl $0x11, %ecx
ja 0x989dd
leaq 0x393e2(%rip), %rdx     # 0xd1c50
movslq (%rdx,%rcx,4), %rax
addq %rdx, %rax
jmpq *%rax
movq 0x8(%rsp), %rsi
leal 0x1(%rsi), %r15d
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rdx
callq 0x91394
movq %rax, %r12
testq %rbp, %rbp
movq 0x20(%rsp), %rax
cmoveq %rax, %rbp
cmpq %rbp, %rax
jae 0x988b7
movq 0x10(%rsp), %rdi
movl %r15d, %esi
leaq 0x394de(%rip), %rdx     # 0xd1d90
callq 0x91090
leaq 0x50(%rsp), %rdi
movq %r12, %rsi
movq %rbp, %rdx
callq 0x91a9f
cmpb $0x73, %r13b
jne 0x988f5
movq 0x50(%rsp), %rax
cmpq %r14, %rax
jb 0x988e6
leaq 0x50(%rsp), %rdi
callq 0x91b40
movq 0x50(%rsp), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x50(%rsp)
movb $0x0, (%rax)
incq %rbp
movl %r15d, %eax
movq %rax, 0x8(%rsp)
jmp 0x989c3
leal -0x48(%rax), %ecx
cmpl $0x2, %ecx
jb 0x98918
cmpl $0x42, %eax
je 0x98918
cmpl $0x4c, %eax
jne 0x989ef
movl 0x18(%rsp), %r15d
movq 0x10(%rsp), %rdi
movq 0x8(%rsp), %r12
movl %r12d, %esi
callq 0x91556
cvttsd2si %xmm0, %rax
movq %rax, %rcx
sarq $0x3f, %rcx
movapd %xmm0, %xmm1
subsd 0x350b9(%rip), %xmm1    # 0xcda00
cvttsd2si %xmm1, %rdx
andq %rcx, %rdx
orq %rax, %rdx
xorpd %xmm1, %xmm1
ucomisd %xmm0, %xmm1
cvttsd2si %xmm0, %rax
cmovbeq %rdx, %rax
cmpl $0x1, %r15d
jne 0x98989
testl %ebp, %ebp
jle 0x989a9
movl %ebp, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
xorl %edx, %edx
movb %al, 0x20(%rsp,%rdx)
shrq $0x8, %rax
incq %rdx
cmpq %rdx, %rcx
jne 0x98977
jmp 0x989a9
testl %ebp, %ebp
jle 0x989a9
movl %ebp, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
incq %rcx
movb %al, 0x1e(%rsp,%rcx)
shrq $0x8, %rax
decq %rcx
cmpq $0x1, %rcx
ja 0x98998
incl %r12d
movq %r12, 0x8(%rsp)
movslq %ebp, %rdx
leaq 0x50(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x91a9f
addq %rbp, %rbx
movq 0x48(%rsp), %r12
movb (%r12), %r13b
testb %r13b, %r13b
jne 0x987c4
jmp 0x98afe
cmpl $0x78, %eax
je 0x98ad4
cmpl $0x54, %eax
je 0x98918
movq 0x10(%rsp), %rdi
movl %r12d, %esi
leaq 0x48(%rsp), %rdx
leaq 0x18(%rsp), %rcx
callq 0x990c5
jmp 0x989c3
movq 0x10(%rsp), %rdi
movq 0x8(%rsp), %r15
movl %r15d, %esi
callq 0x91556
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x20(%rsp)
cmpl $0x2, %ebp
jl 0x98aba
cmpl $0x1, 0x18(%rsp)
je 0x98aba
movl %ebp, %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
addq $-0x2, %rax
xorl %ecx, %ecx
movb 0x20(%rsp,%rcx), %dl
movb 0x21(%rsp,%rax), %sil
movb %sil, 0x20(%rsp,%rcx)
incq %rcx
movb %dl, 0x21(%rsp,%rax)
leaq -0x1(%rax), %rdx
cmpq %rax, %rcx
movq %rdx, %rax
jl 0x98a45
jmp 0x98aba
movq 0x10(%rsp), %rdi
movq 0x8(%rsp), %r15
movl %r15d, %esi
callq 0x91556
movsd %xmm0, 0x20(%rsp)
cmpl $0x2, %ebp
jl 0x98aba
cmpl $0x1, 0x18(%rsp)
je 0x98aba
movl %ebp, %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
addq $-0x2, %rax
xorl %ecx, %ecx
movb 0x20(%rsp,%rcx), %dl
movb 0x21(%rsp,%rax), %sil
movb %sil, 0x20(%rsp,%rcx)
incq %rcx
movb %dl, 0x21(%rsp,%rax)
leaq -0x1(%rax), %rdx
cmpq %rax, %rcx
movq %rdx, %rax
jl 0x98a99
incl %r15d
movq %r15, 0x8(%rsp)
leaq 0x50(%rsp), %rdi
leaq 0x20(%rsp), %rsi
movq %rbp, %rdx
jmp 0x989be
movq 0x50(%rsp), %rax
cmpq %r14, %rax
jb 0x98aed
leaq 0x50(%rsp), %rdi
callq 0x91b40
movq 0x50(%rsp), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x50(%rsp)
movb $0x0, (%rax)
jmp 0x989c3
leaq 0x50(%rsp), %rdi
callq 0x91b22
movl $0x1, %eax
addq $0x2068, %rsp           # imm = 0x2068
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq