// File: /workspace/github_c_makefile_star2_O3/gplessis[P]dotdeb-redis/deps/lua/src/lvm.c
// Function: luaV_concat
void luaV_concat (lua_State *L, int total, int last) {
  do {
    StkId top = L->base + last + 1;
    int n = 2;  /* number of elements handled in this pass (at least 2) */
    if (!(ttisstring(top-2) || ttisnumber(top-2)) || !tostring(L, top-1)) {
      if (!call_binTM(L, top-2, top-1, top-2, TM_CONCAT))
        luaG_concaterror(L, top-2, top-1);
    } else if (tsvalue(top-1)->len == 0)  /* second op is empty? */
      (void)tostring(L, top - 2);  /* result is first op (as string) */
    else {
      /* at least two string values; get as many as possible */
      size_t tl = tsvalue(top-1)->len;
      char *buffer;
      int i;
      /* collect total length */
      for (n = 1; n < total && tostring(L, top-n-1); n++) {
        size_t l = tsvalue(top-n-1)->len;
        if (l >= MAX_SIZET - tl) luaG_runerror(L, "string length overflow");
        tl += l;
      }
      buffer = luaZ_openspace(L, &G(L)->buff, tl);
      tl = 0;
      for (i=n; i>0; i--) {  /* concat all strings */
        size_t l = tsvalue(top-i)->len;
        memcpy(buffer+tl, svalue(top-i), l);
        tl += l;
      }
      setsvalue2s(L, top-n, luaS_newlstr(L, buffer, tl));
    }
    total -= n-1;  /* got `n' strings to create 1 new */
    last -= n-1;
  } while (total > 1);  /* repeat until only 1 result left */
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %edx, %r14d
movl %esi, %ebx
movq %rdi, %rbp
movq %rdi, 0x8(%rsp)
movl %ebx, %ebx
movq 0x18(%rbp), %rax
movslq %r14d, %r15
shlq $0x4, %r15
leaq (%rax,%r15), %r12
movq %rax, 0x30(%rsp)
leaq (%rax,%r15), %r13
addq $-0x10, %r13
movl 0x8(%r13), %eax
addl $-0x3, %eax
cmpl $0x1, %eax
ja 0xf31d
cmpl $0x4, 0x8(%r12)
je 0xf1f4
movq %rbp, %rdi
movq %r12, %rsi
callq 0xeb01
testl %eax, %eax
je 0xf31d
movq (%r12), %rax
movq 0x10(%rax), %rbp
testq %rbp, %rbp
je 0xf34e
movl %r14d, 0x14(%rsp)
movl $0x1, %r14d
cmpl $0x2, %ebx
jl 0xf26f
movl $0x1, %r14d
cmpl $0x4, 0x8(%r13)
je 0xf233
movq 0x8(%rsp), %rdi
movq %r13, %rsi
callq 0xeb01
testl %eax, %eax
je 0xf26f
movq (%r13), %rax
movq 0x10(%rax), %r12
movq $-0x3, %rax
subq %rbp, %rax
cmpq %rax, %r12
jb 0xf25d
movq 0x8(%rsp), %rdi
leaq 0xcc52(%rip), %rsi      # 0x1bea8
xorl %eax, %eax
callq 0x7672
addq %r12, %rbp
incq %r14
addq $-0x10, %r13
cmpq %r14, %rbx
jne 0xf21b
movl %ebx, %r14d
movq 0x30(%rsp), %r12
leaq (%r12,%r15), %rax
addq $0x10, %rax
movq %rax, 0x20(%rsp)
movq 0x8(%rsp), %rdi
movq 0x20(%rdi), %rsi
addq $0x58, %rsi
movq %rbp, %rdx
callq 0x107cd
movq %rax, %r13
movl %r14d, %eax
incl %r14d
movq %rax, 0x28(%rsp)
shlq $0x4, %rax
movq %rax, 0x18(%rsp)
subq %rax, %r15
addq %r12, %r15
addq $0x10, %r15
xorl %r12d, %r12d
movq %r12, %rbp
movq (%r15), %rsi
movq 0x10(%rsi), %r12
movq %r13, %rdi
addq %rbp, %rdi
addq $0x18, %rsi
movq %r12, %rdx
callq 0x4300
addq %rbp, %r12
decl %r14d
addq $0x10, %r15
cmpl $0x1, %r14d
jg 0xf2ba
movq 0x20(%rsp), %r14
subq 0x18(%rsp), %r14
movq 0x8(%rsp), %rbp
movq %rbp, %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0xd282
movq %rax, (%r14)
movl $0x4, 0x8(%r14)
movq 0x28(%rsp), %r15
decl %r15d
movl 0x14(%rsp), %r14d
jmp 0xf373
movq %rbp, %rdi
movq %r13, %rsi
movq %r12, %rdx
movq %r13, %rcx
movl $0xf, %r8d
callq 0xf391
movl $0x1, %r15d
testl %eax, %eax
jne 0xf373
movq %rbp, %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0x7799
jmp 0xf373
movl $0x1, %r15d
cmpl $0x4, -0x8(%r12)
jne 0xf363
movq 0x8(%rsp), %rbp
jmp 0xf373
movq 0x8(%rsp), %rbp
movq %rbp, %rdi
movq %r13, %rsi
callq 0xeb01
subl %r15d, %ebx
subl %r15d, %r14d
cmpl $0x1, %ebx
jg 0xf1ab
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq