// File: /workspace/github_c_makefile_star2_O1/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
subq $0x18, %rsp
movq %rcx, %r15
movq %rdx, 0x10(%rsp)
movq %rsi, %r14
movq %rdi, 0x8(%rsp)
movl $0x64, %ebx
cmpl $0x45, 0x8(%r14)
jne 0x18d08
movq (%r14), %rbp
movq %rbp, %rdi
movq 0x10(%rsp), %rsi
callq 0x1750d
movq %rax, %r12
cmpl $0x0, 0x8(%rax)
je 0x18d28
movq (%r15), %rax
movq %rax, (%r12)
movl 0x8(%r15), %eax
movl %eax, 0x8(%r12)
movb $0x0, 0xa(%rbp)
testb $0x40, 0x8(%r15)
je 0x18d04
movq (%r15), %rax
testb $0x3, 0x9(%rax)
je 0x18d04
testb $0x4, 0x9(%rbp)
je 0x18d04
movq 0x8(%rsp), %rdi
movq %rbp, %rsi
callq 0xc962
xorl %eax, %eax
jmp 0x18d60
movq 0x8(%rsp), %rdi
movq %r14, %rsi
movl $0x1, %edx
callq 0x18170
movq %rax, %r13
cmpl $0x0, 0x8(%rax)
jne 0x18d64
jmp 0x18df3
movq 0x10(%rbp), %rdi
testq %rdi, %rdi
je 0x18d56
testb $0x2, 0xa(%rdi)
jne 0x18d56
movq 0x8(%rsp), %rax
movq 0x18(%rax), %rax
movq 0x128(%rax), %rdx
movl $0x1, %esi
callq 0x18145
movq %rax, %r13
jmp 0x18d59
xorl %r13d, %r13d
movb $0x1, %al
testq %r13, %r13
je 0x18da8
testb %al, %al
je 0x18d97
movl 0x8(%r13), %eax
andl $0xf, %eax
movb $0x1, %bpl
cmpl $0x6, %eax
jne 0x18d92
xorl %ebp, %ebp
movq 0x8(%rsp), %rdi
movq %r13, %rsi
movq %r14, %rdx
movq 0x10(%rsp), %rcx
movq %r15, %r8
xorl %r9d, %r9d
callq 0x18bc4
jmp 0x18d99
movq %r13, %r14
jmp 0x18d99
xorl %ebp, %ebp
testb %bpl, %bpl
je 0x18dd1
decl %ebx
jne 0x18cad
jmp 0x18de0
leaq 0x8221(%rip), %rax      # 0x20fd0
cmpq %rax, %r12
jne 0x18dc9
movq 0x8(%rsp), %rdi
movq %rbp, %rsi
movq 0x10(%rsp), %rdx
callq 0x1705d
movq %rax, %r12
xorl %r13d, %r13d
jmp 0x18ccd
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x90fa(%rip), %rsi      # 0x21ee1
movq 0x8(%rsp), %rdi
xorl %eax, %eax
callq 0xaf1a
leaq 0x8b86(%rip), %rdx      # 0x21980
movq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0xab63