user: 请显示与下面列出的汇编代码相匹配的C语言实现:

```asm
<make_edit_script>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %rdi,%r13
  mov    %rsi,%r15
  mov    %ecx,%ebx
  cmp    $0x1,%edx
  mov    $0x30,%ebp
  adc    $0x0,%bpl
  lea    (%rcx,%rcx,2),%edi
  call   <malloc@plt>
  mov    %rax,%r12
  mov    %rax,%rdi
  call   <assert@plt>
  or     $0xffffff80,%ebp
  mov    %bpl,(%r12)
  test   %ebx,%ebx
  jle    L155
  mov    %ebx,%eax
  mov    %rax,0x8(%rsp)
  mov    $0x0,%ebx
  mov    $0x0,%edx
  mov    $0x0,%ecx
  mov    $0x1,%ebp
  mov    $0x0,%esi
  mov    $0x0,%r14d
  jmp    L98
L83:
  test   %ecx,%ecx
  je     L132
L121:
  movzbl 0x0(%r13,%rbx,1),%edx
  movslq %ebp,%rax
  mov    %dl,(%r12,%rax,1)
  lea    0x1(%rbp),%ebp
  mov    %r14d,%edx
  mov    $0x1,%ecx
  jmp    L164
L132:
  mov    %ebx,%edi
  sub    %esi,%edi
  call   <to_octal_str@plt>
  mov    %rax,%rdi
  lea    0x1(%rbp),%edx
  movslq %ebp,%rax
  movb   $0x69,(%r12,%rax,1)
  movzbl (%rdi),%ecx
  test   %cl,%cl
  je     L36
  lea    0x2(%rbp),%edx
  movslq %edx,%rdx
  mov    %rdi,%rsi
  sub    %rax,%rsi
L51:
  mov    %edx,%ebp
  mov    %cl,-0x1(%r12,%rdx,1)
  add    $0x1,%rdx
  movzbl -0x2(%rsi,%rdx,1),%ecx
  test   %cl,%cl
  jne    L51
L75:
  call   <free@plt>
  mov    0x4(%rsp),%esi
  jmp    L121
L36:
  mov    %edx,%ebp
  jmp    L75
L41:
  mov    %edx,%ebp
  mov    %cl,-0x1(%r12,%rdx,1)
  add    $0x1,%rdx
  movzbl -0x2(%rsi,%rdx,1),%ecx
  test   %cl,%cl
  jne    L41
L49:
  call   <free@plt>
  mov    0x4(%rsp),%esi
L90:
  movzbl 0x0(%r13,%rbx,1),%edx
  movslq %ebp,%rax
  mov    %dl,(%r12,%rax,1)
  lea    0x1(%rbp),%ebp
  mov    $0x1,%edx
  mov    %r14d,%ecx
L164:
  add    $0x1,%rbx
  cmp    0x8(%rsp),%rbx
  je     L66
L98:
  mov    %ebx,0x4(%rsp)
  movzbl (%r15,%rbx,1),%eax
  cmp    %al,0x0(%r13,%rbx,1)
  je     L79
  cmp    $0x2d,%al
  je     L83
  test   %edx,%edx
  jne    L90
  mov    0x4(%rsp),%edi
  sub    %esi,%edi
  call   <to_octal_str@plt>
  mov    %rax,%rdi
  lea    0x1(%rbp),%edx
  movslq %ebp,%rax
  movb   $0x73,(%r12,%rax,1)
  movzbl (%rdi),%ecx
  test   %cl,%cl
  je     L116
  lea    0x2(%rbp),%edx
  movslq %edx,%rdx
  mov    %rdi,%rsi
  sub    %rax,%rsi
  jmp    L41
L116:
  mov    %edx,%ebp
  jmp    L49
L79:
  mov    %r14d,%edx
  mov    %r14d,%ecx
  jmp    L164
L155:
  mov    $0x1,%ebp
L66:
  lea    0x1(%rbp),%esi
  mov    %r12,%rdi
  call   <realloc@plt>
  mov    %rax,%rbx
  mov    %rax,%rdi
  call   <assert@plt>
  movslq %ebp,%rbp
  movb   $0x0,(%rbx,%rbp,1)
  mov    %rbx,%rax
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

assistant: ```c
char *make_edit_script(char *str, char *ref, bool dir, int length) {
  int last_edit = 0, current = 1;
  char *edit_script, *octal, direction = dir ? '0' : '1';
  bool insert_open = false, subdel_open = false;
  edit_script = malloc(3 * length * sizeof(*edit_script));
  assert(edit_script);
  direction |= ((char)0x80);
  edit_script[0] = direction;
  for (int i = 0; i < length; i++) {
    if (str[i] == ref[i]) {
      insert_open = false;
      subdel_open = false;
    } else {
      if (ref[i] == '-') {
        subdel_open = false;
        if (!insert_open) {
          insert_open = true;
          octal = to_octal_str(i - last_edit);
          edit_script[current++] = 'i';
          for (int j = 0; octal[j] != '\0'; j++)
            edit_script[current++] = octal[j];
          last_edit = i;
          free(octal);
        }
        edit_script[current++] = str[i];
      } else {
        insert_open = false;
        if (!subdel_open) {
          subdel_open = true;
          octal = to_octal_str(i - last_edit);
          edit_script[current++] = 's';
          for (int j = 0; octal[j] != '\0'; j++)
            edit_script[current++] = octal[j];
          last_edit = i;
          free(octal);
        }
        edit_script[current++] = str[i];
      }
    }
  }
  edit_script = realloc(edit_script, (current + 1) * sizeof(*edit_script));
  assert(edit_script);
  edit_script[current] = '\0';
  return edit_script;
}
```