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

```asm
<compute_fold_length>:
  endbr64
  push   %r15
  push   %r14
  mov    %esi,%r14d
  push   %r13
  mov    %edx,%r13d
  push   %r12
  mov    %r8d,%r12d
  push   %rbp
  mov    %rdi,%rbp
  xor    %edi,%edi
  push   %rbx
  mov    %ecx,%ebx
  sub    $0x18,%rsp
  cmp    %ecx,%edx
  setg   %dil
  call   <assert@plt>
  lea    0x0(%r13,%rbx,1),%eax
  mov    %r14d,%r9d
  cmp    %r14d,%eax
  jge    L46
  lea    0x1(%rbx),%eax
  mov    %r13d,%r9d
  mov    %ebx,%ecx
  mov    %ebx,%r10d
  sub    %eax,%r9d
  not    %r10d
  movslq %r9d,%rax
  lea    0x0(%rbp,%rax,8),%r11
  mov    (%r11),%rax
  cmp    $0x20,%rax
  sete   %dl
  cmp    $0x9,%rax
  sete   %al
  neg    %ecx
  or     %eax,%edx
  test   %r12d,%r12d
  movzbl %dl,%edx
  setne  %r8b
  test   %ebx,%ebx
  je     L218
  movslq %r13d,%rax
  movslq %ecx,%rcx
  xor    %edi,%edi
  mov    %rax,0x8(%rsp)
  lea    0x0(%rbp,%rax,8),%r15
  jmp    L81
  nopw   0x0(%rax,%rax,1)
L73:
  cmp    %edi,%r14d
  jl     L115
  mov    %esi,%r10d
  mov    %r14d,%edi
L115:
  add    $0x1,%rcx
  test   %ecx,%ecx
  je     L9
L81:
  mov    (%r15,%rcx,8),%r14
  mov    %ecx,%esi
  cmp    $0x9,%r14
  sete   %al
  cmp    $0x20,%r14
  sete   %r12b
  or     %r12d,%eax
  mov    %edx,%r12d
  movzbl %al,%edx
  cmp    $0x3b,%r14
  jne    L131
  xor    %r14d,%r14d
  test   %r8b,%r8b
  je     L73
L131:
  xor    $0x1,%eax
  movzbl %al,%eax
  lea    (%rax,%r12,2),%r14d
  jmp    L73
  nopl   0x0(%rax,%rax,1)
L109:
  xor    $0x1,%eax
  movzbl %al,%eax
  lea    (%rax,%r12,2),%r14d
  cmp    $0x3,%r14d
  jne    L160
  mov    %esi,%r10d
L167:
  test   %edi,%edi
  je     L13
  lea    (%r10,%r13,1),%r9d
L46:
  add    $0x18,%rsp
  mov    %r9d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   (%rax)
L9:
  test   %ebx,%ebx
  js     L167
L68:
  mov    0x8(%rsp),%rax
  xor    %ecx,%ecx
  lea    0x0(%rbp,%rax,8),%rbp
  jmp    L106
  nopw   0x0(%rax,%rax,1)
L84:
  jne    L59
  mov    %r10d,%eax
  neg    %eax
  cmp    %ecx,%eax
  cmovge %esi,%r10d
  nopl   (%rax)
L59:
  add    $0x1,%rcx
  cmp    %ecx,%ebx
  jl     L167
L106:
  mov    0x0(%rbp,%rcx,8),%r14
  mov    %ecx,%esi
  cmp    $0x20,%r14
  sete   %al
  cmp    $0x9,%r14
  sete   %r12b
  or     %r12d,%eax
  mov    %edx,%r12d
  movzbl %al,%edx
  cmp    $0x3b,%r14
  jne    L109
  xor    %r14d,%r14d
  test   %r8b,%r8b
  jne    L109
L160:
  cmp    %edi,%r14d
  jle    L84
  mov    %esi,%r10d
  mov    %r14d,%edi
  jmp    L59
  nopw   0x0(%rax,%rax,1)
L13:
  test   %r9d,%r9d
  jg     L180
  jmp    L46
  nopw   0x0(%rax,%rax,1)
L173:
  sub    $0x8,%r11
  sub    $0x1,%r9d
  je     L46
L180:
  cmpq   $0x3b,(%r11)
  je     L173
  jmp    L46
L218:
  movslq %r13d,%rax
  xor    %edi,%edi
  mov    $0xffffffff,%r10d
  mov    %rax,0x8(%rsp)
  jmp    L68
```

assistant: ```c
ptrdiff_t compute_fold_length(UChar *fold_start, ptrdiff_t line_length, ptrdiff_t target_length, int window, int allow_folding_before_semi) {
  assert(target_length > window);
  if (line_length <= target_length + window) {
    return line_length;
  } else {
    int best_category = 0;
    int best_diff = -(window + 1);
    int diff;
    UChar this_char = fold_start[target_length - (window + 1)];
    int is_space = ((this_char == ((UChar)0x20)) || (this_char == ((UChar)0x09)));
    int was_space;
    for (diff = -window; diff; diff += 1) {
      int category;
      was_space = is_space;
      this_char = fold_start[target_length + diff];
      is_space = ((this_char == ((UChar)0x20)) || (this_char == ((UChar)0x09)));
      category = (allow_folding_before_semi || (this_char != ((UChar)0x3b))) ? ((was_space * 2) + !is_space) : 0;
      if (category >= best_category) {
        best_diff = diff;
        best_category = category;
      }
    }
    for (; diff <= window; diff += 1) {
      int category;
      was_space = is_space;
      this_char = fold_start[target_length + diff];
      is_space = ((this_char == ((UChar)0x20)) || (this_char == ((UChar)0x09)));
      category = (allow_folding_before_semi || (this_char != ((UChar)0x3b))) ? ((was_space * 2) + !is_space) : 0;
      if (category == 3) {
        best_diff = diff;
        break;
      } else if (category > best_category) {
        best_diff = diff;
        best_category = category;
      } else if ((category == best_category) && (diff <= -best_diff)) {
        best_diff = diff;
        best_category = category;
      }
    }
    if (best_category) {
      return target_length + best_diff;
    } else {
      ptrdiff_t best_length;
      for (best_length = target_length - (window + 1); best_length > 0; best_length -= 1) {
        if (fold_start[best_length] != ((UChar)0x3b)) {
          break;
        }
      }
      return best_length;
    }
  }
}
```