// File: /workspace/github_c_makefile_star2_O2/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 0x2596
movq 0x8(%r14), %rdi
xorl %esi, %esi
xorl %eax, %eax
callq 0x1130
testl %eax, %eax
jle 0x25ae
movl %eax, %ebx
leaq 0x8(%rsp), %rsi
movl %eax, %edi
callq 0x1160
cmpl $-0x1, %eax
je 0x25bb
movq 0x38(%rsp), %r15
pushq $0x1
popq %rcx
xorl %edi, %edi
movq %r15, %rsi
movl %ecx, %edx
movl %ebx, %r8d
xorl %r9d, %r9d
callq 0x1090
cmpq $-0x1, %rax
je 0x25c8
movq %rax, %r12
movq %rax, 0x3c48(%rip)      # 0x60e0
movq %r15, 0x3c49(%rip)      # 0x60e8
andq $0x0, 0x3c49(%rip)      # 0x60f0
andq $0x0, 0x7e39(%rip)      # 0xa2e8
movl $0x49525453, 0x7e57(%rip) # imm = 0x49525453
movl $0x474e49, 0x7e50(%rip) # imm = 0x474E49
xorl %eax, %eax
movb %al, 0x7e59(%rip)       # 0xa324
movl $0x5453494c, 0x7e4b(%rip) # imm = 0x5453494C
movl $0x544553, 0x7e51(%rip) # imm = 0x544553
movb %al, 0x7e5f(%rip)       # 0xa344
movl $0x5445535a, 0x7e51(%rip) # imm = 0x5445535A
movb %al, 0x7e5f(%rip)       # 0xa354
movl $0x48534148, 0x7e51(%rip) # imm = 0x48534148
movabsq $0x4954455249505845, %rcx # imm = 0x4954455249505845
movq %rcx, 0x8dd0(%rip)      # 0xb2e0
movl $0x454d49, 0x8dcd(%rip) # imm = 0x454D49
movabsq $0x42445443454c4553, %rcx # imm = 0x42445443454C4553
movq %rcx, 0x8dc5(%rip)      # 0xb2f0
movb %al, 0x8dc7(%rip)       # 0xb2f8
movl $0x464f45, 0x8dc5(%rip) # imm = 0x464F45
movabsq $0x7ff0000000000000, %rax # imm = 0x7FF0000000000000
movq %rax, 0x7dac(%rip)      # 0xa2f8
movabsq $-0x10000000000000, %rax # imm = 0xFFF0000000000000
movq %rax, 0x7d93(%rip)      # 0xa2f0
movabsq $0x7ff8000000000000, %rax # imm = 0x7FF8000000000000
movq %rax, 0x7d92(%rip)      # 0xa300
callq 0x2175
movq %r12, %rdi
movq %r15, %rsi
callq 0x1120
movl %ebx, %edi
callq 0x10c0
xorl %eax, %eax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq (%r14), %rsi
leaq 0xe44(%rip), %rdi       # 0x33e4
xorl %eax, %eax
callq 0x10a0
xorl %edi, %edi
callq 0x1150
movq 0x8(%r14), %rsi
leaq 0xe41(%rip), %rdi       # 0x33fa
jmp 0x25d3
movq 0x8(%r14), %rsi
leaq 0xe4a(%rip), %rdi       # 0x3410
jmp 0x25d3
movq 0x8(%r14), %rsi
leaq 0xe4e(%rip), %rdi       # 0x3421
xorl %eax, %eax
callq 0x10a0
pushq $0x1
popq %rdi
callq 0x1150
nop