// File: /workspace/github_c_makefile_star2_O3/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
movq 0x10(%rdi), %r14
movabsq $0x7fffffffffffffff, %r12 # imm = 0x7FFFFFFFFFFFFFFF
movq %rdi, 0x10(%rsp)
movl %r15d, %r15d
leaq -0x20(%r14), %r13
movl -0x18(%r14), %eax
andl $0xf, %eax
addl $-0x3, %eax
cmpl $0x1, %eax
ja 0x1209c
leaq -0x10(%r14), %rbp
movl -0x8(%r14), %eax
movl %eax, %ecx
andl $0xf, %ecx
cmpl $0x4, %ecx
je 0x12067
cmpl $0x3, %ecx
jne 0x1209c
movq %rbx, %rdi
movq %rbp, %rsi
callq 0xbf1c
movl -0x8(%r14), %eax
cmpl $0x44, %eax
jne 0x120c2
movq -0x10(%r14), %rax
cmpb $0x0, 0xb(%rax)
movl -0x18(%r14), %eax
jne 0x120c6
andl $0xf, %eax
movl $0x1, %r14d
cmpl $0x3, %eax
jne 0x1226e
movq %rbx, %rdi
movq %r13, %rsi
callq 0xbf1c
jmp 0x1226e
addq $-0x10, %r14
movq %rbx, %rdi
movq %r13, %rsi
movq %r14, %rdx
movq %r13, %rcx
movl $0x16, %r8d
callq 0x10b3e
movl $0x1, %r14d
jmp 0x1226e
movl -0x18(%r14), %eax
cmpl $0x44, %eax
jne 0x120d9
movq (%r13), %rax
cmpb $0x0, 0xb(%rax)
je 0x12292
movq (%rbp), %rax
cmpb $0x4, 0x8(%rax)
movq %r14, 0x8(%rsp)
jne 0x120ee
movzbl 0xb(%rax), %ebp
jmp 0x120f2
movq 0x10(%rax), %rbp
movl $0x1, %r14d
cmpl $0x2, %r15d
jl 0x12155
movl $0x1, %r14d
movl 0x8(%r13), %eax
andl $0xf, %eax
cmpl $0x4, %eax
je 0x12120
cmpl $0x3, %eax
jne 0x12155
movq %rbx, %rdi
movq %r13, %rsi
callq 0xbf1c
movq (%r13), %rax
cmpb $0x4, 0x8(%rax)
jne 0x12130
movzbl 0xb(%rax), %eax
jmp 0x12134
movq 0x10(%rax), %rax
movq %rbp, %rcx
xorq %r12, %rcx
cmpq %rcx, %rax
jae 0x122af
addq %rax, %rbp
incq %r14
addq $-0x10, %r13
cmpq %r14, %r15
jne 0x12104
movl %r15d, %r14d
movq %r15, 0x18(%rsp)
movl %r14d, %r15d
cmpq $0x28, %rbp
movq %r15, 0x28(%rsp)
ja 0x121d3
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 0x1218f
movzbl 0xb(%rsi), %r13d
jmp 0x12193
movq 0x10(%rsi), %r13
leaq (%rsp,%r15), %rdi
addq $0x30, %rdi
addq $0x18, %rsi
movq %r13, %rdx
callq 0x5310
addq %r13, %r15
decq %rbx
addq $0x10, %r12
cmpq $0x1, %rbx
jg 0x1217e
movq 0x10(%rsp), %rbx
movq %rbx, %rdi
leaq 0x30(%rsp), %rsi
movq %rbp, %rdx
callq 0xf828
movq 0x18(%rsp), %r15
jmp 0x12243
movq %rbx, %rdi
movq %rbp, %rsi
callq 0xf9fb
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 0x12210
movzbl 0xb(%rsi), %ebp
jmp 0x12214
movq 0x10(%rsi), %rbp
leaq (%r15,%r13), %rdi
addq $0x18, %rsi
movq %rbp, %rdx
callq 0x5310
addq %rbp, %r15
decq %rbx
addq $0x10, %r12
cmpq $0x1, %rbx
jg 0x12200
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
movq 0x10(%rbx), %rcx
movslq %r14d, %rax
movq %rcx, %r14
shlq $0x4, %rax
subq %rax, %r14
movq %r14, 0x10(%rbx)
cmpl $0x1, %r15d
jg 0x1202b
jmp 0x122a0
movups (%rbp), %xmm0
movups %xmm0, (%r13)
jmp 0x120b7
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x10ed1(%rip), %rsi     # 0x23187
movq %rbx, %rdi
xorl %eax, %eax
callq 0x7dd3