// File: /workspace/github_c_makefile_star2_O0/gplessis[P]dotdeb-redis/src/scripting.c
// Function: ldbStartSession
int ldbStartSession(client *c) {
    ldb.forked = (c->flags & CLIENT_LUA_DEBUG_SYNC) == 0;
    if (ldb.forked) {
        pid_t cp = fork();
        if (cp == -1) {
            addReplyError(c,"Fork() failed: can't run EVAL in debugging mode.");
            return 0;
        } else if (cp == 0) {
            /* Child. Let's ignore important signals handled by the parent. */
            struct sigaction act;
            sigemptyset(&act.sa_mask);
            act.sa_flags = 0;
            act.sa_handler = SIG_IGN;
            sigaction(SIGTERM, &act, NULL);
            sigaction(SIGINT, &act, NULL);

            /* Log the creation of the child and close the listening
             * socket to make sure if the parent crashes a reset is sent
             * to the clients. */
            serverLog(LL_WARNING,"Redis forked for debugging eval");
            closeListeningSockets(0);
        } else {
            /* Parent */
            listAddNodeTail(ldb.children,(void*)(unsigned long)cp);
            freeClientAsync(c); /* Close the client in the parent side. */
            return 0;
        }
    } else {
        serverLog(LL_WARNING,
            "Redis synchronous debugging eval session started");
    }

    /* Setup our debugging session. */
    anetBlock(NULL,ldb.fd);
    anetSendTimeout(NULL,ldb.fd,5000);
    ldb.active = 1;

    /* First argument of EVAL is the script itself. We split it into different
     * lines since this is the way the debugger accesses the source code. */
    sds srcstring = sdsdup(c->argv[1]->ptr);
    size_t srclen = sdslen(srcstring);
    while(srclen && (srcstring[srclen-1] == '\n' ||
                     srcstring[srclen-1] == '\r'))
    {
        srcstring[--srclen] = '\0';
    }
    sdssetlen(srcstring,srclen);
    ldb.src = sdssplitlen(srcstring,sdslen(srcstring),"\n",1,&ldb.lines);
    sdsfree(srcstring);
    return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movl 0x98(%rax), %eax
andl $0x4000000, %eax        # imm = 0x4000000
cmpl $0x0, %eax
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x100c19(%rip)    # 0x18cb98
cmpl $0x0, 0x100c12(%rip)    # 0x18cb98
je 0x8c04e
callq 0x26ab0
movl %eax, -0x14(%rbp)
cmpl $-0x1, -0x14(%rbp)
jne 0x8bfb6
movq -0x10(%rbp), %rdi
leaq 0xb85ad(%rip), %rsi     # 0x144552
callq 0x42f90
movl $0x0, -0x4(%rbp)
jmp 0x8c1c1
cmpl $0x0, -0x14(%rbp)
jne 0x8c025
leaq -0xb0(%rbp), %rdi
addq $0x8, %rdi
callq 0x26ac0
movl $0x0, -0x28(%rbp)
movl $0x1, %eax
movq %rax, -0xb0(%rbp)
movl $0xf, %edi
leaq -0xb0(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x266d0
movl $0x2, %edi
leaq -0xb0(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x266d0
movl $0x3, %edi
leaq 0xb856e(%rip), %rsi     # 0x144583
movb $0x0, %al
callq 0x2fc60
xorl %edi, %edi
callq 0x34f40
jmp 0x8c04a
movq 0x100b84(%rip), %rdi    # 0x18cbb0
movslq -0x14(%rbp), %rsi
callq 0x27000
movq -0x10(%rbp), %rdi
callq 0x44460
movl $0x0, -0x4(%rbp)
jmp 0x8c1c1
jmp 0x8c04c
jmp 0x8c061
movl $0x3, %edi
leaq 0xb8549(%rip), %rsi     # 0x1445a3
movb $0x0, %al
callq 0x2fc60
movl 0x100b29(%rip), %esi    # 0x18cb90
xorl %eax, %eax
movl %eax, %edi
callq 0x2b890
movl 0x100b1a(%rip), %esi    # 0x18cb90
xorl %eax, %eax
movl %eax, %edi
movl $0x1388, %edx           # imm = 0x1388
callq 0x2bc40
movl $0x1, 0x100b06(%rip)    # 0x18cb94
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rdi
callq 0x38560
movq %rax, -0xb8(%rbp)
movq -0xb8(%rbp), %rdi
callq 0x895c0
movq %rax, -0xc0(%rbp)
xorl %eax, %eax
cmpq $0x0, -0xc0(%rbp)
movb %al, -0xc1(%rbp)
je 0x8c120
movq -0xb8(%rbp), %rax
movq -0xc0(%rbp), %rcx
subq $0x1, %rcx
movsbl (%rax,%rcx), %ecx
movb $0x1, %al
cmpl $0xa, %ecx
movb %al, -0xc2(%rbp)
je 0x8c114
movq -0xb8(%rbp), %rax
movq -0xc0(%rbp), %rcx
subq $0x1, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0xd, %eax
sete %al
movb %al, -0xc2(%rbp)
movb -0xc2(%rbp), %al
movb %al, -0xc1(%rbp)
movb -0xc1(%rbp), %al
testb $0x1, %al
jne 0x8c12c
jmp 0x8c152
movq -0xb8(%rbp), %rax
movq -0xc0(%rbp), %rcx
movq %rcx, %rdx
addq $-0x1, %rdx
movq %rdx, -0xc0(%rbp)
movb $0x0, -0x1(%rax,%rcx)
jmp 0x8c0bd
movq -0xb8(%rbp), %rdi
movq -0xc0(%rbp), %rsi
callq 0x89520
movq -0xb8(%rbp), %rax
movq %rax, -0xd0(%rbp)
movq -0xb8(%rbp), %rdi
callq 0x895c0
movq -0xd0(%rbp), %rdi
movl %eax, %esi
leaq 0xadcaa(%rip), %rdx     # 0x139e39
movl $0x1, %ecx
leaq 0x1009f5(%rip), %r8     # 0x18cb90
addq $0x140, %r8             # imm = 0x140
callq 0x3a040
movq %rax, 0x100b1a(%rip)    # 0x18ccc8
movq -0xb8(%rbp), %rdi
callq 0x38620
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xd0, %rsp
popq %rbp
retq
nopl (%rax)