// File: /workspace/github_c_makefile_star2_O3/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 0x2bd1
movq 0x8(%r14), %rdi
xorl %esi, %esi
xorl %eax, %eax
callq 0x1120
testl %eax, %eax
jle 0x2be9
movl %eax, %ebx
leaq 0x8(%rsp), %rsi
movl %eax, %edi
callq 0x1150
cmpl $-0x1, %eax
je 0x2bf6
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 0x2c03
movq %rax, %r12
movq %rax, 0x35fb(%rip)      # 0x60d0
movq %r15, 0x35fc(%rip)      # 0x60d8
xorl %eax, %eax
movq %rax, 0x35fb(%rip)      # 0x60e0
movq %rax, 0x77ec(%rip)      # 0xa2d8
movl $0x49525453, 0x780a(%rip) # imm = 0x49525453
movl $0x474e49, 0x7803(%rip) # imm = 0x474E49
movb %al, 0x780e(%rip)       # 0xa314
movl $0x5453494c, 0x7800(%rip) # imm = 0x5453494C
movl $0x544553, 0x7806(%rip) # imm = 0x544553
movb %al, 0x7814(%rip)       # 0xa334
movl $0x5445535a, 0x7806(%rip) # imm = 0x5445535A
movb %al, 0x7814(%rip)       # 0xa344
movl $0x48534148, 0x7806(%rip) # imm = 0x48534148
movabsq $0x4954455249505845, %rcx # imm = 0x4954455249505845
movq %rcx, 0x8785(%rip)      # 0xb2d0
movl $0x454d49, 0x8782(%rip) # imm = 0x454D49
movabsq $0x42445443454c4553, %rcx # imm = 0x42445443454C4553
movq %rcx, 0x877a(%rip)      # 0xb2e0
movb %al, 0x877c(%rip)       # 0xb2e8
movl $0x464f45, 0x877a(%rip) # imm = 0x464F45
movabsq $0x7ff0000000000000, %rax # imm = 0x7FF0000000000000
movq %rax, 0x7761(%rip)      # 0xa2e8
movabsq $-0x10000000000000, %rax # imm = 0xFFF0000000000000
movq %rax, 0x7748(%rip)      # 0xa2e0
movabsq $0x7ff8000000000000, %rax # imm = 0x7FF8000000000000
movq %rax, 0x7747(%rip)      # 0xa2f0
callq 0x270d
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 0x809(%rip), %rdi       # 0x33e4
xorl %eax, %eax
callq 0x10a0
xorl %edi, %edi
callq 0x1140
movq 0x8(%r14), %rsi
leaq 0x806(%rip), %rdi       # 0x33fa
jmp 0x2c0e
movq 0x8(%r14), %rsi
leaq 0x80f(%rip), %rdi       # 0x3410
jmp 0x2c0e
movq 0x8(%r14), %rsi
leaq 0x813(%rip), %rdi       # 0x3421
xorl %eax, %eax
callq 0x10a0
movl $0x1, %edi
callq 0x1140
nop