// File: /workspace/github_c_makefile_star2_O2/tylerneylon[P]APIsWithLua/lua/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) || cvt2str(top-2)) || !tostring(L, top-1))
      luaT_trybinTM(L, top-2, top-1, top-2, TM_CONCAT);
    else if (isemptystr(top - 1))  /* second operand is empty? */
      cast_void(tostring(L, top - 2));  /* result is first operand */
    else if (isemptystr(top - 2)) {  /* first operand is an empty string? */
      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 = vslen(top - 1);
      TString *ts;
      /* collect total length and number of strings */
      for (n = 1; n < total && tostring(L, top - n - 1); n++) {
        size_t l = vslen(top - n - 1);
        if (l >= (MAX_SIZE/sizeof(char)) - tl)
          luaG_runerror(L, "string length overflow");
        tl += l;
      }
      if (tl <= LUAI_MAXSHORTLEN) {  /* is result a short string? */
        char buff[LUAI_MAXSHORTLEN];
        copy2buff(top, n, buff);  /* copy strings to buffer */
        ts = luaS_newlstr(L, buff, tl);
      }
      else {  /* long string; copy strings directly to final result */
        ts = luaS_createlngstrobj(L, tl);
        copy2buff(top, n, getstr(ts));
      }
      setsvalue2s(L, top - n, ts);  /* create result */
    }
    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 $0x38, %rsp
movl %esi, %ebp
movq %rdi, %rbx
movq 0x10(%rdi), %r12
pushq $0x1
popq %r15
movq %rdi, (%rsp)
leaq -0x20(%r12), %r13
movl -0x18(%r12), %eax
andl $0xf, %eax
addl $-0x3, %eax
cmpl $0x1, %eax
ja 0x10762
leaq -0x10(%r12), %r14
movl -0x8(%r12), %eax
movl %eax, %ecx
andl $0xf, %ecx
cmpl $0x4, %ecx
je 0x10731
cmpl $0x3, %ecx
jne 0x10762
movq %rbx, %rdi
movq %r14, %rsi
callq 0xb198
movl -0x8(%r12), %eax
cmpl $0x44, %eax
jne 0x10783
movq -0x10(%r12), %rax
cmpb $0x0, 0xb(%rax)
movl -0x18(%r12), %eax
jne 0x10788
andl $0xf, %eax
movl %r15d, %r14d
cmpl $0x3, %eax
jne 0x10895
movq %rbx, %rdi
movq %r13, %rsi
callq 0xb198
jmp 0x1077b
addq $-0x10, %r12
movq %rbx, %rdi
movq %r13, %rsi
movq %r12, %rdx
movq %r13, %rcx
pushq $0x16
popq %r8
callq 0xf674
movl %r15d, %r14d
jmp 0x10895
movl -0x18(%r12), %eax
cmpl $0x44, %eax
jne 0x1079b
movq (%r13), %rax
cmpb $0x0, 0xb(%rax)
je 0x108b5
movq (%r14), %rax
cmpb $0x4, 0x8(%rax)
jne 0x107ab
movzbl 0xb(%rax), %r15d
jmp 0x107af
movq 0x10(%rax), %r15
movslq %ebp, %rbx
cmpl $0x2, %ebx
pushq $0x1
popq %r14
movl %ebp, 0xc(%rsp)
cmovgel %ebp, %r14d
pushq $0x1
popq %rbp
cmpq %rbx, %rbp
jge 0x10822
movl 0x8(%r13), %eax
andl $0xf, %eax
cmpl $0x4, %eax
je 0x107e6
cmpl $0x3, %eax
jne 0x1081f
movq (%rsp), %rdi
movq %r13, %rsi
callq 0xb198
movq (%r13), %rax
cmpb $0x4, 0x8(%rax)
jne 0x107f6
movzbl 0xb(%rax), %eax
jmp 0x107fa
movq 0x10(%rax), %rax
movq %r15, %rcx
movabsq $0x7fffffffffffffff, %rdx # imm = 0x7FFFFFFFFFFFFFFF
xorq %rdx, %rcx
cmpq %rcx, %rax
jae 0x108d2
addq %rax, %r15
incq %rbp
addq $-0x10, %r13
jmp 0x107c4
movl %ebp, %r14d
cmpq $0x28, %r15
movq (%rsp), %rbx
movl 0xc(%rsp), %ebp
ja 0x10856
movq %r12, %rdi
movl %r14d, %esi
leaq 0x10(%rsp), %r13
movq %r13, %rdx
callq 0x108e4
movq %rbx, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0xe658
movq %rax, %r15
jmp 0x10873
movq %rbx, %rdi
movq %r15, %rsi
callq 0xe7ab
movq %rax, %r15
leaq 0x18(%rax), %rdx
movq %r12, %rdi
movl %r14d, %esi
callq 0x108e4
movl %r14d, %eax
shlq $0x4, %rax
subq %rax, %r12
movq %r15, (%r12)
movzbl 0x8(%r15), %eax
orl $0x40, %eax
movl %eax, 0x8(%r12)
decl %r14d
pushq $0x1
popq %r15
subl %r14d, %ebp
movq 0x10(%rbx), %r12
movslq %r14d, %rax
shlq $0x4, %rax
subq %rax, %r12
movq %r12, 0x10(%rbx)
cmpl $0x1, %ebp
jg 0x106f3
jmp 0x108c3
movups (%r14), %xmm0
movups %xmm0, (%r13)
jmp 0x1077b
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xf8ea(%rip), %rsi      # 0x201c3
movq (%rsp), %rdi
xorl %eax, %eax
callq 0x7930