// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/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 0x71043
movq %rax, 0x18(%rsp)
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, 0x28(%rsp)
movq %rbx, %rdi
callq 0x666bd
leaq 0x50(%rsp), %rsi
movq %rbx, 0x10(%rsp)
movq %rbx, %rdi
callq 0x7173b
movq 0x18(%rsp), %rax
movb (%rax), %r15b
testb %r15b, %r15b
je 0x785a2
leaq 0x2068(%rsp), %r14
movl $0x2, %ecx
movq %rcx, (%rsp)
xorl %ebx, %ebx
incq %rax
movq %rax, 0x18(%rsp)
movsbl %r15b, %r12d
movq 0x10(%rsp), %rdi
movl %r12d, %esi
leaq 0x18(%rsp), %rdx
callq 0x78aca
movq %rax, 0x8(%rsp)
testq %rax, %rax
sete %al
cmpb $0x63, %r12b
sete %cl
orb %al, %cl
movl $0x0, %r13d
jne 0x78296
movslq 0x2c(%rsp), %r13
movq 0x8(%rsp), %rax
cmpq %rax, %r13
cmovaeq %rax, %r13
leal -0x1(%r13), %eax
movl %ebx, %ecx
andl %eax, %ecx
subl %ecx, %r13d
andl %eax, %r13d
testl %r13d, %r13d
jle 0x782c8
leal 0x1(%r13), %ebp
cmpq %r14, 0x50(%rsp)
jb 0x782b0
leaq 0x50(%rsp), %rdi
callq 0x717ef
movq 0x50(%rsp), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x50(%rsp)
movb $0x0, (%rax)
decl %ebp
cmpl $0x1, %ebp
jg 0x7829f
movzbl %r15b, %eax
cmpl $0x53, %eax
jle 0x78387
leal -0x62(%rax), %ecx
cmpl $0x11, %ecx
ja 0x78471
leaq 0x2a2dc(%rip), %rdx     # 0xa25c4
movslq (%rdx,%rcx,4), %rax
addq %rdx, %rax
jmpq *%rax
movq (%rsp), %rsi
leal 0x1(%rsi), %eax
movl %eax, 0x24(%rsp)
movq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rdx
callq 0x71043
movq %rax, %r12
movq 0x8(%rsp), %rcx
testq %rcx, %rcx
movq 0x30(%rsp), %rax
cmoveq %rax, %rcx
movq %rcx, %rbp
cmpq %rcx, %rax
jae 0x7833c
movq 0x10(%rsp), %rdi
movl 0x24(%rsp), %esi
leaq 0x2a3b6(%rip), %rdx     # 0xa26ed
callq 0x70d3c
leaq 0x50(%rsp), %rdi
movq %r12, %rsi
movq %rbp, %r12
movq %rbp, %rdx
callq 0x7174e
cmpb $0x73, %r15b
jne 0x7837a
cmpq %r14, 0x50(%rsp)
jb 0x78366
leaq 0x50(%rsp), %rdi
callq 0x717ef
movq 0x50(%rsp), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x50(%rsp)
movb $0x0, (%rax)
incq %r12
movl 0x24(%rsp), %eax
movq %rax, (%rsp)
jmp 0x78452
leal -0x48(%rax), %ecx
cmpl $0x2, %ecx
jb 0x7839d
cmpl $0x42, %eax
je 0x7839d
cmpl $0x4c, %eax
jne 0x78483
movl 0x28(%rsp), %ebp
movq 0x10(%rsp), %rdi
movq (%rsp), %r15
movl %r15d, %esi
callq 0x71205
cvttsd2si %xmm0, %rax
movq %rax, %rcx
sarq $0x3f, %rcx
movapd %xmm0, %xmm1
subsd 0x27cf6(%rip), %xmm1    # 0xa00c0
cvttsd2si %xmm1, %rdx
andq %rcx, %rdx
orq %rax, %rdx
xorpd %xmm1, %xmm1
ucomisd %xmm0, %xmm1
cvttsd2si %xmm0, %rax
cmovbeq %rdx, %rax
cmpl $0x1, %ebp
jne 0x78412
movq 0x8(%rsp), %r12
testl %r12d, %r12d
jle 0x78439
movl %r12d, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
xorl %edx, %edx
movb %al, 0x30(%rsp,%rdx)
shrq $0x8, %rax
incq %rdx
cmpq %rdx, %rcx
jne 0x78400
jmp 0x78439
movq 0x8(%rsp), %r12
testl %r12d, %r12d
jle 0x78439
movl %r12d, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
incq %rcx
movb %al, 0x2e(%rsp,%rcx)
shrq $0x8, %rax
decq %rcx
cmpq $0x1, %rcx
jg 0x78428
incl %r15d
movq %r15, (%rsp)
movslq %r12d, %rdx
leaq 0x50(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x7174e
movl %r13d, %eax
addq %rax, %rbx
addq %r12, %rbx
movq 0x18(%rsp), %rax
movb (%rax), %r15b
testb %r15b, %r15b
jne 0x7823d
jmp 0x785a2
cmpl $0x78, %eax
je 0x78576
cmpl $0x54, %eax
je 0x7839d
movq 0x10(%rsp), %rdi
movl %r12d, %esi
leaq 0x18(%rsp), %rdx
leaq 0x28(%rsp), %rcx
callq 0x78b77
jmp 0x78598
movq 0x10(%rsp), %rdi
movq (%rsp), %r15
movl %r15d, %esi
callq 0x71205
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x30(%rsp)
movq 0x8(%rsp), %r12
cmpl $0x2, %r12d
jl 0x7855d
cmpl $0x1, 0x28(%rsp)
je 0x7855d
movl %r12d, %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
addq $-0x2, %rax
xorl %ecx, %ecx
movb 0x30(%rsp,%rcx), %dl
movb 0x31(%rsp,%rax), %sil
movb %sil, 0x30(%rsp,%rcx)
incq %rcx
movb %dl, 0x31(%rsp,%rax)
leaq -0x1(%rax), %rdx
cmpq %rax, %rcx
movq %rdx, %rax
jl 0x784e2
jmp 0x7855d
movq 0x10(%rsp), %rdi
movq (%rsp), %r15
movl %r15d, %esi
callq 0x71205
movsd %xmm0, 0x30(%rsp)
movq 0x8(%rsp), %r12
cmpl $0x2, %r12d
jl 0x7855d
cmpl $0x1, 0x28(%rsp)
je 0x7855d
movl %r12d, %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
addq $-0x2, %rax
xorl %ecx, %ecx
movb 0x30(%rsp,%rcx), %dl
movb 0x31(%rsp,%rax), %sil
movb %sil, 0x30(%rsp,%rcx)
incq %rcx
movb %dl, 0x31(%rsp,%rax)
leaq -0x1(%rax), %rdx
cmpq %rax, %rcx
movq %rdx, %rax
jl 0x7853c
incl %r15d
movq %r15, (%rsp)
leaq 0x50(%rsp), %rdi
leaq 0x30(%rsp), %rsi
movq %r12, %rdx
jmp 0x7844d
cmpq %r14, 0x50(%rsp)
jb 0x78587
leaq 0x50(%rsp), %rdi
callq 0x717ef
movq 0x50(%rsp), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x50(%rsp)
movb $0x0, (%rax)
movq 0x8(%rsp), %r12
jmp 0x78452
leaq 0x50(%rsp), %rdi
callq 0x717d1
movl $0x1, %eax
addq $0x2068, %rsp           # imm = 0x2068
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq