// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/redis-check-dump.c
// Function: main
int main(int argc, char **argv) {
    /* expect the first argument to be the dump file */
    if (argc <= 1) {
        printf("Usage: %s <dump.rdb>\n", argv[0]);
        exit(0);
    }

    int fd;
    off_t size;
    struct stat stat;
    void *data;

    fd = open(argv[1], O_RDONLY);
    if (fd < 1) {
        ERROR("Cannot open file: %s\n", argv[1]);
    }
    if (fstat(fd, &stat) == -1) {
        ERROR("Cannot stat: %s\n", argv[1]);
    } else {
        size = stat.st_size;
    }

    if (sizeof(size_t) == sizeof(int32_t) && size >= INT_MAX) {
        ERROR("Cannot check dump files >2GB on a 32-bit platform\n");
    }

    data = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0);
    if (data == MAP_FAILED) {
        ERROR("Cannot mmap: %s\n", argv[1]);
    }

    /* Initialize static vars */
    positions[0].data = data;
    positions[0].size = size;
    positions[0].offset = 0;
    errors.level = 0;

    /* Object types */
    sprintf(types[REDIS_STRING], "STRING");
    sprintf(types[REDIS_LIST], "LIST");
    sprintf(types[REDIS_SET], "SET");
    sprintf(types[REDIS_ZSET], "ZSET");
    sprintf(types[REDIS_HASH], "HASH");

    /* Object types only used for dumping to disk */
    sprintf(types[REDIS_EXPIRETIME], "EXPIRETIME");
    sprintf(types[REDIS_SELECTDB], "SELECTDB");
    sprintf(types[REDIS_EOF], "EOF");

    /* Double constants initialization */
    R_Zero = 0.0;
    R_PosInf = 1.0/R_Zero;
    R_NegInf = -1.0/R_Zero;
    R_Nan = R_Zero/R_Zero;

    process();

    munmap(data, size);
    close(fd);
    return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rsi, %r14
cmpl $0x1, %edi
jle 0x2c16
movq 0x8(%r14), %rdi
xorl %esi, %esi
xorl %eax, %eax
callq 0x1120
testl %eax, %eax
jle 0x2c2e
movl %eax, %ebx
leaq 0x8(%rsp), %rsi
movl %eax, %edi
callq 0x1150
cmpl $-0x1, %eax
je 0x2c3b
movq 0x38(%rsp), %r15
xorl %edi, %edi
movq %r15, %rsi
movl $0x1, %edx
movl $0x1, %ecx
movl %ebx, %r8d
xorl %r9d, %r9d
callq 0x1090
cmpq $-0x1, %rax
je 0x2c48
movq %rax, %r12
movq %rax, 0x35b6(%rip)      # 0x60d0
movq %r15, 0x35b7(%rip)      # 0x60d8
xorl %eax, %eax
movq %rax, 0x35b6(%rip)      # 0x60e0
movq %rax, 0x77a7(%rip)      # 0xa2d8
movl $0x49525453, 0x77c5(%rip) # imm = 0x49525453
movl $0x474e49, 0x77be(%rip) # imm = 0x474E49
movb %al, 0x77c9(%rip)       # 0xa314
movl $0x5453494c, 0x77bb(%rip) # imm = 0x5453494C
movl $0x544553, 0x77c1(%rip) # imm = 0x544553
movb %al, 0x77cf(%rip)       # 0xa334
movl $0x5445535a, 0x77c1(%rip) # imm = 0x5445535A
movb %al, 0x77cf(%rip)       # 0xa344
movl $0x48534148, 0x77c1(%rip) # imm = 0x48534148
movabsq $0x4954455249505845, %rcx # imm = 0x4954455249505845
movq %rcx, 0x8740(%rip)      # 0xb2d0
movl $0x454d49, 0x873d(%rip) # imm = 0x454D49
movabsq $0x42445443454c4553, %rcx # imm = 0x42445443454C4553
movq %rcx, 0x8735(%rip)      # 0xb2e0
movb %al, 0x8737(%rip)       # 0xb2e8
movl $0x464f45, 0x8735(%rip) # imm = 0x464F45
movabsq $0x7ff0000000000000, %rax # imm = 0x7FF0000000000000
movq %rax, 0x771c(%rip)      # 0xa2e8
movabsq $-0x10000000000000, %rax # imm = 0xFFF0000000000000
movq %rax, 0x7703(%rip)      # 0xa2e0
movabsq $0x7ff8000000000000, %rax # imm = 0x7FF8000000000000
movq %rax, 0x7702(%rip)      # 0xa2f0
callq 0x274c
movq %r12, %rdi
movq %r15, %rsi
callq 0x1110
movl %ebx, %edi
callq 0x10c0
xorl %eax, %eax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq (%r14), %rsi
leaq 0x78c(%rip), %rdi       # 0x33ac
xorl %eax, %eax
callq 0x10a0
xorl %edi, %edi
callq 0x1140
movq 0x8(%r14), %rsi
leaq 0x789(%rip), %rdi       # 0x33c2
jmp 0x2c53
movq 0x8(%r14), %rsi
leaq 0x792(%rip), %rdi       # 0x33d8
jmp 0x2c53
movq 0x8(%r14), %rsi
leaq 0x796(%rip), %rdi       # 0x33e9
xorl %eax, %eax
callq 0x10a0
movl $0x1, %edi
callq 0x1140