// File: /workspace/github_c_makefile_star2_O0/gplessis[P]dotdeb-redis/src/rdb.c
// Function: rdbSaveRio
int rdbSaveRio(rio *rdb, int *error) {
    dictIterator *di = NULL;
    dictEntry *de;
    char magic[10];
    int j;
    long long now = mstime();
    uint64_t cksum;

    if (server.rdb_checksum)
        rdb->update_cksum = rioGenericUpdateChecksum;
    snprintf(magic,sizeof(magic),"REDIS%04d",RDB_VERSION);
    if (rdbWriteRaw(rdb,magic,9) == -1) goto werr;
    if (rdbSaveInfoAuxFields(rdb) == -1) goto werr;

    for (j = 0; j < server.dbnum; j++) {
        redisDb *db = server.db+j;
        dict *d = db->dict;
        if (dictSize(d) == 0) continue;
        di = dictGetSafeIterator(d);
        if (!di) return C_ERR;

        /* Write the SELECT DB opcode */
        if (rdbSaveType(rdb,RDB_OPCODE_SELECTDB) == -1) goto werr;
        if (rdbSaveLen(rdb,j) == -1) goto werr;

        /* Write the RESIZE DB opcode. We trim the size to UINT32_MAX, which
         * is currently the largest type we are able to represent in RDB sizes.
         * However this does not limit the actual size of the DB to load since
         * these sizes are just hints to resize the hash tables. */
        uint32_t db_size, expires_size;
        db_size = (dictSize(db->dict) <= UINT32_MAX) ?
                                dictSize(db->dict) :
                                UINT32_MAX;
        expires_size = (dictSize(db->expires) <= UINT32_MAX) ?
                                dictSize(db->expires) :
                                UINT32_MAX;
        if (rdbSaveType(rdb,RDB_OPCODE_RESIZEDB) == -1) goto werr;
        if (rdbSaveLen(rdb,db_size) == -1) goto werr;
        if (rdbSaveLen(rdb,expires_size) == -1) goto werr;

        /* Iterate this DB writing every entry */
        while((de = dictNext(di)) != NULL) {
            sds keystr = dictGetKey(de);
            robj key, *o = dictGetVal(de);
            long long expire;

            initStaticStringObject(key,keystr);
            expire = getExpire(db,&key);
            if (rdbSaveKeyValuePair(rdb,&key,o,expire,now) == -1) goto werr;
        }
        dictReleaseIterator(di);
    }
    di = NULL; /* So that we don't release it again on error. */

    /* EOF opcode */
    if (rdbSaveType(rdb,RDB_OPCODE_EOF) == -1) goto werr;

    /* CRC64 checksum. It will be zero if checksum computation is disabled, the
     * loading code skips the check in this case. */
    cksum = rdb->cksum;
    memrev64ifbe(&cksum);
    if (rioWrite(rdb,&cksum,8) == 0) goto werr;
    return C_OK;

werr:
    if (error) *error = errno;
    if (di) dictReleaseIterator(di);
    return C_ERR;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
callq 0x2ff70
movq %rax, -0x40(%rbp)
leaq 0x12368d(%rip), %rax    # 0x1781d8
cmpl $0x0, 0x754(%rax)
je 0x54b63
movq -0x10(%rbp), %rax
leaq 0x39c21(%rip), %rcx     # 0x8e780
movq %rcx, 0x20(%rax)
leaq -0x32(%rbp), %rdi
movl $0xa, %esi
leaq 0xe86e7(%rip), %rdx     # 0x13d25a
movl $0x7, %ecx
movb $0x0, %al
callq 0x26120
movq -0x10(%rbp), %rdi
leaq -0x32(%rbp), %rsi
movl $0x9, %edx
callq 0x52be0
cmpl $-0x1, %eax
jne 0x54b9b
jmp 0x54e43
movq -0x10(%rbp), %rdi
callq 0x54a50
cmpl $-0x1, %eax
jne 0x54bae
jmp 0x54e43
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
leaq 0x123619(%rip), %rcx    # 0x1781d8
cmpl 0x610(%rcx), %eax
jge 0x54df7
leaq 0x123606(%rip), %rax    # 0x1781d8
movq 0x28(%rax), %rax
movslq -0x38(%rbp), %rcx
shlq $0x6, %rcx
addq %rcx, %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x58(%rbp), %rcx
addq 0x48(%rcx), %rax
cmpq $0x0, %rax
jne 0x54c0b
jmp 0x54de9
movq -0x58(%rbp), %rdi
callq 0x2e470
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x54c2b
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x54e6e
movq -0x10(%rbp), %rdi
movl $0xfe, %esi
callq 0x52bb0
cmpl $-0x1, %eax
jne 0x54c43
jmp 0x54e43
movq -0x10(%rbp), %rdi
movl -0x38(%rbp), %esi
callq 0x52e00
cmpl $-0x1, %eax
jne 0x54c59
jmp 0x54e43
movq -0x50(%rbp), %rax
movq (%rax), %rax
movq 0x28(%rax), %rax
movq -0x50(%rbp), %rcx
movq (%rcx), %rcx
addq 0x48(%rcx), %rax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpq %rcx, %rax
ja 0x54c98
movq -0x50(%rbp), %rax
movq (%rax), %rax
movq 0x28(%rax), %rax
movq -0x50(%rbp), %rcx
movq (%rcx), %rcx
addq 0x48(%rcx), %rax
movq %rax, -0x90(%rbp)
jmp 0x54ca6
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq %rax, -0x90(%rbp)
jmp 0x54ca6
movq -0x90(%rbp), %rax
movl %eax, -0x5c(%rbp)
movq -0x50(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x28(%rax), %rax
movq -0x50(%rbp), %rcx
movq 0x8(%rcx), %rcx
addq 0x48(%rcx), %rax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpq %rcx, %rax
ja 0x54cf3
movq -0x50(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x28(%rax), %rax
movq -0x50(%rbp), %rcx
movq 0x8(%rcx), %rcx
addq 0x48(%rcx), %rax
movq %rax, -0x98(%rbp)
jmp 0x54d01
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq %rax, -0x98(%rbp)
jmp 0x54d01
movq -0x98(%rbp), %rax
movl %eax, -0x60(%rbp)
movq -0x10(%rbp), %rdi
movl $0xfb, %esi
callq 0x52bb0
cmpl $-0x1, %eax
jne 0x54d23
jmp 0x54e43
movq -0x10(%rbp), %rdi
movl -0x5c(%rbp), %esi
callq 0x52e00
cmpl $-0x1, %eax
jne 0x54d39
jmp 0x54e43
movq -0x10(%rbp), %rdi
movl -0x60(%rbp), %esi
callq 0x52e00
cmpl $-0x1, %eax
jne 0x54d4f
jmp 0x54e43
jmp 0x54d51
movq -0x20(%rbp), %rdi
callq 0x2e4a0
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
je 0x54de0
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x68(%rbp)
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x80(%rbp)
movl $0x1, -0x74(%rbp)
movl -0x78(%rbp), %eax
andl $-0x10, %eax
orl $0x0, %eax
movl %eax, -0x78(%rbp)
movl -0x78(%rbp), %eax
andl $0xffffff0f, %eax       # imm = 0xFFFFFF0F
orl $0x0, %eax
movl %eax, -0x78(%rbp)
movq -0x68(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x50(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x4c430
movq %rax, -0x88(%rbp)
movq -0x10(%rbp), %rdi
movq -0x80(%rbp), %rdx
movq -0x88(%rbp), %rcx
movq -0x40(%rbp), %r8
leaq -0x78(%rbp), %rsi
callq 0x54820
cmpl $-0x1, %eax
jne 0x54ddb
jmp 0x54e43
jmp 0x54d51
movq -0x20(%rbp), %rdi
callq 0x2e600
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x54bb5
movq $0x0, -0x20(%rbp)
movq -0x10(%rbp), %rdi
movl $0xff, %esi
callq 0x52bb0
cmpl $-0x1, %eax
jne 0x54e14
jmp 0x54e43
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rdi
leaq -0x48(%rbp), %rsi
movl $0x8, %edx
callq 0x54e80
cmpq $0x0, %rax
jne 0x54e3a
jmp 0x54e43
movl $0x0, -0x4(%rbp)
jmp 0x54e6e
cmpq $0x0, -0x18(%rbp)
je 0x54e57
callq 0x26880
movl (%rax), %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
cmpq $0x0, -0x20(%rbp)
je 0x54e67
movq -0x20(%rbp), %rdi
callq 0x2e600
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0xa0, %rsp
popq %rbp
retq
nopw (%rax,%rax)