// File: /workspace/github_c_makefile_star2_O3/gplessis[P]dotdeb-redis/src/latency.c
// Function: latencyCommand
void latencyCommand(client *c) {
    struct latencyTimeSeries *ts;

    if (!strcasecmp(c->argv[1]->ptr,"history") && c->argc == 3) {
        /* LATENCY HISTORY <event> */
        ts = dictFetchValue(server.latency_events,c->argv[2]->ptr);
        if (ts == NULL) {
            addReplyMultiBulkLen(c,0);
        } else {
            latencyCommandReplyWithSamples(c,ts);
        }
    } else if (!strcasecmp(c->argv[1]->ptr,"graph") && c->argc == 3) {
        /* LATENCY GRAPH <event> */
        sds graph;
        dictEntry *de;
        char *event;

        de = dictFind(server.latency_events,c->argv[2]->ptr);
        if (de == NULL) goto nodataerr;
        ts = dictGetVal(de);
        event = dictGetKey(de);

        graph = latencyCommandGenSparkeline(event,ts);
        addReplyBulkCString(c,graph);
        sdsfree(graph);
    } else if (!strcasecmp(c->argv[1]->ptr,"latest") && c->argc == 2) {
        /* LATENCY LATEST */
        latencyCommandReplyWithLatestEvents(c);
    } else if (!strcasecmp(c->argv[1]->ptr,"doctor") && c->argc == 2) {
        /* LATENCY DOCTOR */
        sds report = createLatencyReport();

        addReplyBulkCBuffer(c,report,sdslen(report));
        sdsfree(report);
    } else if (!strcasecmp(c->argv[1]->ptr,"reset") && c->argc >= 2) {
        /* LATENCY RESET */
        if (c->argc == 2) {
            addReplyLongLong(c,latencyResetEvent(NULL));
        } else {
            int j, resets = 0;

            for (j = 2; j < c->argc; j++)
                resets += latencyResetEvent(c->argv[j]->ptr);
            addReplyLongLong(c,resets);
        }
    } else {
        addReply(c,shared.syntaxerr);
    }
    return;

nodataerr:
    /* Common error when the user asks for an event we have no latency
     * information about. */
    addReplyErrorFormat(c,
        "No samples available for event '%s'", (char*) c->argv[2]->ptr);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x40(%rdi), %r15
movq 0x8(%r15), %rax
movq 0x8(%rax), %r14
leaq 0x4f966(%rip), %rsi     # 0xcf29b
movq %r14, %rdi
callq 0x262f0
testl %eax, %eax
jne 0x7f980
cmpl $0x3, 0x38(%rbx)
jne 0x7f980
leaq 0x81f5a(%rip), %rax     # 0x1018a8
movq 0xa20(%rax), %rdi
movq 0x10(%r15), %rax
movq 0x8(%rax), %rsi
callq 0x2ef19
movq %rbx, %rdi
testq %rax, %rax
je 0x7fa9c
movq %rax, %rsi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x7f5bb
leaq 0x4f91c(%rip), %rsi     # 0xcf2a3
movq %r14, %rdi
callq 0x262f0
testl %eax, %eax
jne 0x7f9dc
cmpl $0x3, 0x38(%rbx)
jne 0x7f9dc
leaq 0x81f08(%rip), %rax     # 0x1018a8
movq 0xa20(%rax), %rdi
movq 0x10(%r15), %rax
movq 0x8(%rax), %rsi
callq 0x2ebca
testq %rax, %rax
je 0x7faad
movq (%rax), %rdi
movq 0x8(%rax), %rsi
callq 0x7f734
movq %rax, %r14
movq %rbx, %rdi
movq %rax, %rsi
callq 0x3d0f2
jmp 0x7fb37
leaq 0x4f8c6(%rip), %rsi     # 0xcf2a9
movq %r14, %rdi
callq 0x262f0
testl %eax, %eax
jne 0x7fa07
cmpl $0x2, 0x38(%rbx)
jne 0x7fa07
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x7f659
leaq 0x4f8a2(%rip), %rsi     # 0xcf2b0
movq %r14, %rdi
callq 0x262f0
testl %eax, %eax
jne 0x7fa52
cmpl $0x2, 0x38(%rbx)
jne 0x7fa52
callq 0x7ee1c
movq %rax, %r14
movzbl -0x1(%rax), %edx
movl %edx, %eax
andl $0x7, %eax
cmpl $0x4, %eax
ja 0x7fb2a
leaq 0x4e1ef(%rip), %rcx     # 0xcdc30
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
shrl $0x3, %edx
jmp 0x7fb2c
leaq 0x49463(%rip), %rsi     # 0xc8ebc
movq %r14, %rdi
callq 0x262f0
testl %eax, %eax
jne 0x7fa7c
cmpl $0x2, 0x38(%rbx)
jl 0x7fa7c
jne 0x7fad4
xorl %edi, %edi
callq 0x7ec65
movslq %eax, %rsi
jmp 0x7fafe
leaq 0x8288d(%rip), %rax     # 0x102310
movq 0x80(%rax), %rsi
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x3c854
xorl %esi, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x3d274
movq 0x40(%rbx), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rdx
leaq 0x4f7f7(%rip), %rsi     # 0xcf2b7
movq %rbx, %rdi
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x3cc2d
xorl %ebp, %ebp
movl $0x2, %r14d
movq 0x40(%rbx), %rax
movq (%rax,%r14,8), %rax
movq 0x8(%rax), %rdi
callq 0x7ec65
addl %eax, %ebp
incq %r14
movslq 0x38(%rbx), %rax
cmpq %rax, %r14
jl 0x7fadc
movslq %ebp, %rsi
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x3d23f
movq -0x11(%r14), %rdx
jmp 0x7fb2c
movzwl -0x5(%r14), %edx
jmp 0x7fb2c
movl -0x9(%r14), %edx
jmp 0x7fb2c
movzbl -0x3(%r14), %edx
jmp 0x7fb2c
xorl %edx, %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3d346
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x36330
nopl (%rax)