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     L31
  movb   $0x61,(%r12)
  mov    %r12,%rdi
  call   <get_pageflags@plt>
  mov    %rbp,%rdi
  mov    %eax,%r13d
  call   <get_pageflags@plt>
  test   %r13d,%r13d
  jns    L53
  test   %eax,%eax
  js     L42
  mov    %r13d,%edi
  call   <get_kpageflags@plt>
  test   $0x40000,%eax
  je     L5
  mov    %r12,%rdi
  call   <is_vma_lock_on_fault@plt>
  test   %eax,%eax
  je     L3
  mov    %rbp,%rdi
  call   <is_vma_lock_on_fault@plt>
  test   %eax,%eax
  je     L3
  add    $0x8,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  nopl   0x0(%rax)
L31:
  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)
L53:
  lea    D27(%rip),%rdi
  call   <printf@plt>
  add    $0x8,%rsp
  mov    $0x1,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  nopl   0x0(%rax)
L3:
  lea    D17(%rip),%rdi
  call   <printf@plt>
  add    $0x8,%rsp
  mov    $0x1,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  nopl   0x0(%rax)
L42:
  lea    D5(%rip),%rdi
  call   <printf@plt>
  add    $0x8,%rsp
  mov    $0x1,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  nopl   0x0(%rax)
L5:
  lea    D6(%rip),%rdi
  call   <printf@plt>
  add    $0x8,%rsp
  mov    $0x1,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
```

tool_calls: name: unpack_data
arguments: data_tag: D41
type: string
name: unpack_data
arguments: data_tag: D27
type: string
name: unpack_data
arguments: data_tag: D17
type: string
name: unpack_data
arguments: data_tag: D5
type: string
name: unpack_data
arguments: data_tag: D6
type: string

tool: D41: Pages were made present by MLOCK_ONFAULT


tool: D27: Page 1 is not present after fault


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


tool: D5: Page 2 was made present


tool: D6: 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 & 0x8000000000000000) || (page2_flags & 0x8000000000000000)) {
    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 & 0x8000000000000000) == 0) {
    printf("Page 1 is not present after fault\n");
    return 1;
  } else if (page2_flags & 0x8000000000000000) {
    printf("Page 2 was made present\n");
    return 1;
  }
  page1_flags = get_kpageflags(page1_flags & 0x007FFFFFFFFFFFFF);
  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;
}
```