// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/slowlog.c
// Function: slowlogCreateEntry
slowlogEntry *slowlogCreateEntry(robj **argv, int argc, long long duration) {
    slowlogEntry *se = zmalloc(sizeof(*se));
    int j, slargc = argc;

    // 如果参数过多，那么只记录服务器允许的最大参数数量
    if (slargc > SLOWLOG_ENTRY_MAX_ARGC) slargc = SLOWLOG_ENTRY_MAX_ARGC;

    // 记录参数数量
    se->argc = slargc;

    // 遍历并记录命令的参数
    se->argv = zmalloc(sizeof(robj*)*slargc);
    for (j = 0; j < slargc; j++) {
        /* Logging too many arguments is a useless memory waste, so we stop
         * at SLOWLOG_ENTRY_MAX_ARGC, but use the last argument to specify
         * how many remaining arguments there were in the original command. */
        // 当参数的数量超过服务器允许的最大参数数量时，
        // 用最后一个参数记录省略提示
        if (slargc != argc && j == slargc-1) {
            se->argv[j] = createObject(REDIS_STRING,
                sdscatprintf(sdsempty(),"... (%d more arguments)",
                argc-slargc+1));
        } else {
            /* Trim too long strings as well... */
            // 如果参数太长，那么进行截断
            if (argv[j]->type == REDIS_STRING &&
                sdsEncodedObject(argv[j]) &&
                sdslen(argv[j]->ptr) > SLOWLOG_ENTRY_MAX_STRING)
            {
                sds s = sdsnewlen(argv[j]->ptr, SLOWLOG_ENTRY_MAX_STRING);

                s = sdscatprintf(s,"... (%lu more bytes)",
                    (unsigned long)
                    sdslen(argv[j]->ptr) - SLOWLOG_ENTRY_MAX_STRING);

                se->argv[j] = createObject(REDIS_STRING,s);
            } else {
                se->argv[j] = argv[j];
                incrRefCount(argv[j]);
            }
        }
    }

    // 命令的执行时间
    se->time = time(NULL);

    // 执行命令耗费的时间
    se->duration = duration;

    // 设置慢查询 id
    se->id = server.slowlog_entry_id++;

    return se;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, 0x10(%rsp)
movl %esi, %ebp
movq %rdi, %r15
movl $0x28, %edi
callq 0x299b5
cmpl $0x20, %ebp
movl $0x20, %r12d
cmovll %ebp, %r12d
movq %rax, %r14
movl %r12d, 0x8(%rax)
movslq %r12d, %rdi
shlq $0x3, %rdi
callq 0x299b5
movq %rax, (%r14)
testl %ebp, %ebp
jle 0x56237
leal -0x1(%r12), %ebx
movl %ebp, %eax
subl %r12d, %eax
incl %eax
movl %eax, 0xc(%rsp)
movl %r12d, %r13d
xorl %r12d, %r12d
cmpl $0x21, %ebp
setge %al
cmpq %r12, %rbx
sete %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x561bf
callq 0x2845e
movq %rax, %rdi
leaq 0x473df(%rip), %rsi     # 0x9d580
movl 0xc(%rsp), %edx
xorl %eax, %eax
callq 0x28a5e
xorl %edi, %edi
movq %rax, %rsi
callq 0x3059c
movq (%r14), %rcx
movq %rax, (%rcx,%rbx,8)
jmp 0x561da
movq (%r15,%r12,8), %rax
movl (%rax), %ecx
testb $0xf, %cl
je 0x561e4
movq (%r14), %rcx
movq %rax, (%rcx,%r12,8)
movq (%r15,%r12,8), %rdi
callq 0x306f3
incq %r12
cmpq %r12, %r13
jne 0x5617f
jmp 0x56237
shrl $0x4, %ecx
testb $0x7, %cl
jne 0x561ca
movq 0x8(%rax), %rdi
cmpl $0x81, -0x8(%rdi)
jb 0x561ca
movl $0x80, %esi
callq 0x283f4
movq (%r15,%r12,8), %rcx
movq 0x8(%rcx), %rcx
movslq -0x8(%rcx), %rdx
addq $-0x80, %rdx
movq %rax, %rdi
leaq 0x4737b(%rip), %rsi     # 0x9d598
xorl %eax, %eax
callq 0x28a5e
xorl %edi, %edi
movq %rax, %rsi
callq 0x3059c
movq (%r14), %rcx
movq %rax, (%rcx,%r12,8)
jmp 0x561da
xorl %edi, %edi
callq 0x1fc50
movq %rax, 0x20(%r14)
movq 0x10(%rsp), %rax
movq %rax, 0x18(%r14)
leaq 0x73d56(%rip), %rax     # 0xc9fa8
movq 0x3b0(%rax), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x3b0(%rax)
movq %rcx, 0x10(%r14)
movq %r14, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq