user: What is the c source code of the assembly code below?

```asm
<pattern_fill>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %esi,-0x2c(%rbp)
  mov    %rdx,-0x38(%rbp)
  mov    %ecx,-0x30(%rbp)
  mov    %r8d,-0x3c(%rbp)
  cmpl   $0x0,-0x30(%rbp)
  je     L26
  mov    -0x3c(%rbp),%eax
  cltd
  idivl  -0x30(%rbp)
  mov    %edx,-0x3c(%rbp)
L26:
  mov    -0x28(%rbp),%rax
  mov    %rax,-0x8(%rbp)
  mov    -0x2c(%rbp),%eax
  mov    %eax,-0x10(%rbp)
  mov    -0x30(%rbp),%eax
  sub    -0x3c(%rbp),%eax
  mov    %eax,-0xc(%rbp)
  mov    -0x10(%rbp),%eax
  cmp    -0xc(%rbp),%eax
  jge    L51
  mov    -0x10(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x3c(%rbp),%eax
  movslq %eax,%rcx
  mov    -0x38(%rbp),%rax
  add    %rax,%rcx
  mov    -0x8(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <memcpy@plt>
  mov    $0x0,%eax
  jmp    L39
L51:
  mov    -0xc(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x3c(%rbp),%eax
  movslq %eax,%rcx
  mov    -0x38(%rbp),%rax
  add    %rax,%rcx
  mov    -0x8(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <memcpy@plt>
  mov    -0xc(%rbp),%eax
  sub    %eax,-0x10(%rbp)
  mov    -0xc(%rbp),%eax
  cltq
  add    %rax,-0x8(%rbp)
  cmpl   $0x0,-0x3c(%rbp)
  jle    L40
  mov    -0x3c(%rbp),%eax
  mov    %eax,-0xc(%rbp)
  mov    -0x10(%rbp),%eax
  cmp    -0xc(%rbp),%eax
  jge    L57
  mov    -0x10(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x38(%rbp),%rcx
  mov    -0x8(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <memcpy@plt>
  mov    $0x0,%eax
  jmp    L39
L57:
  mov    -0xc(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x38(%rbp),%rcx
  mov    -0x8(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <memcpy@plt>
  mov    -0xc(%rbp),%eax
  sub    %eax,-0x10(%rbp)
  mov    -0xc(%rbp),%eax
  cltq
  add    %rax,-0x8(%rbp)
L40:
  mov    -0x8(%rbp),%rax
  sub    -0x28(%rbp),%rax
  mov    %eax,-0x14(%rbp)
  jmp    L70
L32:
  mov    -0x10(%rbp),%edx
  mov    -0x14(%rbp),%eax
  cmp    %eax,%edx
  cmovle %edx,%eax
  mov    %eax,-0xc(%rbp)
  mov    -0xc(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x28(%rbp),%rcx
  mov    -0x8(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <memcpy@plt>
  mov    -0xc(%rbp),%eax
  cltq
  add    %rax,-0x8(%rbp)
  mov    -0xc(%rbp),%eax
  add    %eax,-0x14(%rbp)
  mov    -0xc(%rbp),%eax
  sub    %eax,-0x10(%rbp)
L70:
  mov    -0x14(%rbp),%eax
  cmp    -0x2c(%rbp),%eax
  jl     L32
  mov    $0x0,%eax
L39:
  leave
  ret
```

assistant: ```c
int pattern_fill(buf, buflen, pat, patlen, patshift)
char *buf;
int buflen;
char *pat;
int patlen;
int patshift;
{
  int trans, ncopied, nleft;
  char *cp;
  if (patlen)
    patshift = patshift % patlen;
  cp = buf;
  nleft = buflen;
  trans = patlen - patshift;
  if (nleft < trans) {
    memcpy(cp, pat + patshift, nleft);
    return 0;
  } else {
    memcpy(cp, pat + patshift, trans);
    nleft -= trans;
    cp += trans;
  }
  if (patshift > 0) {
    trans = patshift;
    if (nleft < trans) {
      memcpy(cp, pat, nleft);
      return 0;
    } else {
      memcpy(cp, pat, trans);
      nleft -= trans;
      cp += trans;
    }
  }
  ncopied = cp - buf;
  while (ncopied < buflen) {
    trans = (ncopied < nleft) ? ncopied : nleft;
    memcpy(cp, buf, trans);
    cp += trans;
    ncopied += trans;
    nleft -= trans;
  }
  return (0);
}
```