user: Please show me the C implementation that matches the assembly code listed below:

```asm
<make_edit_script>:
  endbr64
  push   %r15
  mov    %rdi,%r15
  push   %r14
  movslq %ecx,%r14
  push   %r13
  lea    (%r14,%r14,2),%edi
  push   %r12
  push   %rbp
  push   %rbx
  mov    $0xffffffb0,%ebx
  sub    $0x28,%rsp
  cmp    $0x1,%edx
  adc    $0x0,%bl
  mov    %rsi,(%rsp)
  call   <malloc@plt>
  mov    %rax,%r12
  mov    %rax,%rdi
  call   <assert@plt>
  mov    %bl,(%r12)
  test   %r14d,%r14d
  jle    L118
  mov    (%rsp),%rsi
  xor    %ebx,%ebx
  xor    %ecx,%ecx
  xor    %edi,%edi
  mov    $0x1,%ebp
  xor    %r11d,%r11d
  jmp    L50
  nopl   0x0(%rax)
L40:
  movslq %ebp,%r13
  lea    0x1(%rbp),%r9d
  lea    (%r12,%r13,1),%r10
  cmp    $0x2d,%dl
  je     L28
  test   %ecx,%ecx
  je     L90
L101:
  mov    %al,(%r12,%r13,1)
  movslq %r9d,%rbp
  mov    $0x1,%ecx
  xor    %edi,%edi
L172:
  add    $0x1,%rbx
  cmp    %rbx,%r14
  je     L153
L50:
  movzbl (%r15,%rbx,1),%eax
  movzbl (%rsi,%rbx,1),%edx
  cmp    %dl,%al
  jne    L40
  add    $0x1,%rbx
  xor    %ecx,%ecx
  xor    %edi,%edi
  cmp    %rbx,%r14
  jne    L50
L153:
  lea    0x1(%rbp),%esi
L142:
  mov    %r12,%rdi
  call   <realloc@plt>
  mov    %rax,%r12
  mov    %rax,%rdi
  call   <assert@plt>
  movb   $0x0,(%r12,%rbp,1)
  add    $0x28,%rsp
  mov    %r12,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopw   0x0(%rax,%rax,1)
L28:
  test   %edi,%edi
  je     L35
L81:
  mov    %al,(%r12,%r13,1)
  movslq %r9d,%rbp
  xor    %ecx,%ecx
  mov    $0x1,%edi
  jmp    L172
L90:
  mov    %ebx,%edi
  mov    %r9d,0x1c(%rsp)
  sub    %r11d,%edi
  mov    %rsi,0x10(%rsp)
  mov    %r10,0x8(%rsp)
  mov    %ebx,(%rsp)
  call   <to_octal_str@plt>
  mov    0x8(%rsp),%r10
  mov    (%rsp),%r8d
  mov    0x10(%rsp),%rsi
  mov    0x1c(%rsp),%r9d
  mov    %rax,%rdi
  movb   $0x73,(%r10)
  movzbl (%rax),%ecx
  test   %cl,%cl
  je     L176
  lea    0x2(%rbp),%edx
  mov    %rax,%r9
  movslq %edx,%rdx
  sub    %r13,%r9
  nopl   (%rax)
L127:
  mov    %cl,-0x1(%r12,%rdx,1)
  mov    %edx,%ebp
  add    $0x1,%rdx
  movzbl -0x2(%r9,%rdx,1),%ecx
  test   %cl,%cl
  jne    L127
L21:
  mov    %rsi,0x8(%rsp)
  movslq %ebp,%r13
  mov    %r8d,(%rsp)
  call   <free@plt>
  movzbl (%r15,%rbx,1),%eax
  mov    (%rsp),%r11d
  lea    0x1(%rbp),%r9d
  mov    0x8(%rsp),%rsi
  jmp    L101
  nopl   (%rax)
L35:
  mov    %ebx,%edi
  mov    %r9d,0x1c(%rsp)
  sub    %r11d,%edi
  mov    %rsi,0x10(%rsp)
  mov    %r10,0x8(%rsp)
  mov    %ebx,(%rsp)
  call   <to_octal_str@plt>
  mov    0x8(%rsp),%r10
  mov    (%rsp),%r8d
  mov    0x10(%rsp),%rsi
  mov    0x1c(%rsp),%r9d
  mov    %rax,%rdi
  movb   $0x69,(%r10)
  movzbl (%rax),%ecx
  test   %cl,%cl
  je     L148
  lea    0x2(%rbp),%edx
  mov    %rax,%r9
  movslq %edx,%rdx
  sub    %r13,%r9
  nopl   0x0(%rax)
L128:
  mov    %cl,-0x1(%r12,%rdx,1)
  mov    %edx,%ebp
  add    $0x1,%rdx
  movzbl -0x2(%r9,%rdx,1),%ecx
  test   %cl,%cl
  jne    L128
L67:
  mov    %rsi,0x8(%rsp)
  movslq %ebp,%r13
  mov    %r8d,(%rsp)
  call   <free@plt>
  movzbl (%r15,%rbx,1),%eax
  mov    (%rsp),%r11d
  lea    0x1(%rbp),%r9d
  mov    0x8(%rsp),%rsi
  jmp    L81
L176:
  mov    %r9d,%ebp
  jmp    L21
  nopl   (%rax)
L118:
  mov    $0x1,%ebp
  mov    $0x2,%esi
  jmp    L142
L148:
  mov    %r9d,%ebp
  jmp    L67
```

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;
}
```