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

```asm
<breakval>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  movb   $0x0,(%rdi)
  mov    %rdi,-0x18(%rsp)
  test   %rdx,%rdx
  je     L77
  mov    %rcx,%r13
  xor    %ecx,%ecx
  cmp    $0x1,%r8
  mov    %rsi,%r10
  cmova  %r8,%rcx
  mov    %rsi,%rax
  mov    %rdi,%r8
  mov    %rcx,-0x8(%rsp)
  sub    $0x1,%r10
  je     L290
  lea    -0x4(%rsi),%rbx
  sub    $0x3,%rax
  mov    %rdx,%r14
  mov    %rdi,%r15
  mov    %rbx,-0x28(%rsp)
  lea    -0x2(%rsi),%rbx
  xor    %ecx,%ecx
  mov    %rbx,-0x20(%rsp)
  mov    %rax,-0x10(%rsp)
  nopw   0x0(%rax,%rax,1)
L119:
  movzbl (%rdx),%eax
  test   %al,%al
  je     L290
  lea    -0x1(%r13),%r9
  mov    %rcx,%r12
  xor    %ebp,%ebp
  xor    %edi,%edi
  jmp    L295
  nopl   0x0(%rax,%rax,1)
L120:
  cmp    $0xa,%al
  je     L227
  cmp    $0x5c,%al
  je     L156
  lea    0x1(%r8),%rbx
  lea    0x1(%rcx),%r11
  add    $0x1,%rdi
  cmp    $0x20,%al
  je     L34
L84:
  mov    %al,(%r8)
  mov    %r11,%rcx
  movzbl 0x1(%rdx),%eax
  mov    %rbx,%r8
  mov    %rsi,%rdx
L81:
  cmp    %r10,%rcx
  jae    L244
L117:
  test   %al,%al
  je     L303
L295:
  cmp    %rdi,%r9
  jbe    L218
  lea    0x1(%rdx),%rsi
  cmp    $0xd,%al
  jne    L120
L227:
  movzbl 0x1(%rdx),%eax
  mov    %rsi,%rdx
  cmp    %r10,%rcx
  jb     L117
L244:
  test   %rbp,%rbp
  je     L246
  test   %al,%al
  je     L303
L10:
  movzbl (%r14),%eax
  mov    %r14,%rdx
  mov    %r15,%r8
  mov    %r12,%rcx
L246:
  test   %al,%al
  je     L303
  cmpb   $0x0,0x1(%rdx)
  je     L170
  cmp    %rcx,-0x10(%rsp)
  jbe    L303
  mov    $0xd5c,%eax
  add    $0x3,%r8
  add    $0x3,%rcx
  mov    %rdx,%r14
  mov    -0x8(%rsp),%r13
  mov    %ax,-0x3(%r8)
  movb   $0xa,-0x1(%r8)
  mov    %r8,%r15
  nopl   0x0(%rax,%rax,1)
L303:
  cmp    %r10,%rcx
  jb     L119
L290:
  movb   $0x0,(%r8)
L77:
  mov    -0x18(%rsp),%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   (%rax)
L156:
  movzbl 0x1(%rdx),%eax
  cmp    $0xd,%al
  je     L195
  cmp    $0xa,%al
  je     L207
  cmp    %rcx,-0x20(%rsp)
  jbe    L213
  movb   $0x5c,(%r8)
  movzbl 0x1(%rdx),%eax
  add    $0x2,%r8
  add    $0x2,%rcx
  add    $0x2,%rdi
  add    $0x2,%rdx
  mov    %al,-0x1(%r8)
  movzbl (%rdx),%eax
  jmp    L81
  nopl   0x0(%rax,%rax,1)
L34:
  cmp    %rcx,-0x28(%rsp)
  jbe    L84
  movb   $0x20,(%r8)
  mov    %rsi,%r14
  movzbl 0x1(%rdx),%eax
  mov    %rbx,%r8
  mov    %rsi,%rdx
  mov    %rbx,%r15
  mov    %rdi,%rbp
  mov    %r11,%r12
  mov    %r11,%rcx
  jmp    L81
  nopl   (%rax)
L195:
  movzbl 0x2(%rdx),%eax
  lea    0x2(%rdx),%rsi
  mov    %rsi,%rdx
  cmp    $0xa,%al
  jne    L81
L207:
  movzbl 0x1(%rsi),%eax
  lea    0x1(%rsi),%rdx
  jmp    L81
  nopl   0x0(%rax,%rax,1)
L218:
  test   %rbp,%rbp
  jne    L10
  jmp    L246
  xchg   %ax,%ax
L170:
  cmp    $0x5c,%al
  je     L303
  add    $0x1,%rcx
  mov    %al,(%r8)
  add    $0x1,%rdx
  add    $0x1,%r8
  cmp    %r10,%rcx
  jb     L119
  jmp    L290
  nopl   (%rax)
L213:
  mov    %rsi,%rdx
  jmp    L81
```

assistant: ```c
char *breakval(char buffer[], unsigned long buflen, const char *string, unsigned long pos1, unsigned long pos2) {
  unsigned long i, is;
  unsigned long pos, poss;
  unsigned long breakpos = pos1;
  char *pb = buffer, *pbs;
  const char *ps = string, *pss;
  char c;
  buffer[0] = '\0';
  if (!string)
    return (buffer);
  if (pos1 <= 1)
    pos1 = 0U;
  if (pos2 <= 1)
    pos2 = 0U;
  i = 0U;
  pbs = pb;
  pss = ps;
  while ((i < buflen - 1) && (*ps)) {
    pos = 0U;
    poss = pos;
    is = i;
    while ((i < buflen - 1) && (*ps) && (pos < breakpos - 1)) {
      if ((*ps) == '\r')
        ps++;
      else if ((*ps) == '\n')
        ps++;
      else if ((*ps) == '\\') {
        c = *ps;
        ps++;
        if ((*ps) == ('\r')) {
          ps++;
          c = (char)0;
        }
        if ((*ps) == ('\n')) {
          ps++;
          c = (char)0;
        }
        if ((c) && (i < buflen - 2)) {
          *pb = c;
          pb++;
          *pb = *ps;
          pb++;
          ps++;
          i += 2;
          pos += 2;
        }
      } else if (((*ps) == ' ') && (i < buflen - 4)) {
        if (i < buflen - 1) {
          *pb = *ps;
          pb++;
          ps++;
          i++;
          pos++;
        }
        pbs = pb;
        pss = ps;
        poss = pos;
        is = i;
      } else {
        *pb = *ps;
        pb++;
        ps++;
        i++;
        pos++;
      }
    }
    if ((poss != 0U) && (*ps)) {
      pb = pbs;
      ps = pss;
      pos = poss;
      i = is;
    }
    if (*ps) {
      if (ps[1]) {
        if (i < buflen - 3) {
          *pb = '\\';
          pb++;
          *pb = '\r';
          pb++;
          *pb = '\n';
          pb++;
          i += 3;
          pos = 0U;
          pbs = pb;
          pss = ps;
          poss = pos;
          is = i;
          breakpos = pos2;
        }
      } else {
        if (*ps != '\\') {
          *pb = *ps;
          pb++;
          ps++;
          i++;
          pos++;
        }
      }
    }
  }
  while ((i < buflen - 1) && (*ps)) {
    if ((*ps) == '\r')
      ps++;
    else if ((*ps) == '\n')
      ps++;
    else if ((*ps) == '\\') {
      c = *ps;
      ps++;
      if ((*ps) == ('\r')) {
        ps++;
        c = (char)0;
      }
      if ((*ps) == ('\n')) {
        ps++;
        c = (char)0;
      }
      if ((c) && (i < buflen - 2)) {
        *pb = c;
        pb++;
        *pb = *ps;
        pb++;
        ps++;
        i += 2;
        pos += 2;
      }
    } else {
      *pb = *ps;
      pb++;
      ps++;
      i++;
      pos++;
    }
  }
  *pb = '\0';
  pb++;
  return (buffer);
}
```