// File: /workspace/github_c_makefile_star2_O2/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 0x2f988
movq %rax, %r14
testq %rax, %rax
je 0x36a69
movq %rbx, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x2eec6
testl %eax, %eax
jne 0x36ba4
leaq 0x20(%rsp), %rdx
movq %rbx, %rdi
movq %r14, %rsi
xorl %ecx, %ecx
callq 0x2f4e9
testl %eax, %eax
jne 0x36ba4
movq 0x38(%rbx), %rax
movq 0x10(%rax), %rsi
leaq 0x30(%rsp), %rdx
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x2f4e9
testl %eax, %eax
jne 0x36ba4
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 0x36afc
fstp %st(0)
leaq 0x5842f(%rip), %rsi     # 0x8ef1e
movq %rbx, %rdi
callq 0x2c2da
jmp 0x36ba4
fstpt (%rsp)
callq 0x2ead0
movq %rax, %r15
movq 0x8(%rbx), %rdi
movq 0x38(%rbx), %rax
movq 0x8(%rax), %rsi
movq %r15, %rdx
testq %r14, %r14
je 0x36b22
callq 0x2fab8
jmp 0x36b27
callq 0x2fa09
movq 0x8(%rbx), %rdi
movq 0x38(%rbx), %rax
movq 0x8(%rax), %rsi
callq 0x2fbc0
movq 0x8(%rbx), %rax
movq 0x38(%rbx), %rcx
movq 0x8(%rcx), %rdx
movl 0x30(%rax), %ecx
leaq 0x53942(%rip), %rsi     # 0x8a490
pushq $0x8
popq %rdi
callq 0x5b488
leaq 0x9044b(%rip), %rax     # 0xc6fa8
incq 0x560(%rax)
movq %rbx, %rdi
movq %r15, %rsi
callq 0x2c84a
leaq 0x5f05a(%rip), %rdi     # 0x95bd0
pushq $0x3
popq %rsi
callq 0x2ea81
movq %rax, %r14
movq %rbx, %rdi
xorl %esi, %esi
movq %rax, %rdx
callq 0x2de87
movq %r14, %rdi
callq 0x2ee1f
pushq $0x2
popq %rsi
movq %rbx, %rdi
movq %r15, %rdx
callq 0x2de87
addq $0x40, %rsp
popq %rbx
popq %r14
popq %r15
retq