// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movq 0x18(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movq 0x10(%rax), %rsi
leaq -0x18(%rbp), %rdx
xorl %eax, %eax
movl %eax, %ecx
callq 0x49f20
cmpl $0x0, %eax
je 0x57f7a
jmp 0x58203
cmpq $0x0, -0x18(%rbp)
jge 0x57f96
movq -0x8(%rbp), %rdi
leaq 0xe594e(%rip), %rsi     # 0x13d8da
callq 0x42f90
jmp 0x58203
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movq 0x8(%rax), %rsi
callq 0x4a6f0
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x5806a
movq -0x20(%rbp), %rdi
callq 0x58210
cmpq $0x0, %rax
jne 0x57fe6
movq -0x8(%rbp), %rdi
leaq 0x120c68(%rip), %rax    # 0x178c40
movq 0x20(%rax), %rsi
callq 0x42cc0
jmp 0x58203
movq -0x8(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x20(%rbp), %rdi
callq 0x58210
movq -0x38(%rbp), %rsi
movq -0x30(%rbp), %rdi
addq %rax, %rsi
callq 0x582a0
cmpl $0x0, %eax
je 0x58019
jmp 0x58203
movq -0x18(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x20(%rbp), %rdi
callq 0x58210
movq -0x40(%rbp), %rsi
addq %rax, %rsi
xorl %eax, %eax
movl %eax, %edi
callq 0x38230
movq %rax, %rsi
xorl %edi, %edi
callq 0x48480
movq %rax, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movq 0x8(%rax), %rsi
movq -0x10(%rbp), %rdx
callq 0x4a7d0
jmp 0x58105
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
xorl %edx, %edx
callq 0x490a0
cmpl $0x0, %eax
je 0x58083
jmp 0x58203
movq -0x10(%rbp), %rdi
callq 0x498c0
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rdi
callq 0x58210
cmpq $0x0, %rax
jne 0x580b1
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x43780
jmp 0x58203
movq -0x8(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x20(%rbp), %rdi
callq 0x58210
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdi
addq %rax, %rsi
callq 0x582a0
cmpl $0x0, %eax
je 0x580e4
jmp 0x58203
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movq 0x8(%rax), %rsi
movq -0x10(%rbp), %rdx
callq 0x4ad00
movq %rax, -0x10(%rbp)
movq -0x20(%rbp), %rdi
callq 0x58210
cmpq $0x0, %rax
jbe 0x581e2
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x68(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x20(%rbp), %rdi
callq 0x58210
movq -0x70(%rbp), %rsi
movq -0x68(%rbp), %rdi
addq %rax, %rsi
callq 0x38fa0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
addq -0x18(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x20(%rbp), %rdi
callq 0x58210
movq -0x60(%rbp), %rdi
movq -0x58(%rbp), %rsi
movq %rax, %rdx
callq 0x26c60
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movq 0x8(%rax), %rsi
callq 0x4aa60
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movq 0x8(%rax), %rdx
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movl 0x30(%rax), %ecx
movl $0x8, %edi
leaq 0xdf34a(%rip), %rsi     # 0x137507
callq 0x9ce20
leaq 0x12000f(%rip), %rax    # 0x1781d8
movq 0x720(%rax), %rcx
addq $0x1, %rcx
leaq 0x11fffd(%rip), %rax    # 0x1781d8
movq %rcx, 0x720(%rax)
movq -0x8(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x58210
movq -0x78(%rbp), %rdi
movq %rax, %rsi
callq 0x43780
addq $0x80, %rsp
popq %rbp
retq
nopl (%rax)