user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<onfault_check>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    $0x0,%eax
  call   <getpagesize@plt>
  mov    %rax,-0x8(%rbp)
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <get_pageflags@plt>
  mov    %eax,-0x10(%rbp)
  mov    -0x18(%rbp),%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,%rdi
  call   <get_pageflags@plt>
  mov    %eax,-0xc(%rbp)
  cmpl   $0x0,-0x10(%rbp)
  js     L128
  cmpl   $0x0,-0xc(%rbp)
  jns    L94
L128:
  lea    D53(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
  mov    $0x1,%eax
  jmp    L40
L94:
  mov    -0x18(%rbp),%rax
  movb   $0x61,(%rax)
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <get_pageflags@plt>
  mov    %eax,-0x10(%rbp)
  mov    -0x18(%rbp),%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,%rdi
  call   <get_pageflags@plt>
  mov    %eax,-0xc(%rbp)
  cmpl   $0x0,-0x10(%rbp)
  js     L97
  lea    D4(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
  mov    $0x1,%eax
  jmp    L40
L97:
  cmpl   $0x0,-0xc(%rbp)
  jns    L38
  lea    D10(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
  mov    $0x1,%eax
  jmp    L40
L38:
  mov    -0x10(%rbp),%eax
  mov    %eax,%edi
  call   <get_kpageflags@plt>
  mov    %eax,-0x10(%rbp)
  mov    -0x10(%rbp),%eax
  cltq
  and    $0x40000,%eax
  test   %rax,%rax
  jne    L89
  lea    D37(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
  mov    $0x1,%eax
  jmp    L40
L89:
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <is_vma_lock_on_fault@plt>
  test   %eax,%eax
  jne    L24
  lea    D31(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
  mov    $0x1,%eax
  jmp    L40
L24:
  mov    -0x18(%rbp),%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,%rdi
  call   <is_vma_lock_on_fault@plt>
  test   %eax,%eax
  jne    L37
  lea    D31(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
  mov    $0x1,%eax
  jmp    L40
L37:
  mov    $0x0,%eax
L40:
  leave
  ret
```

tool_calls: name: parse_data
arguments: tag: D53
type: string
name: parse_data
arguments: tag: D4
type: string
name: parse_data
arguments: tag: D10
type: string
name: parse_data
arguments: tag: D37
type: string
name: parse_data
arguments: tag: D31
type: string

tool: D53: Pages were made present by MLOCK_ONFAULT


tool: D4: Page 1 is not present after fault


tool: D10: Page 2 was made present


tool: D37: Failed to make faulted page unevictable


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


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;
}
```