// File: /workspace/github_c_makefile_star2_O1/zhou-yuxin[P]redis-aof-no-cow/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
pushq %r15
pushq %r14
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 0x44ba1
testl %eax, %eax
jne 0x4f1de
cmpq $0x0, (%rsp)
js 0x4ee7a
movq 0x10(%rbx), %rdi
movq 0x40(%rbx), %rax
movq 0x8(%rax), %rsi
callq 0x44f66
testq %rax, %rax
je 0x4ee8e
movq %rax, %r15
xorl %ebp, %ebp
movq %rbx, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x441ab
testl %eax, %eax
jne 0x4f020
movq %r15, %rdi
callq 0x446f9
movzbl -0x1(%r14), %ecx
movl %ecx, %edx
andl $0x7, %edx
cmpl $0x4, %edx
ja 0x4ef48
leaq 0x77231(%rip), %rsi     # 0xc6098
movslq (%rsi,%rdx,4), %rdi
addq %rsi, %rdi
jmpq *%rdi
movl %ecx, %esi
shrl $0x3, %esi
jmp 0x4ef4a
leaq 0x77335(%rip), %rsi     # 0xc61b6
movq %rbx, %rdi
callq 0x3ffcb
jmp 0x4f1de
movzbl -0x1(%r14), %eax
movl %eax, %ecx
andl $0x7, %ecx
cmpl $0x4, %ecx
ja 0x4eece
leaq 0x7721c(%rip), %rdx     # 0xc60c0
movslq (%rdx,%rcx,4), %rsi
addq %rdx, %rsi
jmpq *%rsi
movl %eax, %edx
shrl $0x3, %edx
jmp 0x4eed0
movq -0x11(%r14), %rdx
jmp 0x4eed0
movzwl -0x5(%r14), %edx
jmp 0x4eed0
movl -0x9(%r14), %edx
jmp 0x4eed0
movzbl -0x3(%r14), %edx
jmp 0x4eed0
xorl %edx, %edx
testq %rdx, %rdx
je 0x4eefc
movq (%rsp), %rdx
cmpl $0x4, %ecx
ja 0x4ef83
movl %ecx, %ecx
leaq 0x771e9(%rip), %rsi     # 0xc60d4
movslq (%rsi,%rcx,4), %rcx
addq %rsi, %rcx
jmpq *%rcx
shrl $0x3, %eax
jmp 0x4ef85
leaq 0xb83ad(%rip), %rax     # 0x1072b0
movq 0x20(%rax), %rsi
movq %rbx, %rdi
callq 0x3fc19
jmp 0x4f1de
movq -0x11(%r14), %rsi
jmp 0x4ef4a
movq -0x11(%r14), %rax
jmp 0x4ef85
movzwl -0x5(%r14), %esi
jmp 0x4ef4a
movzwl -0x5(%r14), %eax
jmp 0x4ef85
movl -0x9(%r14), %esi
jmp 0x4ef4a
movl -0x9(%r14), %eax
jmp 0x4ef85
movzbl -0x3(%r14), %esi
jmp 0x4ef4a
movzbl -0x3(%r14), %eax
jmp 0x4ef85
xorl %esi, %esi
testq %rsi, %rsi
je 0x4ef73
movq (%rsp), %rax
cmpl $0x4, %edx
ja 0x4efe5
movl %edx, %edx
leaq 0x77147(%rip), %rsi     # 0xc60ac
movslq (%rsi,%rdx,4), %rdx
addq %rsi, %rdx
jmpq *%rdx
shrl $0x3, %ecx
jmp 0x4efe7
movq %rbx, %rdi
movq %rax, %rsi
callq 0x40606
jmp 0x4f01e
xorl %eax, %eax
addq %rdx, %rax
cmpq $0x20000001, %rax       # imm = 0x20000001
jge 0x4efbf
movq (%rsp), %rax
movzbl -0x1(%r14), %esi
movl %esi, %ecx
andl $0x7, %ecx
cmpl $0x4, %ecx
ja 0x4f044
leaq 0x7713a(%rip), %rdx     # 0xc60e8
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
shrl $0x3, %esi
jmp 0x4f046
leaq 0x77278(%rip), %rsi     # 0xc623e
jmp 0x4ee81
movq -0x11(%r14), %rcx
jmp 0x4efe7
movzwl -0x5(%r14), %ecx
jmp 0x4efe7
movl -0x9(%r14), %ecx
jmp 0x4efe7
movzbl -0x3(%r14), %ecx
jmp 0x4efe7
xorl %ecx, %ecx
addq %rax, %rcx
cmpq $0x20000001, %rcx       # imm = 0x20000001
jge 0x4f00f
movq 0x10(%rbx), %rdi
movq 0x40(%rbx), %rax
movq 0x8(%rax), %rsi
movq %r15, %rdx
callq 0x453b8
movq %rax, %r15
movb $0x1, %bpl
jmp 0x4f020
leaq 0x77228(%rip), %rsi     # 0xc623e
movq %rbx, %rdi
callq 0x3ffcb
xorl %ebp, %ebp
testb %bpl, %bpl
jne 0x4f071
jmp 0x4f1de
movq -0x11(%r14), %rsi
jmp 0x4f046
movzwl -0x5(%r14), %esi
jmp 0x4f046
movl -0x9(%r14), %esi
jmp 0x4f046
movzbl -0x3(%r14), %esi
jmp 0x4f046
xorl %esi, %esi
addq %rax, %rsi
xorl %edi, %edi
callq 0x3910c
xorl %edi, %edi
movq %rax, %rsi
callq 0x43ab4
movq %rax, %r15
movq 0x10(%rbx), %rdi
movq 0x40(%rbx), %rax
movq 0x8(%rax), %rsi
movq %r15, %rdx
callq 0x45007
movzbl -0x1(%r14), %esi
movl %esi, %eax
andl $0x7, %eax
cmpl $0x4, %eax
ja 0x4f0b1
leaq 0x77075(%rip), %rcx     # 0xc60fc
movslq (%rcx,%rax,4), %rdx
addq %rcx, %rdx
jmpq *%rdx
movl %esi, %ecx
shrl $0x3, %ecx
jmp 0x4f0b3
movq -0x11(%r14), %rcx
jmp 0x4f0b3
movzwl -0x5(%r14), %ecx
jmp 0x4f0b3
movl -0x9(%r14), %ecx
jmp 0x4f0b3
movzbl -0x3(%r14), %ecx
jmp 0x4f0b3
xorl %ecx, %ecx
testq %rcx, %rcx
je 0x4f196
movq 0x8(%r15), %rdi
movq (%rsp), %rcx
cmpl $0x4, %eax
ja 0x4f0fa
movl %eax, %eax
leaq 0x7703e(%rip), %rdx     # 0xc6110
movslq (%rdx,%rax,4), %rax
addq %rdx, %rax
jmpq *%rax
shrl $0x3, %esi
jmp 0x4f0fc
movq -0x11(%r14), %rsi
jmp 0x4f0fc
movzwl -0x5(%r14), %esi
jmp 0x4f0fc
movl -0x9(%r14), %esi
jmp 0x4f0fc
movzbl -0x3(%r14), %esi
jmp 0x4f0fc
xorl %esi, %esi
addq %rcx, %rsi
callq 0x39987
movq %rax, 0x8(%r15)
addq (%rsp), %rax
movzbl -0x1(%r14), %edx
movl %edx, %ecx
andl $0x7, %ecx
cmpl $0x4, %ecx
ja 0x4f14a
leaq 0x77002(%rip), %rsi     # 0xc6124
movslq (%rsi,%rcx,4), %rcx
addq %rsi, %rcx
jmpq *%rcx
shrl $0x3, %edx
jmp 0x4f14c
movq -0x11(%r14), %rdx
jmp 0x4f14c
movzwl -0x5(%r14), %edx
jmp 0x4f14c
movl -0x9(%r14), %edx
jmp 0x4f14c
movzbl -0x3(%r14), %edx
jmp 0x4f14c
xorl %edx, %edx
movq %rax, %rdi
movq %r14, %rsi
callq 0x26c60
movq 0x10(%rbx), %rdi
movq 0x40(%rbx), %rax
movq 0x8(%rax), %rsi
callq 0x45220
movq 0x10(%rbx), %rax
movq 0x40(%rbx), %rcx
movq 0x8(%rcx), %rdx
movl 0x30(%rax), %ecx
leaq 0x703c9(%rip), %rsi     # 0xbf547
movl $0x8, %edi
callq 0x800c9
leaq 0xb76c9(%rip), %rax     # 0x106858
incq 0x710(%rax)
movq 0x8(%r15), %rax
movzbl -0x1(%rax), %esi
movl %esi, %ecx
andl $0x7, %ecx
cmpl $0x4, %ecx
ja 0x4f1d4
leaq 0x76f89(%rip), %rdx     # 0xc6138
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
shrl $0x3, %esi
jmp 0x4f1d6
movq -0x11(%rax), %rsi
jmp 0x4f1d6
movzwl -0x5(%rax), %esi
jmp 0x4f1d6
movl -0x9(%rax), %esi
jmp 0x4f1d6
movzbl -0x3(%rax), %esi
jmp 0x4f1d6
xorl %esi, %esi
movq %rbx, %rdi
callq 0x40606
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq