// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movl $0x28, %edi
callq 0x2e130
movq %rax, -0x20(%rbp)
movl -0xc(%rbp), %eax
movl %eax, -0x28(%rbp)
cmpl $0x20, -0x28(%rbp)
jle 0x72534
movl $0x20, -0x28(%rbp)
movl -0x28(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x8(%rax)
movslq -0x28(%rbp), %rdi
shlq $0x3, %rdi
callq 0x2e130
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x28(%rbp), %eax
jge 0x726e2
movl -0x28(%rbp), %eax
cmpl -0xc(%rbp), %eax
je 0x725bd
movl -0x24(%rbp), %eax
movl -0x28(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jne 0x725bd
callq 0x2c0c0
movq %rax, %rdi
movl -0xc(%rbp), %edx
subl -0x28(%rbp), %edx
addl $0x1, %edx
leaq 0x74ffb(%rip), %rsi     # 0xe7590
movb $0x0, %al
callq 0x2cad0
movq %rax, %rsi
xorl %edi, %edi
callq 0x3a0d0
movq %rax, %rdx
movq -0x20(%rbp), %rax
movq (%rax), %rax
movslq -0x24(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0x726d2
movq -0x8(%rbp), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl (%rax), %eax
andl $0xf, %eax
cmpl $0x0, %eax
jne 0x726a4
movq -0x8(%rbp), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl (%rax), %eax
shrl $0x4, %eax
andl $0xf, %eax
cmpl $0x0, %eax
je 0x7260d
movq -0x8(%rbp), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl (%rax), %eax
shrl $0x4, %eax
andl $0xf, %eax
cmpl $0x8, %eax
jne 0x726a4
movq -0x8(%rbp), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x8(%rax), %rdi
callq 0x724c0
cmpq $0x80, %rax
jbe 0x726a4
movq -0x8(%rbp), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x8(%rax), %rdi
movl $0x80, %esi
callq 0x2c000
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x8(%rax), %rdi
callq 0x724c0
movq -0x38(%rbp), %rdi
movq %rax, %rdx
subq $0x80, %rdx
leaq 0x74f2e(%rip), %rsi     # 0xe75a8
movb $0x0, %al
callq 0x2cad0
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rsi
xorl %edi, %edi
callq 0x3a0d0
movq %rax, %rdx
movq -0x20(%rbp), %rax
movq (%rax), %rax
movslq -0x24(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0x726d0
movq -0x8(%rbp), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
movq -0x20(%rbp), %rax
movq (%rax), %rax
movslq -0x24(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x8(%rbp), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x3a3f0
jmp 0x726d2
jmp 0x726d4
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x7255c
xorl %eax, %eax
movl %eax, %edi
callq 0x1fc70
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x18(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x18(%rax)
leaq 0xa11ef(%rip), %rax     # 0x1138f8
movq 0x3b0(%rax), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
leaq 0xa11da(%rip), %rax     # 0x1138f8
movq %rdx, 0x3b0(%rax)
movq -0x20(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x20(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nopw (%rax,%rax)