// File: /workspace/github_c_makefile_star2_O2/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, %r14
xorl %ebx, %ebx
pushq $0x1
popq %rsi
xorl %edx, %edx
callq 0x8293c
movq %rax, %r12
movabsq $0x100000001, %rax      # imm = 0x100000001
leaq 0x20(%rsp), %rcx
movq %rax, (%rcx)
movq %r14, %rdi
callq 0x78a55
leaq 0x50(%rsp), %r15
movq %r14, 0x8(%rsp)
movq %r14, %rdi
movq %r15, %rsi
callq 0x82fa7
pushq $0x2
popq %rax
movq %rax, (%rsp)
leaq 0x2068(%rsp), %r14
movsbl (%r12), %r13d
testl %r13d, %r13d
je 0x898d7
incq %r12
movq %r12, 0x28(%rsp)
movq 0x8(%rsp), %rdi
movl %r13d, %esi
leaq 0x28(%rsp), %rdx
callq 0x89d82
movq %rax, %rbp
testq %rax, %rax
sete %al
cmpb $0x63, %r13b
sete %cl
xorl %r12d, %r12d
orb %al, %cl
jne 0x8967c
movslq 0x24(%rsp), %r12
cmpq %rbp, %r12
cmovaeq %rbp, %r12
leal -0x1(%r12), %eax
movl %ebx, %ecx
andl %eax, %ecx
subl %ecx, %r12d
andl %eax, %r12d
movl %r12d, %eax
movq %rax, 0x10(%rsp)
testl %r12d, %r12d
jle 0x896b1
movq 0x50(%rsp), %rax
cmpq %r14, %rax
jb 0x896a0
movq %r15, %rdi
callq 0x8304c
movq 0x50(%rsp), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x50(%rsp)
movb $0x0, (%rax)
decl %r12d
jmp 0x89684
movzbl %r13b, %eax
leal -0x62(%rax), %ecx
cmpl $0x11, %ecx
ja 0x8975a
leaq 0x3904c(%rip), %rdx     # 0xc2714
movslq (%rdx,%rcx,4), %rax
addq %rdx, %rax
jmpq *%rax
movq (%rsp), %rsi
leal 0x1(%rsi), %eax
movl %eax, 0x1c(%rsp)
movq 0x8(%rsp), %rdi
leaq 0x30(%rsp), %rdx
callq 0x8293c
movq %rax, %r12
testq %rbp, %rbp
movq 0x30(%rsp), %rax
cmoveq %rax, %rbp
cmpq %rbp, %rax
jae 0x89714
movq 0x8(%rsp), %rdi
movl 0x1c(%rsp), %esi
leaq 0x39145(%rip), %rdx     # 0xc2854
callq 0x82650
movq %r15, %rdi
movq %r12, %rsi
movq %rbp, %rdx
callq 0x82fb7
cmpb $0x73, %r13b
jne 0x8974e
movq 0x50(%rsp), %rax
cmpq %r14, %rax
jb 0x8973f
movq %r15, %rdi
callq 0x8304c
movq 0x50(%rsp), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x50(%rsp)
movb $0x0, (%rax)
incq %rbp
movl 0x1c(%rsp), %eax
movl %eax, %r13d
jmp 0x89812
leal -0x48(%rax), %ecx
cmpl $0x2, %ecx
jb 0x8977e
cmpl $0x42, %eax
je 0x8977e
cmpl $0x4c, %eax
je 0x8977e
cmpl $0x78, %eax
je 0x898a6
cmpl $0x54, %eax
jne 0x8982b
movl 0x20(%rsp), %r12d
movq 0x8(%rsp), %rdi
movq (%rsp), %r13
movl %r13d, %esi
callq 0x82af9
cvttsd2si %xmm0, %rax
movq %rax, %rcx
sarq $0x3f, %rcx
movapd %xmm0, %xmm1
subsd 0x34dfc(%rip), %xmm1    # 0xbe5a8
cvttsd2si %xmm1, %rdx
andq %rcx, %rdx
orq %rax, %rdx
xorpd %xmm1, %xmm1
ucomisd %xmm0, %xmm1
cvttsd2si %xmm0, %rax
cmovbeq %rdx, %rax
cmpl $0x1, %r12d
jne 0x897ec
testl %ebp, %ebp
movl $0x0, %ecx
cmovgl %ebp, %ecx
xorl %edx, %edx
cmpq %rdx, %rcx
je 0x897ff
movb %al, 0x30(%rsp,%rdx)
shrq $0x8, %rax
incq %rdx
jmp 0x897da
movl %ebp, %ecx
testl %ecx, %ecx
jle 0x897ff
movb %al, 0x2f(%rsp,%rcx)
decq %rcx
shrq $0x8, %rax
jmp 0x897ee
incl %r13d
movslq %ebp, %rdx
movq %r15, %rdi
leaq 0x30(%rsp), %rsi
callq 0x82fb7
movq 0x10(%rsp), %rax
movq %r13, (%rsp)
addq %rax, %rbx
addq %rbp, %rbx
movq 0x28(%rsp), %r12
jmp 0x89622
movq 0x8(%rsp), %rdi
movl %r13d, %esi
leaq 0x28(%rsp), %rdx
leaq 0x20(%rsp), %rcx
callq 0x89e46
jmp 0x898c9
movq (%rsp), %rsi
leal 0x1(%rsi), %r12d
movq 0x8(%rsp), %rdi
callq 0x82af9
movsd %xmm0, 0x30(%rsp)
jmp 0x8987d
movq (%rsp), %rsi
leal 0x1(%rsi), %r12d
movq 0x8(%rsp), %rdi
callq 0x82af9
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x30(%rsp)
movl 0x20(%rsp), %edx
leaq 0x30(%rsp), %r13
movq %r13, %rdi
movl %ebp, %esi
callq 0x89e1d
movq %r15, %rdi
movq %r13, %rsi
movq %rbp, %rdx
callq 0x82fb7
movl %r12d, %r13d
jmp 0x89812
movq 0x50(%rsp), %rax
cmpq %r14, %rax
jb 0x898bd
movq %r15, %rdi
callq 0x8304c
movq 0x50(%rsp), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x50(%rsp)
movb $0x0, (%rax)
movq 0x10(%rsp), %rax
movq (%rsp), %r13
jmp 0x89817
leaq 0x50(%rsp), %rdi
callq 0x8302e
pushq $0x1
popq %rax
addq $0x2068, %rsp           # imm = 0x2068
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq