// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/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 mt = {}\n";
    s[j++]="setmetatable(_G, mt)\n";
    s[j++]="mt.__newindex = function (t, n, v)\n";
    s[j++]="  if debug.getinfo(2) then\n";
    s[j++]="    local w = debug.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 debug.getinfo(2) and debug.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++]=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 %rbp
movq %rsp, %rbp
subq $0x140, %rsp            # imm = 0x140
movq %rdi, -0x8(%rbp)
callq 0x2c0c0
movq %rax, -0x118(%rbp)
movl $0x0, -0x11c(%rbp)
movl -0x11c(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x11c(%rbp)
cltq
leaq 0x73a99(%rip), %rcx     # 0xe7988
movq %rcx, -0x110(%rbp,%rax,8)
movl -0x11c(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x11c(%rbp)
cltq
leaq 0x73a86(%rip), %rcx     # 0xe7997
movq %rcx, -0x110(%rbp,%rax,8)
movl -0x11c(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x11c(%rbp)
cltq
leaq 0x73a7a(%rip), %rcx     # 0xe79ad
movq %rcx, -0x110(%rbp,%rax,8)
movl -0x11c(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x11c(%rbp)
cltq
leaq 0x73a7c(%rip), %rcx     # 0xe79d1
movq %rcx, -0x110(%rbp,%rax,8)
movl -0x11c(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x11c(%rbp)
cltq
leaq 0x73a76(%rip), %rcx     # 0xe79ed
movq %rcx, -0x110(%rbp,%rax,8)
movl -0x11c(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x11c(%rbp)
cltq
leaq 0x73a7e(%rip), %rcx     # 0xe7a17
movq %rcx, -0x110(%rbp,%rax,8)
movl -0x11c(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x11c(%rbp)
cltq
leaq 0x73a82(%rip), %rcx     # 0xe7a3d
movq %rcx, -0x110(%rbp,%rax,8)
movl -0x11c(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x11c(%rbp)
cltq
leaq 0x73ab2(%rip), %rcx     # 0xe7a8f
movq %rcx, -0x110(%rbp,%rax,8)
movl -0x11c(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x11c(%rbp)
cltq
leaq 0x73a92(%rip), %rcx     # 0xe7a91
movq %rcx, -0x110(%rbp,%rax,8)
movl -0x11c(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x11c(%rbp)
cltq
leaq 0x73a77(%rip), %rcx     # 0xe7a98
movq %rcx, -0x110(%rbp,%rax,8)
movl -0x11c(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x11c(%rbp)
cltq
leaq 0x73c19(%rip), %rcx     # 0xe7c5c
movq %rcx, -0x110(%rbp,%rax,8)
movl -0x11c(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x11c(%rbp)
cltq
leaq 0x73a46(%rip), %rcx     # 0xe7aab
movq %rcx, -0x110(%rbp,%rax,8)
movl -0x11c(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x11c(%rbp)
cltq
leaq 0x73a42(%rip), %rcx     # 0xe7ac9
movq %rcx, -0x110(%rbp,%rax,8)
movl -0x11c(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x11c(%rbp)
cltq
leaq 0x73a62(%rip), %rcx     # 0xe7b0b
movq %rcx, -0x110(%rbp,%rax,8)
movl -0x11c(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x11c(%rbp)
cltq
leaq 0x739c6(%rip), %rcx     # 0xe7a91
movq %rcx, -0x110(%rbp,%rax,8)
movl -0x11c(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x11c(%rbp)
cltq
leaq 0x73a79(%rip), %rcx     # 0xe7b66
movq %rcx, -0x110(%rbp,%rax,8)
movl -0x11c(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x11c(%rbp)
cltq
leaq 0x73b4d(%rip), %rcx     # 0xe7c5c
movq %rcx, -0x110(%rbp,%rax,8)
movl -0x11c(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x11c(%rbp)
cltq
movq $0x0, -0x110(%rbp,%rax,8)
movl $0x0, -0x11c(%rbp)
movslq -0x11c(%rbp), %rax
cmpq $0x0, -0x110(%rbp,%rax,8)
je 0x741b8
movq -0x118(%rbp), %rax
movq %rax, -0x130(%rbp)
movslq -0x11c(%rbp), %rax
movq -0x110(%rbp,%rax,8), %rax
movq %rax, -0x128(%rbp)
movslq -0x11c(%rbp), %rax
movq -0x110(%rbp,%rax,8), %rdi
callq 0x1f4d0
movq -0x130(%rbp), %rdi
movq -0x128(%rbp), %rsi
movq %rax, %rdx
callq 0x2c500
movq %rax, -0x118(%rbp)
movl -0x11c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x11c(%rbp)
jmp 0x74140
movq -0x8(%rbp), %rax
movq %rax, -0x140(%rbp)
movq -0x118(%rbp), %rax
movq %rax, -0x138(%rbp)
movq -0x118(%rbp), %rdi
callq 0x72b70
movq -0x140(%rbp), %rdi
movq -0x138(%rbp), %rsi
movq %rax, %rdx
leaq 0x73988(%rip), %rcx     # 0xe7b7d
callq 0xa0a80
movq -0x8(%rbp), %rdi
xorl %ecx, %ecx
movl %ecx, %esi
movl %ecx, %edx
callq 0x8d340
movq -0x118(%rbp), %rdi
callq 0x2c160
addq $0x140, %rsp            # imm = 0x140
popq %rbp
retq
nop