// File: /workspace/github_c_makefile_star2_O0/gplessis[P]dotdeb-redis/src/memtest.c
// Function: memtest_preserving_test
int memtest_preserving_test(unsigned long *m, size_t bytes, int passes) {
    unsigned long backup[MEMTEST_BACKUP_WORDS];
    unsigned long *p = m;
    unsigned long *end = (unsigned long*) (((unsigned char*)m)+(bytes-MEMTEST_DECACHE_SIZE));
    size_t left = bytes;
    int errors = 0;

    if (bytes & 4095) return 0; /* Can't test across 4k page boundaries. */
    if (bytes < 4096*2) return 0; /* Can't test a single page. */

    while(left) {
        /* If we have to test a single final page, go back a single page
         * so that we can test two pages, since the code can't test a single
         * page but at least two. */
        if (left == 4096) {
            left += 4096;
            p -= 4096/sizeof(unsigned long);
        }

        int pass = 0;
        size_t len = (left > sizeof(backup)) ? sizeof(backup) : left;

        /* Always test an even number of pages. */
        if (len/4096 % 2) len -= 4096;

        memcpy(backup,p,len); /* Backup. */
        while(pass != passes) {
            pass++;
            errors += memtest_addressing(p,len,0);
            memtest_fill_random(p,len,0);
            if (bytes >= MEMTEST_DECACHE_SIZE) {
                memtest_compare_times(m,MEMTEST_DECACHE_SIZE,pass,1,0);
                memtest_compare_times(end,MEMTEST_DECACHE_SIZE,pass,1,0);
            }
            errors += memtest_compare_times(p,len,pass,4,0);
            memtest_fill_value(p,len,0,(unsigned long)-1,'S',0);
            if (bytes >= MEMTEST_DECACHE_SIZE) {
                memtest_compare_times(m,MEMTEST_DECACHE_SIZE,pass,1,0);
                memtest_compare_times(end,MEMTEST_DECACHE_SIZE,pass,1,0);
            }
            errors += memtest_compare_times(p,len,pass,4,0);
            memtest_fill_value(p,len,ULONG_ONEZERO,ULONG_ZEROONE,'C',0);
            if (bytes >= MEMTEST_DECACHE_SIZE) {
                memtest_compare_times(m,MEMTEST_DECACHE_SIZE,pass,1,0);
                memtest_compare_times(end,MEMTEST_DECACHE_SIZE,pass,1,0);
            }
            errors += memtest_compare_times(p,len,pass,4,0);
        }
        memcpy(p,backup,len); /* Restore. */
        left -= len;
        p += len/sizeof(unsigned long);
    }
    return errors;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x100050, %rsp         # imm = 0x100050
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x100028(%rbp)
movq -0x10(%rbp), %rax
movq -0x18(%rbp), %rcx
subq $0x2000, %rcx           # imm = 0x2000
addq %rcx, %rax
movq %rax, -0x100030(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x100038(%rbp)
movl $0x0, -0x10003c(%rbp)
movq -0x18(%rbp), %rax
andq $0xfff, %rax            # imm = 0xFFF
cmpq $0x0, %rax
je 0x8fcab
movl $0x0, -0x4(%rbp)
jmp 0x8ffed
cmpq $0x2000, -0x18(%rbp)    # imm = 0x2000
jae 0x8fcc1
movl $0x0, -0x4(%rbp)
jmp 0x8ffed
jmp 0x8fcc3
cmpq $0x0, -0x100038(%rbp)
je 0x8ffe4
cmpq $0x1000, -0x100038(%rbp) # imm = 0x1000
jne 0x8fd06
movq -0x100038(%rbp), %rax
addq $0x1000, %rax           # imm = 0x1000
movq %rax, -0x100038(%rbp)
movq -0x100028(%rbp), %rax
addq $-0x1000, %rax          # imm = 0xF000
movq %rax, -0x100028(%rbp)
movl $0x0, -0x100040(%rbp)
cmpq $0x100000, -0x100038(%rbp) # imm = 0x100000
jbe 0x8fd2b
movl $0x100000, %eax         # imm = 0x100000
movq %rax, -0x100050(%rbp)
jmp 0x8fd39
movq -0x100038(%rbp), %rax
movq %rax, -0x100050(%rbp)
movq -0x100050(%rbp), %rax
movq %rax, -0x100048(%rbp)
movq -0x100048(%rbp), %rax
shrq $0xc, %rax
andq $0x1, %rax
cmpq $0x0, %rax
je 0x8fd70
movq -0x100048(%rbp), %rax
subq $0x1000, %rax           # imm = 0x1000
movq %rax, -0x100048(%rbp)
leaq -0x100020(%rbp), %rdi
movq -0x100028(%rbp), %rsi
movq -0x100048(%rbp), %rdx
callq 0x26c60
movl -0x100040(%rbp), %eax
cmpl -0x1c(%rbp), %eax
je 0x8ff90
movl -0x100040(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x100040(%rbp)
movq -0x100028(%rbp), %rdi
movq -0x100048(%rbp), %rsi
xorl %edx, %edx
callq 0x8f430
addl -0x10003c(%rbp), %eax
movl %eax, -0x10003c(%rbp)
movq -0x100028(%rbp), %rdi
movq -0x100048(%rbp), %rsi
xorl %edx, %edx
callq 0x8f580
cmpq $0x2000, -0x18(%rbp)    # imm = 0x2000
jb 0x8fe23
movq -0x10(%rbp), %rdi
movl -0x100040(%rbp), %edx
movl $0x2000, %esi           # imm = 0x2000
movl $0x1, %ecx
xorl %r8d, %r8d
callq 0x8fa20
movq -0x100030(%rbp), %rdi
movl -0x100040(%rbp), %edx
movl $0x2000, %esi           # imm = 0x2000
movl $0x1, %ecx
xorl %r8d, %r8d
callq 0x8fa20
movq -0x100028(%rbp), %rdi
movq -0x100048(%rbp), %rsi
movl -0x100040(%rbp), %edx
movl $0x4, %ecx
xorl %r8d, %r8d
callq 0x8fa20
addl -0x10003c(%rbp), %eax
movl %eax, -0x10003c(%rbp)
movq -0x100028(%rbp), %rdi
movq -0x100048(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
movq $-0x1, %rcx
movl $0x53, %r8d
xorl %r9d, %r9d
callq 0x8f730
cmpq $0x2000, -0x18(%rbp)    # imm = 0x2000
jb 0x8febc
movq -0x10(%rbp), %rdi
movl -0x100040(%rbp), %edx
movl $0x2000, %esi           # imm = 0x2000
movl $0x1, %ecx
xorl %r8d, %r8d
callq 0x8fa20
movq -0x100030(%rbp), %rdi
movl -0x100040(%rbp), %edx
movl $0x2000, %esi           # imm = 0x2000
movl $0x1, %ecx
xorl %r8d, %r8d
callq 0x8fa20
movq -0x100028(%rbp), %rdi
movq -0x100048(%rbp), %rsi
movl -0x100040(%rbp), %edx
movl $0x4, %ecx
xorl %r8d, %r8d
callq 0x8fa20
addl -0x10003c(%rbp), %eax
movl %eax, -0x10003c(%rbp)
movq -0x100028(%rbp), %rdi
movq -0x100048(%rbp), %rsi
movabsq $-0x5555555555555556, %rdx # imm = 0xAAAAAAAAAAAAAAAA
movabsq $0x5555555555555555, %rcx # imm = 0x5555555555555555
movl $0x43, %r8d
xorl %r9d, %r9d
callq 0x8f730
cmpq $0x2000, -0x18(%rbp)    # imm = 0x2000
jb 0x8ff5e
movq -0x10(%rbp), %rdi
movl -0x100040(%rbp), %edx
movl $0x2000, %esi           # imm = 0x2000
movl $0x1, %ecx
xorl %r8d, %r8d
callq 0x8fa20
movq -0x100030(%rbp), %rdi
movl -0x100040(%rbp), %edx
movl $0x2000, %esi           # imm = 0x2000
movl $0x1, %ecx
xorl %r8d, %r8d
callq 0x8fa20
movq -0x100028(%rbp), %rdi
movq -0x100048(%rbp), %rsi
movl -0x100040(%rbp), %edx
movl $0x4, %ecx
xorl %r8d, %r8d
callq 0x8fa20
addl -0x10003c(%rbp), %eax
movl %eax, -0x10003c(%rbp)
jmp 0x8fd8a
movq -0x100028(%rbp), %rdi
leaq -0x100020(%rbp), %rsi
movq -0x100048(%rbp), %rdx
callq 0x26c60
movq -0x100048(%rbp), %rcx
movq -0x100038(%rbp), %rax
subq %rcx, %rax
movq %rax, -0x100038(%rbp)
movq -0x100048(%rbp), %rax
shrq $0x3, %rax
shlq $0x3, %rax
addq -0x100028(%rbp), %rax
movq %rax, -0x100028(%rbp)
jmp 0x8fcc3
movl -0x10003c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x100050, %rsp         # imm = 0x100050
popq %rbp
retq
nopl (%rax)