user: Converte this assembly snippet into its equivalent C code:

```asm
<sad4_one_macroblock>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x70,%rsp
  mov    %rdi,-0x48(%rbp)
  mov    %rsi,-0x50(%rbp)
  mov    %rdx,-0x58(%rbp)
  mov    %ecx,-0x5c(%rbp)
  mov    %r8d,-0x60(%rbp)
  mov    %r9d,-0x64(%rbp)
  mov    -0x64(%rbp),%eax
  shl    $0x4,%eax
  mov    %eax,-0x10(%rbp)
  mov    0x10(%rbp),%eax
  shl    $0x4,%eax
  mov    %eax,-0xc(%rbp)
  movl   $0x0,-0x2c(%rbp)
  movl   $0xfffffff0,-0x30(%rbp)
  jmp    L35
L52:
  movl   $0xfffffff0,-0x34(%rbp)
  jmp    L20
L112:
  movl   $0x0,-0x28(%rbp)
  jmp    L140
L111:
  movl   $0x0,-0x24(%rbp)
  jmp    L62
L89:
  movw   $0x0,-0x36(%rbp)
  movl   $0x0,-0x20(%rbp)
  jmp    L44
L31:
  movl   $0x0,-0x1c(%rbp)
  jmp    L22
L149:
  mov    -0x60(%rbp),%edx
  mov    -0x34(%rbp),%eax
  add    %eax,%edx
  mov    -0x24(%rbp),%eax
  shl    $0x2,%eax
  add    %eax,%edx
  mov    -0x1c(%rbp),%eax
  add    %edx,%eax
  mov    %eax,-0x18(%rbp)
  cmpl   $0x0,-0x18(%rbp)
  jns    L159
  movl   $0x0,-0x18(%rbp)
L159:
  mov    -0x18(%rbp),%eax
  cmp    -0x10(%rbp),%eax
  jl     L76
  mov    -0x10(%rbp),%eax
  sub    $0x1,%eax
  mov    %eax,-0x18(%rbp)
L76:
  mov    -0x5c(%rbp),%edx
  mov    -0x30(%rbp),%eax
  add    %eax,%edx
  mov    -0x28(%rbp),%eax
  shl    $0x2,%eax
  add    %eax,%edx
  mov    -0x20(%rbp),%eax
  add    %edx,%eax
  mov    %eax,-0x14(%rbp)
  cmpl   $0x0,-0x14(%rbp)
  jns    L119
  movl   $0x0,-0x14(%rbp)
L119:
  mov    -0x14(%rbp),%eax
  cmp    -0xc(%rbp),%eax
  jl     L30
  mov    -0xc(%rbp),%eax
  sub    $0x1,%eax
  mov    %eax,-0x14(%rbp)
L30:
  mov    -0x14(%rbp),%eax
  imul   -0x10(%rbp),%eax
  mov    %eax,%edx
  mov    -0x18(%rbp),%eax
  add    %edx,%eax
  cltq
  lea    (%rax,%rax,1),%rdx
  mov    -0x58(%rbp),%rax
  add    %rdx,%rax
  movzwl (%rax),%eax
  movzwl %ax,%eax
  mov    %eax,-0x8(%rbp)
  mov    -0x28(%rbp),%eax
  lea    0x0(,%rax,4),%edx
  mov    -0x20(%rbp),%eax
  add    %edx,%eax
  imul   -0x10(%rbp),%eax
  mov    %eax,%edx
  mov    -0x24(%rbp),%eax
  lea    0x0(,%rax,4),%ecx
  mov    -0x1c(%rbp),%eax
  add    %ecx,%eax
  add    %edx,%eax
  cltq
  lea    (%rax,%rax,1),%rdx
  mov    -0x50(%rbp),%rax
  add    %rdx,%rax
  movzwl (%rax),%eax
  movzwl %ax,%eax
  mov    %eax,-0x4(%rbp)
  mov    -0x4(%rbp),%eax
  sub    -0x8(%rbp),%eax
  mov    %eax,%edi
  call   <abs@plt>
  add    %ax,-0x36(%rbp)
  addl   $0x1,-0x1c(%rbp)
L22:
  cmpl   $0x3,-0x1c(%rbp)
  jle    L149
  addl   $0x1,-0x20(%rbp)
L44:
  cmpl   $0x3,-0x20(%rbp)
  jle    L31
  mov    -0x28(%rbp),%eax
  lea    0x0(,%rax,4),%edx
  mov    -0x24(%rbp),%eax
  add    %edx,%eax
  imul   $0x444,%eax,%edx
  mov    -0x2c(%rbp),%eax
  add    %edx,%eax
  cltq
  lea    (%rax,%rax,1),%rdx
  mov    -0x48(%rbp),%rax
  add    %rax,%rdx
  movzwl -0x36(%rbp),%eax
  mov    %ax,(%rdx)
  addl   $0x1,-0x24(%rbp)
L62:
  cmpl   $0x3,-0x24(%rbp)
  jle    L89
  addl   $0x1,-0x28(%rbp)
L140:
  cmpl   $0x3,-0x28(%rbp)
  jle    L111
  addl   $0x1,-0x34(%rbp)
  addl   $0x1,-0x2c(%rbp)
L20:
  cmpl   $0x10,-0x34(%rbp)
  jle    L112
  addl   $0x1,-0x30(%rbp)
L35:
  cmpl   $0x10,-0x30(%rbp)
  jle    L52
  nop
  nop
  leave
  ret
```

assistant: ```c
void sad4_one_macroblock(unsigned short *macroblock_sad, unsigned short *frame, unsigned short *ref, int frame_y, int frame_x, int mb_width, int mb_height) {
  int pos_x, pos_y;
  int width = mb_width * 16;
  int height = mb_height * 16;
  int pos;
  pos = 0;
  for (pos_y = -16; pos_y <= 16; pos_y++) {
    for (pos_x = -16; pos_x <= 16; pos_x++, pos++) {
      int blky, blkx;
      for (blky = 0; blky < 4; blky++) {
        for (blkx = 0; blkx < 4; blkx++) {
          int y, x;
          unsigned short sad = 0;
          for (y = 0; y < 4; y++) {
            for (x = 0; x < 4; x++) {
              int ref_x, ref_y;
              unsigned int a, b;
              ref_x = frame_x + pos_x + (blkx * 4) + x;
              if (ref_x < 0)
                ref_x = 0;
              if (ref_x >= width)
                ref_x = width - 1;
              ref_y = frame_y + pos_y + (blky * 4) + y;
              if (ref_y < 0)
                ref_y = 0;
              if (ref_y >= height)
                ref_y = height - 1;
              b = ref[ref_y * width + ref_x];
              a = frame[(blky * 4 + y) * width + (blkx * 4 + x)];
              sad += abs(a - b);
            }
          }
          macroblock_sad[1092 * (4 * blky + blkx) + pos] = sad;
        }
      }
    }
  }
}
```