user: 请将以下的汇编代码转换成C语言代码:

```asm
<memset>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %rdi,-0x18(%rbp)
  mov    %esi,-0x1c(%rbp)
  mov    %rdx,-0x28(%rbp)
  mov    -0x1c(%rbp),%eax
  cltq
  mov    %rax,-0x10(%rbp)
  mov    -0x18(%rbp),%rax
  mov    %rax,-0x8(%rbp)
  cmpq   $0x0,-0x28(%rbp)
  sete   %al
  movzbl %al,%eax
  test   %rax,%rax
  je     L35
  mov    -0x18(%rbp),%rax
  jmp    L143
L35:
  cmpq   $0x0,-0x10(%rbp)
  setne  %al
  movzbl %al,%eax
  test   %rax,%rax
  je     L155
  andq   $0xff,-0x10(%rbp)
  mov    -0x10(%rbp),%rax
  shl    $0x8,%rax
  or     %rax,-0x10(%rbp)
  mov    -0x10(%rbp),%rax
  shl    $0x10,%rax
  or     %rax,-0x10(%rbp)
  mov    -0x10(%rbp),%rax
  shl    $0x20,%rax
  or     %rax,-0x10(%rbp)
L155:
  mov    -0x8(%rbp),%rax
  and    $0x1,%eax
  test   %rax,%rax
  je     L113
  mov    -0x10(%rbp),%rax
  mov    %eax,%edx
  mov    -0x8(%rbp),%rax
  mov    %dl,(%rax)
  addq   $0x1,-0x8(%rbp)
  subq   $0x1,-0x28(%rbp)
L113:
  mov    -0x8(%rbp),%rax
  and    $0x2,%eax
  test   %rax,%rax
  je     L133
  cmpq   $0x1,-0x28(%rbp)
  jbe    L32
  mov    -0x10(%rbp),%rax
  mov    %eax,%edx
  mov    -0x8(%rbp),%rax
  mov    %dx,(%rax)
  addq   $0x2,-0x8(%rbp)
  subq   $0x2,-0x28(%rbp)
L133:
  mov    -0x8(%rbp),%rax
  and    $0x4,%eax
  test   %rax,%rax
  je     L169
  cmpq   $0x3,-0x28(%rbp)
  jbe    L130
  mov    -0x10(%rbp),%rax
  mov    %eax,%edx
  mov    -0x8(%rbp),%rax
  mov    %edx,(%rax)
  addq   $0x4,-0x8(%rbp)
  subq   $0x4,-0x28(%rbp)
  jmp    L169
L0:
  mov    -0x10(%rbp),%rdx
  mov    -0x8(%rbp),%rax
  mov    %rdx,(%rax)
  addq   $0x8,-0x8(%rbp)
  subq   $0x8,-0x28(%rbp)
L169:
  cmpq   $0x7,-0x28(%rbp)
  ja     L0
  cmpq   $0x3,-0x28(%rbp)
  jbe    L43
  mov    -0x10(%rbp),%rax
  mov    %eax,%edx
  mov    -0x8(%rbp),%rax
  mov    %edx,(%rax)
  addq   $0x4,-0x8(%rbp)
  subq   $0x4,-0x28(%rbp)
  jmp    L15
L130:
  nop
  jmp    L15
L43:
  nop
L15:
  cmpq   $0x1,-0x28(%rbp)
  jbe    L159
  mov    -0x10(%rbp),%rax
  mov    %eax,%edx
  mov    -0x8(%rbp),%rax
  mov    %dx,(%rax)
  addq   $0x2,-0x8(%rbp)
  subq   $0x2,-0x28(%rbp)
  jmp    L102
L32:
  nop
  jmp    L102
L159:
  nop
L102:
  cmpq   $0x0,-0x28(%rbp)
  je     L95
  mov    -0x10(%rbp),%rax
  mov    %eax,%edx
  mov    -0x8(%rbp),%rax
  mov    %dl,(%rax)
  addq   $0x1,-0x8(%rbp)
  subq   $0x1,-0x28(%rbp)
L95:
  mov    -0x18(%rbp),%rax
L143:
  pop    %rbp
  ret
```

assistant: ```c
void *memset(void *optr, int ival, unsigned long size) {
  unsigned long val = ival;
  void *ptr = optr;
  if (__builtin_expect(size == 0, 0))
    return optr;
  if (__builtin_expect(val != 0, 0)) {
    val = val & 0xff;
    val |= val << 8;
    val |= val << 16;
    val |= val << 32;
  }
  if (__builtin_expect((unsigned long)ptr & 1, 0)) {
    *(char *)ptr = val;
    ptr += 1;
    size -= 1;
  }
  if (__builtin_expect((unsigned long)ptr & 2, 0)) {
    if (size < 2)
      goto tail_1;
    *(short *)ptr = val;
    ptr += 2;
    size -= 2;
  }
  if (__builtin_expect((unsigned long)ptr & 4, 0)) {
    if (size < 4)
      goto tail_3;
    *(int *)ptr = val;
    ptr += 4;
    size -= 4;
  }
  while (size >= 8) {
    *(long *)ptr = val;
    ptr += 8;
    size -= 8;
  }
  if (size >= 4) {
    *(int *)ptr = val;
    ptr += 4;
    size -= 4;
  }
tail_3:
  if (size >= 2) {
    *(short *)ptr = val;
    ptr += 2;
    size -= 2;
  }
tail_1:
  if (size > 0) {
    *(char *)ptr = val;
    ptr += 1;
    size -= 1;
  }
  return optr;
}
```