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

```asm
<sad4_one_macroblock>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x98,%rsp
  mov    %rdi,0x80(%rsp)
  mov    %rsi,0x60(%rsp)
  mov    %rdx,0x40(%rsp)
  mov    %r8d,0x8c(%rsp)
  mov    %r9d,%eax
  mov    %r9d,%r15d
  shl    $0x4,%r15d
  mov    0xd0(%rsp),%esi
  shl    $0x4,%esi
  mov    %esi,0x18(%rsp)
  lea    -0xc(%rcx),%esi
  mov    %esi,0x74(%rsp)
  shl    $0x6,%eax
  cltq
  mov    %rax,0x58(%rsp)
  movslq %r15d,%rax
  add    %rax,%rax
  mov    %rax,0x20(%rsp)
  movq   $0x0,0x78(%rsp)
  lea    0x11(%r8),%eax
  mov    %eax,0x88(%rsp)
  jmp    L70
L9:
  addl   $0x1,0x3c(%rsp)
  mov    0x3c(%rsp),%eax
  addq   $0x1,0x68(%rsp)
  cmp    0x88(%rsp),%eax
  je     L52
L64:
  mov    0x80(%rsp),%rax
  mov    0x68(%rsp),%rcx
  lea    (%rax,%rcx,2),%rax
  mov    %rax,0x48(%rsp)
  mov    0x74(%rsp),%eax
  mov    %eax,0xc(%rsp)
  movq   $0x0,0x50(%rsp)
  movl   $0x0,0x70(%rsp)
L80:
  mov    0xc(%rsp),%eax
  sub    $0x4,%eax
  mov    %eax,0x38(%rsp)
  mov    0x60(%rsp),%rax
  mov    0x50(%rsp),%rcx
  lea    (%rax,%rcx,2),%rax
  mov    %rax,0x30(%rsp)
  mov    0x48(%rsp),%rax
  mov    %rax,0x28(%rsp)
  movq   $0x0,0x10(%rsp)
L66:
  mov    0x3c(%rsp),%eax
  add    0x10(%rsp),%eax
  mov    %eax,0x4(%rsp)
  mov    0x30(%rsp),%r12
  mov    0x38(%rsp),%r13d
  mov    $0x0,%edx
  mov    0x40(%rsp),%r14
L61:
  test   %r13d,%r13d
  mov    $0x0,%eax
  cmovns %r13d,%eax
  cmp    0x18(%rsp),%eax
  cmovge 0x1c(%rsp),%eax
  imul   %r15d,%eax
  mov    %eax,(%rsp)
  mov    $0x0,%ebx
  lea    -0x1(%r15),%ebp
  mov    %r13d,0x8(%rsp)
  mov    %edx,%r13d
L86:
  mov    0x4(%rsp),%eax
  add    %ebx,%eax
  mov    $0x0,%edx
  cmovs  %edx,%eax
  cmp    %r15d,%eax
  cmovge %ebp,%eax
  movzwl (%r12,%rbx,2),%edi
  add    (%rsp),%eax
  cltq
  movzwl (%r14,%rax,2),%eax
  sub    %eax,%edi
  call   <abs@plt>
  add    %eax,%r13d
  add    $0x1,%rbx
  cmp    $0x4,%rbx
  jne    L86
  mov    %r13d,%edx
  mov    0x8(%rsp),%r13d
  add    $0x1,%r13d
  add    0x20(%rsp),%r12
  cmp    0xc(%rsp),%r13d
  jne    L61
  mov    0x28(%rsp),%rax
  mov    %dx,(%rax)
  add    $0x888,%rax
  mov    %rax,0x28(%rsp)
  addq   $0x4,0x10(%rsp)
  mov    0x10(%rsp),%rax
  addq   $0x8,0x30(%rsp)
  cmp    $0x10,%rax
  jne    L66
  addl   $0x4,0x70(%rsp)
  mov    0x70(%rsp),%eax
  addl   $0x4,0xc(%rsp)
  addq   $0x2220,0x48(%rsp)
  mov    0x58(%rsp),%rsi
  add    %rsi,0x50(%rsp)
  cmp    $0x10,%eax
  jne    L80
  jmp    L9
L52:
  addl   $0x1,0x74(%rsp)
  addq   $0x21,0x78(%rsp)
  mov    0x78(%rsp),%rax
  cmp    $0x441,%rax
  je     L83
L70:
  mov    0x8c(%rsp),%eax
  sub    $0x10,%eax
  mov    %eax,0x3c(%rsp)
  mov    0x78(%rsp),%rax
  mov    %rax,0x68(%rsp)
  mov    0x18(%rsp),%eax
  sub    $0x1,%eax
  mov    %eax,0x1c(%rsp)
  jmp    L64
L83:
  add    $0x98,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  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;
        }
      }
    }
  }
}
```