user: 请从给定的汇编指令推导出C源代码:

```asm
<sad4_one_macroblock>:
  endbr64
  push   %r15
  mov    %r9d,%eax
  sub    $0x10,%ecx
  push   %r14
  shl    $0x6,%eax
  push   %r13
  cltq
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0xa8,%rsp
  mov    %rsi,0x70(%rsp)
  mov    %r9d,%esi
  shl    $0x4,%esi
  mov    %rdx,0x20(%rsp)
  mov    0xe0(%rsp),%edx
  mov    %rax,0x68(%rsp)
  movslq %esi,%rax
  add    %rax,%rax
  shl    $0x4,%edx
  mov    %esi,0x4(%rsp)
  mov    %rax,0x18(%rsp)
  lea    -0x10(%r8),%eax
  mov    %edx,0x14(%rsp)
  sub    $0x1,%edx
  mov    %eax,0x8c(%rsp)
  lea    -0x1(%rsi),%eax
  mov    %rdi,0x98(%rsp)
  mov    %edx,0x40(%rsp)
  mov    %ecx,0x94(%rsp)
  movq   $0x0,0x80(%rsp)
  mov    %eax,0x8(%rsp)
L21:
  mov    0x98(%rsp),%rax
  mov    0x80(%rsp),%rcx
  movq   $0x0,0x60(%rsp)
  lea    (%rax,%rcx,2),%rax
  mov    %rax,0x78(%rsp)
  mov    0x94(%rsp),%eax
  add    $0x4,%eax
  mov    %eax,0x90(%rsp)
L37:
  movq   $0x0,0x50(%rsp)
  mov    0x8c(%rsp),%eax
  add    0x60(%rsp),%eax
  mov    %eax,0x88(%rsp)
  mov    0x90(%rsp),%eax
  mov    %eax,0x10(%rsp)
  mov    0x78(%rsp),%rax
  mov    %rax,0x48(%rsp)
  add    $0x8880,%rax
  mov    %rax,0x58(%rsp)
L54:
  mov    0x70(%rsp),%rax
  mov    0x50(%rsp),%rcx
  movq   $0x0,0x28(%rsp)
  mov    0x88(%rsp),%r15d
  lea    (%rax,%rcx,2),%rax
  mov    %rax,0x30(%rsp)
  mov    0x48(%rsp),%rax
  mov    %rax,0x38(%rsp)
  mov    0x10(%rsp),%eax
  sub    $0x4,%eax
  mov    %eax,0x44(%rsp)
L41:
  mov    0x44(%rsp),%r13d
  mov    0x30(%rsp),%r12
  xor    %ebp,%ebp
L25:
  xor    %ebx,%ebx
  test   %r13d,%r13d
  mov    %r13d,0xc(%rsp)
  cmovns %r13d,%ebx
  cmp    %ebx,0x14(%rsp)
  cmovle 0x40(%rsp),%ebx
  xor    %r14d,%r14d
  mov    %r14,%r13
  mov    0x20(%rsp),%r14
  imul   0x4(%rsp),%ebx
L1:
  lea    (%r15,%r13,1),%eax
  xor    %esi,%esi
  movzwl (%r12,%r13,2),%edi
  test   %eax,%eax
  cmovs  %esi,%eax
  cmp    %eax,0x4(%rsp)
  cmovle 0x8(%rsp),%eax
  add    $0x1,%r13
  add    %ebx,%eax
  cltq
  movzwl (%r14,%rax,2),%eax
  sub    %eax,%edi
  call   <abs@plt>
  add    %eax,%ebp
  cmp    $0x4,%r13
  jne    L1
  mov    0xc(%rsp),%r13d
  add    0x18(%rsp),%r12
  add    $0x1,%r13d
  cmp    %r13d,0x10(%rsp)
  jne    L25
  mov    0x38(%rsp),%rax
  addq   $0x4,0x28(%rsp)
  add    $0x4,%r15d
  addq   $0x8,0x30(%rsp)
  mov    %bp,(%rax)
  add    $0x888,%rax
  mov    %rax,0x38(%rsp)
  mov    0x28(%rsp),%rax
  cmp    $0x10,%rax
  jne    L41
  addq   $0x2220,0x48(%rsp)
  mov    0x68(%rsp),%rsi
  addl   $0x4,0x10(%rsp)
  mov    0x48(%rsp),%rax
  add    %rsi,0x50(%rsp)
  cmp    0x58(%rsp),%rax
  jne    L54
  addq   $0x1,0x60(%rsp)
  mov    0x60(%rsp),%rax
  addq   $0x2,0x78(%rsp)
  cmp    $0x21,%rax
  jne    L37
  addq   $0x21,0x80(%rsp)
  mov    0x80(%rsp),%rax
  addl   $0x1,0x94(%rsp)
  cmp    $0x441,%rax
  jne    L21
  add    $0xa8,%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;
        }
      }
    }
  }
}
```