// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/redis-check-dump.c
// Function: process
void process() {
    uint64_t num_errors = 0, num_valid_ops = 0, num_valid_bytes = 0;
    entry entry;
    int dump_version = processHeader();

    /* Exclude the final checksum for RDB >= 5. Will be checked at the end. */
    if (dump_version >= 5) {
        if (positions[0].size < 8) {
            printf("RDB version >= 5 but no room for checksum.\n");
            exit(1);
        }
        positions[0].size -= 8;;
    }

    level = 1;
    while(positions[0].offset < positions[0].size) {
        positions[1] = positions[0];

        entry = loadEntry();
        if (!entry.success) {
            printValid(num_valid_ops, num_valid_bytes);
            printErrorStack(&entry);
            num_errors++;
            num_valid_ops = 0;
            num_valid_bytes = 0;

            /* search for next valid entry */
            uint64_t offset = positions[0].offset + 1;
            int i = 0;

            while (!entry.success && offset < positions[0].size) {
                positions[1].offset = offset;

                /* find 3 consecutive valid entries */
                for (i = 0; i < 3; i++) {
                    entry = loadEntry();
                    if (!entry.success) break;
                }
                /* check if we found 3 consecutive valid entries */
                if (i < 3) {
                    offset++;
                }
            }

            /* print how many bytes we have skipped to find a new valid opcode */
            if (offset < positions[0].size) {
                printSkipped(offset - positions[0].offset, offset);
            }

            positions[0].offset = offset;
        } else {
            num_valid_ops++;
            num_valid_bytes += positions[1].offset - positions[0].offset;

            /* advance position */
            positions[0] = positions[1];
        }
        free(entry.key);
    }

    /* because there is another potential error,
     * print how many valid ops we have processed */
    printValid(num_valid_ops, num_valid_bytes);

    /* expect an eof */
    if (entry.type != REDIS_EOF) {
        /* last byte should be EOF, add error */
        errors.level = 0;
        SHIFT_ERROR(positions[0].offset, "Expected EOF, got %s", types[entry.type]);

        /* this is an EOF error so reset type */
        entry.type = -1;
        printErrorStack(&entry);

        num_errors++;
    }

    /* Verify checksum */
    if (dump_version >= 5) {
        uint64_t crc = crc64(0,positions[0].data,positions[0].size);
        uint64_t crc2;
        unsigned char *p = (unsigned char*)positions[0].data+positions[0].size;
        crc2 = ((uint64_t)p[0] << 0) |
               ((uint64_t)p[1] << 8) |
               ((uint64_t)p[2] << 16) |
               ((uint64_t)p[3] << 24) |
               ((uint64_t)p[4] << 32) |
               ((uint64_t)p[5] << 40) |
               ((uint64_t)p[6] << 48) |
               ((uint64_t)p[7] << 56);
        if (crc != crc2) {
            SHIFT_ERROR(positions[0].offset, "RDB CRC64 does not match.");
        } else {
            printf("CRC64 checksum is OK\n");
        }
    }

    /* print summary on errors */
    if (num_errors) {
        printf("\n");
        printf("Total unprocessable opcodes: %llu\n",
            (unsigned long long) num_errors);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq $0x0, -0x8(%rbp)
movq $0x0, -0x10(%rbp)
movq $0x0, -0x18(%rbp)
callq 0x1390
movl %eax, -0x2c(%rbp)
cmpl $0x5, -0x2c(%rbp)
jl 0x2b25
cmpq $0x8, 0x45df(%rip)      # 0x70d8
jae 0x2b13
leaq 0x189b(%rip), %rdi      # 0x439d
movb $0x0, %al
callq 0x1080
movl $0x1, %edi
callq 0x1130
movq 0x45be(%rip), %rax      # 0x70d8
subq $0x8, %rax
movq %rax, 0x45b3(%rip)      # 0x70d8
movb $0x1, 0x4724(%rip)      # 0x7250
movq 0x45ad(%rip), %rax      # 0x70e0
cmpq 0x459e(%rip), %rax      # 0x70d8
jae 0x2ce7
movq 0x4589(%rip), %rax      # 0x70d0
movq %rax, 0x459a(%rip)      # 0x70e8
movq 0x4583(%rip), %rax      # 0x70d8
movq %rax, 0x4594(%rip)      # 0x70f0
movq 0x457d(%rip), %rax      # 0x70e0
movq %rax, 0x458e(%rip)      # 0x70f8
callq 0x23d0
movq %rax, -0x40(%rbp)
movq %rdx, -0x38(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x20(%rbp)
cmpb $0x0, -0x1c(%rbp)
jne 0x2c8d
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x2850
leaq -0x28(%rbp), %rdi
callq 0x28f0
movq -0x8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x8(%rbp)
movq $0x0, -0x10(%rbp)
movq $0x0, -0x18(%rbp)
movq 0x4516(%rip), %rax      # 0x70e0
addq $0x1, %rax
movq %rax, -0x48(%rbp)
movl $0x0, -0x4c(%rbp)
xorl %eax, %eax
cmpb $0x0, -0x1c(%rbp)
movb %al, -0x79(%rbp)
jne 0x2bf5
movq -0x48(%rbp), %rax
cmpq 0x44e9(%rip), %rax      # 0x70d8
setb %al
movb %al, -0x79(%rbp)
movb -0x79(%rbp), %al
testb $0x1, %al
jne 0x2bfe
jmp 0x2c5f
movq -0x48(%rbp), %rax
movq %rax, 0x44ef(%rip)      # 0x70f8
movl $0x0, -0x4c(%rbp)
cmpl $0x3, -0x4c(%rbp)
jge 0x2c48
callq 0x23d0
movq %rax, -0x60(%rbp)
movq %rdx, -0x58(%rbp)
movq -0x60(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x58(%rbp), %rax
movq %rax, -0x20(%rbp)
cmpb $0x0, -0x1c(%rbp)
jne 0x2c3b
jmp 0x2c48
jmp 0x2c3d
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x2c10
cmpl $0x3, -0x4c(%rbp)
jge 0x2c5a
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
jmp 0x2bd9
movq -0x48(%rbp), %rax
cmpq 0x446e(%rip), %rax      # 0x70d8
jae 0x2c80
movq -0x48(%rbp), %rdi
subq 0x4469(%rip), %rdi      # 0x70e0
movq -0x48(%rbp), %rsi
callq 0x28a0
movq -0x48(%rbp), %rax
movq %rax, 0x4455(%rip)      # 0x70e0
jmp 0x2cd9
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
movq 0x4458(%rip), %rax      # 0x70f8
subq 0x4439(%rip), %rax      # 0x70e0
addq -0x18(%rbp), %rax
movq %rax, -0x18(%rbp)
movq 0x4432(%rip), %rax      # 0x70e8
movq %rax, 0x4413(%rip)      # 0x70d0
movq 0x442c(%rip), %rax      # 0x70f0
movq %rax, 0x440d(%rip)      # 0x70d8
movq 0x4426(%rip), %rax      # 0x70f8
movq %rax, 0x4407(%rip)      # 0x70e0
movq -0x28(%rbp), %rdi
callq 0x1030
jmp 0x2b2c
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x2850
cmpl $0xff, -0x20(%rbp)
je 0x2d8c
movq $0x0, 0x85cc(%rip) # 0xb2d8
movq 0x85c5(%rip), %rax      # 0xb2d8
leaq 0x453e(%rip), %rdi      # 0x7258
shlq $0xa, %rax
addq %rax, %rdi
movslq -0x20(%rbp), %rax
leaq 0x85d4(%rip), %rdx      # 0xb300
shlq $0x4, %rax
addq %rax, %rdx
leaq 0x168f(%rip), %rsi      # 0x43c9
movb $0x0, %al
callq 0x1120
movq 0x4398(%rip), %rdx      # 0x70e0
movq 0x8589(%rip), %rcx      # 0xb2d8
leaq 0x4502(%rip), %rax      # 0x7258
movq %rdx, 0x4000(%rax,%rcx,8)
movq 0x8573(%rip), %rax      # 0xb2d8
addq $0x1, %rax
movq %rax, 0x8568(%rip)      # 0xb2d8
movl $0xffffffff, -0x20(%rbp) # imm = 0xFFFFFFFF
leaq -0x28(%rbp), %rdi
callq 0x28f0
movq -0x8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x8(%rbp)
cmpl $0x5, -0x2c(%rbp)
jl 0x2ea9
movq 0x4333(%rip), %rsi      # 0x70d0
movq 0x4334(%rip), %rdx      # 0x70d8
xorl %eax, %eax
movl %eax, %edi
callq 0x3f10
movq %rax, -0x68(%rbp)
movq 0x4318(%rip), %rax      # 0x70d0
addq 0x4319(%rip), %rax      # 0x70d8
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rax
movzbl (%rax), %eax
shlq $0x0, %rax
movq -0x78(%rbp), %rcx
movzbl 0x1(%rcx), %ecx
shlq $0x8, %rcx
orq %rcx, %rax
movq -0x78(%rbp), %rcx
movzbl 0x2(%rcx), %ecx
shlq $0x10, %rcx
orq %rcx, %rax
movq -0x78(%rbp), %rcx
movzbl 0x3(%rcx), %ecx
shlq $0x18, %rcx
orq %rcx, %rax
movq -0x78(%rbp), %rcx
movzbl 0x4(%rcx), %ecx
shlq $0x20, %rcx
orq %rcx, %rax
movq -0x78(%rbp), %rcx
movzbl 0x5(%rcx), %ecx
shlq $0x28, %rcx
orq %rcx, %rax
movq -0x78(%rbp), %rcx
movzbl 0x6(%rcx), %ecx
shlq $0x30, %rcx
orq %rcx, %rax
movq -0x78(%rbp), %rcx
movzbl 0x7(%rcx), %ecx
shlq $0x38, %rcx
orq %rcx, %rax
movq %rax, -0x70(%rbp)
movq -0x68(%rbp), %rax
cmpq -0x70(%rbp), %rax
je 0x2e99
movq 0x848c(%rip), %rax      # 0xb2d8
leaq 0x4405(%rip), %rdi      # 0x7258
shlq $0xa, %rax
addq %rax, %rdi
leaq 0x157d(%rip), %rsi      # 0x43de
movb $0x0, %al
callq 0x1120
movq 0x4271(%rip), %rdx      # 0x70e0
movq 0x8462(%rip), %rcx      # 0xb2d8
leaq 0x43db(%rip), %rax      # 0x7258
movq %rdx, 0x4000(%rax,%rcx,8)
movq 0x844c(%rip), %rax      # 0xb2d8
addq $0x1, %rax
movq %rax, 0x8441(%rip)      # 0xb2d8
jmp 0x2ea7
leaq 0x1558(%rip), %rdi      # 0x43f8
movb $0x0, %al
callq 0x1080
jmp 0x2ea9
cmpq $0x0, -0x8(%rbp)
je 0x2ed0
leaq 0x1510(%rip), %rdi      # 0x43c7
movb $0x0, %al
callq 0x1080
movq -0x8(%rbp), %rsi
leaq 0x1545(%rip), %rdi      # 0x440e
movb $0x0, %al
callq 0x1080
addq $0x80, %rsp
popq %rbp
retq
nopl (%rax)