// File: /workspace/github_c_makefile_star2_O0/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:
subq $0x68, %rsp
movq %rdi, 0x60(%rsp)
movq %rsi, 0x58(%rsp)
movq %rdx, 0x50(%rsp)
movq %rcx, 0x48(%rsp)
movl $0x0, 0x44(%rsp)
cmpl $0x64, 0x44(%rsp)
jge 0x27a51
movq 0x58(%rsp), %rax
cmpl $0x45, 0x8(%rax)
jne 0x279cd
movq 0x58(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x30(%rsp)
movq 0x30(%rsp), %rdi
movq 0x50(%rsp), %rsi
callq 0x25270
movq %rax, 0x28(%rsp)
movq 0x28(%rsp), %rax
cmpl $0x0, 0x8(%rax)
jne 0x27945
movq 0x30(%rsp), %rax
cmpq $0x0, 0x10(%rax)
jne 0x278af
xorl %eax, %eax
movq %rax, 0x10(%rsp)
jmp 0x278ff
movq 0x30(%rsp), %rax
movq 0x10(%rax), %rax
movzbl 0xa(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x278cd
xorl %eax, %eax
movq %rax, 0x8(%rsp)
jmp 0x278f5
movq 0x30(%rsp), %rax
movq 0x10(%rax), %rdi
movq 0x60(%rsp), %rax
movq 0x18(%rax), %rax
movq 0x128(%rax), %rdx
movl $0x1, %esi
callq 0x264d0
movq %rax, 0x8(%rsp)
movq 0x8(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x10(%rsp), %rax
movq %rax, 0x38(%rsp)
cmpq $0x0, %rax
jne 0x279cb
leaq 0xe976(%rip), %rax      # 0x36290
cmpq %rax, 0x28(%rsp)
jne 0x27945
movq 0x60(%rsp), %rdi
movq 0x30(%rsp), %rsi
movq 0x50(%rsp), %rdx
callq 0x24a80
movq %rax, 0x28(%rsp)
movb $0x1, %al
testb $0x1, %al
jne 0x27945
jmp 0x279cb
movq 0x48(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x28(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0x18(%rsp), %rax
movq 0x20(%rsp), %rcx
movq (%rcx), %rcx
movq %rcx, (%rax)
movq 0x20(%rsp), %rax
movl 0x8(%rax), %ecx
movq 0x18(%rsp), %rax
movl %ecx, 0x8(%rax)
movq 0x30(%rsp), %rax
movb $0x0, 0xa(%rax)
movq 0x48(%rsp), %rax
movl 0x8(%rax), %eax
andl $0x40, %eax
cmpl $0x0, %eax
je 0x279c6
movq 0x48(%rsp), %rax
movq (%rax), %rax
movzbl 0x9(%rax), %eax
andl $0x3, %eax
cmpl $0x0, %eax
je 0x279c6
movq 0x30(%rsp), %rax
movzbl 0x9(%rax), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x279c6
movq 0x60(%rsp), %rdi
movq 0x30(%rsp), %rsi
callq 0x12d70
jmp 0x27a64
jmp 0x27a04
movq 0x60(%rsp), %rdi
movq 0x58(%rsp), %rsi
movl $0x1, %edx
callq 0x26540
movq %rax, 0x38(%rsp)
cmpl $0x0, 0x8(%rax)
jne 0x27a02
movq 0x60(%rsp), %rdi
movq 0x58(%rsp), %rsi
leaq 0xf243(%rip), %rdx      # 0x36c40
callq 0xee00
jmp 0x27a04
movq 0x38(%rsp), %rax
movl 0x8(%rax), %eax
andl $0xf, %eax
cmpl $0x6, %eax
jne 0x27a37
movq 0x60(%rsp), %rdi
movq 0x38(%rsp), %rsi
movq 0x58(%rsp), %rdx
movq 0x50(%rsp), %rcx
movq 0x48(%rsp), %r8
xorl %r9d, %r9d
callq 0x27620
jmp 0x27a64
movq 0x38(%rsp), %rax
movq %rax, 0x58(%rsp)
movl 0x44(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x44(%rsp)
jmp 0x27850
movq 0x60(%rsp), %rdi
leaq 0xf760(%rip), %rsi      # 0x371bd
movb $0x0, %al
callq 0xf360
addq $0x68, %rsp
retq
nopl (%rax)