// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/t_string.c
// Function: incrbyfloatCommand
void incrbyfloatCommand(redisClient *c) {
    long double incr, value;
    robj *o, *new, *aux;

    // 取出值对象
    o = lookupKeyWrite(c->db,c->argv[1]);

    // 检查对象是否存在，以及类型是否正确
    if (o != NULL && checkType(c,o,REDIS_STRING)) return;

    // 将对象的整数值保存到 value 参数中
    // 并取出 incr 参数的值
    if (getLongDoubleFromObjectOrReply(c,o,&value,NULL) != REDIS_OK ||
        getLongDoubleFromObjectOrReply(c,c->argv[2],&incr,NULL) != REDIS_OK)
        return;

    // 进行加法计算，并检查是否溢出
    value += incr;
    if (isnan(value) || isinf(value)) {
        addReplyError(c,"increment would produce NaN or Infinity");
        return;
    }

    // 用一个包含新值的新对象替换现有的值对象
    new = createStringObjectFromLongDouble(value);
    if (o)
        dbOverwrite(c->db,c->argv[1],new);
    else
        dbAdd(c->db,c->argv[1],new);

    // 向数据库发送键被修改的信号
    signalModifiedKey(c->db,c->argv[1]);

    // 发送事件通知
    notifyKeyspaceEvent(REDIS_NOTIFY_STRING,"incrbyfloat",c->argv[1],c->db->id);

    // 将服务器设为脏
    server.dirty++;

    // 回复
    addReplyBulk(c,new);

    /* Always replicate INCRBYFLOAT as a SET command with the final value
     * in order to make sure that differences in float precision or formatting
     * will not create differences in replicas or after an AOF restart. */
    // 在传播 INCRBYFLOAT 命令时，总是用 SET 命令来替换 INCRBYFLOAT 命令
    // 从而防止因为不同的浮点精度和格式化造成 AOF 重启时的数据不一致
    aux = createStringObject("SET",3);
    rewriteClientCommandArgument(c,0,aux);
    decrRefCount(aux);
    rewriteClientCommandArgument(c,2,new);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x40, %rsp
movq %rdi, %rbx
movq 0x8(%rdi), %rdi
movq 0x38(%rbx), %rax
movq 0x8(%rax), %rsi
callq 0x31724
movq %rax, %r14
testq %rax, %rax
je 0x393a7
movq %rbx, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x30bbf
testl %eax, %eax
jne 0x394e8
leaq 0x20(%rsp), %rdx
movq %rbx, %rdi
movq %r14, %rsi
xorl %ecx, %ecx
callq 0x31218
testl %eax, %eax
jne 0x394e8
movq 0x38(%rbx), %rax
movq 0x10(%rax), %rsi
leaq 0x30(%rsp), %rdx
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x31218
testl %eax, %eax
jne 0x394e8
fldt 0x30(%rsp)
fldt 0x20(%rsp)
faddp %st, %st(1)
fld %st(0)
fstpt 0x10(%rsp)
movzwl 0x18(%rsp), %eax
movq 0x10(%rsp), %rcx
fld %st(0)
fstpt 0x20(%rsp)
shrq $0x3f, %rcx
andl $0x7fff, %eax           # imm = 0x7FFF
leal -0x1(%rax), %edx
movzwl %dx, %edx
cmpl $0x7ffe, %edx           # imm = 0x7FFE
setb %dl
andb %cl, %dl
testq %rax, %rax
sete %al
orb %dl, %al
jne 0x3943a
fstp %st(0)
leaq 0x5fb2d(%rip), %rsi     # 0x98f5a
movq %rbx, %rdi
callq 0x2dc63
jmp 0x394e8
fstpt (%rsp)
callq 0x306f7
movq %rax, %r15
movq 0x8(%rbx), %rdi
movq 0x38(%rbx), %rax
movq 0x8(%rax), %rsi
movq %r15, %rdx
testq %r14, %r14
je 0x39460
callq 0x318a1
jmp 0x39465
callq 0x317f0
movq 0x8(%rbx), %rdi
movq 0x38(%rbx), %rax
movq 0x8(%rax), %rsi
callq 0x319b8
movq 0x8(%rbx), %rax
movq 0x38(%rbx), %rcx
movq 0x8(%rcx), %rdx
movl 0x30(%rax), %ecx
leaq 0x5b044(%rip), %rsi     # 0x944d0
movl $0x8, %edi
callq 0x60371
leaq 0x90b0b(%rip), %rax     # 0xc9fa8
incq 0x560(%rax)
movq %rbx, %rdi
movq %r15, %rsi
callq 0x2e204
leaq 0x667a6(%rip), %rdi     # 0x9fc5c
movl $0x3, %esi
callq 0x3068f
movq %rax, %r14
movq %rbx, %rdi
xorl %esi, %esi
movq %rax, %rdx
callq 0x2f9cc
movq %r14, %rdi
callq 0x30b0c
movq %rbx, %rdi
movl $0x2, %esi
movq %r15, %rdx
callq 0x2f9cc
addq $0x40, %rsp
popq %rbx
popq %r14
popq %r15
retq