// File: /workspace/github_c_makefile_star2_O1/zhou-yuxin[P]redis-aof-no-cow/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
pushq %r14
pushq %rbx
subq $0xa0, %rsp
movq %rdi, %rbx
movl 0x98(%rdi), %eax
shrl $0x1a, %eax
andl $0x1, %eax
movl %eax, %ecx
xorl $0x1, %ecx
movl %ecx, 0xa7205(%rip)     # 0x11b208
testl %eax, %eax
jne 0x7402d
callq 0x26ac0
testl %eax, %eax
je 0x74042
cmpl $-0x1, %eax
jne 0x74105
leaq 0x5957a(%rip), %rsi     # 0xcd59a
movq %rbx, %rdi
callq 0x3ffcb
jmp 0x7411c
leaq 0x595b7(%rip), %rsi     # 0xcd5eb
movl $0x3, %edi
xorl %eax, %eax
callq 0x32ea6
jmp 0x7409f
leaq 0x10(%rsp), %r14
movq %r14, %rdi
callq 0x26ad0
movl $0x0, 0x80(%r14)
movq $0x1, -0x8(%r14)
leaq 0x8(%rsp), %r14
movl $0xf, %edi
movq %r14, %rsi
xorl %edx, %edx
callq 0x266d0
movl $0x2, %edi
movq %r14, %rsi
xorl %edx, %edx
callq 0x266d0
leaq 0x5953f(%rip), %rsi     # 0xcd5cb
movl $0x3, %edi
xorl %eax, %eax
callq 0x32ea6
xorl %edi, %edi
callq 0x36c98
movl 0xa715b(%rip), %esi     # 0x11b200
xorl %r14d, %r14d
xorl %edi, %edi
callq 0x30783
movl 0xa714b(%rip), %esi     # 0x11b200
movl $0x1388, %edx           # imm = 0x1388
xorl %edi, %edi
callq 0x309c8
movl $0x1, 0xa7139(%rip)     # 0x11b204
movq 0x40(%rbx), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rdi
callq 0x39266
movq %rax, %rbx
movzbl -0x1(%rax), %eax
movl %eax, %ecx
andl $0x7, %ecx
cmpl $0x4, %ecx
ja 0x7413b
leaq 0x58668(%rip), %rdx     # 0xcc75c
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
shrl $0x3, %eax
movq %rax, %r14
jmp 0x7413b
movq 0xa7114(%rip), %rdi     # 0x11b220
movslq %eax, %rsi
callq 0x2e40f
movq %rbx, %rdi
callq 0x40ebf
xorl %ebp, %ebp
jmp 0x74206
movq -0x11(%rbx), %r14
jmp 0x7413b
movzwl -0x5(%rbx), %r14d
jmp 0x7413b
movl -0x9(%rbx), %r14d
jmp 0x7413b
movzbl -0x3(%rbx), %r14d
testq %r14, %r14
je 0x7415e
movzbl -0x1(%rbx,%r14), %eax
cmpl $0xd, %eax
je 0x74150
cmpl $0xa, %eax
jne 0x7415e
movb $0x0, -0x1(%rbx,%r14)
decq %r14
jne 0x74140
xorl %r14d, %r14d
movzbl -0x1(%rbx), %eax
andl $0x7, %eax
cmpl $0x4, %eax
ja 0x7419b
leaq 0x585ff(%rip), %rcx     # 0xcc770
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
shlb $0x3, %r14b
movb %r14b, -0x1(%rbx)
jmp 0x7419b
movq %r14, -0x11(%rbx)
jmp 0x7419b
movw %r14w, -0x5(%rbx)
jmp 0x7419b
movl %r14d, -0x9(%rbx)
jmp 0x7419b
movb %r14b, -0x3(%rbx)
movzbl -0x1(%rbx), %esi
movl %esi, %eax
andl $0x7, %eax
cmpl $0x4, %eax
ja 0x741d5
leaq 0x585d4(%rip), %rcx     # 0xcc784
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
shrl $0x3, %esi
jmp 0x741d7
movq -0x11(%rbx), %rsi
jmp 0x741d7
movzwl -0x5(%rbx), %esi
jmp 0x741d7
movl -0x9(%rbx), %esi
jmp 0x741d7
movzbl -0x3(%rbx), %esi
jmp 0x741d7
xorl %esi, %esi
leaq 0x4dc79(%rip), %rdx     # 0xc1e57
leaq 0xa715b(%rip), %r8      # 0x11b340
movl $0x1, %ebp
movq %rbx, %rdi
movl $0x1, %ecx
callq 0x3a9d4
movq %rax, 0xa713a(%rip)     # 0x11b338
movq %rbx, %rdi
callq 0x392b6
movl %ebp, %eax
addq $0xa0, %rsp
popq %rbx
popq %r14
popq %rbp
retq