LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O2/gplessis[P]dotdeb-redis/src/db.c
// Function: sortGetKeys
int *sortGetKeys(struct redisCommand *cmd, robj **argv, int argc, int *numkeys) {
    int i, j, num, *keys, found_store = 0;
    UNUSED(cmd);

    num = 0;
    keys = zmalloc(sizeof(int)*2); /* Alloc 2 places for the worst case. */

    keys[num++] = 1; /* <sort-key> is always present. */

    /* Search for STORE option. By default we consider options to don't
     * have arguments, so if we find an unknown option name we scan the
     * next. However there are options with 1 or 2 arguments, so we
     * provide a list here in order to skip the right number of args. */
    struct {
        char *name;
        int skip;
    } skiplist[] = {
        {"limit", 2},
        {"get", 1},
        {"by", 1},
        {NULL, 0} /* End of elements. */
    };

    for (i = 2; i < argc; i++) {
        for (j = 0; skiplist[j].name != NULL; j++) {
            if (!strcasecmp(argv[i]->ptr,skiplist[j].name)) {
                i += skiplist[j].skip;
                break;
            } else if (!strcasecmp(argv[i]->ptr,"store") && i+1 < argc) {
                /* Note: we don't increment "num" here and continue the loop
                 * to be sure to process the *last* "STORE" option if multiple
                 * ones are provided. This is same behavior as SORT. */
                found_store = 1;
                keys[num] = i+1; /* <store-key> */
                break;
            }
        }
    }
    *numkeys = num + found_store;
    return keys;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rcx, 0x10(%rsp)
movl %edx, %ebp
movq %rsi, 0x18(%rsp)
pushq $0x8
popq %rdi
callq 0x327b9
movq %rax, 0x8(%rsp)
movl $0x1, (%rax)
pushq $0x1
popq %rax
movl %eax, 0x4(%rsp)
pushq $0x2
popq %r14
leaq 0xb547d(%rip), %rbx     # 0xf1d00
movl %r14d, %ecx
cmpl %ebp, %ecx
jge 0x3c903
movslq %ecx, %rax
movq %rcx, 0x20(%rsp)
leal 0x1(%rcx), %r14d
movq 0x18(%rsp), %rcx
movq (%rcx,%rax,8), %rax
movq 0x8(%rax), %r13
xorl %r12d, %r12d
leaq 0x10(%r12), %r15
cmpq $0x40, %r15
je 0x3c883
movq (%r12,%rbx), %rsi
movq %r13, %rdi
callq 0x262f0
testl %eax, %eax
je 0x3c8e1
movq %r13, %rdi
leaq 0x71f23(%rip), %rsi     # 0xae7ee
callq 0x262f0
movq %r15, %r12
testl %eax, %eax
jne 0x3c8a6
movq %r15, %r12
cmpl %ebp, %r14d
jge 0x3c8a6
jmp 0x3c8f1
movl 0x8(%r12,%rbx), %eax
movq 0x20(%rsp), %rcx
addl %eax, %ecx
incl %ecx
jmp 0x3c886
movq 0x8(%rsp), %rax
movl %r14d, 0x4(%rax)
pushq $0x2
popq %rax
movl %eax, 0x4(%rsp)
jmp 0x3c883
movq 0x10(%rsp), %rax
movl 0x4(%rsp), %ecx
movl %ecx, (%rax)
movq 0x8(%rsp), %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/gplessis[P]dotdeb-redis/src/db.c
// Function: migrateGetKeys
int *migrateGetKeys(struct redisCommand *cmd, robj **argv, int argc, int *numkeys) {
    int i, num, first, *keys;
    UNUSED(cmd);

    /* Assume the obvious form. */
    first = 3;
    num = 1;

    /* But check for the extended one with the KEYS option. */
    if (argc > 6) {
        for (i = 6; i < argc; i++) {
            if (!strcasecmp(argv[i]->ptr,"keys") &&
                sdslen(argv[3]->ptr) == 0)
            {
                first = i+1;
                num = argc-first;
                break;
            }
        }
    }

    keys = zmalloc(sizeof(int)*num);
    for (i = 0; i < num; i++) keys[i] = first+i;
    *numkeys = num;
    return keys;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %r15
pushq $0x3
popq %rbx
pushq $0x1
popq %r12
cmpl $0x7, %edx
jl 0x3c9a5
movl %edx, %ebp
movq %rsi, %r14
movq %r15, (%rsp)
movl %edx, %r12d
addq $-0x6, %r12
xorl %r13d, %r13d
leaq 0x7d23b(%rip), %r15     # 0xb9b91
cmpq %r13, %r12
je 0x3c987
movq 0x30(%r14,%r13,8), %rax
movq 0x8(%rax), %rdi
movq %r15, %rsi
callq 0x262f0
testl %eax, %eax
jne 0x3c982
movq 0x18(%r14), %rax
movq 0x8(%rax), %rdi
callq 0x3b1a7
testq %rax, %rax
je 0x3c991
incq %r13
jmp 0x3c956
movq (%rsp), %r15
pushq $0x1
popq %r12
jmp 0x3c9a5
subl %r13d, %ebp
addl $-0x7, %ebp
addq $0x7, %r13
movl %ebp, %r12d
movq %r13, %rbx
movq (%rsp), %r15
movslq %r12d, %r14
leaq (,%r14,4), %rdi
callq 0x327b9
xorl %ecx, %ecx
testl %r14d, %r14d
movl $0x0, %edx
cmovgl %r12d, %edx
cmpq %rcx, %rdx
je 0x3c9d3
leal (%rbx,%rcx), %esi
movl %esi, (%rax,%rcx,4)
incq %rcx
jmp 0x3c9c3
movl %r12d, (%r15)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/gplessis[P]dotdeb-redis/src/db.c
// Function: georadiusGetKeys
int *georadiusGetKeys(struct redisCommand *cmd, robj **argv, int argc, int *numkeys) {
    int i, num, *keys;
    UNUSED(cmd);

    /* Check for the presence of the stored key in the command */
    int stored_key = -1;
    for (i = 5; i < argc; i++) {
        char *arg = argv[i]->ptr;
        /* For the case when user specifies both "store" and "storedist" options, the
         * second key specified would override the first key. This behavior is kept 
         * the same as in georadiusCommand method.
         */
        if ((!strcasecmp(arg, "store") || !strcasecmp(arg, "storedist")) && ((i+1) < argc)) {
            stored_key = i+1;
            i++;
        }
    }
    num = 1 + (stored_key == -1 ? 0 : 1);

    /* Keys in the command come from two places:
     * argv[1] = key,
     * argv[5...n] = stored key if present
     */
    keys = zmalloc(sizeof(int) * num);

    /* Add all key positions to keys[] */
    keys[0] = 1;
    if(num > 1) {
         keys[1] = stored_key;
    }
    *numkeys = num; 
    return keys;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, (%rsp)
movl %edx, %ebp
movq %rsi, %r14
pushq $0x5
popq %r12
pushq $-0x1
popq %rbx
leaq 0x71de7(%rip), %r15     # 0xae7ee
cmpl %ebp, %r12d
jge 0x3ca4c
movslq %r12d, %rax
movq (%r14,%rax,8), %rax
movq 0x8(%rax), %r13
movq %r13, %rdi
movq %r15, %rsi
callq 0x262f0
testl %eax, %eax
je 0x3ca39
movq %r13, %rdi
leaq 0x75ec9(%rip), %rsi     # 0xb28f9
callq 0x262f0
testl %eax, %eax
jne 0x3ca47
leal 0x1(%r12), %eax
cmpl %ebp, %eax
cmovll %eax, %ebx
cmovll %eax, %r12d
incl %r12d
jmp 0x3ca07
xorl %eax, %eax
cmpl $-0x1, %ebx
setne %al
leal 0x4(,%rax,4), %edi
movl %eax, %ebp
incl %ebp
callq 0x327b9
movl $0x1, (%rax)
cmpl $-0x1, %ebx
je 0x3ca72
movl %ebx, 0x4(%rax)
movq (%rsp), %rcx
movl %ebp, (%rcx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/gplessis[P]dotdeb-redis/src/db.c
// Function: getKeysInSlot
unsigned int getKeysInSlot(unsigned int hashslot, robj **keys, unsigned int count) {
    zskiplistNode *n;
    zrangespec range;
    int j = 0;

    range.min = range.max = hashslot;
    range.minex = range.maxex = 0;

    n = zslFirstInRange(server.cluster->slots_to_keys, &range);
    while(n && n->score == hashslot && count--) {
        keys[j++] = n->obj;
        n = n->level[0].forward;
    }
    return j;
}

// Assembly:
pushq %rbp
pushq %rbx
subq $0x28, %rsp
movl %edx, %ebp
movl %edi, %eax
cvtsi2sd %rax, %xmm0
leaq 0x10(%rsp), %rax
movsd %xmm0, 0x8(%rax)
movsd %xmm0, 0x8(%rsp)
movsd %xmm0, (%rax)
andq $0x0, 0x10(%rax)
movq %rsi, %rbx
leaq 0xbcdef(%rip), %rcx     # 0xf98a8
movq 0x9b0(%rcx), %rcx
movq 0x60028(%rcx), %rdi
movq %rax, %rsi
callq 0x47d7b
movl %ebp, %edx
xorl %ecx, %ecx
testq %rax, %rax
je 0x3cafb
movsd 0x8(%rax), %xmm0
ucomisd 0x8(%rsp), %xmm0
jne 0x3cafb
jp 0x3cafb
cmpl %ecx, %edx
je 0x3cafb
movq (%rax), %rsi
movq %rsi, (%rbx,%rcx,8)
incq %rcx
movq 0x18(%rax), %rax
jmp 0x3cad3
movl %ecx, %eax
addq $0x28, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/gplessis[P]dotdeb-redis/src/db.c
// Function: delKeysInSlot
unsigned int delKeysInSlot(unsigned int hashslot) {
    zskiplistNode *n;
    zrangespec range;
    int j = 0;

    range.min = range.max = hashslot;
    range.minex = range.maxex = 0;

    n = zslFirstInRange(server.cluster->slots_to_keys, &range);
    while(n && n->score == hashslot) {
        robj *key = n->obj;
        n = n->level[0].forward; /* Go to the next item before freeing it. */
        incrRefCount(key); /* Protect the object while freeing it. */
        dbDelete(&server.db[0],key);
        decrRefCount(key);
        j++;
    }
    return j;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %edi, %eax
cvtsi2sd %rax, %xmm0
leaq 0x10(%rsp), %rsi
movsd %xmm0, 0x8(%rsi)
movsd %xmm0, 0x8(%rsp)
movsd %xmm0, (%rsi)
andq $0x0, 0x10(%rsi)
leaq 0xbcd72(%rip), %r12     # 0xf98a8
movq 0x9b0(%r12), %rax
movq 0x60028(%rax), %rdi
callq 0x47d7b
movq %rax, %r14
xorl %ebx, %ebx
testq %r14, %r14
je 0x3cb8c
movsd 0x8(%r14), %xmm0
ucomisd 0x8(%rsp), %xmm0
jne 0x3cb8c
jp 0x3cb8c
movq (%r14), %r15
movq 0x18(%r14), %r14
movq %r15, %rdi
callq 0x39e74
movq 0x28(%r12), %rdi
movq %r15, %rsi
callq 0x3b1df
movq %r15, %rdi
callq 0x3a265
incl %ebx
jmp 0x3cb4f
movl %ebx, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/gplessis[P]dotdeb-redis/src/db.c
// Function: countKeysInSlot
unsigned int countKeysInSlot(unsigned int hashslot) {
    zskiplist *zsl = server.cluster->slots_to_keys;
    zskiplistNode *zn;
    zrangespec range;
    int rank, count = 0;

    range.min = range.max = hashslot;
    range.minex = range.maxex = 0;

    /* Find first element in range */
    zn = zslFirstInRange(zsl, &range);

    /* Use rank of first element, if any, to determine preliminary count */
    if (zn != NULL) {
        rank = zslGetRank(zsl, zn->score, zn->obj);
        count = (zsl->length - (rank - 1));

        /* Find last element in range */
        zn = zslLastInRange(zsl, &range);

        /* Use rank of last element, if any, to determine the actual count */
        if (zn != NULL) {
            rank = zslGetRank(zsl, zn->score, zn->obj);
            count -= (zsl->length - rank);
        }
    }
    return count;
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x18, %rsp
leaq 0xbcd00(%rip), %rax     # 0xf98a8
movq 0x9b0(%rax), %rax
movq 0x60028(%rax), %rbx
movl %edi, %eax
cvtsi2sd %rax, %xmm0
movq %rsp, %rsi
movsd %xmm0, 0x8(%rsi)
movsd %xmm0, (%rsi)
andq $0x0, 0x10(%rsi)
movq %rbx, %rdi
callq 0x47d7b
testq %rax, %rax
je 0x3cc28
movsd 0x8(%rax), %xmm0
movq (%rax), %rsi
movq %rbx, %rdi
callq 0x48176
movq 0x10(%rbx), %rcx
subq %rax, %rcx
movabsq $-0xffffffff, %r14      # imm = 0xFFFFFFFF00000001
addq %rcx, %r14
movq %rsp, %rsi
movq %rbx, %rdi
callq 0x47e31
testq %rax, %rax
je 0x3cc2b
movsd 0x8(%rax), %xmm0
movq (%rax), %rsi
movq %rbx, %rdi
callq 0x48176
addl %eax, %r14d
subl 0x10(%rbx), %r14d
jmp 0x3cc2b
xorl %r14d, %r14d
movl %r14d, %eax
addq $0x18, %rsp
popq %rbx
popq %r14
retq
nop
// File: /workspace/github_c_makefile_star2_O2/gplessis[P]dotdeb-redis/src/replication.c
// Function: replicationGetSlaveName
char *replicationGetSlaveName(client *c) {
    static char buf[NET_PEER_ID_LEN];
    char ip[NET_IP_STR_LEN];

    ip[0] = '\0';
    buf[0] = '\0';
    if (c->slave_ip[0] != '\0' ||
        anetPeerToString(c->fd,ip,sizeof(ip),NULL) != -1)
    {
        /* Note that the 'ip' buffer is always larger than 'c->slave_ip' */
        if (c->slave_ip[0] != '\0') memcpy(ip,c->slave_ip,sizeof(c->slave_ip));

        if (c->slave_listening_port)
            anetFormatAddr(buf,sizeof(buf),ip,c->slave_listening_port);
        else
            snprintf(buf,sizeof(buf),"%s:<unknown-slave-port>",ip);
    } else {
        snprintf(buf,sizeof(buf),"client id #%llu",
            (unsigned long long) c->id);
    }
    return buf;
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x38, %rsp
movq %rdi, %rbx
xorl %eax, %eax
movb %al, (%rsp)
movb %al, 0xd1513(%rip)      # 0x10e160
leaq 0x118(%rdi), %r14
cmpb %al, 0x118(%rdi)
je 0x3cc96
movups (%r14), %xmm0
movups 0x10(%r14), %xmm1
movups 0x1e(%r14), %xmm2
movups %xmm2, 0x1e(%rsp)
movaps %xmm1, 0x10(%rsp)
movaps %xmm0, (%rsp)
movl 0x114(%rbx), %ecx
leaq 0xd14db(%rip), %rdi     # 0x10e160
testl %ecx, %ecx
je 0x3ccb3
pushq $0x4e
popq %rsi
movq %rsp, %rdx
callq 0x29e9c
jmp 0x3ccdd
movl 0x8(%rbx), %edi
movq %rsp, %rsi
pushq $0x2e
popq %rdx
xorl %ecx, %ecx
callq 0x29db9
cmpl $-0x1, %eax
je 0x3ccc2
cmpb $0x0, (%r14)
jne 0x3cc5c
jmp 0x3cc78
leaq 0x75c8e(%rip), %rdx     # 0xb2948
pushq $0x4e
popq %rsi
movq %rsp, %rcx
jmp 0x3ccd6
movq (%rbx), %rcx
leaq 0xd1494(%rip), %rdi     # 0x10e160
leaq 0x75c8d(%rip), %rdx     # 0xb2960
pushq $0x4e
popq %rsi
xorl %eax, %eax
callq 0x26120
leaq 0xd147c(%rip), %rax     # 0x10e160
addq $0x38, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/gplessis[P]dotdeb-redis/src/replication.c
// Function: createReplicationBacklog
void createReplicationBacklog(void) {
    serverAssert(server.repl_backlog == NULL);
    server.repl_backlog = zmalloc(server.repl_backlog_size);
    server.repl_backlog_histlen = 0;
    server.repl_backlog_idx = 0;
    /* When a new backlog buffer is created, we increment the replication
     * offset by one to make sure we'll not be able to PSYNC with any
     * previous slave. This is needed because we avoid incrementing the
     * master_repl_offset if no backlog exists nor slaves are attached. */
    server.master_repl_offset++;

    /* We don't have any data inside our buffer, but virtually the first
     * byte we have is the next byte that will be generated for the
     * replication stream. */
    server.repl_backlog_off = server.master_repl_offset+1;
}

// Assembly:
pushq %rbx
leaq 0xbcbb4(%rip), %rbx     # 0xf98a8
cmpq $0x0, 0x7d0(%rbx)
jne 0x3cd3a
movq 0x7d8(%rbx), %rdi
callq 0x327b9
movq %rax, 0x7d0(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x7e0(%rbx)
movq 0x7c0(%rbx), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x7c0(%rbx)
addq $0x2, %rax
movq %rax, 0x7f0(%rbx)
popq %rbx
retq
leaq 0x75c2f(%rip), %rdi     # 0xb2970
leaq 0x75c44(%rip), %rsi     # 0xb298c
pushq $0x4e
popq %rdx
callq 0x57ac8
pushq $0x1
popq %rdi
callq 0x263c0
// File: /workspace/github_c_makefile_star2_O2/gplessis[P]dotdeb-redis/src/replication.c
// Function: resizeReplicationBacklog
void resizeReplicationBacklog(long long newsize) {
    if (newsize < CONFIG_REPL_BACKLOG_MIN_SIZE)
        newsize = CONFIG_REPL_BACKLOG_MIN_SIZE;
    if (server.repl_backlog_size == newsize) return;

    server.repl_backlog_size = newsize;
    if (server.repl_backlog != NULL) {
        /* What we actually do is to flush the old buffer and realloc a new
         * empty one. It will refill with new data incrementally.
         * The reason is that copying a few gigabytes adds latency and even
         * worse often we need to alloc additional space before freeing the
         * old buffer. */
        zfree(server.repl_backlog);
        server.repl_backlog = zmalloc(server.repl_backlog_size);
        server.repl_backlog_histlen = 0;
        server.repl_backlog_idx = 0;
        /* Next byte we have is... the next since the buffer is empty. */
        server.repl_backlog_off = server.master_repl_offset+1;
    }
}

// Assembly:
pushq %rbx
cmpq $0x4001, %rdi           # imm = 0x4001
movl $0x4000, %eax           # imm = 0x4000
cmovgeq %rdi, %rax
leaq 0xbcb38(%rip), %rbx     # 0xf98a8
cmpq %rax, 0x7d8(%rbx)
je 0x3cdbf
movq %rax, 0x7d8(%rbx)
movq 0x7d0(%rbx), %rdi
testq %rdi, %rdi
je 0x3cdbf
callq 0x328f9
movq 0x7d8(%rbx), %rdi
callq 0x327b9
movq %rax, 0x7d0(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x7e0(%rbx)
movq 0x7c0(%rbx), %rax
incq %rax
movq %rax, 0x7f0(%rbx)
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/gplessis[P]dotdeb-redis/src/replication.c
// Function: feedReplicationBacklog
void feedReplicationBacklog(void *ptr, size_t len) {
    unsigned char *p = ptr;

    server.master_repl_offset += len;

    /* This is a circular buffer, so write as much data we can at every
     * iteration and rewind the "idx" index if we reach the limit. */
    while(len) {
        size_t thislen = server.repl_backlog_size - server.repl_backlog_idx;
        if (thislen > len) thislen = len;
        memcpy(server.repl_backlog+server.repl_backlog_idx,p,thislen);
        server.repl_backlog_idx += thislen;
        if (server.repl_backlog_idx == server.repl_backlog_size)
            server.repl_backlog_idx = 0;
        len -= thislen;
        p += thislen;
        server.repl_backlog_histlen += thislen;
    }
    if (server.repl_backlog_histlen > server.repl_backlog_size)
        server.repl_backlog_histlen = server.repl_backlog_size;
    /* Set the offset of the first byte we have in the backlog. */
    server.repl_backlog_off = server.master_repl_offset -
                              server.repl_backlog_histlen + 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
movl $0x7c0, %eax            # imm = 0x7C0
addq 0xb8190(%rip), %rax     # 0xf4fb8
leaq 0xbca79(%rip), %r15     # 0xf98a8
xorl %r12d, %r12d
leaq 0x7e0(%r15), %r13
movq %rsi, %rbp
addq %r14, (%rax)
testq %rbp, %rbp
je 0x3ce95
movq 0x7d8(%r15), %r14
movq 0x7e8(%r15), %rdi
subq %rdi, %r14
cmpq %rbp, %r14
cmovaeq %rbp, %r14
addq 0x7d0(%r15), %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x26c50
movq 0x7e8(%r15), %rax
addq %r14, %rax
cmpq 0x7d8(%r15), %rax
cmoveq %r12, %rax
movq %rax, 0x7e8(%r15)
subq %r14, %rbp
addq %r14, %rbx
movq %r13, %rax
jmp 0x3ce3c
movq 0x7d8(%r15), %rcx
movq 0x7e0(%r15), %rax
cmpq %rcx, %rax
jle 0x3ceb2
movq %rcx, 0x7e0(%r15)
movq %rcx, %rax
movq 0x7c0(%r15), %rcx
subq %rax, %rcx
incq %rcx
movq %rcx, 0x7f0(%r15)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/gplessis[P]dotdeb-redis/src/replication.c
// Function: feedReplicationBacklogWithObject
void feedReplicationBacklogWithObject(robj *o) {
    char llstr[LONG_STR_SIZE];
    void *p;
    size_t len;

    if (o->encoding == OBJ_ENCODING_INT) {
        len = ll2string(llstr,sizeof(llstr),(long)o->ptr);
        p = llstr;
    } else {
        len = sdslen(o->ptr);
        p = o->ptr;
    }
    feedReplicationBacklog(p,len);
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x18, %rsp
movl $0xf0, %eax
andl (%rdi), %eax
movq 0x8(%rdi), %rbx
cmpl $0x10, %eax
jne 0x3cf05
movq %rsp, %r14
pushq $0x15
popq %rsi
movq %r14, %rdi
movq %rbx, %rdx
callq 0x39796
movslq %eax, %rsi
movq %r14, %rbx
jmp 0x3cf10
movq %rbx, %rdi
callq 0x3cf20
movq %rax, %rsi
movq %rbx, %rdi
callq 0x3ce0b
addq $0x18, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/gplessis[P]dotdeb-redis/src/replication.c
// Function: replicationSetupSlaveForFullResync
int replicationSetupSlaveForFullResync(client *slave, long long offset) {
    char buf[128];
    int buflen;

    slave->psync_initial_offset = offset;
    slave->replstate = SLAVE_STATE_WAIT_BGSAVE_END;
    /* We are going to accumulate the incremental changes for this
     * slave as well. Set slaveseldb to -1 in order to force to re-emit
     * a SLEECT statement in the replication stream. */
    server.slaveseldb = -1;

    /* Don't send this reply to slaves that approached us with
     * the old SYNC command. */
    if (!(slave->flags & CLIENT_PRE_PSYNC)) {
        buflen = snprintf(buf,sizeof(buf),"+FULLRESYNC %s %lld\r\n",
                          server.runid,offset);
        if (write(slave->fd,buf,buflen) != buflen) {
            freeClientAsync(slave);
            return C_ERR;
        }
    }
    return C_OK;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x88, %rsp
movq %rsi, 0xe0(%rdi)
movl $0x7, 0xa0(%rdi)
leaq 0xbc385(%rip), %rcx     # 0xf98a8
orl $-0x1, 0x7bc(%rcx)
xorl %ebp, %ebp
testb $0x1, 0x9a(%rdi)
jne 0x3d57b
movq %rsi, %r8
movq %rdi, %rbx
addq $0x70, %rcx
leaq 0x7560a(%rip), %rdx     # 0xb2b50
xorl %ebp, %ebp
movq %rsp, %r14
movl $0x80, %esi
movq %r14, %rdi
xorl %eax, %eax
callq 0x26120
movl 0x8(%rbx), %edi
movslq %eax, %r15
movq %r14, %rsi
movq %r15, %rdx
callq 0x26bb0
cmpq %r15, %rax
je 0x3d57b
movq %rbx, %rdi
callq 0x378cf
pushq $-0x1
popq %rbp
movl %ebp, %eax
addq $0x88, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/gplessis[P]dotdeb-redis/src/replication.c
// Function: refreshGoodSlavesCount
void refreshGoodSlavesCount(void) {
    listIter li;
    listNode *ln;
    int good = 0;

    if (!server.repl_min_slaves_to_write ||
        !server.repl_min_slaves_max_lag) return;

    listRewind(server.slaves,&li);
    while((ln = listNext(&li))) {
        client *slave = ln->value;
        time_t lag = server.unixtime - slave->repl_ack_time;

        if (slave->replstate == SLAVE_STATE_ONLINE &&
            lag <= server.repl_min_slaves_max_lag) good++;
    }
    server.repl_good_slaves_count = good;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
leaq 0xbc120(%rip), %r14     # 0xf98a8
cmpl $0x0, 0x808(%r14)
je 0x3d7f2
cmpl $0x0, 0x80c(%r14)
je 0x3d7f2
movq 0x1e0(%r14), %rdi
movq %rsp, %rbx
movq %rbx, %rsi
callq 0x2702c
xorl %ebp, %ebp
movq %rbx, %rdi
callq 0x27046
testq %rax, %rax
je 0x3d7eb
movq 0x10(%rax), %rax
cmpl $0x9, 0xa0(%rax)
jne 0x3d7b0
movq 0x978(%r14), %rcx
subq 0xd8(%rax), %rcx
movslq 0x80c(%r14), %rax
xorl %edx, %edx
cmpq %rax, %rcx
setle %dl
addl %edx, %ebp
jmp 0x3d7b0
movl %ebp, 0x810(%r14)
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/gplessis[P]dotdeb-redis/src/replication.c
// Function: putSlaveOnline
void putSlaveOnline(client *slave) {
    slave->replstate = SLAVE_STATE_ONLINE;
    slave->repl_put_online_on_ack = 0;
    slave->repl_ack_time = server.unixtime; /* Prevent false timeout. */
    if (aeCreateFileEvent(server.el, slave->fd, AE_WRITABLE,
        sendReplyToClient, slave) == AE_ERR) {
        serverLog(LL_WARNING,"Unable to register writable event for slave bulk transfer: %s", strerror(errno));
        freeClient(slave);
        return;
    }
    refreshGoodSlavesCount();
    serverLog(LL_NOTICE,"Synchronization with slave %s succeeded",
        replicationGetSlaveName(slave));
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movq $0x9, 0xa0(%rdi)
leaq 0xbba8e(%rip), %rax     # 0xf98a8
movq 0x978(%rax), %rcx
movq %rcx, 0xd8(%rdi)
movq 0x40(%rax), %rdi
movl 0x8(%rbx), %esi
leaq -0x62eb(%rip), %rcx     # 0x37b4b
pushq $0x2
popq %rdx
movq %rbx, %r8
callq 0x28ae8
cmpl $-0x1, %eax
je 0x3de6c
callq 0x3d779
movq %rbx, %rdi
callq 0x3cc38
leaq 0x751b3(%rip), %rsi     # 0xb300d
leaq 0xd02ff(%rip), %rdx     # 0x10e160
pushq $0x2
popq %rdi
xorl %eax, %eax
popq %rbx
jmp 0x2b699
callq 0x26880
movl (%rax), %edi
callq 0x26680
leaq 0x75150(%rip), %rsi     # 0xb2fcf
pushq $0x3
popq %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x2b699
movq %rbx, %rdi
popq %rbx
jmp 0x37527
// File: /workspace/github_c_makefile_star2_O2/gplessis[P]dotdeb-redis/src/replication.c
// Function: replicationSendAck
void replicationSendAck(void) {
    client *c = server.master;

    if (c != NULL) {
        c->flags |= CLIENT_MASTER_FORCE_REPLY;
        addReplyMultiBulkLen(c,3);
        addReplyBulkCString(c,"REPLCONF");
        addReplyBulkCString(c,"ACK");
        addReplyBulkLongLong(c,c->reploff);
        c->flags &= ~CLIENT_MASTER_FORCE_REPLY;
    }
}

// Assembly:
pushq %rbx
leaq 0xbba0b(%rip), %rax     # 0xf98a8
movq 0x838(%rax), %rbx
testq %rbx, %rbx
je 0x3deef
orb $0x20, 0x99(%rbx)
pushq $0x3
popq %rsi
movq %rbx, %rdi
callq 0x370d9
leaq 0x70c19(%rip), %rsi     # 0xaeadb
movq %rbx, %rdi
callq 0x36f5d
leaq 0x70c16(%rip), %rsi     # 0xaeae7
movq %rbx, %rdi
callq 0x36f5d
movq 0xc8(%rbx), %rsi
movq %rbx, %rdi
callq 0x37206
andb $-0x21, 0x99(%rbx)
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/gplessis[P]dotdeb-redis/src/replication.c
// Function: replicationSendNewlineToMaster
void replicationSendNewlineToMaster(void) {
    static time_t newline_sent;
    if (time(NULL) != newline_sent) {
        newline_sent = time(NULL);
        if (write(server.repl_transfer_s,"\n",1) == -1) {
            /* Pinging back in this stage is best-effort. */
        }
    }
}

// Assembly:
pushq %rax
xorl %edi, %edi
callq 0x26cd0
cmpq 0xcfef7(%rip), %rax     # 0x10e1b0
jne 0x3e2bd
popq %rax
retq
xorl %edi, %edi
callq 0x26cd0
movq %rax, 0xcfee5(%rip)     # 0x10e1b0
leaq 0xbb5d6(%rip), %rax     # 0xf98a8
movl 0x868(%rax), %edi
leaq 0x72ada(%rip), %rsi     # 0xb0db9
pushq $0x1
popq %rdx
popq %rax
jmp 0x26bb0
// File: /workspace/github_c_makefile_star2_O2/gplessis[P]dotdeb-redis/src/replication.c
// Function: replicationCreateMasterClient
void replicationCreateMasterClient(int fd) {
    server.master = createClient(fd);
    server.master->flags |= CLIENT_MASTER;
    server.master->authenticated = 1;
    server.repl_state = REPL_STATE_CONNECTED;
    server.master->reploff = server.repl_master_initial_offset;
    memcpy(server.master->replrunid, server.repl_master_runid,
        sizeof(server.repl_master_runid));
    /* If master offset is set to -1, this master is old and is not
     * PSYNC capable, so we flag it accordingly. */
    if (server.master->reploff == -1)
        server.master->flags |= CLIENT_PRE_PSYNC;
}

// Assembly:
pushq %rax
callq 0x36144
leaq 0xbb5ae(%rip), %rcx     # 0xf98a8
movq %rax, 0x838(%rcx)
orb $0x2, 0x98(%rax)
movl $0x1, 0x9c(%rax)
movl $0xf, 0x84c(%rcx)
movq 0x8d8(%rcx), %rdx
movq %rdx, 0xc8(%rax)
movups 0x8a8(%rcx), %xmm0
movups 0x8b8(%rcx), %xmm1
movups 0x8c1(%rcx), %xmm2
movups %xmm2, 0x101(%rax)
movups %xmm1, 0xf8(%rax)
movups %xmm0, 0xe8(%rax)
movq 0x838(%rcx), %rax
cmpq $-0x1, 0xc8(%rax)
jne 0x3e36c
orb $0x1, 0x9a(%rax)
popq %rax
retq
// File: /workspace/github_c_makefile_star2_O2/gplessis[P]dotdeb-redis/src/replication.c
// Function: cancelReplicationHandshake
int cancelReplicationHandshake(void) {
    if (server.repl_state == REPL_STATE_TRANSFER) {
        replicationAbortSyncTransfer();
        server.repl_state = REPL_STATE_CONNECT;
    } else if (server.repl_state == REPL_STATE_CONNECTING ||
               slaveIsInHandshakeState())
    {
        undoConnectWithMaster();
        server.repl_state = REPL_STATE_CONNECT;
    } else {
        return 0;
    }
    return 1;
}

// Assembly:
pushq %rbx
leaq 0xbb01e(%rip), %rbx     # 0xf98a8
movl 0x84c(%rbx), %ecx
cmpl $0x2, %ecx
je 0x3e8ab
cmpl $0xe, %ecx
jne 0x3e8a1
callq 0x3f615
jmp 0x3e8b0
addl $-0xe, %ecx
xorl %eax, %eax
cmpl $-0xb, %ecx
jb 0x3e8bd
callq 0x3f5de
movl $0x1, 0x84c(%rbx)
pushq $0x1
popq %rax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/gplessis[P]dotdeb-redis/src/replication.c
// Function: replicationDiscardCachedMaster
void replicationDiscardCachedMaster(void) {
    if (server.cached_master == NULL) return;

    serverLog(LL_NOTICE,"Discarding previously cached master state.");
    server.cached_master->flags &= ~CLIENT_MASTER;
    freeClient(server.cached_master);
    server.cached_master = NULL;
}

// Assembly:
pushq %rbx
leaq 0xbaaef(%rip), %rbx     # 0xf98a8
cmpq $0x0, 0x840(%rbx)
je 0x3edef
leaq 0x74f19(%rip), %rsi     # 0xb3ce3
pushq $0x2
popq %rdi
xorl %eax, %eax
callq 0x2b699
movq 0x840(%rbx), %rdi
andl $-0x3, 0x98(%rdi)
callq 0x37527
andq $0x0, 0x840(%rbx)
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/gplessis[P]dotdeb-redis/src/replication.c
// Function: replicationResurrectCachedMaster
void replicationResurrectCachedMaster(int newfd) {
    server.master = server.cached_master;
    server.cached_master = NULL;
    server.master->fd = newfd;
    server.master->flags &= ~(CLIENT_CLOSE_AFTER_REPLY|CLIENT_CLOSE_ASAP);
    server.master->authenticated = 1;
    server.master->lastinteraction = server.unixtime;
    server.repl_state = REPL_STATE_CONNECTED;

    /* Re-add to the list of clients. */
    listAddNodeTail(server.clients,server.master);
    if (aeCreateFileEvent(server.el, newfd, AE_READABLE,
                          readQueryFromClient, server.master)) {
        serverLog(LL_WARNING,"Error resurrecting the cached master, impossible to add the readable handler: %s", strerror(errno));
        freeClientAsync(server.master); /* Close ASAP. */
    }

    /* We may also need to install the write handler as well if there is
     * pending data in the write buffers. */
    if (clientHasPendingReplies(server.master)) {
        if (aeCreateFileEvent(server.el, newfd, AE_WRITABLE,
                          sendReplyToClient, server.master)) {
            serverLog(LL_WARNING,"Error resurrecting the cached master, impossible to add the writable handler: %s", strerror(errno));
            freeClientAsync(server.master); /* Close ASAP. */
        }
    }
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movl %edi, %ebx
leaq 0xbaaaa(%rip), %r14     # 0xf98a8
movq 0x840(%r14), %rsi
movq %rsi, 0x838(%r14)
andq $0x0, 0x840(%r14)
movl %edi, 0x8(%rsi)
andl $0xfffffbbf, 0x98(%rsi) # imm = 0xFFFFFBBF
movl $0x1, 0x9c(%rsi)
movq 0x978(%r14), %rax
movq %rax, 0x88(%rsi)
movl $0xf, 0x84c(%r14)
movq 0x1c8(%r14), %rdi
callq 0x26ecc
movq 0x40(%r14), %rdi
movq 0x838(%r14), %r8
leaq -0x8b31(%rip), %rcx     # 0x36331
pushq $0x1
popq %rdx
movl %ebx, %esi
callq 0x28ae8
testl %eax, %eax
je 0x3ee9c
callq 0x26880
movl (%rax), %edi
callq 0x26680
leaq 0x74e8b(%rip), %rsi     # 0xb3d0e
pushq $0x3
popq %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x2b699
movq 0x838(%r14), %rdi
callq 0x378cf
movq 0x838(%r14), %rdi
callq 0x3655e
testl %eax, %eax
je 0x3eeff
movq 0x40(%r14), %rdi
movq 0x838(%r14), %r8
leaq -0x7373(%rip), %rcx     # 0x37b4b
pushq $0x2
popq %rdx
movl %ebx, %esi
callq 0x28ae8
testl %eax, %eax
je 0x3eeff
callq 0x26880
movl (%rax), %edi
callq 0x26680
leaq 0x74e80(%rip), %rsi     # 0xb3d5f
pushq $0x3
popq %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x2b699
movq 0x838(%r14), %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x378cf
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/gplessis[P]dotdeb-redis/src/replication.c
// Function: connectWithMaster
int connectWithMaster(void) {
    int fd;

    fd = anetTcpNonBlockBestEffortBindConnect(NULL,
        server.masterhost,server.masterport,NET_FIRST_BIND_ADDR);
    if (fd == -1) {
        serverLog(LL_WARNING,"Unable to connect to MASTER: %s",
            strerror(errno));
        return C_ERR;
    }

    if (aeCreateFileEvent(server.el,fd,AE_READABLE|AE_WRITABLE,syncWithMaster,NULL) ==
            AE_ERR)
    {
        close(fd);
        serverLog(LL_WARNING,"Can't create readable event for SYNC");
        return C_ERR;
    }

    server.repl_transfer_lastio = server.unixtime;
    server.repl_transfer_s = fd;
    server.repl_state = REPL_STATE_CONNECTING;
    return C_OK;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
leaq 0xba385(%rip), %r15     # 0xf98a8
movq 0x828(%r15), %rsi
movl 0x830(%r15), %edx
cmpl $0x0, 0x128(%r15)
movl $0x0, %ecx
je 0x3f547
movq 0xa8(%r15), %rcx
xorl %edi, %edi
callq 0x2986a
cmpl $-0x1, %eax
je 0x3f597
movl %eax, %ebx
movq 0x40(%r15), %rdi
leaq -0x659(%rip), %rcx      # 0x3ef07
xorl %r14d, %r14d
pushq $0x3
popq %rdx
movl %eax, %esi
xorl %r8d, %r8d
callq 0x28ae8
cmpl $-0x1, %eax
je 0x3f5b9
movq 0x978(%r15), %rax
movq %rax, 0x878(%r15)
movl %ebx, 0x868(%r15)
movl $0x2, 0x84c(%r15)
jmp 0x3f5d5
callq 0x26880
movl (%rax), %edi
callq 0x26680
leaq 0x74531(%rip), %rsi     # 0xb3adb
pushq $0x3
popq %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x2b699
jmp 0x3f5d1
movl %ebx, %edi
callq 0x26180
leaq 0x74534(%rip), %rsi     # 0xb3afb
pushq $0x3
popq %rdi
xorl %eax, %eax
callq 0x2b699
pushq $-0x1
popq %r14
movl %r14d, %eax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/gplessis[P]dotdeb-redis/src/replication.c
// Function: undoConnectWithMaster
void undoConnectWithMaster(void) {
    int fd = server.repl_transfer_s;

    aeDeleteFileEvent(server.el,fd,AE_READABLE|AE_WRITABLE);
    close(fd);
    server.repl_transfer_s = -1;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
leaq 0xba2bf(%rip), %r14     # 0xf98a8
movl 0x868(%r14), %ebx
movq 0x40(%r14), %rdi
pushq $0x3
popq %rdx
movl %ebx, %esi
callq 0x28ba8
movl %ebx, %edi
callq 0x26180
orl $-0x1, 0x868(%r14)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/gplessis[P]dotdeb-redis/src/replication.c
// Function: replicationAbortSyncTransfer
void replicationAbortSyncTransfer(void) {
    serverAssert(server.repl_state == REPL_STATE_TRANSFER);
    undoConnectWithMaster();
    close(server.repl_transfer_fd);
    unlink(server.repl_transfer_tmpfile);
    zfree(server.repl_transfer_tmpfile);
}

// Assembly:
pushq %rbx
leaq 0xba28b(%rip), %rbx     # 0xf98a8
cmpl $0xe, 0x84c(%rbx)
jne 0x3f64f
callq 0x3f5de
movl 0x86c(%rbx), %edi
callq 0x26180
movq 0x870(%rbx), %rdi
callq 0x263b0
movq 0x870(%rbx), %rdi
popq %rbx
jmp 0x328f9
leaq 0x744ca(%rip), %rdi     # 0xb3b20
leaq 0x7332f(%rip), %rsi     # 0xb298c
movl $0x6a0, %edx            # imm = 0x6A0
callq 0x57ac8
pushq $0x1
popq %rdi
callq 0x263c0
// File: /workspace/github_c_makefile_star2_O2/gplessis[P]dotdeb-redis/src/replication.c
// Function: replicationSetMaster
void replicationSetMaster(char *ip, int port) {
    sdsfree(server.masterhost);
    server.masterhost = sdsnew(ip);
    server.masterport = port;
    if (server.master) freeClient(server.master);
    disconnectAllBlockedClients(); /* Clients blocked in master, now slave. */
    disconnectSlaves(); /* Force our slaves to resync with us as well. */
    replicationDiscardCachedMaster(); /* Don't try a PSYNC. */
    freeReplicationBacklog(); /* Don't allow our chained slaves to PSYNC. */
    cancelReplicationHandshake();
    server.repl_state = REPL_STATE_CONNECT;
    server.master_repl_offset = 0;
    server.repl_down_since = 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movl %esi, %ebx
movq %rdi, %r14
leaq 0xba228(%rip), %r15     # 0xf98a8
movq 0x828(%r15), %rdi
callq 0x311c8
movq %r14, %rdi
callq 0x3115a
movq %rax, 0x828(%r15)
movl %ebx, 0x830(%r15)
movq 0x838(%r15), %rdi
testq %rdi, %rdi
je 0x3f6b3
callq 0x37527
callq 0x7024c
callq 0x37501
callq 0x3edb1
callq 0x3cdc1
callq 0x3e882
movl $0x1, 0x84c(%r15)
andq $0x0, 0x7c0(%r15)
andq $0x0, 0x888(%r15)
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/gplessis[P]dotdeb-redis/src/replication.c
// Function: replicationUnsetMaster
void replicationUnsetMaster(void) {
    if (server.masterhost == NULL) return; /* Nothing to do. */
    sdsfree(server.masterhost);
    server.masterhost = NULL;
    if (server.master) {
        if (listLength(server.slaves) == 0) {
            /* If this instance is turned into a master and there are no
             * slaves, it inherits the replication offset from the master.
             * Under certain conditions this makes replicas comparable by
             * replication offset to understand what is the most updated. */
            server.master_repl_offset = server.master->reploff;
            freeReplicationBacklog();
        }
        freeClient(server.master);
    }
    replicationDiscardCachedMaster();
    cancelReplicationHandshake();
    server.repl_state = REPL_STATE_NONE;
}

// Assembly:
pushq %rbx
leaq 0xba1b3(%rip), %rbx     # 0xf98a8
movq 0x828(%rbx), %rdi
testq %rdi, %rdi
je 0x3f758
callq 0x311c8
andq $0x0, 0x828(%rbx)
movq 0x838(%rbx), %rdi
testq %rdi, %rdi
je 0x3f747
movq 0x1e0(%rbx), %rax
cmpq $0x0, 0x28(%rax)
jne 0x3f742
movq 0xc8(%rdi), %rax
movq %rax, 0x7c0(%rbx)
callq 0x3cdc1
movq 0x838(%rbx), %rdi
callq 0x37527
callq 0x3edb1
callq 0x3e882
andl $0x0, 0x84c(%rbx)
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/gplessis[P]dotdeb-redis/src/replication.c
// Function: replicationCacheMaster
void replicationCacheMaster(client *c) {
    serverAssert(server.master != NULL && server.cached_master == NULL);
    serverLog(LL_NOTICE,"Caching the disconnected master state.");

    /* Unlink the client from the server structures. */
    unlinkClient(c);

    /* Save the master. Server.master will be set to null later by
     * replicationHandleMasterDisconnection(). */
    server.cached_master = server.master;

    /* Invalidate the Peer ID cache. */
    if (c->peerid) {
        sdsfree(c->peerid);
        c->peerid = NULL;
    }

    /* Caching the master happens instead of the actual freeClient() call,
     * so make sure to adjust the replication state. This function will
     * also set server.master to NULL. */
    replicationHandleMasterDisconnection();
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
leaq 0xb9d84(%rip), %r14     # 0xf98a8
cmpq $0x0, 0x838(%r14)
je 0x3fba4
cmpq $0x0, 0x840(%r14)
jne 0x3fba4
movq %rdi, %rbx
leaq 0x7417a(%rip), %rsi     # 0xb3cbc
pushq $0x2
popq %rdi
xorl %eax, %eax
callq 0x2b699
movq %rbx, %rdi
callq 0x37763
movq 0x838(%r14), %rax
movq %rax, 0x840(%r14)
movq 0x1b8(%rbx), %rdi
testq %rdi, %rdi
je 0x3fb7b
callq 0x311c8
andq $0x0, 0x1b8(%rbx)
andq $0x0, 0x838(%r14)
movl $0x1, 0x84c(%r14)
movq 0x978(%r14), %rax
movq %rax, 0x888(%r14)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
leaq 0x740db(%rip), %rdi     # 0xb3c86
leaq 0x72dda(%rip), %rsi     # 0xb298c
movl $0x776, %edx            # imm = 0x776
callq 0x57ac8
pushq $0x1
popq %rdi
callq 0x263c0
// File: /workspace/github_c_makefile_star2_O2/gplessis[P]dotdeb-redis/src/replication.c
// Function: replicationScriptCacheAdd
void replicationScriptCacheAdd(sds sha1) {
    int retval;
    sds key = sdsdup(sha1);

    /* Evict oldest. */
    if (listLength(server.repl_scriptcache_fifo) == server.repl_scriptcache_size)
    {
        listNode *ln = listLast(server.repl_scriptcache_fifo);
        sds oldest = listNodeValue(ln);

        retval = dictDelete(server.repl_scriptcache_dict,oldest);
        serverAssert(retval == DICT_OK);
        listDelNode(server.repl_scriptcache_fifo,ln);
    }

    /* Add current. */
    retval = dictAdd(server.repl_scriptcache_dict,key,NULL);
    listAddNodeHead(server.repl_scriptcache_fifo,key);
    serverAssert(retval == DICT_OK);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
callq 0x3117b
movq %rax, %rbx
leaq 0xb9c99(%rip), %r15     # 0xf98a8
movq 0x8e8(%r15), %rax
movl 0x8f0(%r15), %ecx
cmpq %rcx, 0x28(%rax)
jne 0x3fc4a
movq 0x8(%rax), %r14
movq 0x10(%r14), %rsi
movq 0x8e0(%r15), %rdi
callq 0x2a6dc
testl %eax, %eax
jne 0x3fc90
movq 0x8e8(%r15), %rdi
movq %r14, %rsi
callq 0x26fa8
movq 0x8e0(%r15), %rdi
movq %rbx, %rsi
xorl %edx, %edx
callq 0x2a3ed
movl %eax, %ebp
movq 0x8e8(%r15), %rdi
movq %rbx, %rsi
callq 0x26e75
testl %ebp, %ebp
jne 0x3fc7b
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x72aaa(%rip), %rdi     # 0xb272c
leaq 0x72d03(%rip), %rsi     # 0xb298c
movl $0x81c, %edx            # imm = 0x81C
jmp 0x3fca3
leaq 0x72a95(%rip), %rdi     # 0xb272c
leaq 0x72cee(%rip), %rsi     # 0xb298c
movl $0x815, %edx            # imm = 0x815
callq 0x57ac8
pushq $0x1
popq %rdi
callq 0x263c0
// File: /workspace/github_c_makefile_star2_O2/gplessis[P]dotdeb-redis/src/replication.c
// Function: replicationCountAcksByOffset
int replicationCountAcksByOffset(long long offset) {
    listIter li;
    listNode *ln;
    int count = 0;

    listRewind(server.slaves,&li);
    while((ln = listNext(&li))) {
        client *slave = ln->value;

        if (slave->replstate != SLAVE_STATE_ONLINE) continue;
        if (slave->repl_ack_off >= offset) count++;
    }
    return count;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
leaq 0xb9bb1(%rip), %rax     # 0xf98a8
movq 0x1e0(%rax), %rdi
movq %rsp, %r14
movq %r14, %rsi
callq 0x2702c
xorl %ebp, %ebp
movq %r14, %rdi
callq 0x27046
testq %rax, %rax
je 0x3fd35
movq 0x10(%rax), %rax
cmpl $0x9, 0xa0(%rax)
jne 0x3fd0b
xorl %ecx, %ecx
cmpq %rbx, 0xd0(%rax)
setge %cl
addl %ecx, %ebp
jmp 0x3fd0b
movl %ebp, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/gplessis[P]dotdeb-redis/src/replication.c
// Function: waitCommand
void waitCommand(client *c) {
    mstime_t timeout;
    long numreplicas, ackreplicas;
    long long offset = c->woff;

    /* Argument parsing. */
    if (getLongFromObjectOrReply(c,c->argv[1],&numreplicas,NULL) != C_OK)
        return;
    if (getTimeoutFromObjectOrReply(c,c->argv[2],&timeout,UNIT_MILLISECONDS)
        != C_OK) return;

    /* First try without blocking at all. */
    ackreplicas = replicationCountAcksByOffset(c->woff);
    if (ackreplicas >= numreplicas || c->flags & CLIENT_MULTI) {
        addReplyLongLong(c,ackreplicas);
        return;
    }

    /* Otherwise block the client and put it into our list of clients
     * waiting for ack from slaves. */
    c->bpop.timeout = timeout;
    c->bpop.reploffset = offset;
    c->bpop.numreplicas = numreplicas;
    listAddNodeTail(server.clients_waiting_acks,c);
    blockClient(c,BLOCKED_WAIT);

    /* Make sure that the server will send an ACK request to all the slaves
     * before returning to the event loop. */
    replicationRequestAckFromSlaves();
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
movq 0x40(%rdi), %rax
movq 0x198(%rdi), %r14
movq 0x8(%rax), %rsi
leaq 0x8(%rsp), %rdx
xorl %ecx, %ecx
callq 0x3ab5e
testl %eax, %eax
jne 0x3fdfa
movq 0x40(%rbx), %rax
movq 0x10(%rax), %rsi
leaq 0x10(%rsp), %rdx
pushq $0x1
popq %rcx
movq %rbx, %rdi
callq 0x7001c
testl %eax, %eax
jne 0x3fdfa
movq 0x198(%rbx), %rdi
callq 0x3fce5
movslq %eax, %rsi
movq 0x8(%rsp), %rax
cmpq %rsi, %rax
jle 0x3fdf2
testb $0x8, 0x98(%rbx)
jne 0x3fdf2
movq 0x10(%rsp), %rcx
movq %rcx, 0x170(%rbx)
movq %r14, 0x190(%rbx)
movl %eax, 0x188(%rbx)
leaq 0xb9add(%rip), %r14     # 0xf98a8
movq 0x8f8(%r14), %rdi
movq %rbx, %rsi
callq 0x26ecc
pushq $0x2
popq %rsi
movq %rbx, %rdi
callq 0x7008e
movl $0x1, 0x900(%r14)
jmp 0x3fdfa
movq %rbx, %rdi
callq 0x370a6
addq $0x18, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/gplessis[P]dotdeb-redis/src/replication.c
// Function: processClientsWaitingReplicas
void processClientsWaitingReplicas(void) {
    long long last_offset = 0;
    int last_numreplicas = 0;

    listIter li;
    listNode *ln;

    listRewind(server.clients_waiting_acks,&li);
    while((ln = listNext(&li))) {
        client *c = ln->value;

        /* Every time we find a client that is satisfied for a given
         * offset and number of replicas, we remember it so the next client
         * may be unblocked without calling replicationCountAcksByOffset()
         * if the requested offset / replicas were equal or less. */
        if (last_offset && last_offset > c->bpop.reploffset &&
                           last_numreplicas > c->bpop.numreplicas)
        {
            unblockClient(c);
            addReplyLongLong(c,last_numreplicas);
        } else {
            int numreplicas = replicationCountAcksByOffset(c->bpop.reploffset);

            if (numreplicas >= c->bpop.numreplicas) {
                last_offset = c->bpop.reploffset;
                last_numreplicas = numreplicas;
                unblockClient(c);
                addReplyLongLong(c,numreplicas);
            }
        }
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x18, %rsp
leaq 0xb9a48(%rip), %rax     # 0xf98a8
movq 0x8f8(%rax), %rdi
leaq 0x8(%rsp), %rbx
movq %rbx, %rsi
callq 0x2702c
xorl %r15d, %r15d
xorl %r12d, %r12d
movq %rbx, %rdi
callq 0x27046
testq %rax, %rax
je 0x3feda
testq %r12, %r12
setne %cl
movq 0x10(%rax), %r14
movq 0x190(%r14), %rdi
cmpq %rdi, %r12
setg %al
andb %cl, %al
cmpb $0x1, %al
jne 0x3fead
cmpl 0x188(%r14), %r15d
jg 0x3fec5
callq 0x3fce5
cmpl 0x188(%r14), %eax
jl 0x3fe7a
movq 0x190(%r14), %r12
movl %eax, %r15d
movq %r14, %rdi
callq 0x70160
movslq %r15d, %rsi
movq %r14, %rdi
callq 0x370a6
jmp 0x3fe7a
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/gplessis[P]dotdeb-redis/src/replication.c
// Function: replicationGetSlaveOffset
long long replicationGetSlaveOffset(void) {
    long long offset = 0;

    if (server.masterhost != NULL) {
        if (server.master) {
            offset = server.master->reploff;
        } else if (server.cached_master) {
            offset = server.cached_master->reploff;
        }
    }
    /* offset may be -1 when the master does not support it at all, however
     * this function is designed to return an offset that can express the
     * amount of data processed by the master, so we return a positive
     * integer. */
    if (offset < 0) offset = 0;
    return offset;
}

// Assembly:
leaq 0xb99bb(%rip), %rcx     # 0xf98a8
cmpq $0x0, 0x828(%rcx)
je 0x3ff18
movq 0x838(%rcx), %rax
testq %rax, %rax
jne 0x3ff0f
movq 0x840(%rcx), %rax
testq %rax, %rax
je 0x3ff18
movq 0xc8(%rax), %rcx
jmp 0x3ff1a
xorl %ecx, %ecx
xorl %eax, %eax
testq %rcx, %rcx
cmovgq %rcx, %rax
retq
// File: /workspace/github_c_makefile_star2_O2/gplessis[P]dotdeb-redis/src/rdb.c
// Function: rdbCheckThenExit
void rdbCheckThenExit(int linenum, char *reason, ...) {
    va_list ap;
    char msg[1024];
    int len;

    len = snprintf(msg,sizeof(msg),
        "Internal error in RDB reading function at rdb.c:%d -> ", linenum);
    va_start(ap,reason);
    vsnprintf(msg+len,sizeof(msg)-len,reason,ap);
    va_end(ap);

    if (!rdbCheckMode) {
        serverLog(LL_WARNING, "%s", msg);
        char *argv[2] = {"",server.rdb_filename};
        redis_check_rdb_main(2,argv);
    } else {
        rdbCheckError("%s",msg);
    }
    exit(1);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x4e0, %rsp            # imm = 0x4E0
movq %rsi, %rbx
movl %edi, %r10d
leaq 0x30(%rsp), %r15
movq %rdx, 0x10(%r15)
movq %rcx, 0x18(%r15)
movq %r8, 0x20(%r15)
movq %r9, 0x28(%r15)
testb %al, %al
je 0x4036d
movaps %xmm0, 0x60(%rsp)
movaps %xmm1, 0x70(%rsp)
movaps %xmm2, 0x80(%rsp)
movaps %xmm3, 0x90(%rsp)
movaps %xmm4, 0xa0(%rsp)
movaps %xmm5, 0xb0(%rsp)
movaps %xmm6, 0xc0(%rsp)
movaps %xmm7, 0xd0(%rsp)
leaq 0x73cd4(%rip), %rdx     # 0xb4048
leaq 0xe0(%rsp), %rdi
movl $0x400, %r14d           # imm = 0x400
movl $0x400, %esi            # imm = 0x400
movl %r10d, %ecx
xorl %eax, %eax
callq 0x26120
movabsq $0x3000000010, %rdx     # imm = 0x3000000010
leaq 0x10(%rsp), %rcx
movq %rdx, (%rcx)
leaq 0x500(%rsp), %rdx
movq %rdx, 0x8(%rcx)
movq %r15, 0x10(%rcx)
cltq
leaq (%rsp,%rax), %rdi
addq $0xe0, %rdi
subq %rax, %r14
movq %r14, %rsi
movq %rbx, %rdx
callq 0x26810
leaq 0xce5bb(%rip), %rax     # 0x10e990
cmpl $0x0, (%rax)
jne 0x4041c
leaq 0x7d1e5(%rip), %rsi     # 0xbd5c6
pushq $0x3
popq %rdi
leaq 0xe0(%rsp), %rdx
xorl %eax, %eax
callq 0x2b699
leaq 0x7200b(%rip), %rax     # 0xb2405
movq %rsp, %rsi
movq %rax, (%rsi)
leaq 0xb94a1(%rip), %rax     # 0xf98a8
movq 0x748(%rax), %rax
movq %rax, 0x8(%rsi)
pushq $0x2
popq %rdi
callq 0x73837
jmp 0x40432
leaq 0x7d1a3(%rip), %rdi     # 0xbd5c6
leaq 0xe0(%rsp), %rsi
xorl %eax, %eax
callq 0x7309d
pushq $0x1
popq %rdi
callq 0x262c0
// File: /workspace/github_c_makefile_star2_O2/gplessis[P]dotdeb-redis/src/./rio.h
// Function: rioRead
static inline size_t rioRead(rio *r, void *buf, size_t len) {
    while (len) {
        size_t bytes_to_read = (r->max_processing_chunk && r->max_processing_chunk < len) ? r->max_processing_chunk : len;
        if (r->read(r,buf,bytes_to_read) == 0)
            return 0;
        if (r->update_cksum) r->update_cksum(r,buf,bytes_to_read);
        buf = (char*)buf + bytes_to_read;
        len -= bytes_to_read;
        r->processed_bytes += bytes_to_read;
    }
    return 1;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %r12
pushq $0x1
popq %rbx
testq %r14, %r14
je 0x404fd
movq 0x38(%r12), %rax
cmpq %r14, %rax
movq %r14, %r13
cmovbq %rax, %r13
testq %rax, %rax
cmoveq %r14, %r13
movq %r12, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq *(%r12)
testq %rax, %rax
je 0x404fb
movq 0x20(%r12), %rax
testq %rax, %rax
je 0x404ee
movq %r12, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq *%rax
addq %r13, %r15
subq %r13, %r14
addq %r13, 0x30(%r12)
jmp 0x404ac
xorl %ebx, %ebx
movq %rbx, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq