// File: /workspace/github_c_makefile_star2_O2/gplessis[P]dotdeb-redis/src/t_string.c
// Function: setrangeCommand
void setrangeCommand(client *c) {
    robj *o;
    long offset;
    sds value = c->argv[3]->ptr;

    if (getLongFromObjectOrReply(c,c->argv[2],&offset,NULL) != C_OK)
        return;

    if (offset < 0) {
        addReplyError(c,"offset is out of range");
        return;
    }

    o = lookupKeyWrite(c->db,c->argv[1]);
    if (o == NULL) {
        /* Return 0 when setting nothing on a non-existing string */
        if (sdslen(value) == 0) {
            addReply(c,shared.czero);
            return;
        }

        /* Return when the resulting string exceeds allowed size */
        if (checkStringLength(c,offset+sdslen(value)) != C_OK)
            return;

        o = createObject(OBJ_STRING,sdsnewlen(NULL, offset+sdslen(value)));
        dbAdd(c->db,c->argv[1],o);
    } else {
        size_t olen;

        /* Key exists, check type */
        if (checkType(c,o,OBJ_STRING))
            return;

        /* Return existing string length when setting nothing */
        olen = stringObjectLen(o);
        if (sdslen(value) == 0) {
            addReplyLongLong(c,olen);
            return;
        }

        /* Return when the resulting string exceeds allowed size */
        if (checkStringLength(c,offset+sdslen(value)) != C_OK)
            return;

        /* Create a copy when the object is shared or encoded. */
        o = dbUnshareStringValue(c->db,c->argv[1],o);
    }

    if (sdslen(value) > 0) {
        o->ptr = sdsgrowzero(o->ptr,offset+sdslen(value));
        memcpy((char*)o->ptr+offset,value,sdslen(value));
        signalModifiedKey(c->db,c->argv[1]);
        notifyKeyspaceEvent(NOTIFY_STRING,
            "setrange",c->argv[1],c->db->id);
        server.dirty++;
    }
    addReplyLongLong(c,sdslen(o->ptr));
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x40(%rdi), %rax
movq 0x10(%rax), %rsi
movq 0x18(%rax), %rax
movq 0x8(%rax), %r14
movq %rsp, %rdx
xorl %ecx, %ecx
callq 0x3ab5e
testl %eax, %eax
je 0x43753
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
cmpq $0x0, (%rsp)
js 0x437cc
movq 0x10(%rbx), %rdi
movq 0x40(%rbx), %rax
movq 0x8(%rax), %rsi
callq 0x3aec2
testq %rax, %rax
je 0x437e0
movq %rax, %r15
movq %rbx, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x3a311
testl %eax, %eax
jne 0x43747
movq %r15, %rdi
callq 0x3a747
movq %rax, %r12
movq %r14, %rdi
callq 0x438f6
testq %rax, %rax
je 0x438e6
addq (%rsp), %rax
movq %rbx, %rdi
movq %rax, %rsi
callq 0x4392e
testl %eax, %eax
jne 0x43747
movq 0x10(%rbx), %rdi
movq 0x40(%rbx), %rax
movq 0x8(%rax), %rsi
movq %r15, %rdx
callq 0x3b27c
movq %rax, %r15
jmp 0x43842
leaq 0x71033(%rip), %rsi     # 0xb4806
movq %rbx, %rdi
callq 0x36b6f
jmp 0x43747
movq %r14, %rdi
callq 0x438f6
testq %rax, %rax
je 0x438ce
addq (%rsp), %rax
movq %rbx, %rdi
movq %rax, %rsi
callq 0x4392e
testl %eax, %eax
jne 0x43747
movq (%rsp), %r15
movq %r14, %rdi
callq 0x438f6
addq %rax, %r15
xorl %edi, %edi
movq %r15, %rsi
callq 0x31018
xorl %edi, %edi
movq %rax, %rsi
callq 0x39d58
movq %rax, %r15
movq 0x10(%rbx), %rdi
movq 0x40(%rbx), %rax
movq 0x8(%rax), %rsi
movq %r15, %rdx
callq 0x3af45
movq %r14, %rdi
callq 0x438f6
testq %rax, %rax
je 0x438bd
movq 0x8(%r15), %rdi
addq (%rsp), %rax
movq %rax, %rsi
callq 0x316f6
movq %rax, %r12
movq %rax, 0x8(%r15)
addq (%rsp), %r12
movq %r14, %rdi
callq 0x438f6
movq %r12, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x26c50
movq 0x10(%rbx), %rdi
movq 0x40(%rbx), %rax
movq 0x8(%rax), %rsi
callq 0x3b125
movq 0x10(%rbx), %rax
movq 0x40(%rbx), %rcx
movq 0x8(%rcx), %rdx
movl 0x30(%rax), %ecx
leaq 0x6abe0(%rip), %rsi     # 0xae487
pushq $0x8
popq %rdi
callq 0x6fb58
leaq 0xb5ff2(%rip), %rax     # 0xf98a8
incq 0x720(%rax)
movq 0x8(%r15), %rdi
callq 0x438f6
movq %rbx, %rdi
movq %rax, %rsi
jmp 0x438ec
leaq 0xb6a3b(%rip), %rax     # 0xfa310
movq 0x20(%rax), %rsi
movq %rbx, %rdi
callq 0x36987
jmp 0x43747
movq %rbx, %rdi
movq %r12, %rsi
callq 0x370a6
jmp 0x43747