user: 请将以下的汇编代码转换成C语言代码：

```asm
<Subsample_Horizontal>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    0x38(%rsp),%r12d
  mov    0x48(%rsp),%r15d
  mov    %rdi,-0x18(%rsp)
  test   %ecx,%ecx
  jle    L107
  mov    %r15d,%ebx
  lea    -0x1(%r8),%edi
  mov    %edx,%ebp
  mov    %rsi,%rax
  sar    %ebx
  mov    %edi,-0xc(%rsp)
  mov    %ecx,%edx
  mov    %ebx,-0x10(%rsp)
  movslq %r8d,%rbx
  add    %rbx,%rbx
  cmp    $0x1,%r8d
  jne    L103
  cmp    $0x1,%r9d
  jne    L103
  lea    -0x1(%r12),%r14d
  lea    -0x1(%rcx),%eax
  imul   0x40(%rsp),%ebp
  lea    0x2(%rsi,%r14,1),%r13
  lea    0x1(%rsi,%r14,1),%r9
  add    %rax,%r13
  nopl   0x0(%rax)
L96:
  mov    %ebp,%eax
  mov    -0x18(%rsp),%rdi
  mov    %r9,%rsi
  mov    $0x10,%r11d
  cltd
  sub    %r14,%rsi
  idiv   %r15d
  sub    $0x1,%rsi
  movslq %eax,%rcx
  test   %eax,%eax
  mov    -0x10(%rsp),%eax
  lea    (%rdi,%rcx,2),%r10
  lea    0x2(%r10),%r8
  cmovns %r10,%r8
  shl    $0x4,%edx
  add    %edx,%eax
  cltd
  idiv   %r15d
  sub    %eax,%r11d
  test   %r12d,%r12d
  jle    L32
  xor    %edi,%edi
  jmp    L49
  nopl   (%rax)
L0:
  sub    $0xffffff80,%edx
  add    $0x1,%rsi
  add    %rbx,%rdi
  mov    %dh,-0x1(%rsi)
  cmp    %r9,%rsi
  je     L32
L49:
  movswl (%r10,%rdi,1),%edx
  movswl (%r8,%rdi,1),%ecx
  imul   %r11d,%edx
  imul   %eax,%ecx
  add    %ecx,%edx
  jns    L0
  add    $0x7f,%edx
  add    $0x1,%rsi
  add    %rbx,%rdi
  mov    %dh,-0x1(%rsi)
  cmp    %r9,%rsi
  jne    L49
L32:
  add    $0x1,%r9
  add    0x40(%rsp),%ebp
  cmp    %r9,%r13
  jne    L96
L107:
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L103:
  mov    0x40(%rsp),%r14d
  movslq %r9d,%r9
  imul   %ebp,%r14d
  mov    %rax,%rbp
  lea    -0x1(%rdx),%eax
  lea    0x1(%rbp,%rax,1),%rax
  mov    %rax,-0x8(%rsp)
  nopl   0x0(%rax)
L143:
  mov    %r14d,%eax
  mov    -0x18(%rsp),%rdi
  mov    $0x10,%r13d
  mov    %rbp,%r8
  cltd
  idiv   %r15d
  cmp    -0xc(%rsp),%eax
  movslq %eax,%rcx
  mov    -0x10(%rsp),%eax
  lea    (%rdi,%rcx,2),%r11
  lea    0x2(%r11),%r10
  cmovge %r11,%r10
  shl    $0x4,%edx
  xor    %esi,%esi
  xor    %edi,%edi
  add    %edx,%eax
  cltd
  idiv   %r15d
  sub    %eax,%r13d
  test   %r12d,%r12d
  jg     L13
  jmp    L33
  nopl   0x0(%rax,%rax,1)
L62:
  sub    $0xffffff80,%edx
L139:
  movzbl %dh,%ecx
  add    $0x1,%edi
  add    %rbx,%rsi
  mov    %cl,(%r8)
  add    %r9,%r8
  cmp    %edi,%r12d
  je     L33
L13:
  movswl (%r11,%rsi,1),%edx
  movswl (%r10,%rsi,1),%ecx
  imul   %r13d,%edx
  imul   %eax,%ecx
  add    %ecx,%edx
  jns    L62
  add    $0x7f,%edx
  jmp    L139
  nopl   0x0(%rax)
L33:
  add    0x40(%rsp),%r14d
  add    $0x1,%rbp
  cmp    %rbp,-0x8(%rsp)
  jne    L143
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

assistant: ```c
void Subsample_Horizontal(short *s, unsigned char *d, int x0, int lx, int lxs, int lxd, int ly, int m, int n) {
  int i;
  int i1;
  int j;
  int id;
  int c1;
  int c2;
  int v;
  short *s1;
  short *s2;
  unsigned char *d1;
  int tmp;
  {
    i1 = 0;
    while (i1 < lx) {
      d1 = d + i1;
      i = x0 + i1;
      id = (i * m) / n;
      s1 = s + id;
      if (id < lxs - 1) {
        s2 = s1 + 1;
      } else {
        s2 = s1;
      }
      c2 = (16 * ((i * m) % n) + (n >> 1)) / n;
      c1 = 16 - c2;
      j = 0;
      while (j < ly) {
        v = c1 * (int)*s1 + c2 * (int)*s2;
        if (v >= 0) {
          tmp = 128;
        } else {
          tmp = 127;
        }
        *d1 = (unsigned char)((v + tmp) >> 8);
        d1 += lxd;
        s1 += lxs;
        s2 += lxs;
        j++;
      }
      i1++;
    }
    return;
  }
}
```