// File: /workspace/github_c_makefile_star2_O3/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 $0x18, %rsp
movl %esi, %r15d
movq %rdi, %rbx
movq 0x10(%rdi), %rbp
movq %rdi, (%rsp)
movl %r15d, %r15d
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 0x19332
movl -0x8(%rbp), %eax
andl $0xf, %eax
cmpl $0x4, %eax
je 0x19211
leaq -0x10(%rbp), %rsi
movq %rbx, %rdi
callq 0x18b00
testl %eax, %eax
je 0x19332
movq -0x10(%rbp), %rax
movq 0x10(%rax), %r13
movl -0x18(%rbp), %ecx
andl $0xf, %ecx
testq %r13, %r13
je 0x19378
cmpl $0x4, %ecx
jne 0x1923c
movq (%r12), %rcx
cmpq $0x0, 0x10(%rcx)
je 0x19390
movl $0x1, %r14d
cmpl $0x2, %r15d
movq %r15, 0x10(%rsp)
jl 0x1929c
movl $0x1, %r14d
movl 0x8(%r12), %eax
andl $0xf, %eax
cmpl $0x4, %eax
je 0x1926f
movq %rbx, %rdi
movq %r12, %rsi
callq 0x18b00
testl %eax, %eax
je 0x1929c
movq (%r12), %rax
movq 0x10(%rax), %rax
movq $-0x3, %rcx
subq %r13, %rcx
cmpq %rcx, %rax
jae 0x193b1
addq %rax, %r13
incq %r14
addq $-0x10, %r12
cmpq %r14, %r15
jne 0x19253
movl %r15d, %r14d
movq 0x18(%rbx), %rsi
movl $0xd8, %eax
addq %rax, %rsi
movq %rbx, %rdi
movq %r13, %rdx
callq 0x1ab56
movq %rax, %r12
movslq %r14d, %rax
leaq 0x1(%rax), %rbx
shlq $0x4, %rax
movq %rbp, 0x8(%rsp)
movq %rbp, %r15
subq %rax, %r15
xorl %r13d, %r13d
movq %r13, %rbp
movq (%r15), %rsi
movq 0x10(%rsi), %r13
leaq (%r12,%rbp), %rdi
addq $0x18, %rsi
movq %r13, %rdx
callq 0x6360
addq %rbp, %r13
decq %rbx
addq $0x10, %r15
cmpq $0x1, %rbx
jg 0x192cf
movl %r14d, %eax
shlq $0x4, %rax
movq 0x8(%rsp), %r15
subq %rax, %r15
movq (%rsp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x14b50
movq %rax, (%r15)
movzbl 0x8(%rax), %eax
orl $0x40, %eax
movl %eax, 0x8(%r15)
decl %r14d
movq 0x10(%rsp), %r15
jmp 0x19357
addq $-0x10, %rbp
movq %rbx, %rdi
movq %r12, %rsi
movq %rbp, %rdx
movq %r12, %rcx
movl $0xf, %r8d
callq 0x193d0
movl $0x1, %r14d
testl %eax, %eax
je 0x193c2
subl %r14d, %r15d
movq 0x10(%rbx), %rbp
movslq %r14d, %rax
shlq $0x4, %rax
subq %rax, %rbp
movq %rbp, 0x10(%rbx)
cmpl $0x1, %r15d
jg 0x191cf
jmp 0x193a2
movl $0x1, %r14d
cmpl $0x4, %ecx
je 0x19357
movq %rbx, %rdi
movq %r12, %rsi
callq 0x18b00
jmp 0x19357
movq %rax, -0x20(%rbp)
movl -0x8(%rbp), %eax
movl %eax, -0x18(%rbp)
movl $0x1, %r14d
jmp 0x19357
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x8b3a(%rip), %rsi      # 0x21ef2
movq %rbx, %rdi
xorl %eax, %eax
callq 0xb027
movq %rbx, %rdi
movq %r12, %rsi
movq %rbp, %rdx
callq 0xb0bd