// File: /workspace/github_c_makefile_star2_O0/gplessis[P]dotdeb-redis/deps/hiredis/sds.c
// Function: sdsnewlen
sds sdsnewlen(const void *init, size_t initlen) {
    void *sh;
    sds s;
    char type = sdsReqType(initlen);
    /* Empty strings are usually created in order to append. Use type 8
     * since type 5 is not good at this. */
    if (type == SDS_TYPE_5 && initlen == 0) type = SDS_TYPE_8;
    int hdrlen = sdsHdrSize(type);
    unsigned char *fp; /* flags pointer. */

    sh = s_malloc(hdrlen+initlen+1);
    if (!init)
        memset(sh, 0, hdrlen+initlen+1);
    if (sh == NULL) return NULL;
    s = (char*)sh+hdrlen;
    fp = ((unsigned char*)s)-1;
    switch(type) {
        case SDS_TYPE_5: {
            *fp = type | (initlen << SDS_TYPE_BITS);
            break;
        }
        case SDS_TYPE_8: {
            SDS_HDR_VAR(8,s);
            sh->len = initlen;
            sh->alloc = initlen;
            *fp = type;
            break;
        }
        case SDS_TYPE_16: {
            SDS_HDR_VAR(16,s);
            sh->len = initlen;
            sh->alloc = initlen;
            *fp = type;
            break;
        }
        case SDS_TYPE_32: {
            SDS_HDR_VAR(32,s);
            sh->len = initlen;
            sh->alloc = initlen;
            *fp = type;
            break;
        }
        case SDS_TYPE_64: {
            SDS_HDR_VAR(64,s);
            sh->len = initlen;
            sh->alloc = initlen;
            *fp = type;
            break;
        }
    }
    if (initlen && init)
        memcpy(s, init, initlen);
    s[initlen] = '\0';
    return s;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x18(%rbp), %rdi
callq 0x1ec90
movb %al, -0x29(%rbp)
movsbl -0x29(%rbp), %eax
cmpl $0x0, %eax
jne 0x1ead0
cmpq $0x0, -0x18(%rbp)
jne 0x1ead0
movb $0x1, -0x29(%rbp)
movsbl -0x29(%rbp), %edi
callq 0x1ece0
movl %eax, -0x30(%rbp)
movslq -0x30(%rbp), %rdi
addq -0x18(%rbp), %rdi
addq $0x1, %rdi
callq 0x10410
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x1eb0f
movq -0x20(%rbp), %rdi
movslq -0x30(%rbp), %rdx
addq -0x18(%rbp), %rdx
addq $0x1, %rdx
xorl %esi, %esi
callq 0x10250
cmpq $0x0, -0x20(%rbp)
jne 0x1eb23
movq $0x0, -0x8(%rbp)
jmp 0x1ec77
movq -0x20(%rbp), %rax
movslq -0x30(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
decq %rax
movq %rax, -0x38(%rbp)
movsbl -0x29(%rbp), %eax
movl %eax, %ecx
movq %rcx, -0x60(%rbp)
subl $0x4, %eax
ja 0x1ec44
movq -0x60(%rbp), %rax
leaq 0x6f031(%rip), %rcx     # 0x8db8c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movsbq -0x29(%rbp), %rax
movq -0x18(%rbp), %rcx
shlq $0x3, %rcx
orq %rcx, %rax
movb %al, %cl
movq -0x38(%rbp), %rax
movb %cl, (%rax)
jmp 0x1ec44
movq -0x28(%rbp), %rax
addq $-0x3, %rax
movq %rax, -0x40(%rbp)
movq -0x18(%rbp), %rax
movb %al, %cl
movq -0x40(%rbp), %rax
movb %cl, (%rax)
movq -0x18(%rbp), %rax
movb %al, %cl
movq -0x40(%rbp), %rax
movb %cl, 0x1(%rax)
movb -0x29(%rbp), %cl
movq -0x38(%rbp), %rax
movb %cl, (%rax)
jmp 0x1ec44
movq -0x28(%rbp), %rax
addq $-0x5, %rax
movq %rax, -0x48(%rbp)
movq -0x18(%rbp), %rax
movw %ax, %cx
movq -0x48(%rbp), %rax
movw %cx, (%rax)
movq -0x18(%rbp), %rax
movw %ax, %cx
movq -0x48(%rbp), %rax
movw %cx, 0x2(%rax)
movb -0x29(%rbp), %cl
movq -0x38(%rbp), %rax
movb %cl, (%rax)
jmp 0x1ec44
movq -0x28(%rbp), %rax
addq $-0x9, %rax
movq %rax, -0x50(%rbp)
movq -0x18(%rbp), %rax
movl %eax, %ecx
movq -0x50(%rbp), %rax
movl %ecx, (%rax)
movq -0x18(%rbp), %rax
movl %eax, %ecx
movq -0x50(%rbp), %rax
movl %ecx, 0x4(%rax)
movb -0x29(%rbp), %cl
movq -0x38(%rbp), %rax
movb %cl, (%rax)
jmp 0x1ec44
movq -0x28(%rbp), %rax
addq $-0x11, %rax
movq %rax, -0x58(%rbp)
movq -0x18(%rbp), %rcx
movq -0x58(%rbp), %rax
movq %rcx, (%rax)
movq -0x18(%rbp), %rcx
movq -0x58(%rbp), %rax
movq %rcx, 0x8(%rax)
movb -0x29(%rbp), %cl
movq -0x38(%rbp), %rax
movb %cl, (%rax)
cmpq $0x0, -0x18(%rbp)
je 0x1ec63
cmpq $0x0, -0x10(%rbp)
je 0x1ec63
movq -0x28(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x103b0
movq -0x28(%rbp), %rax
movq -0x18(%rbp), %rcx
movb $0x0, (%rax,%rcx)
movq -0x28(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)