user: Please show me the C implementation that matches the assembly code listed below:

```asm
<onfault_check>:
  endbr64
  push   %r13
  xor    %eax,%eax
  push   %r12
  mov    %rdi,%r12
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  call   <getpagesize@plt>
  mov    %r12,%rdi
  mov    %rax,%rbp
  call   <get_pageflags@plt>
  add    %r12,%rbp
  mov    %rbp,%rdi
  mov    %eax,%ebx
  call   <get_pageflags@plt>
  or     %eax,%ebx
  js     L42
  movb   $0x61,(%r12)
  mov    %r12,%rdi
  call   <get_pageflags@plt>
  mov    %rbp,%rdi
  mov    %eax,%r13d
  call   <get_pageflags@plt>
  test   %r13d,%r13d
  jns    L23
  test   %eax,%eax
  js     L55
  mov    %r13d,%edi
  call   <get_kpageflags@plt>
  test   $0x40000,%eax
  je     L51
  mov    %r12,%rdi
  call   <is_vma_lock_on_fault@plt>
  test   %eax,%eax
  je     L47
  mov    %rbp,%rdi
  call   <is_vma_lock_on_fault@plt>
  test   %eax,%eax
  je     L47
  add    $0x8,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  nopl   0x0(%rax)
L42:
  lea    D38(%rip),%rdi
  call   <printf@plt>
  add    $0x8,%rsp
  mov    $0x1,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  nopl   0x0(%rax)
L23:
  lea    D44(%rip),%rdi
  call   <printf@plt>
  add    $0x8,%rsp
  mov    $0x1,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  nopl   0x0(%rax)
L47:
  lea    D48(%rip),%rdi
  call   <printf@plt>
  add    $0x8,%rsp
  mov    $0x1,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  nopl   0x0(%rax)
L55:
  lea    D33(%rip),%rdi
  call   <printf@plt>
  add    $0x8,%rsp
  mov    $0x1,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  nopl   0x0(%rax)
L51:
  lea    D23(%rip),%rdi
  call   <printf@plt>
  add    $0x8,%rsp
  mov    $0x1,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
```

tool_calls: name: extract_symbolic_data
arguments: data_tag: D38
data_type: string
name: extract_symbolic_data
arguments: data_tag: D44
data_type: string
name: extract_symbolic_data
arguments: data_tag: D48
data_type: string
name: extract_symbolic_data
arguments: data_tag: D33
data_type: string
name: extract_symbolic_data
arguments: data_tag: D23
data_type: string

tool: D38: Pages were made present by MLOCK_ONFAULT


tool: D44: Page 1 is not present after fault


tool: D48: VMA is not marked for lock on fault


tool: D33: Page 2 was made present


tool: D23: Failed to make faulted page unevictable


assistant: ```c
int onfault_check(char *map) {
  unsigned long page_size = getpagesize();
  uint64_t page1_flags, page2_flags;
  page1_flags = get_pageflags((unsigned long)map);
  page2_flags = get_pageflags((unsigned long)map + page_size);
  if ((page1_flags & 0x8000000000000000ULL) || (page2_flags & 0x8000000000000000ULL)) {
    printf("Pages were made present by MLOCK_ONFAULT\n");
    return 1;
  }
  *map = 'a';
  page1_flags = get_pageflags((unsigned long)map);
  page2_flags = get_pageflags((unsigned long)map + page_size);
  if ((page1_flags & 0x8000000000000000ULL) == 0) {
    printf("Page 1 is not present after fault\n");
    return 1;
  } else if (page2_flags & 0x8000000000000000ULL) {
    printf("Page 2 was made present\n");
    return 1;
  }
  page1_flags = get_kpageflags(page1_flags & 0x007FFFFFFFFFFFFFULL);
  if ((page1_flags & (1UL << 18)) == 0) {
    printf("Failed to make faulted page unevictable\n");
    return 1;
  }
  if (!is_vma_lock_on_fault((unsigned long)map)) {
    printf("VMA is not marked for lock on fault\n");
    return 1;
  }
  if (!is_vma_lock_on_fault((unsigned long)map + page_size)) {
    printf("VMA is not marked for lock on fault\n");
    return 1;
  }
  return 0;
}
```