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

```asm
<dist1>:
  endbr64
  push   %rbp
  push   %rbx
  mov    %ecx,%ebx
  or     %r8d,%ebx
  je     L134
  test   %r8d,%r8d
  jne    L195
  test   %ecx,%ecx
  jne    L35
L195:
  test   %r8d,%r8d
  je     L188
  test   %ecx,%ecx
  je     L209
L188:
  movslq %edx,%r11
  lea    (%rdi,%r11,1),%r8
  test   %r9d,%r9d
  jle    L171
  mov    %rdi,%rbx
  mov    $0x0,%eax
  mov    $0x0,%edi
L102:
  mov    %rbx,%r10
  mov    $0x0,%edx
L194:
  movzbl (%r10,%rdx,1),%ecx
  movzbl 0x1(%r10,%rdx,1),%ebp
  add    %ebp,%ecx
  movzbl (%r8,%rdx,1),%ebp
  add    %ebp,%ecx
  movzbl 0x1(%r8,%rdx,1),%ebp
  lea    0x2(%rcx,%rbp,1),%ecx
  shr    $0x2,%ecx
  movzbl (%rsi,%rdx,1),%ebp
  sub    %ebp,%ecx
  lea    (%rax,%rcx,1),%ebp
  sub    %ecx,%eax
  test   %ecx,%ecx
  cmovns %ebp,%eax
  add    $0x1,%rdx
  cmp    $0x10,%rdx
  jne    L194
  add    %r11,%r8
  add    %r11,%rsi
  add    $0x1,%edi
  add    %r11,%rbx
  cmp    %edi,%r9d
  jne    L102
  jmp    L3
L134:
  mov    %ebx,%eax
  movslq %edx,%r11
  test   %r9d,%r9d
  jle    L3
L207:
  mov    $0x0,%ecx
L53:
  movzbl (%rdi,%rcx,1),%edx
  movzbl (%rsi,%rcx,1),%r8d
  mov    %r8d,%r10d
  sub    %edx,%r10d
  sub    %r8d,%edx
  cmovs  %r10d,%edx
  add    %edx,%eax
  add    $0x1,%rcx
  cmp    $0x10,%rcx
  jne    L53
  add    %r11,%rdi
  add    %r11,%rsi
  add    $0x1,%ebx
  cmp    %ebx,%r9d
  jne    L207
L3:
  pop    %rbx
  pop    %rbp
  ret
L35:
  mov    $0x0,%eax
  mov    $0x0,%ebp
  movslq %edx,%r10
  test   %r9d,%r9d
  jle    L3
L155:
  mov    $0x0,%ecx
L118:
  movzbl (%rdi,%rcx,1),%r8d
  movzbl 0x1(%rdi,%rcx,1),%edx
  lea    0x1(%r8,%rdx,1),%edx
  shr    %edx
  movzbl (%rsi,%rcx,1),%r8d
  sub    %r8d,%edx
  lea    (%rax,%rdx,1),%r8d
  sub    %edx,%eax
  test   %edx,%edx
  cmovns %r8d,%eax
  add    $0x1,%rcx
  cmp    $0x10,%rcx
  jne    L118
  add    %r10,%rdi
  add    %r10,%rsi
  add    $0x1,%ebp
  cmp    %ebp,%r9d
  jne    L155
  jmp    L3
L209:
  movslq %edx,%rbx
  lea    (%rdi,%rbx,1),%r10
  test   %r9d,%r9d
  jle    L11
  mov    $0x0,%eax
  mov    $0x0,%ebp
L91:
  mov    %rdi,%r11
  mov    $0x0,%ecx
L105:
  movzbl (%r11,%rcx,1),%r8d
  movzbl (%r10,%rcx,1),%edx
  lea    0x1(%r8,%rdx,1),%edx
  shr    %edx
  movzbl (%rsi,%rcx,1),%r8d
  sub    %r8d,%edx
  lea    (%rax,%rdx,1),%r8d
  sub    %edx,%eax
  test   %edx,%edx
  cmovns %r8d,%eax
  add    $0x1,%rcx
  cmp    $0x10,%rcx
  jne    L105
  add    %rbx,%r10
  add    %rbx,%rsi
  add    $0x1,%ebp
  add    %rbx,%rdi
  cmp    %ebp,%r9d
  jne    L91
  jmp    L3
L11:
  mov    $0x0,%eax
  jmp    L3
L171:
  mov    $0x0,%eax
  jmp    L3
```

assistant: ```c
int dist1(unsigned char *blk1, unsigned char *blk2, int lx, int hx, int hy, int h, int distlim) {
  unsigned char *p1;
  unsigned char *p1a;
  unsigned char *p2;
  int i;
  int j;
  int s;
  int v;
  int sa;
  int tmp;
  {
    sa = 0;
    if (!hx) {
      if (!hy) {
        s = 0;
        p1 = blk1;
        p2 = blk2;
        j = 0;
        while (j < h) {
          i = 0;
          while (i < 16) {
            v = (int)*(p1 + i) - (int)*(p2 + i);
            if (v >= 0) {
              tmp = v;
            } else {
              tmp = -v;
            }
            s += tmp;
            i++;
          }
          p1 += lx;
          p2 += lx;
          j++;
        }
      } else {
        goto _L___1;
      }
    } else
    _L___1:
      if (hx) {
        if (!hy) {
          s = 0;
          p1 = blk1;
          p2 = blk2;
          j = 0;
          while (j < h) {
            i = 0;
            while (i < 16) {
              v = (int)(((unsigned int)(((int)*(p1 + i) + (int)*(p1 + (i + 1))) + 1) >> 1) - (unsigned int)*(p2 + i));
              if (v >= 0) {
                s += v;
              } else {
                s -= v;
              }
              i++;
            }
            p1 += lx;
            p2 += lx;
            j++;
          }
        } else {
          goto _L___0;
        }
      } else
      _L___0:
        if (!hx) {
          if (hy) {
            s = 0;
            p1 = blk1;
            p2 = blk2;
            p1a = p1 + lx;
            j = 0;
            while (j < h) {
              i = 0;
              while (i < 16) {
                v = (int)(((unsigned int)(((int)*(p1 + i) + (int)*(p1a + i)) + 1) >> 1) - (unsigned int)*(p2 + i));
                if (v >= 0) {
                  s += v;
                } else {
                  s -= v;
                }
                i++;
              }
              p1 = p1a;
              p1a += lx;
              p2 += lx;
              j++;
            }
          } else {
            goto _L;
          }
        } else {
        _L:
          s = 0;
          p1 = blk1;
          p2 = blk2;
          p1a = p1 + lx;
          j = 0;
          while (j < h) {
            i = 0;
            while (i < 16) {
              v = (int)(((unsigned int)(((((int)*(p1 + i) + (int)*(p1 + (i + 1))) + (int)*(p1a + i)) + (int)*(p1a + (i + 1))) + 2) >> 2) - (unsigned int)*(p2 + i));
              if (v >= 0) {
                s += v;
              } else {
                s -= v;
              }
              i++;
            }
            p1 = p1a;
            p1a += lx;
            p2 += lx;
            j++;
          }
        }
    return (s);
  }
}
```