// File: /workspace/github_c_makefile_star2_O3/tylerneylon[P]APIsWithLua/lua/ldebug.c
// Function: getobjname
static const char *getobjname (Proto *p, int lastpc, int reg,
                               const char **name) {
  int pc;
  *name = luaF_getlocalname(p, reg + 1, lastpc);
  if (*name)  /* is a local? */
    return "local";
  /* else try symbolic execution */
  pc = findsetreg(p, lastpc, reg);
  if (pc != -1) {  /* could find instruction? */
    Instruction i = p->code[pc];
    OpCode op = GET_OPCODE(i);
    switch (op) {
      case OP_MOVE: {
        int b = GETARG_B(i);  /* move from 'b' to 'a' */
        if (b < GETARG_A(i))
          return getobjname(p, pc, b, name);  /* get name for 'b' */
        break;
      }
      case OP_GETTABUP:
      case OP_GETTABLE: {
        int k = GETARG_C(i);  /* key index */
        int t = GETARG_B(i);  /* table index */
        const char *vn = (op == OP_GETTABLE)  /* name of indexed variable */
                         ? luaF_getlocalname(p, t + 1, pc)
                         : upvalname(p, t);
        kname(p, pc, k, name);
        return (vn && strcmp(vn, LUA_ENV) == 0) ? "global" : "field";
      }
      case OP_GETUPVAL: {
        *name = upvalname(p, GETARG_B(i));
        return "upvalue";
      }
      case OP_LOADK:
      case OP_LOADKX: {
        int b = (op == OP_LOADK) ? GETARG_Bx(i)
                                 : GETARG_Ax(p->code[pc + 1]);
        if (ttisstring(&p->k[b])) {
          *name = svalue(&p->k[b]);
          return "constant";
        }
        break;
      }
      case OP_SELF: {
        int k = GETARG_C(i);  /* key index */
        kname(p, pc, k, name);
        return "method";
      }
      default: break;  /* go through to return NULL */
    }
  }
  return NULL;  /* could not find reasonable name */
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %rbx
movl %edx, %r12d
movl %esi, %ebp
movq %rdi, %r14
xorl %r15d, %r15d
leaq 0x1a623(%rip), %r13     # 0x228e0
leal 0x1(%r12), %esi
movq %r14, %rdi
movl %ebp, %edx
callq 0xa0ff
movq %rax, (%rbx)
testq %rax, %rax
jne 0x842c
movl %ebp, %ecx
testl %ecx, %ecx
jle 0x850d
movq 0x38(%r14), %rax
xorl %edx, %edx
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
xorl %esi, %esi
movl (%rax,%rdx,4), %r8d
movl %r8d, %r9d
andl $0x3f, %r9d
movl %r8d, %edi
shrl $0x6, %edi
movzbl %dil, %edi
cmpl $0x23, %r9d
jle 0x8324
leal -0x24(%r9), %r8d
cmpl $0x2, %r8d
jb 0x831d
cmpl $0x29, %r9d
jne 0x836d
addl $0x2, %edi
cmpl %r12d, %edi
jle 0x837c
jmp 0x838b
cmpl $0x4, %r9d
je 0x835a
cmpl $0x1e, %r9d
jne 0x836d
shrl $0xe, %r8d
leaq (%rdx,%r8), %rdi
addq $-0x1fffe, %rdi         # imm = 0xFFFE0002
movslq %edi, %rdi
cmpl %esi, %edi
movl %esi, %r8d
cmovgl %edi, %r8d
cmpq %rdi, %rdx
cmovgel %esi, %r8d
cmpl %ecx, %edi
cmovlel %r8d, %esi
jmp 0x838b
cmpl %r12d, %edi
jg 0x838b
shrl $0x17, %r8d
addl %r8d, %edi
cmpl %r12d, %edi
jae 0x837c
jmp 0x838b
cmpl %r12d, %edi
jne 0x838b
movb (%r9,%r13), %dil
andb $0x40, %dil
je 0x838b
movslq %esi, %rdi
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
cmpq %rdi, %rdx
jl 0x838b
movl %edx, %ebp
incq %rdx
cmpq %rdx, %rcx
jne 0x82ef
cmpl $-0x1, %ebp
je 0x850d
movslq %ebp, %rsi
movl (%rax,%rsi,4), %edx
movl %edx, %ecx
andl $0x3f, %ecx
jne 0x83c8
movl %edx, %r12d
shrl $0x17, %r12d
shrl $0x6, %edx
movzbl %dl, %eax
cmpl %eax, %r12d
jb 0x82bd
jmp 0x850d
leal -0x1(%rcx), %edi
cmpl $0xb, %edi
ja 0x850d
leaq 0x19ed1(%rip), %r8      # 0x222ac
movslq (%r8,%rdi,4), %rdi
addq %r8, %rdi
jmpq *%rdi
movl %edx, %r15d
shrl $0xe, %r15d
andl $0x1ff, %r15d           # imm = 0x1FF
shrl $0x17, %edx
cmpl $0x7, %ecx
jne 0x843d
incl %edx
movq %r14, %rdi
movl %edx, %esi
movl %ebp, %edx
callq 0xa0ff
movq %rax, %r12
movq %r14, %rdi
movl %ebp, %esi
movl %r15d, %edx
movq %rbx, %rcx
callq 0x851f
testq %r12, %r12
jne 0x846a
leaq 0x19f96(%rip), %r15     # 0x223bd
jmp 0x850d
leaq 0x1b908(%rip), %r15     # 0x23d3b
jmp 0x850d
shrl $0xe, %edx
jmp 0x8496
movq 0x58(%r14), %rax
shll $0x4, %edx
movq (%rax,%rdx), %rax
leaq 0x18(%rax), %rcx
testq %rax, %rax
leaq 0x19f3c(%rip), %r12     # 0x22392
cmovneq %rcx, %r12
movq %r14, %rdi
movl %ebp, %esi
movl %r15d, %edx
movq %rbx, %rcx
callq 0x851f
leaq 0x19f40(%rip), %rsi     # 0x223b1
movq %r12, %rdi
callq 0x5280
testl %eax, %eax
leaq 0x19f34(%rip), %rax     # 0x223b6
leaq 0x19f34(%rip), %r15     # 0x223bd
cmoveq %rax, %r15
jmp 0x850d
movl 0x4(%rax,%rsi,4), %edx
shrl $0x6, %edx
movq 0x30(%r14), %rax
shll $0x4, %edx
movl 0x8(%rax,%rdx), %ecx
andl $0xf, %ecx
cmpl $0x4, %ecx
jne 0x84bf
addq %rdx, %rax
movq (%rax), %rax
addq $0x18, %rax
movq %rax, (%rbx)
leaq 0x19f06(%rip), %r15     # 0x223c3
jmp 0x850d
xorl %r15d, %r15d
jmp 0x850d
shrl $0xe, %edx
andl $0x1ff, %edx            # imm = 0x1FF
movq %r14, %rdi
movl %ebp, %esi
movq %rbx, %rcx
callq 0x851f
leaq 0x19ec9(%rip), %r15     # 0x223aa
jmp 0x850d
movq 0x58(%r14), %rax
shrl $0x13, %edx
andl $-0x10, %edx
movq (%rax,%rdx), %rax
leaq 0x18(%rax), %rcx
testq %rax, %rax
leaq 0x19e93(%rip), %rax     # 0x22392
cmovneq %rcx, %rax
movq %rax, (%rbx)
leaq 0x1b843(%rip), %r15     # 0x23d50
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq