// File: /workspace/github_c_makefile_star2_O0/erikdubbelboer[P]discnt/src/debug.c
// Function: memtest_test_linux_anonymous_maps
int memtest_test_linux_anonymous_maps(void) {
    FILE *fp = fopen("/proc/self/maps","r");
    char line[1024];
    size_t start_addr, end_addr, size;
    size_t start_vect[MEMTEST_MAX_REGIONS];
    size_t size_vect[MEMTEST_MAX_REGIONS];
    int regions = 0, j;
    uint64_t crc1 = 0, crc2 = 0, crc3 = 0;

    while(fgets(line,sizeof(line),fp) != NULL) {
        char *start, *end, *p = line;

        start = p;
        p = strchr(p,'-');
        if (!p) continue;
        *p++ = '\0';
        end = p;
        p = strchr(p,' ');
        if (!p) continue;
        *p++ = '\0';
        if (strstr(p,"stack") ||
            strstr(p,"vdso") ||
            strstr(p,"vsyscall")) continue;
        if (!strstr(p,"00:00")) continue;
        if (!strstr(p,"rw")) continue;

        start_addr = strtoul(start,NULL,16);
        end_addr = strtoul(end,NULL,16);
        size = end_addr-start_addr;

        start_vect[regions] = start_addr;
        size_vect[regions] = size;
        printf("Testing %lx %lu\n", (unsigned long) start_vect[regions],
                                    (unsigned long) size_vect[regions]);
        regions++;
    }

    /* Test all the regions as an unique sequential region.
     * 1) Take the CRC64 of the memory region. */
    for (j = 0; j < regions; j++) {
        crc1 = crc64(crc1,(void*)start_vect[j],size_vect[j]);
    }

    /* 2) Invert bits, swap adjacent words, swap again, invert bits.
     * This is the error amplification step. */
    for (j = 0; j < regions; j++)
        memtest_non_destructive_invert((void*)start_vect[j],size_vect[j]);
    for (j = 0; j < regions; j++)
        memtest_non_destructive_swap((void*)start_vect[j],size_vect[j]);
    for (j = 0; j < regions; j++)
        memtest_non_destructive_swap((void*)start_vect[j],size_vect[j]);
    for (j = 0; j < regions; j++)
        memtest_non_destructive_invert((void*)start_vect[j],size_vect[j]);

    /* 3) Take the CRC64 sum again. */
    for (j = 0; j < regions; j++)
        crc2 = crc64(crc2,(void*)start_vect[j],size_vect[j]);

    /* 4) Swap + Swap again */
    for (j = 0; j < regions; j++)
        memtest_non_destructive_swap((void*)start_vect[j],size_vect[j]);
    for (j = 0; j < regions; j++)
        memtest_non_destructive_swap((void*)start_vect[j],size_vect[j]);

    /* 5) Take the CRC64 sum again. */
    for (j = 0; j < regions; j++)
        crc3 = crc64(crc3,(void*)start_vect[j],size_vect[j]);

    /* NOTE: It is very important to close the file descriptor only now
     * because closing it before may result into unmapping of some memory
     * region that we are testing. */
    fclose(fp);

    /* If the two CRC are not the same, we trapped a memory error. */
    return crc1 != crc2 || crc2 != crc3;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc70, %rsp            # imm = 0xC70
leaq 0x7659b(%rip), %rdi     # 0xa6efd
leaq 0x74c98(%rip), %rsi     # 0xa5601
callq 0x124e0
movq %rax, -0x8(%rbp)
movl $0x0, -0xc34(%rbp)
movq $0x0, -0xc40(%rbp)
movq $0x0, -0xc48(%rbp)
movq $0x0, -0xc50(%rbp)
leaq -0x410(%rbp), %rdi
movq -0x8(%rbp), %rdx
movl $0x400, %esi            # imm = 0x400
callq 0x12450
cmpq $0x0, %rax
je 0x30ba6
leaq -0x410(%rbp), %rax
movq %rax, -0xc68(%rbp)
movq -0xc68(%rbp), %rax
movq %rax, -0xc58(%rbp)
movq -0xc68(%rbp), %rdi
movl $0x2d, %esi
callq 0x122a0
movq %rax, -0xc68(%rbp)
cmpq $0x0, -0xc68(%rbp)
jne 0x309fc
jmp 0x3099d
movq -0xc68(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0xc68(%rbp)
movb $0x0, (%rax)
movq -0xc68(%rbp), %rax
movq %rax, -0xc60(%rbp)
movq -0xc68(%rbp), %rdi
movl $0x20, %esi
callq 0x122a0
movq %rax, -0xc68(%rbp)
cmpq $0x0, -0xc68(%rbp)
jne 0x30a49
jmp 0x3099d
movq -0xc68(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0xc68(%rbp)
movb $0x0, (%rax)
movq -0xc68(%rbp), %rdi
leaq 0x7649e(%rip), %rsi     # 0xa6f0d
callq 0x12960
cmpq $0x0, %rax
jne 0x30aac
movq -0xc68(%rbp), %rdi
leaq 0x7648b(%rip), %rsi     # 0xa6f13
callq 0x12960
cmpq $0x0, %rax
jne 0x30aac
movq -0xc68(%rbp), %rdi
leaq 0x76477(%rip), %rsi     # 0xa6f18
callq 0x12960
cmpq $0x0, %rax
je 0x30ab1
jmp 0x3099d
movq -0xc68(%rbp), %rdi
leaq 0x76462(%rip), %rsi     # 0xa6f21
callq 0x12960
cmpq $0x0, %rax
jne 0x30acf
jmp 0x3099d
movq -0xc68(%rbp), %rdi
leaq 0x7644a(%rip), %rsi     # 0xa6f27
callq 0x12960
cmpq $0x0, %rax
jne 0x30aed
jmp 0x3099d
movq -0xc58(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0x10, %edx
callq 0x127e0
movq %rax, -0x418(%rbp)
movq -0xc60(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0x10, %edx
callq 0x127e0
movq %rax, -0x420(%rbp)
movq -0x420(%rbp), %rax
subq -0x418(%rbp), %rax
movq %rax, -0x428(%rbp)
movq -0x418(%rbp), %rcx
movslq -0xc34(%rbp), %rax
movq %rcx, -0x830(%rbp,%rax,8)
movq -0x428(%rbp), %rcx
movslq -0xc34(%rbp), %rax
movq %rcx, -0xc30(%rbp,%rax,8)
movslq -0xc34(%rbp), %rax
movq -0x830(%rbp,%rax,8), %rsi
movslq -0xc34(%rbp), %rax
movq -0xc30(%rbp,%rax,8), %rdx
leaq 0x7639f(%rip), %rdi     # 0xa6f2a
movb $0x0, %al
callq 0x122b0
movl -0xc34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc34(%rbp)
jmp 0x3099d
movl $0x0, -0xc38(%rbp)
movl -0xc38(%rbp), %eax
cmpl -0xc34(%rbp), %eax
jge 0x30c00
movq -0xc40(%rbp), %rdi
movslq -0xc38(%rbp), %rax
movq -0x830(%rbp,%rax,8), %rsi
movslq -0xc38(%rbp), %rax
movq -0xc30(%rbp,%rax,8), %rdx
callq 0x37460
movq %rax, -0xc40(%rbp)
movl -0xc38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc38(%rbp)
jmp 0x30bb0
movl $0x0, -0xc38(%rbp)
movl -0xc38(%rbp), %eax
cmpl -0xc34(%rbp), %eax
jge 0x30c4c
movslq -0xc38(%rbp), %rax
movq -0x830(%rbp,%rax,8), %rdi
movslq -0xc38(%rbp), %rax
movq -0xc30(%rbp,%rax,8), %rsi
callq 0x372e0
movl -0xc38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc38(%rbp)
jmp 0x30c0a
movl $0x0, -0xc38(%rbp)
movl -0xc38(%rbp), %eax
cmpl -0xc34(%rbp), %eax
jge 0x30c98
movslq -0xc38(%rbp), %rax
movq -0x830(%rbp,%rax,8), %rdi
movslq -0xc38(%rbp), %rax
movq -0xc30(%rbp,%rax,8), %rsi
callq 0x37340
movl -0xc38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc38(%rbp)
jmp 0x30c56
movl $0x0, -0xc38(%rbp)
movl -0xc38(%rbp), %eax
cmpl -0xc34(%rbp), %eax
jge 0x30ce4
movslq -0xc38(%rbp), %rax
movq -0x830(%rbp,%rax,8), %rdi
movslq -0xc38(%rbp), %rax
movq -0xc30(%rbp,%rax,8), %rsi
callq 0x37340
movl -0xc38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc38(%rbp)
jmp 0x30ca2
movl $0x0, -0xc38(%rbp)
movl -0xc38(%rbp), %eax
cmpl -0xc34(%rbp), %eax
jge 0x30d30
movslq -0xc38(%rbp), %rax
movq -0x830(%rbp,%rax,8), %rdi
movslq -0xc38(%rbp), %rax
movq -0xc30(%rbp,%rax,8), %rsi
callq 0x372e0
movl -0xc38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc38(%rbp)
jmp 0x30cee
movl $0x0, -0xc38(%rbp)
movl -0xc38(%rbp), %eax
cmpl -0xc34(%rbp), %eax
jge 0x30d8a
movq -0xc48(%rbp), %rdi
movslq -0xc38(%rbp), %rax
movq -0x830(%rbp,%rax,8), %rsi
movslq -0xc38(%rbp), %rax
movq -0xc30(%rbp,%rax,8), %rdx
callq 0x37460
movq %rax, -0xc48(%rbp)
movl -0xc38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc38(%rbp)
jmp 0x30d3a
movl $0x0, -0xc38(%rbp)
movl -0xc38(%rbp), %eax
cmpl -0xc34(%rbp), %eax
jge 0x30dd6
movslq -0xc38(%rbp), %rax
movq -0x830(%rbp,%rax,8), %rdi
movslq -0xc38(%rbp), %rax
movq -0xc30(%rbp,%rax,8), %rsi
callq 0x37340
movl -0xc38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc38(%rbp)
jmp 0x30d94
movl $0x0, -0xc38(%rbp)
movl -0xc38(%rbp), %eax
cmpl -0xc34(%rbp), %eax
jge 0x30e22
movslq -0xc38(%rbp), %rax
movq -0x830(%rbp,%rax,8), %rdi
movslq -0xc38(%rbp), %rax
movq -0xc30(%rbp,%rax,8), %rsi
callq 0x37340
movl -0xc38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc38(%rbp)
jmp 0x30de0
movl $0x0, -0xc38(%rbp)
movl -0xc38(%rbp), %eax
cmpl -0xc34(%rbp), %eax
jge 0x30e7c
movq -0xc50(%rbp), %rdi
movslq -0xc38(%rbp), %rax
movq -0x830(%rbp,%rax,8), %rsi
movslq -0xc38(%rbp), %rax
movq -0xc30(%rbp,%rax,8), %rdx
callq 0x37460
movq %rax, -0xc50(%rbp)
movl -0xc38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc38(%rbp)
jmp 0x30e2c
movq -0x8(%rbp), %rdi
callq 0x12200
movq -0xc40(%rbp), %rcx
movb $0x1, %al
cmpq -0xc48(%rbp), %rcx
movb %al, -0xc69(%rbp)
jne 0x30eb4
movq -0xc48(%rbp), %rax
cmpq -0xc50(%rbp), %rax
setne %al
movb %al, -0xc69(%rbp)
movb -0xc69(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
addq $0xc70, %rsp            # imm = 0xC70
popq %rbp
retq
nopl (%rax,%rax)