// File: /workspace/github_c_makefile_star2_O1/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 %rdi, (%rsp)
movl %r15d, %r15d
movq 0x10(%rbx), %rbp
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 0x192d4
movl -0x8(%rbp), %eax
andl $0xf, %eax
cmpl $0x4, %eax
je 0x191b3
leaq -0x10(%rbp), %rsi
movq %rbx, %rdi
callq 0x18a40
testl %eax, %eax
je 0x192d4
movq -0x10(%rbp), %rax
movq 0x10(%rax), %r13
movl -0x18(%rbp), %eax
andl $0xf, %eax
testq %r13, %r13
je 0x19313
cmpl $0x4, %eax
jne 0x191de
movq (%r12), %rax
cmpq $0x0, 0x10(%rax)
je 0x1932b
movl $0x1, %r14d
cmpl $0x2, %r15d
movq %r15, 0x10(%rsp)
jl 0x1923e
movl $0x1, %r14d
movl 0x8(%r12), %eax
andl $0xf, %eax
cmpl $0x4, %eax
je 0x19211
movq %rbx, %rdi
movq %r12, %rsi
callq 0x18a40
testl %eax, %eax
je 0x1923e
movq (%r12), %rax
movq 0x10(%rax), %rax
movq $-0x3, %rcx
subq %r13, %rcx
cmpq %rcx, %rax
jae 0x19350
addq %rax, %r13
incq %r14
addq $-0x10, %r12
cmpq %r14, %r15
jne 0x191f5
movl %r15d, %r14d
movq 0x18(%rbx), %rsi
movl $0xd8, %eax
addq %rax, %rsi
movq %rbx, %rdi
movq %r13, %rdx
callq 0x1ab38
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 0x19271
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 0x14a3f
movq %rax, (%r15)
movzbl 0x8(%rax), %eax
orl $0x40, %eax
movl %eax, 0x8(%r15)
decl %r14d
movq 0x10(%rsp), %r15
jmp 0x192f9
addq $-0x10, %rbp
movq %rbx, %rdi
movq %r12, %rsi
movq %rbp, %rdx
movq %r12, %rcx
movl $0xf, %r8d
callq 0x1936f
movl $0x1, %r14d
testl %eax, %eax
je 0x19361
subl %r14d, %r15d
movslq %r14d, %rax
shlq $0x4, %rax
subq %rax, 0x10(%rbx)
cmpl $0x1, %r15d
jg 0x1916d
jmp 0x19341
movl $0x1, %r14d
cmpl $0x4, %eax
je 0x192f9
movq %rbx, %rdi
movq %r12, %rsi
callq 0x18a40
jmp 0x192f9
movq -0x10(%rbp), %rax
movq %rax, -0x20(%rbp)
movl -0x8(%rbp), %eax
movl %eax, -0x18(%rbp)
movl $0x1, %r14d
jmp 0x192f9
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x8b9b(%rip), %rsi      # 0x21ef2
movq %rbx, %rdi
xorl %eax, %eax
callq 0xaf1a
movq %rbx, %rdi
movq %r12, %rsi
movq %rbp, %rdx
callq 0xafb0