// File: /workspace/github_c_makefile_star2_O1/zhou-yuxin[P]redis-aof-no-cow/src/scripting.c
// Function: scriptingEnableGlobalsProtection
void scriptingEnableGlobalsProtection(lua_State *lua) {
    char *s[32];
    sds code = sdsempty();
    int j = 0;

    /* strict.lua from: http://metalua.luaforge.net/src/lib/strict.lua.html.
     * Modified to be adapted to Redis. */
    s[j++]="local dbg=debug\n";
    s[j++]="local mt = {}\n";
    s[j++]="setmetatable(_G, mt)\n";
    s[j++]="mt.__newindex = function (t, n, v)\n";
    s[j++]="  if dbg.getinfo(2) then\n";
    s[j++]="    local w = dbg.getinfo(2, \"S\").what\n";
    s[j++]="    if w ~= \"main\" and w ~= \"C\" then\n";
    s[j++]="      error(\"Script attempted to create global variable '\"..tostring(n)..\"'\", 2)\n";
    s[j++]="    end\n";
    s[j++]="  end\n";
    s[j++]="  rawset(t, n, v)\n";
    s[j++]="end\n";
    s[j++]="mt.__index = function (t, n)\n";
    s[j++]="  if dbg.getinfo(2) and dbg.getinfo(2, \"S\").what ~= \"C\" then\n";
    s[j++]="    error(\"Script attempted to access unexisting global variable '\"..tostring(n)..\"'\", 2)\n";
    s[j++]="  end\n";
    s[j++]="  return rawget(t, n)\n";
    s[j++]="end\n";
    s[j++]="debug = nil\n";
    s[j++]=NULL;

    for (j = 0; s[j] != NULL; j++) code = sdscatlen(code,s[j],strlen(s[j]));
    luaL_loadbuffer(lua,code,sdslen(code),"@enable_strict_lua");
    lua_pcall(lua,0,0,0);
    sdsfree(code);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movq %rdi, %rbx
callq 0x39222
movq %rax, %r14
leaq 0x5a6a8(%rip), %rax     # 0xccd15
movq %rax, (%rsp)
leaq 0x5a6ae(%rip), %rax     # 0xccd26
movq %rax, 0x8(%rsp)
leaq 0x5a6b1(%rip), %rax     # 0xccd35
movq %rax, 0x10(%rsp)
leaq 0x5a6bb(%rip), %rax     # 0xccd4b
movq %rax, 0x18(%rsp)
leaq 0x5a6d3(%rip), %rax     # 0xccd6f
movq %rax, 0x20(%rsp)
leaq 0x5a6e1(%rip), %rax     # 0xccd89
movq %rax, 0x28(%rsp)
leaq 0x5a6fd(%rip), %rax     # 0xccdb1
movq %rax, 0x30(%rsp)
leaq 0x5a717(%rip), %rax     # 0xccdd7
movq %rax, 0x38(%rsp)
leaq 0x5a75d(%rip), %rax     # 0xcce29
movq %rax, 0x40(%rsp)
leaq 0x5a753(%rip), %rax     # 0xcce2b
movq %rax, 0x48(%rsp)
leaq 0x5a74e(%rip), %rcx     # 0xcce32
movq %rcx, 0x50(%rsp)
leaq 0x5a95d(%rip), %rcx     # 0xcd04d
movq %rcx, 0x58(%rsp)
leaq 0x5a749(%rip), %rdx     # 0xcce45
movq %rdx, 0x60(%rsp)
leaq 0x5a75b(%rip), %rdx     # 0xcce63
movq %rdx, 0x68(%rsp)
leaq 0x5a78d(%rip), %rdx     # 0xccea1
movq %rdx, 0x70(%rsp)
movq %rax, 0x78(%rsp)
leaq 0x5a7d7(%rip), %rax     # 0xccefc
movq %rax, 0x80(%rsp)
movq %rcx, 0x88(%rsp)
leaq 0x5a7d7(%rip), %rax     # 0xccf13
movq %rax, 0x90(%rsp)
movq $0x0, 0x98(%rsp)
movq (%rsp), %r15
testq %r15, %r15
je 0x72784
leaq 0x8(%rsp), %r12
movq %r15, %rdi
callq 0x26510
movq %r14, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x39a56
movq %rax, %r14
movq (%r12), %r15
addq $0x8, %r12
testq %r15, %r15
jne 0x7275e
movzbl -0x1(%r14), %edx
movl %edx, %eax
andl $0x7, %eax
cmpl $0x4, %eax
ja 0x727c2
leaq 0x59f0e(%rip), %rcx     # 0xcc6a8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
shrl $0x3, %edx
jmp 0x727c4
movq -0x11(%r14), %rdx
jmp 0x727c4
movzwl -0x5(%r14), %edx
jmp 0x727c4
movl -0x9(%r14), %edx
jmp 0x727c4
movzbl -0x3(%r14), %edx
jmp 0x727c4
xorl %edx, %edx
leaq 0x5a755(%rip), %rcx     # 0xccf20
movq %rbx, %rdi
movq %r14, %rsi
callq 0x9558c
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x8a6ac
movq %r14, %rdi
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x392b6