// File: /workspace/github_c_makefile_star2_O2/bhk[P]tooltree/lua/../opensource/lua-5.2.3/src/lvm.c
// Function: luaV_concat
void luaV_concat (lua_State *L, int total) {
  lua_assert(total >= 2);
  do {
    StkId top = L->top;
    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 operand is empty? */
      (void)tostring(L, top - 2);  /* result is first operand */
    else if (ttisstring(top-2) && tsvalue(top-2)->len == 0) {
      setobjs2s(L, top - 2, top - 1);  /* result is second op. */
    }
    else {
      /* at least two non-empty string values; get as many as possible */
      size_t tl = tsvalue(top-1)->len;
      char *buffer;
      int i;
      /* collect total length */
      for (i = 1; i < total && tostring(L, top-i-1); i++) {
        size_t l = tsvalue(top-i-1)->len;
        if (l >= (MAX_SIZET/sizeof(char)) - tl)
          luaG_runerror(L, "string length overflow");
        tl += l;
      }
      buffer = luaZ_openspace(L, &G(L)->buff, tl);
      tl = 0;
      n = i;
      do {  /* concat all strings */
        size_t l = tsvalue(top-i)->len;
        memcpy(buffer+tl, svalue(top-i), l * sizeof(char));
        tl += l;
      } while (--i > 0);
      setsvalue2s(L, top-n, luaS_newlstr(L, buffer, tl));
    }
    total -= n-1;  /* got 'n' strings to create 1 new */
    L->top -= n-1;  /* popped 'n' strings and pushed one */
  } while (total > 1);  /* repeat until only 1 result left */
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %esi, %ebx
movq %rdi, %r15
movq 0x10(%rdi), %rbp
pushq $0x1
popq %r14
movq %rdi, 0x18(%rsp)
leaq -0x20(%rbp), %r12
movl -0x18(%rbp), %eax
movl %eax, %ecx
andl $0xf, %ecx
cmpl $0x4, %ecx
setne %cl
cmpl $0x3, %eax
setne %al
testb %cl, %al
jne 0x17725
movl -0x8(%rbp), %eax
andl $0xf, %eax
cmpl $0x4, %eax
je 0x1769a
leaq -0x10(%rbp), %rsi
movq %r15, %rdi
callq 0x16fa4
testl %eax, %eax
je 0x17725
movq -0x10(%rbp), %rax
movq 0x10(%rax), %r13
movl -0x18(%rbp), %ecx
andl $0xf, %ecx
testq %r13, %r13
je 0x1774e
cmpl $0x4, %ecx
jne 0x176c5
movq (%r12), %rcx
cmpq $0x0, 0x10(%rcx)
je 0x17808
movl %r14d, %eax
movslq %ebx, %r14
cmpl $0x2, %r14d
movl %ebx, 0x14(%rsp)
cmovgel %ebx, %eax
movl %eax, 0x8(%rsp)
pushq $0x1
popq %rbx
cmpq %r14, %rbx
jge 0x1776a
movl 0x8(%r12), %eax
andl $0xf, %eax
cmpl $0x4, %eax
je 0x17702
movq %r15, %rdi
movq %r12, %rsi
callq 0x16fa4
testl %eax, %eax
je 0x17770
movq (%r12), %rax
movq 0x10(%rax), %rax
pushq $-0x3
popq %rcx
subq %r13, %rcx
cmpq %rcx, %rax
jae 0x17841
addq %rax, %r13
incq %rbx
addq $-0x10, %r12
jmp 0x176dd
addq $-0x10, %rbp
movq %r15, %rdi
movq %r12, %rsi
movq %rbp, %rdx
movq %r12, %rcx
pushq $0xf
popq %r8
callq 0x17860
movl %r14d, %edx
testl %eax, %eax
jne 0x17815
jmp 0x17852
movl %r14d, %edx
cmpl $0x4, %ecx
je 0x17815
movq %r15, %rdi
movq %r12, %rsi
callq 0x16fa4
jmp 0x17812
movl 0x8(%rsp), %ebx
jmp 0x17770
movq 0x18(%r15), %rsi
movl $0xd8, %eax
addq %rax, %rsi
movq %r15, %rdi
movq %r13, %rdx
callq 0x18e8d
movq %rax, %r12
movl %ebx, %eax
leaq 0x1(%rax), %rbx
movq %rax, 0x8(%rsp)
shlq $0x4, %rax
movq %rbp, %r15
movq %rax, 0x20(%rsp)
subq %rax, %r15
xorl %r13d, %r13d
movq %r13, %r14
movq (%r15), %rsi
movq 0x10(%rsi), %r13
leaq (%r12,%r14), %rdi
addq $0x18, %rsi
movq %r13, %rdx
callq 0x6350
addq %r14, %r13
decq %rbx
addq $0x10, %r15
cmpq $0x1, %rbx
ja 0x177a7
subq 0x20(%rsp), %rbp
movq 0x18(%rsp), %r15
movq %r15, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x13766
movq %rax, (%rbp)
movzbl 0x8(%rax), %eax
orl $0x40, %eax
movl %eax, 0x8(%rbp)
movq 0x8(%rsp), %rdx
decl %edx
movl 0x14(%rsp), %ebx
pushq $0x1
popq %r14
jmp 0x17815
movq %rax, -0x20(%rbp)
movl -0x8(%rbp), %eax
movl %eax, -0x18(%rbp)
movl %r14d, %edx
subl %edx, %ebx
movq 0x10(%r15), %rbp
movslq %edx, %rax
shlq $0x4, %rax
subq %rax, %rbp
movq %rbp, 0x10(%r15)
cmpl $0x1, %ebx
jg 0x1765b
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x869a(%rip), %rsi      # 0x1fee2
movq %r15, %rdi
xorl %eax, %eax
callq 0xaa89
movq %r15, %rdi
movq %r12, %rsi
movq %rbp, %rdx
callq 0xab1f