// File: /workspace/github_c_makefile_star2_O3/gplessis[P]dotdeb-redis/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 0x3628d
movq %rax, %r14
leaq 0x5b1c8(%rip), %r15     # 0xc9dad
leaq 0x8(%rsp), %r12
movq %r15, -0x8(%r12)
leaq 0x5b1c8(%rip), %rax     # 0xc9dbe
movq %rax, (%r12)
leaq 0x5b1cc(%rip), %rax     # 0xc9dcd
movq %rax, 0x8(%r12)
leaq 0x5b1d6(%rip), %rax     # 0xc9de3
movq %rax, 0x10(%r12)
leaq 0x5b1ee(%rip), %rax     # 0xc9e07
movq %rax, 0x18(%r12)
leaq 0x5b1fc(%rip), %rax     # 0xc9e21
movq %rax, 0x20(%r12)
leaq 0x5b218(%rip), %rax     # 0xc9e49
movq %rax, 0x28(%r12)
leaq 0x5b232(%rip), %rax     # 0xc9e6f
movq %rax, 0x30(%r12)
leaq 0x5b278(%rip), %rax     # 0xc9ec1
movq %rax, 0x38(%r12)
leaq 0x5b26e(%rip), %rax     # 0xc9ec3
movq %rax, 0x40(%r12)
leaq 0x5b269(%rip), %rcx     # 0xc9eca
movq %rcx, 0x48(%r12)
leaq 0x5b478(%rip), %rcx     # 0xca0e5
movq %rcx, 0x50(%r12)
leaq 0x5b264(%rip), %rdx     # 0xc9edd
movq %rdx, 0x58(%r12)
leaq 0x5b276(%rip), %rdx     # 0xc9efb
movq %rdx, 0x60(%r12)
leaq 0x5b2a8(%rip), %rdx     # 0xc9f39
movq %rdx, 0x68(%r12)
movq %rax, 0x70(%r12)
leaq 0x5b2f2(%rip), %rax     # 0xc9f94
movq %rax, 0x78(%r12)
movq %rcx, 0x80(%r12)
leaq 0x5b2f5(%rip), %rax     # 0xc9fab
movq %rax, 0x88(%r12)
movq $0x0, 0x90(%r12)
movq %r15, %rdi
callq 0x26500
movq %r14, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x36ad1
movq %rax, %r14
movq (%r12), %r15
addq $0x8, %r12
testq %r15, %r15
jne 0x6ecca
movzbl -0x1(%r14), %edx
movl %edx, %eax
andl $0x7, %eax
cmpl $0x4, %eax
ja 0x6ed2e
leaq 0x5aa2a(%rip), %rcx     # 0xc9730
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
shrl $0x3, %edx
jmp 0x6ed30
movq -0x11(%r14), %rdx
jmp 0x6ed30
movzwl -0x5(%r14), %edx
jmp 0x6ed30
movl -0x9(%r14), %edx
jmp 0x6ed30
movzbl -0x3(%r14), %edx
jmp 0x6ed30
xorl %edx, %edx
leaq 0x5b281(%rip), %rcx     # 0xc9fb8
movq %rbx, %rdi
movq %r14, %rsi
callq 0x9204c
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x86bad
movq %r14, %rdi
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x36330