// File: /workspace/github_c_makefile_star2_O1/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 $0x58, %rsp
movl %esi, %r15d
movq %rdi, %rbx
movabsq $0x7fffffffffffffff, %r12 # imm = 0x7FFFFFFFFFFFFFFF
movq %rdi, 0x10(%rsp)
movl %r15d, %r15d
movq 0x10(%rbx), %r14
leaq -0x20(%r14), %rbp
movl -0x18(%r14), %eax
andl $0xf, %eax
addl $-0x3, %eax
cmpl $0x1, %eax
ja 0x11841
leaq -0x10(%r14), %r13
movl -0x8(%r14), %eax
andl $0xf, %eax
cmpl $0x4, %eax
je 0x11801
cmpl $0x3, %eax
jne 0x11841
movq %rbx, %rdi
movq %r13, %rsi
callq 0xbabd
cmpl $0x44, -0x8(%r14)
jne 0x11816
movq (%r13), %rax
cmpb $0x0, 0xb(%rax)
je 0x119ff
cmpl $0x44, -0x18(%r14)
jne 0x1182b
movq (%rbp), %rax
cmpb $0x0, 0xb(%rax)
je 0x11a1e
movq (%r13), %rax
cmpb $0x4, 0x8(%rax)
movq %r14, 0x8(%rsp)
jne 0x11867
movzbl 0xb(%rax), %r13d
jmp 0x1186b
addq $-0x10, %r14
movq %rbx, %rdi
movq %rbp, %rsi
movq %r14, %rdx
movq %rbp, %rcx
movl $0x16, %r8d
callq 0x104cb
movl $0x1, %r14d
jmp 0x119e5
movq 0x10(%rax), %r13
movl $0x1, %r14d
cmpl $0x2, %r15d
jl 0x118cd
movl $0x1, %r14d
movl 0x8(%rbp), %eax
andl $0xf, %eax
cmpl $0x4, %eax
je 0x11898
cmpl $0x3, %eax
jne 0x118cd
movq %rbx, %rdi
movq %rbp, %rsi
callq 0xbabd
movq (%rbp), %rax
cmpb $0x4, 0x8(%rax)
jne 0x118a8
movzbl 0xb(%rax), %eax
jmp 0x118ac
movq 0x10(%rax), %rax
movq %r13, %rcx
xorq %r12, %rcx
cmpq %rcx, %rax
jae 0x11a3b
addq %rax, %r13
incq %r14
addq $-0x10, %rbp
cmpq %r14, %r15
jne 0x1187d
movl %r15d, %r14d
movq %r15, 0x18(%rsp)
movl %r14d, %r15d
cmpq $0x28, %r13
movq %r15, 0x28(%rsp)
ja 0x1194a
leaq 0x1(%r15), %rbx
movq %r15, %rax
shlq $0x4, %rax
movq 0x8(%rsp), %r12
subq %rax, %r12
xorl %r15d, %r15d
movq (%r12), %rsi
cmpb $0x4, 0x8(%rsi)
jne 0x11906
movzbl 0xb(%rsi), %ebp
jmp 0x1190a
movq 0x10(%rsi), %rbp
leaq (%rsp,%r15), %rdi
addq $0x30, %rdi
addq $0x18, %rsi
movq %rbp, %rdx
callq 0x5320
addq %rbp, %r15
decq %rbx
addq $0x10, %r12
cmpq $0x1, %rbx
jg 0x118f6
movq 0x10(%rsp), %rbx
movq %rbx, %rdi
leaq 0x30(%rsp), %rsi
movq %r13, %rdx
callq 0xf2f1
movq 0x18(%rsp), %r15
jmp 0x119ba
movq %rbx, %rdi
movq %r13, %rsi
callq 0xf4c4
movq %rax, %r13
movq %rax, 0x20(%rsp)
addq $0x18, %r13
leaq 0x1(%r15), %rbx
movq %r15, %rax
shlq $0x4, %rax
movq 0x8(%rsp), %r12
subq %rax, %r12
xorl %r15d, %r15d
movq (%r12), %rsi
cmpb $0x4, 0x8(%rsi)
jne 0x11987
movzbl 0xb(%rsi), %ebp
jmp 0x1198b
movq 0x10(%rsi), %rbp
leaq (%r15,%r13), %rdi
addq $0x18, %rsi
movq %rbp, %rdx
callq 0x5320
addq %rbp, %r15
decq %rbx
addq $0x10, %r12
cmpq $0x1, %rbx
jg 0x11977
movq 0x10(%rsp), %rbx
movq 0x18(%rsp), %r15
movq 0x20(%rsp), %rax
movq 0x28(%rsp), %rdx
shlq $0x4, %rdx
movq 0x8(%rsp), %rcx
subq %rdx, %rcx
movq %rax, (%rcx)
movzbl 0x8(%rax), %eax
orl $0x40, %eax
movl %eax, 0x8(%rcx)
decl %r14d
movabsq $0x7fffffffffffffff, %r12 # imm = 0x7FFFFFFFFFFFFFFF
subl %r14d, %r15d
movslq %r14d, %rax
shlq $0x4, %rax
subq %rax, 0x10(%rbx)
cmpl $0x1, %r15d
jg 0x117c7
jmp 0x11a2c
movl -0x18(%r14), %eax
andl $0xf, %eax
movl $0x1, %r14d
cmpl $0x3, %eax
jne 0x119e5
movq %rbx, %rdi
movq %rbp, %rsi
callq 0xbabd
jmp 0x119e5
movups (%r13), %xmm0
movups %xmm0, (%rbp)
jmp 0x1185c
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x106b5(%rip), %rsi     # 0x220f7
movq %rbx, %rdi
xorl %eax, %eax
callq 0x7cd8