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

```asm
<get_ram_size>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x150,%rsp
  mov    %rdi,-0x148(%rbp)
  mov    %rsi,-0x150(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  movl   $0x0,-0x134(%rbp)
  mov    -0x150(%rbp),%rax
  shr    $0x3,%rax
  shr    %rax
  mov    %rax,-0x130(%rbp)
  jmp    L124
L93:
  mov    -0x130(%rbp),%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x148(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,-0x128(%rbp)
  mov    -0x134(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0x134(%rbp)
  mov    -0x128(%rbp),%rdx
  mov    (%rdx),%rdx
  cltq
  mov    %rdx,-0x110(%rbp,%rax,8)
  mov    -0x130(%rbp),%rax
  not    %rax
  mov    %rax,%rdx
  mov    -0x128(%rbp),%rax
  mov    %rdx,(%rax)
  sarq   -0x130(%rbp)
L124:
  cmpq   $0x0,-0x130(%rbp)
  jg     L93
  mov    -0x148(%rbp),%rax
  mov    %rax,-0x128(%rbp)
  mov    -0x128(%rbp),%rax
  mov    (%rax),%rdx
  mov    -0x134(%rbp),%eax
  cltq
  mov    %rdx,-0x110(%rbp,%rax,8)
  mov    -0x128(%rbp),%rax
  movq   $0x0,(%rax)
  mov    -0x128(%rbp),%rax
  mov    (%rax),%rax
  mov    %rax,-0x120(%rbp)
  cmpq   $0x0,-0x120(%rbp)
  je     L94
  mov    -0x134(%rbp),%eax
  cltq
  mov    -0x110(%rbp,%rax,8),%rdx
  mov    -0x128(%rbp),%rax
  mov    %rdx,(%rax)
  movq   $0x1,-0x130(%rbp)
  jmp    L74
L47:
  mov    -0x130(%rbp),%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x148(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,-0x128(%rbp)
  subl   $0x1,-0x134(%rbp)
  mov    -0x134(%rbp),%eax
  cltq
  mov    -0x110(%rbp,%rax,8),%rdx
  mov    -0x128(%rbp),%rax
  mov    %rdx,(%rax)
  shlq   -0x130(%rbp)
L74:
  mov    -0x150(%rbp),%rax
  shr    $0x3,%rax
  mov    %rax,%rdx
  mov    -0x130(%rbp),%rax
  cmp    %rax,%rdx
  ja     L47
  mov    $0x0,%eax
  jmp    L77
L94:
  movq   $0x1,-0x130(%rbp)
  jmp    L45
L105:
  mov    -0x130(%rbp),%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x148(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,-0x128(%rbp)
  mov    -0x128(%rbp),%rax
  mov    (%rax),%rax
  mov    %rax,-0x120(%rbp)
  subl   $0x1,-0x134(%rbp)
  mov    -0x134(%rbp),%eax
  cltq
  mov    -0x110(%rbp,%rax,8),%rdx
  mov    -0x128(%rbp),%rax
  mov    %rdx,(%rax)
  mov    -0x130(%rbp),%rax
  not    %rax
  cmp    %rax,-0x120(%rbp)
  je     L96
  mov    -0x130(%rbp),%rax
  shl    $0x3,%rax
  mov    %rax,-0x118(%rbp)
  shlq   -0x130(%rbp)
  jmp    L86
L24:
  mov    -0x130(%rbp),%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x148(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,-0x128(%rbp)
  subl   $0x1,-0x134(%rbp)
  mov    -0x134(%rbp),%eax
  cltq
  mov    -0x110(%rbp,%rax,8),%rdx
  mov    -0x128(%rbp),%rax
  mov    %rdx,(%rax)
  shlq   -0x130(%rbp)
L86:
  mov    -0x150(%rbp),%rax
  shr    $0x3,%rax
  mov    %rax,%rdx
  mov    -0x130(%rbp),%rax
  cmp    %rax,%rdx
  ja     L24
  mov    -0x118(%rbp),%rax
  jmp    L77
L96:
  shlq   -0x130(%rbp)
L45:
  mov    -0x150(%rbp),%rax
  shr    $0x3,%rax
  mov    %rax,%rdx
  mov    -0x130(%rbp),%rax
  cmp    %rax,%rdx
  ja     L105
  mov    -0x150(%rbp),%rax
L77:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L10
  call   <__stack_chk_fail@plt>
L10:
  leave
  ret
```

assistant: ```c
long get_ram_size(volatile long *base, long maxsize) {
  volatile long *addr;
  long save[32];
  long cnt;
  long val;
  long size;
  int i = 0;
  for (cnt = (maxsize / sizeof(long)) >> 1; cnt > 0; cnt >>= 1) {
    addr = base + cnt;
    save[i++] = *addr;
    *addr = ~cnt;
  }
  addr = base;
  save[i] = *addr;
  *addr = 0;
  if ((val = *addr) != 0) {
    *addr = save[i];
    for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
      addr = base + cnt;
      *addr = save[--i];
    }
    return (0);
  }
  for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
    addr = base + cnt;
    val = *addr;
    *addr = save[--i];
    if (val != ~cnt) {
      size = cnt * sizeof(long);
      for (cnt <<= 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
        addr = base + cnt;
        *addr = save[--i];
      }
      return (size);
    }
  }
  return (maxsize);
}
```