user: Demonstrate the C code that generates the assembly output below:

```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     L58
  cmpl   $0x0,-0xc(%rbp)
  jns    L103
L58:
  lea    D39(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
  mov    $0x1,%eax
  jmp    L69
L103:
  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     L34
  lea    D55(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
  mov    $0x1,%eax
  jmp    L69
L34:
  cmpl   $0x0,-0xc(%rbp)
  jns    L43
  lea    D28(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
  mov    $0x1,%eax
  jmp    L69
L43:
  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    D45(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
  mov    $0x1,%eax
  jmp    L69
L89:
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <is_vma_lock_on_fault@plt>
  test   %eax,%eax
  jne    L125
  lea    D15(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
  mov    $0x1,%eax
  jmp    L69
L125:
  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    D15(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
  mov    $0x1,%eax
  jmp    L69
L37:
  mov    $0x0,%eax
L69:
  leave
  ret
```

tool_calls: name: disassemble_data
arguments: label: D39
datatype: string
name: disassemble_data
arguments: label: D55
datatype: string
name: disassemble_data
arguments: label: D28
datatype: string
name: disassemble_data
arguments: label: D45
datatype: string
name: disassemble_data
arguments: label: D15
datatype: string

tool: D39: Pages were made present by MLOCK_ONFAULT


tool: D55: Page 1 is not present after fault


tool: D28: Page 2 was made present


tool: D45: Failed to make faulted page unevictable


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