// File: /workspace/github_c_makefile_star2_O3/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
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, 0xa5d11(%rip)     # 0x116268
testl %eax, %eax
jne 0x70581
callq 0x26ab0
testl %eax, %eax
je 0x70596
cmpl $-0x1, %eax
jne 0x70655
leaq 0x5a0be(%rip), %rsi     # 0xca632
movq %rbx, %rdi
callq 0x3cc06
jmp 0x7066c
leaq 0x5a0fb(%rip), %rsi     # 0xca683
movl $0x3, %edi
xorl %eax, %eax
callq 0x2fdad
jmp 0x705f3
leaq 0x10(%rsp), %r14
movq %r14, %rdi
callq 0x26ac0
movl $0x0, 0x80(%r14)
movq $0x1, -0x8(%r14)
leaq 0x8(%rsp), %r14
movl $0xf, %edi
movq %r14, %rsi
xorl %edx, %edx
callq 0x266c0
movl $0x2, %edi
movq %r14, %rsi
xorl %edx, %edx
callq 0x266c0
leaq 0x5a083(%rip), %rsi     # 0xca663
movl $0x3, %edi
xorl %eax, %eax
callq 0x2fdad
xorl %edi, %edi
callq 0x33c2a
movl 0xa5c67(%rip), %esi     # 0x116260
xorl %edi, %edi
callq 0x2d6ab
movl 0xa5c5a(%rip), %esi     # 0x116260
movl $0x1388, %edx           # imm = 0x1388
xorl %edi, %edi
callq 0x2d8f0
movl $0x1, 0xa5c48(%rip)     # 0x116264
movq 0x40(%rbx), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rdi
callq 0x362e0
movq %rax, %rbx
movzbl -0x1(%rax), %eax
movl %eax, %ecx
andl $0x7, %ecx
cmpl $0x4, %ecx
ja 0x706b2
leaq 0x5919b(%rip), %rdx     # 0xc97e0
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
movl %eax, %ecx
shrl $0x3, %ecx
jmp 0x70688
movq 0xa5c24(%rip), %rdi     # 0x116280
movslq %eax, %rsi
callq 0x2b24b
movq %rbx, %rdi
callq 0x3db03
xorl %ebp, %ebp
jmp 0x7079b
movq -0x11(%rbx), %rcx
jmp 0x70688
movzwl -0x5(%rbx), %ecx
jmp 0x70688
movl -0x9(%rbx), %ecx
jmp 0x70688
movzbl -0x3(%rbx), %ecx
testq %rcx, %rcx
je 0x706b2
leal (,%rcx,8), %eax
movzbl -0x1(%rbx,%rcx), %edx
cmpl $0xa, %edx
je 0x706a3
cmpl $0xd, %edx
jne 0x706d7
addb $-0x8, %al
movb $0x0, -0x1(%rbx,%rcx)
decq %rcx
jne 0x70694
movb -0x1(%rbx), %al
movl %eax, %ecx
andb $0x7, %cl
cmpb $0x4, %cl
ja 0x70731
movzbl %cl, %ecx
leaq 0x59142(%rip), %rdx     # 0xc9808
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
movb $0x0, -0x1(%rbx)
xorl %esi, %esi
jmp 0x7074e
movzbl -0x1(%rbx), %edx
movl %edx, %esi
andl $0x7, %esi
cmpl $0x4, %esi
ja 0x7072f
leaq 0x59108(%rip), %rdi     # 0xc97f4
movslq (%rdi,%rsi,4), %rsi
addq %rdi, %rsi
jmpq *%rsi
movb %al, -0x1(%rbx)
jmp 0x70731
movq $0x0, -0x11(%rbx)
jmp 0x70731
movw $0x0, -0x5(%rbx)
jmp 0x70731
movl $0x0, -0x9(%rbx)
jmp 0x70731
movb $0x0, -0x3(%rbx)
jmp 0x70731
movq %rcx, -0x11(%rbx)
jmp 0x7072f
movw %cx, -0x5(%rbx)
jmp 0x7072f
movl %ecx, -0x9(%rbx)
jmp 0x7072f
movb %cl, -0x3(%rbx)
movl %edx, %eax
movzbl %al, %esi
movl %esi, %eax
andl $0x7, %eax
cmpl $0x4, %eax
ja 0x7076a
leaq 0x590d7(%rip), %rcx     # 0xc981c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
shrl $0x3, %esi
jmp 0x7076c
movq -0x11(%rbx), %rsi
jmp 0x7076c
movzwl -0x5(%rbx), %esi
jmp 0x7076c
movl -0x9(%rbx), %esi
jmp 0x7076c
movzbl -0x3(%rbx), %esi
jmp 0x7076c
xorl %esi, %esi
leaq 0x4e756(%rip), %rdx     # 0xbeec9
leaq 0xa5c26(%rip), %r8      # 0x1163a0
movl $0x1, %ebp
movq %rbx, %rdi
movl $0x1, %ecx
callq 0x37a38
movq %rax, 0xa5c05(%rip)     # 0x116398
movq %rbx, %rdi
callq 0x36330
movl %ebp, %eax
addq $0xa0, %rsp
popq %rbx
popq %r14
popq %rbp
retq