// File: /workspace/github_c_makefile_star2_O3/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 %rbx
subq $0x10, %rsp
movq %rdi, %rbx
movq 0x40(%rdi), %rax
movq 0x10(%rax), %rsi
movq 0x18(%rax), %rax
movq 0x8(%rax), %r14
leaq 0x8(%rsp), %rdx
xorl %ecx, %ecx
callq 0x41718
testl %eax, %eax
jne 0x4ba5a
cmpq $0x0, 0x8(%rsp)
js 0x4b75e
movq 0x10(%rbx), %rdi
movq 0x40(%rbx), %rax
movq 0x8(%rax), %rsi
callq 0x41ad6
testq %rax, %rax
je 0x4b76a
movq %rax, %r15
movq %rbx, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x40d47
testl %eax, %eax
jne 0x4ba5a
movq %r15, %rdi
callq 0x41270
movzbl -0x1(%r14), %ecx
movl %ecx, %edx
andl $0x7, %edx
cmpl $0x4, %edx
ja 0x4b82f
leaq 0x779cd(%rip), %rsi     # 0xc3118
movslq (%rsi,%rdx,4), %rdi
addq %rsi, %rdi
jmpq *%rdi
movl %ecx, %esi
shrl $0x3, %esi
jmp 0x4b80e
leaq 0x77ad1(%rip), %rsi     # 0xc3236
jmp 0x4b88b
movzbl -0x1(%r14), %esi
movl %esi, %ecx
andl $0x7, %ecx
cmpl $0x4, %ecx
ja 0x4b7cb
leaq 0x779c0(%rip), %rax     # 0xc3140
movslq (%rax,%rcx,4), %rdx
addq %rax, %rdx
jmpq *%rdx
movl %esi, %eax
shrl $0x3, %eax
jmp 0x4b7a8
movq -0x11(%r14), %rax
jmp 0x4b7a8
movzwl -0x5(%r14), %eax
jmp 0x4b7a8
movl -0x9(%r14), %eax
jmp 0x4b7a8
movzbl -0x3(%r14), %eax
testq %rax, %rax
je 0x4b7cb
movq 0x8(%rsp), %rax
movl %ecx, %ecx
leaq 0x77999(%rip), %rdx     # 0xc3154
movslq (%rdx,%rcx,4), %rdi
addq %rdx, %rdi
jmpq *%rdi
movl %esi, %edx
shrl $0x3, %edx
jmp 0x4b83f
leaq 0xb6b3e(%rip), %rax     # 0x102310
movq 0x20(%rax), %rsi
movq %rbx, %rdi
callq 0x3c854
jmp 0x4ba5a
movq -0x11(%r14), %rsi
jmp 0x4b80e
movq -0x11(%r14), %rdx
jmp 0x4b83f
movzwl -0x5(%r14), %esi
jmp 0x4b80e
movzwl -0x5(%r14), %edx
jmp 0x4b83f
movl -0x9(%r14), %esi
jmp 0x4b80e
movl -0x9(%r14), %edx
jmp 0x4b83f
movzbl -0x3(%r14), %esi
testq %rsi, %rsi
je 0x4b82f
movq 0x8(%rsp), %rax
movl %edx, %edx
leaq 0x7790b(%rip), %rsi     # 0xc312c
movslq (%rsi,%rdx,4), %rdx
addq %rsi, %rdx
jmpq *%rdx
shrl $0x3, %ecx
jmp 0x4b878
movq %rbx, %rdi
movq %rax, %rsi
jmp 0x4ba55
movzbl -0x3(%r14), %edx
addq %rax, %rdx
cmpq $0x20000001, %rdx       # imm = 0x20000001
jge 0x4b884
leaq 0x77916(%rip), %rdx     # 0xc3168
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
shrl $0x3, %esi
jmp 0x4b8c9
movq -0x11(%r14), %rcx
jmp 0x4b878
movzwl -0x5(%r14), %ecx
jmp 0x4b878
movl -0x9(%r14), %ecx
jmp 0x4b878
movzbl -0x3(%r14), %ecx
addq %rax, %rcx
cmpq $0x20000001, %rcx       # imm = 0x20000001
jl 0x4b898
leaq 0x77a33(%rip), %rsi     # 0xc32be
movq %rbx, %rdi
callq 0x3cc06
jmp 0x4ba5a
movq 0x10(%rbx), %rdi
movq 0x40(%rbx), %rax
movq 0x8(%rax), %rsi
movq %r15, %rdx
callq 0x41f24
movq %rax, %r15
jmp 0x4b8f4
movq -0x11(%r14), %rsi
jmp 0x4b8c9
movzwl -0x5(%r14), %esi
jmp 0x4b8c9
movl -0x9(%r14), %esi
jmp 0x4b8c9
movzbl -0x3(%r14), %esi
addq %rax, %rsi
xorl %edi, %edi
callq 0x36178
xorl %edi, %edi
movq %rax, %rsi
callq 0x40650
movq %rax, %r15
movq 0x10(%rbx), %rdi
movq 0x40(%rbx), %rax
movq 0x8(%rax), %rsi
movq %r15, %rdx
callq 0x41b77
movzbl -0x1(%r14), %esi
movl %esi, %eax
andl $0x7, %eax
cmpl $0x4, %eax
ja 0x4ba12
leaq 0x7786e(%rip), %rcx     # 0xc317c
movslq (%rcx,%rax,4), %rdx
addq %rcx, %rdx
jmpq *%rdx
movl %esi, %ecx
shrl $0x3, %ecx
jmp 0x4b936
movq -0x11(%r14), %rcx
jmp 0x4b936
movzwl -0x5(%r14), %ecx
jmp 0x4b936
movl -0x9(%r14), %ecx
jmp 0x4b936
movzbl -0x3(%r14), %ecx
testq %rcx, %rcx
je 0x4ba12
movq 0x8(%r15), %rdi
movq 0x8(%rsp), %rcx
movl %eax, %eax
leaq 0x7783f(%rip), %rdx     # 0xc3190
movslq (%rdx,%rax,4), %rax
addq %rdx, %rax
jmpq *%rax
shrl $0x3, %esi
jmp 0x4b977
movq -0x11(%r14), %rsi
jmp 0x4b977
movzwl -0x5(%r14), %esi
jmp 0x4b977
movl -0x9(%r14), %esi
jmp 0x4b977
movzbl -0x3(%r14), %esi
addq %rcx, %rsi
callq 0x36a02
movq %rax, 0x8(%r15)
addq 0x8(%rsp), %rax
movzbl -0x1(%r14), %edx
movl %edx, %ecx
andl $0x7, %ecx
cmpl $0x4, %ecx
ja 0x4b9c6
leaq 0x77806(%rip), %rsi     # 0xc31a4
movslq (%rsi,%rcx,4), %rcx
addq %rsi, %rcx
jmpq *%rcx
shrl $0x3, %edx
jmp 0x4b9c8
movq -0x11(%r14), %rdx
jmp 0x4b9c8
movzwl -0x5(%r14), %edx
jmp 0x4b9c8
movl -0x9(%r14), %edx
jmp 0x4b9c8
movzbl -0x3(%r14), %edx
jmp 0x4b9c8
xorl %edx, %edx
movq %rax, %rdi
movq %r14, %rsi
callq 0x26c50
movq 0x10(%rbx), %rdi
movq 0x40(%rbx), %rax
movq 0x8(%rax), %rsi
callq 0x41d90
movq 0x10(%rbx), %rax
movq 0x40(%rbx), %rcx
movq 0x8(%rcx), %rdx
movl 0x30(%rax), %ecx
leaq 0x70b9d(%rip), %rsi     # 0xbc597
movl $0x8, %edi
callq 0x7c665
leaq 0xb5e9d(%rip), %rax     # 0x1018a8
incq 0x720(%rax)
movq 0x8(%r15), %rax
movzbl -0x1(%rax), %esi
movl %esi, %ecx
andl $0x7, %ecx
cmpl $0x4, %ecx
ja 0x4ba50
leaq 0x7778d(%rip), %rdx     # 0xc31b8
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
shrl $0x3, %esi
jmp 0x4ba52
movq -0x11(%rax), %rsi
jmp 0x4ba52
movzwl -0x5(%rax), %esi
jmp 0x4ba52
movl -0x9(%rax), %esi
jmp 0x4ba52
movzbl -0x3(%rax), %esi
jmp 0x4ba52
xorl %esi, %esi
movq %rbx, %rdi
callq 0x3d23f
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq