// File: /workspace/github_c_makefile_star2_O2/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
pushq $0x28
popq %rdi
callq 0x2828d
cmpl $0x20, %ebp
pushq $0x20
popq %rcx
cmovll %ebp, %ecx
movq %rax, %r14
movl %ecx, 0x8(%rax)
movslq %ecx, %rbx
leaq (,%rbx,8), %rdi
callq 0x2828d
leal -0x1(%rbx), %r13d
movl %ebp, %ecx
subl %ebx, %ecx
incl %ecx
movl %ecx, 0xc(%rsp)
xorl %ecx, %ecx
testl %ebx, %ebx
cmovlel %ecx, %ebx
movq %rax, (%r14)
xorl %r12d, %r12d
cmpq %r12, %rbx
je 0x51dd2
cmpl $0x21, %ebp
setge %al
cmpq %r12, %r13
sete %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x51d5f
callq 0x271bf
movq %rax, %rdi
leaq 0x417ff(%rip), %rsi     # 0x93540
movl 0xc(%rsp), %edx
xorl %eax, %eax
callq 0x2763d
xorl %edi, %edi
movq %rax, %rsi
callq 0x2e9b4
movq (%r14), %rcx
movq %rax, (%rcx,%r13,8)
jmp 0x51d7a
movq (%r15,%r12,8), %rax
movl (%rax), %ecx
testb $0xf, %cl
je 0x51d7f
movq (%r14), %rcx
movq %rax, (%rcx,%r12,8)
movq (%r15,%r12,8), %rdi
callq 0x2eacc
incq %r12
jmp 0x51d16
shrl $0x4, %ecx
testb $0x7, %cl
jne 0x51d6a
movq 0x8(%rax), %rdi
cmpl $0x81, -0x8(%rdi)
jb 0x51d6a
movl $0x80, %esi
callq 0x27158
movq (%r15,%r12,8), %rcx
movq 0x8(%rcx), %rcx
movslq -0x8(%rcx), %rdx
addq $-0x80, %rdx
movq %rax, %rdi
leaq 0x417a0(%rip), %rsi     # 0x93558
xorl %eax, %eax
callq 0x2763d
xorl %edi, %edi
movq %rax, %rsi
callq 0x2e9b4
movq (%r14), %rcx
movq %rax, (%rcx,%r12,8)
jmp 0x51d7a
xorl %edi, %edi
callq 0x1fc50
movq %rax, 0x20(%r14)
movq 0x10(%rsp), %rax
movq %rax, 0x18(%r14)
leaq 0x751bb(%rip), %rax     # 0xc6fa8
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