// File: /workspace/github_c_makefile_star2_O1/genometools[P]genometools/src/external/lua-5.1.5/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, %r13d
movq %rdi, %rbx
movq %rdi, 0x18(%rsp)
movl %esi, %esi
movq %rsi, 0x10(%rsp)
movq 0x18(%rbx), %r14
movslq %r13d, %rbp
shlq $0x4, %rbp
leaq (%r14,%rbp), %r15
leaq (%r14,%rbp), %r12
addq $-0x10, %r12
movl 0x8(%r12), %eax
addl $-0x3, %eax
cmpl $0x1, %eax
ja 0x59ddb
cmpl $0x4, 0x8(%r15)
je 0x59cc1
movq %rbx, %rdi
movq %r15, %rsi
callq 0x580b3
testl %eax, %eax
je 0x59ddb
movl %r13d, 0xc(%rsp)
movq (%r15), %rax
movq 0x10(%rax), %r13
testq %r13, %r13
je 0x59e1e
movq %r14, 0x30(%rsp)
movl $0x1, %r14d
movq 0x10(%rsp), %r15
cmpl $0x2, %r15d
jl 0x59d36
movl $0x1, %r14d
cmpl $0x4, 0x8(%r12)
je 0x59d09
movq %rbx, %rdi
movq %r12, %rsi
callq 0x580b3
testl %eax, %eax
je 0x59d36
movq (%r12), %rax
movq 0x10(%rax), %rax
movq $-0x3, %rcx
subq %r13, %rcx
cmpq %rcx, %rax
jae 0x59e5e
addq %rax, %r13
incq %r14
addq $-0x10, %r12
cmpq %r14, %r15
jne 0x59cf2
movl %r15d, %r14d
movq 0x30(%rsp), %r15
leaq (%r15,%rbp), %rax
addq $0x10, %rax
movq %rax, 0x28(%rsp)
movq 0x20(%rbx), %rsi
addq $0x58, %rsi
movq %rbx, %rdi
movq %r13, %rdx
callq 0x608b0
movq %rax, %r12
movl %r14d, %eax
leal 0x1(%r14), %r13d
movq %rax, 0x20(%rsp)
shlq $0x4, %rax
subq %rax, %rbp
addq %r15, %rbp
addq $0x10, %rbp
xorl %r15d, %r15d
movq %r15, %rbx
movq (%rbp), %rsi
movq 0x10(%rsi), %r15
leaq (%r12,%rbx), %rdi
addq $0x18, %rsi
movq %r15, %rdx
callq 0xb520
addq %rbx, %r15
decl %r13d
addq $0x10, %rbp
cmpl $0x1, %r13d
jg 0x59d7b
movq 0x20(%rsp), %rax
shlq $0x4, %rax
movq 0x28(%rsp), %r13
subq %rax, %r13
movq 0x18(%rsp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x583e8
movq %rax, (%r13)
movl $0x4, 0x8(%r13)
decl %r14d
jmp 0x59e36
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r12, %rcx
movl $0xf, %r8d
callq 0x5fa80
movl $0x1, %r14d
testl %eax, %eax
jne 0x59e3b
movl -0x8(%r15), %eax
addl $-0x3, %eax
cmpl $0x2, %eax
cmovbq %r15, %r12
movq %rbx, %rdi
movq %r12, %rsi
leaq 0x945eb(%rip), %rdx     # 0xee402
callq 0x5f08c
jmp 0x59e3b
movl $0x1, %r14d
cmpl $0x4, -0x8(%r15)
je 0x59e36
movq %rbx, %rdi
movq %r12, %rsi
callq 0x580b3
movl 0xc(%rsp), %r13d
movq 0x10(%rsp), %rsi
subl %r14d, %esi
subl %r14d, %r13d
cmpl $0x1, %esi
jg 0x59c78
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x94586(%rip), %rsi     # 0xee3eb
movq %rbx, %rdi
xorl %eax, %eax
callq 0x57b1c