user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<expand_sha2>:
  endbr64
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rdi,%rbx
  sub    $0x38,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x28(%rsp)
  xor    %eax,%eax
  cmp    $0x20,%esi
  jbe    L23
  lea    0x1(%rdx),%rcx
  mov    %rdi,%rax
  sub    %rcx,%rax
  cmp    $0xe,%rax
  jbe    L247
  movdqu (%rdx),%xmm0
  movups %xmm0,(%rdi)
  movdqu 0x10(%rdx),%xmm1
  movups %xmm1,0x10(%rdi)
L220:
  lea    -0x20(%rsi),%r12d
  cmp    $0x1f,%r12d
  jbe    L40
  lea    -0x40(%rsi),%r12d
  mov    %r12d,%r13d
  shr    $0x5,%r13d
  lea    0x1(%r13),%ebp
  shl    $0x5,%rbp
  add    %rbx,%rbp
  xchg   %ax,%ax
L186:
  mov    %rbx,%rsi
  add    $0x20,%rbx
  mov    %rbx,%rdi
  call   <sha2_chain@plt>
  cmp    %rbp,%rbx
  jne    L186
  shl    $0x5,%r13d
  sub    %r13d,%r12d
  jne    L2
L98:
  mov    0x28(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L166
  add    $0x38,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
L40:
  mov    %rbx,%rbp
L2:
  mov    %rsp,%r13
  mov    %rbp,%rsi
  mov    %r13,%rdi
  call   <sha2_chain@plt>
  mov    %r12d,%edx
  test   %r12d,%r12d
  mov    $0x1,%eax
  cmove  %rax,%rdx
  lea    0x20(%rbp),%rdi
  mov    %r13,%rsi
  call   <memcpy@plt>
  jmp    L98
  nopl   0x0(%rax)
L23:
  test   %esi,%esi
  je     L98
  lea    0x1(%rdx),%rdi
  mov    %rbx,%rcx
  lea    -0x1(%rsi),%eax
  sub    %rdi,%rcx
  cmp    $0xe,%rcx
  jbe    L257
  cmp    $0x6,%eax
  jbe    L257
  cmp    $0xe,%eax
  jbe    L144
  movdqu (%rdx),%xmm2
  mov    %esi,%eax
  shr    $0x4,%eax
  movups %xmm2,(%rbx)
  cmp    $0x2,%eax
  je     L225
  cmp    $0x10,%esi
  je     L98
  lea    -0x11(%rsi),%eax
  lea    -0x10(%rsi),%r8d
  cmp    $0x6,%eax
  mov    $0x10,%eax
  jbe    L274
L13:
  mov    %eax,%ecx
  add    $0x8,%eax
  mov    (%rdx,%rcx,1),%rdi
  mov    %rdi,(%rbx,%rcx,1)
  cmp    $0x8,%r8d
  je     L98
L274:
  mov    %eax,%ecx
  movzbl (%rdx,%rcx,1),%edi
  mov    %dil,(%rbx,%rcx,1)
  lea    0x1(%rax),%ecx
  cmp    %ecx,%esi
  jbe    L98
  movzbl (%rdx,%rcx,1),%edi
  mov    %dil,(%rbx,%rcx,1)
  lea    0x2(%rax),%ecx
  cmp    %ecx,%esi
  jbe    L98
  movzbl (%rdx,%rcx,1),%edi
  mov    %dil,(%rbx,%rcx,1)
  lea    0x3(%rax),%ecx
  cmp    %ecx,%esi
  jbe    L98
  movzbl (%rdx,%rcx,1),%edi
  mov    %dil,(%rbx,%rcx,1)
  lea    0x4(%rax),%ecx
  cmp    %ecx,%esi
  jbe    L98
  movzbl (%rdx,%rcx,1),%edi
  mov    %dil,(%rbx,%rcx,1)
  lea    0x5(%rax),%ecx
  cmp    %ecx,%esi
  jbe    L98
  movzbl (%rdx,%rcx,1),%edi
  add    $0x6,%eax
  mov    %dil,(%rbx,%rcx,1)
  cmp    %eax,%esi
  jbe    L98
  movzbl (%rdx,%rax,1),%edx
  mov    %dl,(%rbx,%rax,1)
  jmp    L98
L225:
  movdqu 0x10(%rdx),%xmm3
  movups %xmm3,0x10(%rbx)
  jmp    L98
L247:
  xor    %eax,%eax
  nopl   0x0(%rax,%rax,1)
L180:
  movzbl (%rdx,%rax,1),%ecx
  mov    %cl,(%rbx,%rax,1)
  add    $0x1,%rax
  cmp    $0x20,%rax
  jne    L180
  jmp    L220
L257:
  mov    %esi,%esi
  xor    %eax,%eax
  nopw   0x0(%rax,%rax,1)
L190:
  movzbl (%rdx,%rax,1),%ecx
  mov    %cl,(%rbx,%rax,1)
  add    $0x1,%rax
  cmp    %rax,%rsi
  jne    L190
  jmp    L98
L144:
  mov    %esi,%r8d
  xor    %eax,%eax
  jmp    L13
L166:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int expand_sha2(unsigned char *digest, unsigned n_digest, const unsigned char *hash) {
  if ((32) >= n_digest) {
    for (unsigned i = 0; i < n_digest; i++)
      digest[i] = hash[i];
    return 0;
  } else {
    for (unsigned i = 0; i < (32); i++)
      digest[i] = hash[i];
    n_digest -= (32);
  }
  while ((32) <= n_digest) {
    sha2_chain(digest + (32), digest);
    n_digest -= (32);
    digest += (32);
  }
  unsigned char temp[(32)];
  if (n_digest) {
    sha2_chain(temp, digest);
    for (unsigned i = 0; i < n_digest; i++)
      digest[(32) + i] = temp[i];
  }
  return 0;
}
```