// File: /workspace/github_c_makefile_star2_O2/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
subq $0x18, %rsp
movq %rcx, 0x10(%rsp)
movl %edx, %r12d
movl %esi, %r13d
movq %rdi, %r14
pushq $-0x1
popq %r15
movq $0x0, 0x8(%rsp)
leaq 0x17ad4(%rip), %rbx     # 0x1f900
leal 0x1(%r12), %esi
movq %r14, %rdi
movl %r13d, %edx
callq 0x96f1
movq 0x10(%rsp), %rcx
movq %rax, (%rcx)
testq %rax, %rax
jne 0x7f7b
xorl %eax, %eax
testl %r13d, %r13d
movl $0x0, %ecx
cmovgl %r13d, %ecx
xorl %edx, %edx
movl %r15d, %ebp
cmpq %rax, %rcx
je 0x7f03
movq 0x38(%r14), %rsi
movl (%rsi,%rax,4), %edi
movl %edi, %r9d
andl $0x3f, %r9d
movl %edi, %esi
shrl $0x6, %esi
movzbl %sil, %r8d
leal -0x24(%r9), %r10d
movslq %edx, %rsi
cmpl $0x2, %r10d
jb 0x7edb
cmpl $0x29, %r9d
je 0x7ed7
cmpl $0x1e, %r9d
je 0x7eb1
cmpl $0x4, %r9d
jne 0x7ee2
cmpl %r12d, %r8d
jg 0x7efb
shrl $0x17, %edi
addl %edi, %r8d
cmpl %r12d, %r8d
jae 0x7ef1
jmp 0x7efb
shrl $0xe, %edi
leaq (%rax,%rdi), %rsi
addq $-0x1fffe, %rsi         # imm = 0xFFFE0002
movslq %esi, %rsi
cmpl %edx, %esi
movl %edx, %edi
cmovgl %esi, %edi
cmpq %rsi, %rax
cmovgel %edx, %edi
cmpl %r13d, %esi
cmovlel %edi, %edx
jmp 0x7efb
addl $0x2, %r8d
cmpl %r12d, %r8d
jle 0x7ef1
jmp 0x7efb
cmpl %r12d, %r8d
jne 0x7efb
movb (%r9,%rbx), %dil
andb $0x40, %dil
je 0x7efb
movl %r15d, %ebp
cmpq %rsi, %rax
jl 0x7efb
movl %eax, %ebp
incq %rax
jmp 0x7e60
cmpl $-0x1, %ebp
je 0x808f
movq 0x38(%r14), %rcx
movslq %ebp, %rsi
movl (%rcx,%rsi,4), %edx
movl %edx, %eax
andl $0x3f, %eax
cmpl $0xc, %eax
ja 0x808f
leaq 0x17361(%rip), %r8      # 0x1f28c
movslq (%r8,%rax,4), %rdi
addq %r8, %rdi
jmpq *%rdi
movl %edx, %r12d
shrl $0x17, %r12d
shrl $0x6, %edx
movzbl %dl, %eax
movl %ebp, %r13d
cmpl %eax, %r12d
jb 0x7e2c
jmp 0x808f
movl %edx, %r15d
shrl $0xe, %r15d
andl $0x1ff, %r15d           # imm = 0x1FF
shrl $0x17, %edx
cmpl $0x7, %eax
jne 0x7f87
incl %edx
movq %r14, %rdi
movl %edx, %esi
movl %ebp, %edx
callq 0x96f1
movq %rax, %r12
jmp 0x7fa4
leaq 0x18e49(%rip), %rax     # 0x20dcb
jmp 0x808a
movq 0x58(%r14), %rax
shll $0x4, %edx
movq (%rax,%rdx), %rax
leaq 0x18(%rax), %rcx
testq %rax, %rax
leaq 0x173d6(%rip), %r12     # 0x1f376
cmovneq %rcx, %r12
movq %r14, %rdi
movl %ebp, %esi
movl %r15d, %edx
movq 0x10(%rsp), %rcx
callq 0x80a3
testq %r12, %r12
je 0x8083
leaq 0x173cf(%rip), %rsi     # 0x1f395
movq %r12, %rdi
callq 0x5270
testl %eax, %eax
leaq 0x173c3(%rip), %rax     # 0x1f39a
leaq 0x173c3(%rip), %rcx     # 0x1f3a1
cmoveq %rax, %rcx
movq %rcx, 0x8(%rsp)
jmp 0x808f
movl 0x4(%rcx,%rsi,4), %edx
shrl $0x6, %edx
jmp 0x8029
movq 0x58(%r14), %rax
shrl $0x13, %edx
andl $-0x10, %edx
movq (%rax,%rdx), %rax
leaq 0x18(%rax), %rcx
testq %rax, %rax
leaq 0x17365(%rip), %rax     # 0x1f376
cmovneq %rcx, %rax
movq 0x10(%rsp), %rcx
movq %rax, (%rcx)
leaq 0x18dbc(%rip), %rax     # 0x20de0
jmp 0x808a
shrl $0xe, %edx
movq 0x30(%r14), %rax
shll $0x4, %edx
movl 0x8(%rax,%rdx), %ecx
andl $0xf, %ecx
cmpl $0x4, %ecx
jne 0x8057
addq %rdx, %rax
movq (%rax), %rax
addq $0x18, %rax
movq 0x10(%rsp), %rcx
movq %rax, (%rcx)
leaq 0x17352(%rip), %rax     # 0x1f3a7
jmp 0x808a
movq $0x0, 0x8(%rsp)
jmp 0x808f
shrl $0xe, %edx
andl $0x1ff, %edx            # imm = 0x1FF
movq %r14, %rdi
movl %ebp, %esi
movq 0x10(%rsp), %rcx
callq 0x80a3
leaq 0x1730d(%rip), %rax     # 0x1f38e
jmp 0x808a
leaq 0x17317(%rip), %rax     # 0x1f3a1
movq %rax, 0x8(%rsp)
movq 0x8(%rsp), %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq