// File: /workspace/github_c_makefile_star2_O2/bhk[P]tooltree/lua/../opensource/lua-5.2.3/src/lvm.c
// Function: luaV_settable
void luaV_settable (lua_State *L, const TValue *t, TValue *key, StkId val) {
  int loop;
  for (loop = 0; loop < MAXTAGLOOP; loop++) {
    const TValue *tm;
    if (ttistable(t)) {  /* `t' is a table? */
      Table *h = hvalue(t);
      TValue *oldval = cast(TValue *, luaH_get(h, key));
      /* if previous value is not nil, there must be a previous entry
         in the table; moreover, a metamethod has no relevance */
      if (!ttisnil(oldval) ||
         /* previous value is nil; must check the metamethod */
         ((tm = fasttm(L, h->metatable, TM_NEWINDEX)) == NULL &&
         /* no metamethod; is there a previous entry in the table? */
         (oldval != luaO_nilobject ||
         /* no previous entry; must create one. (The next test is
            always true; we only need the assignment.) */
         (oldval = luaH_newkey(L, h, key), 1)))) {
        /* no metamethod and (now) there is an entry with given key */
        setobj2t(L, oldval, val);  /* assign new value to that entry */
        invalidateTMcache(h);
        luaC_barrierback(L, obj2gco(h), val);
        return;
      }
      /* else will try the metamethod */
    }
    else  /* not a table; check metamethod */
      if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_NEWINDEX)))
        luaG_typeerror(L, t, "index");
    /* there is a metamethod */
    if (ttisfunction(tm)) {
      callTM(L, tm, t, key, val, 0);
      return;
    }
    t = tm;  /* else repeat with 'tm' */
  }
  luaG_runerror(L, "loop in settable");
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, (%rsp)
movq %rdx, %r15
movq %rsi, %rax
movq %rdi, %rbx
pushq $0x65
popq %rbp
decl %ebp
je 0x172dc
movq %rax, %r12
cmpl $0x45, 0x8(%rax)
jne 0x17226
movq (%r12), %r13
movq %r13, %rdi
movq %r15, %rsi
callq 0x15f09
movq %rax, %r14
cmpl $0x0, 0x8(%rax)
jne 0x1728a
movq 0x10(%r13), %rdi
testq %rdi, %rdi
je 0x1726d
testb $0x2, 0xa(%rdi)
jne 0x1726d
movq 0x18(%rbx), %rax
movq 0x128(%rax), %rdx
pushq $0x1
popq %rsi
callq 0x1694f
testq %rax, %rax
je 0x1726d
movl 0x8(%rax), %ecx
jmp 0x1723f
movq %rbx, %rdi
movq %r12, %rsi
pushq $0x1
popq %rdx
callq 0x16978
movl 0x8(%rax), %ecx
testl %ecx, %ecx
je 0x172ed
andl $0xf, %ecx
cmpl $0x6, %ecx
jne 0x171cd
movq %rbx, %rdi
movq %rax, %rsi
movq %r12, %rdx
movq %r15, %rcx
movq (%rsp), %r8
xorl %r9d, %r9d
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x170ee
leaq 0x7d2c(%rip), %rax      # 0x1efa0
cmpq %rax, %r14
jne 0x1728a
movq %rbx, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x15ad4
movq %rax, %r14
movq (%rsp), %rcx
movq (%rcx), %rax
movq %rax, (%r14)
movl 0x8(%rcx), %eax
movl %eax, 0x8(%r14)
movb $0x0, 0xa(%r13)
testb $0x40, %al
je 0x172b4
movq (%rcx), %rax
testb $0x3, 0x9(%rax)
je 0x172b4
testb $0x4, 0x9(%r13)
jne 0x172c3
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
movq %r13, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xc1db
leaq 0x8bee(%rip), %rsi      # 0x1fed1
movq %rbx, %rdi
xorl %eax, %eax
callq 0xaa89
leaq 0x866c(%rip), %rdx      # 0x1f960
movq %rbx, %rdi
movq %r12, %rsi
callq 0xa6bd