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     L48
  movb   $0x61,(%r12)
  mov    %r12,%rdi
  call   <get_pageflags@plt>
  mov    %rbp,%rdi
  mov    %eax,%r13d
  call   <get_pageflags@plt>
  test   %r13d,%r13d
  jns    L19
  test   %eax,%eax
  js     L50
  mov    %r13d,%edi
  call   <get_kpageflags@plt>
  test   $0x40000,%eax
  je     L39
  mov    %r12,%rdi
  call   <is_vma_lock_on_fault@plt>
  test   %eax,%eax
  je     L4
  mov    %rbp,%rdi
  call   <is_vma_lock_on_fault@plt>
  test   %eax,%eax
  je     L4
  add    $0x8,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  nopl   0x0(%rax)
L48:
  lea    D26(%rip),%rdi
  call   <printf@plt>
  add    $0x8,%rsp
  mov    $0x1,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  nopl   0x0(%rax)
L19:
  lea    D41(%rip),%rdi
  call   <printf@plt>
  add    $0x8,%rsp
  mov    $0x1,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  nopl   0x0(%rax)
L4:
  lea    D36(%rip),%rdi
  call   <printf@plt>
  add    $0x8,%rsp
  mov    $0x1,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  nopl   0x0(%rax)
L50:
  lea    D21(%rip),%rdi
  call   <printf@plt>
  add    $0x8,%rsp
  mov    $0x1,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  nopl   0x0(%rax)
L39:
  lea    D25(%rip),%rdi
  call   <printf@plt>
  add    $0x8,%rsp
  mov    $0x1,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
```

tool_calls: name: parse_data
arguments: data_tag: D26
type_guessed: string
name: parse_data
arguments: data_tag: D41
type_guessed: string
name: parse_data
arguments: data_tag: D36
type_guessed: string
name: parse_data
arguments: data_tag: D21
type_guessed: string
name: parse_data
arguments: data_tag: D25
type_guessed: string

tool: D26: Pages were made present by MLOCK_ONFAULT


tool: D41: Page 1 is not present after fault


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


tool: D21: Page 2 was made present


tool: D25: 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;
}
```