// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x2090, %rsp           # imm = 0x2090
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movl $0x1, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0xc06a0
movq %rax, -0x2028(%rbp)
movl $0x2, -0x2034(%rbp)
movq $0x0, -0x2040(%rbp)
movsbl 0x80db0(%rip), %eax     # 0x14be84
movl %eax, -0x2030(%rbp)
movl $0x1, -0x202c(%rbp)
movq -0x8(%rbp), %rdi
callq 0xad2c0
movq -0x8(%rbp), %rdi
leaq -0x2020(%rbp), %rsi
callq 0xc0ff0
movq -0x2028(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0xcb4cf
movq -0x2028(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x2028(%rbp)
movsbl (%rax), %eax
movl %eax, -0x2044(%rbp)
movq -0x8(%rbp), %rdi
movl -0x2044(%rbp), %eax
leaq -0x2028(%rbp), %rdx
movsbl %al, %esi
callq 0xcb9a0
movq %rax, -0x2050(%rbp)
movq -0x2040(%rbp), %rdi
movl -0x2044(%rbp), %edx
movq -0x2050(%rbp), %rcx
leaq -0x2030(%rbp), %rsi
callq 0xcbaa0
movl %eax, -0x2054(%rbp)
movslq -0x2054(%rbp), %rax
addq -0x2040(%rbp), %rax
movq %rax, -0x2040(%rbp)
movl -0x2054(%rbp), %eax
movl %eax, %ecx
addl $-0x1, %ecx
movl %ecx, -0x2054(%rbp)
cmpl $0x0, %eax
jle 0xcb1fe
movq -0x2020(%rbp), %rcx
leaq -0x2020(%rbp), %rdx
addq $0x18, %rdx
addq $0x2000, %rdx           # imm = 0x2000
movb $0x1, %al
cmpq %rdx, %rcx
movb %al, -0x2071(%rbp)
jb 0xcb1de
leaq -0x2020(%rbp), %rdi
callq 0xc1140
cmpq $0x0, %rax
setne %al
movb %al, -0x2071(%rbp)
movb -0x2071(%rbp), %al
movq -0x2020(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x2020(%rbp)
movb $0x0, (%rax)
jmp 0xcb189
movl -0x2044(%rbp), %eax
addl $-0x42, %eax
movl %eax, %ecx
movq %rcx, -0x2080(%rbp)
subl $0x36, %eax
ja 0xcb498
movq -0x2080(%rbp), %rax
leaq 0x8094d(%rip), %rcx     # 0x14bb74
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x8(%rbp), %rdi
movl -0x2034(%rbp), %edx
movl %edx, %eax
addl $0x1, %eax
movl %eax, -0x2034(%rbp)
movl -0x2030(%rbp), %ecx
movq -0x2050(%rbp), %rax
movl %eax, %r8d
leaq -0x2020(%rbp), %rsi
callq 0xcbb10
jmp 0xcb4b5
movq -0x2020(%rbp), %rcx
leaq -0x2020(%rbp), %rdx
addq $0x18, %rdx
addq $0x2000, %rdx           # imm = 0x2000
movb $0x1, %al
cmpq %rdx, %rcx
movb %al, -0x2081(%rbp)
jb 0xcb2a5
leaq -0x2020(%rbp), %rdi
callq 0xc1140
cmpq $0x0, %rax
setne %al
movb %al, -0x2081(%rbp)
movb -0x2081(%rbp), %al
movq -0x2020(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x2020(%rbp)
movb $0x0, (%rax)
jmp 0xcb4b5
movq -0x8(%rbp), %rdi
movl -0x2034(%rbp), %esi
movl %esi, %eax
addl $0x1, %eax
movl %eax, -0x2034(%rbp)
callq 0xc0940
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x2058(%rbp)
movq -0x2050(%rbp), %rax
movl %eax, %esi
movl -0x2030(%rbp), %edx
leaq -0x2058(%rbp), %rdi
callq 0xcbc20
movq -0x2050(%rbp), %rdx
leaq -0x2020(%rbp), %rdi
leaq -0x2058(%rbp), %rsi
callq 0xc1030
jmp 0xcb4b5
movq -0x8(%rbp), %rdi
movl -0x2034(%rbp), %esi
movl %esi, %eax
addl $0x1, %eax
movl %eax, -0x2034(%rbp)
callq 0xc0940
movsd %xmm0, -0x2060(%rbp)
movq -0x2050(%rbp), %rax
movl %eax, %esi
movl -0x2030(%rbp), %edx
leaq -0x2060(%rbp), %rdi
callq 0xcbc20
movq -0x2050(%rbp), %rdx
leaq -0x2020(%rbp), %rdi
leaq -0x2060(%rbp), %rsi
callq 0xc1030
jmp 0xcb4b5
movq -0x8(%rbp), %rdi
movl -0x2034(%rbp), %esi
movl %esi, %eax
addl $0x1, %eax
movl %eax, -0x2034(%rbp)
leaq -0x2068(%rbp), %rdx
callq 0xc06a0
movq %rax, -0x2070(%rbp)
cmpq $0x0, -0x2050(%rbp)
jne 0xcb3c4
movq -0x2068(%rbp), %rax
movq %rax, -0x2050(%rbp)
movq -0x2068(%rbp), %rcx
movb $0x1, %al
cmpq -0x2050(%rbp), %rcx
movb %al, -0x2082(%rbp)
jae 0xcb3fe
movq -0x8(%rbp), %rdi
movl -0x2034(%rbp), %esi
leaq 0x80b1f(%rip), %rdx     # 0x14bf0c
callq 0xc0270
cmpl $0x0, %eax
setne %al
movb %al, -0x2082(%rbp)
movb -0x2082(%rbp), %al
movq -0x2070(%rbp), %rsi
movq -0x2050(%rbp), %rdx
leaq -0x2020(%rbp), %rdi
callq 0xc1030
cmpl $0x73, -0x2044(%rbp)
jne 0xcb496
movq -0x2020(%rbp), %rcx
leaq -0x2020(%rbp), %rdx
addq $0x18, %rdx
addq $0x2000, %rdx           # imm = 0x2000
movb $0x1, %al
cmpq %rdx, %rcx
movb %al, -0x2083(%rbp)
jb 0xcb466
leaq -0x2020(%rbp), %rdi
callq 0xc1140
cmpq $0x0, %rax
setne %al
movb %al, -0x2083(%rbp)
movb -0x2083(%rbp), %al
movq -0x2020(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x2020(%rbp)
movb $0x0, (%rax)
movq -0x2050(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x2050(%rbp)
jmp 0xcb4b5
movq -0x8(%rbp), %rdi
movl -0x2044(%rbp), %esi
leaq -0x2028(%rbp), %rdx
leaq -0x2030(%rbp), %rcx
callq 0xcbca0
movq -0x2050(%rbp), %rax
addq -0x2040(%rbp), %rax
movq %rax, -0x2040(%rbp)
jmp 0xcb0fd
leaq -0x2020(%rbp), %rdi
callq 0xc1100
movl $0x1, %eax
addq $0x2090, %rsp           # imm = 0x2090
popq %rbp
retq
nopl (%rax)