user: 请从给定的汇编指令推导出C源代码:

```asm
<shahash>:
  endbr64
  push   %r15
  mov    %rdi,%r15
  mov    $0x14,%edi
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x58,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x48(%rsp)
  xor    %eax,%eax
  call   <malloc@plt>
  mov    %rax,%rdi
  mov    %rax,%r13
  call   <sha_init@plt>
  mov    %r15,%rdi
  call   <strlen@plt>
  test   %eax,%eax
  je     L66
  mov    %eax,%r14d
  mov    $0x0,%r12d
  mov    %rsp,%rbp
  jle    L65
  nopl   0x0(%rax)
L79:
  mov    $0x41,%edx
  xor    %esi,%esi
  mov    %rbp,%rdi
  call   <memset@plt>
  mov    $0x40,%edx
  mov    %r15,%rsi
  mov    %rbp,%rdi
  call   <strncpy@plt>
  mov    %rbp,%rdi
  call   <strlen@plt>
  mov    %eax,%ebx
  cltq
  sub    %ebx,%r14d
  add    %rax,%r12
  test   %r14d,%r14d
  jle    L39
  mov    %r13,%rsi
  mov    %rbp,%rdi
  add    $0x40,%r15
  call   <sha_hash@plt>
  jmp    L79
  nopw   0x0(%rax,%rax,1)
L39:
  lea    0x1(%rbx),%edi
  movb   $0x80,(%rsp,%rax,1)
  shl    $0x3,%r12
  cmp    $0x3f,%edi
  jg     L22
  mov    $0x3e,%edx
  movslq %edi,%rdi
  xor    %esi,%esi
  sub    %ebx,%edx
  add    %rbp,%rdi
  add    $0x1,%rdx
  call   <memset@plt>
L22:
  cmp    $0x37,%ebx
  jg     L47
L42:
  lea    0x38(%rsp),%rax
  lea    0x40(%rsp),%rsi
  mov    $0x38,%ecx
L92:
  mov    %r12,%rdx
  add    $0x1,%rax
  sar    %cl,%rdx
  sub    $0x8,%ecx
  mov    %dl,-0x1(%rax)
  cmp    %rsi,%rax
  jne    L92
  mov    %r13,%rsi
  mov    %rbp,%rdi
  call   <sha_hash@plt>
L65:
  lea    D8(%rip),%r12
  mov    %r13,%rsi
  mov    %r12,%rdi
  call   <strprintsha@plt>
  mov    %r13,%rdi
  call   <free@plt>
  mov    0x48(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L76
  add    $0x58,%rsp
  mov    %r12,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L66:
  mov    %rsp,%rbp
  xor    %esi,%esi
  mov    $0x41,%edx
  mov    %rbp,%rdi
  call   <memset@plt>
  mov    %r13,%rsi
  mov    %rbp,%rdi
  movb   $0x80,(%rsp)
  call   <sha_hash@plt>
  jmp    L65
  nopl   0x0(%rax,%rax,1)
L47:
  mov    %r13,%rsi
  mov    %rbp,%rdi
  call   <sha_hash@plt>
  pxor   %xmm0,%xmm0
  movq   $0x0,0x30(%rsp)
  movaps %xmm0,(%rsp)
  movaps %xmm0,0x10(%rsp)
  movaps %xmm0,0x20(%rsp)
  jmp    L42
L76:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
char *shahash(const char *str) {
  char read_buffer[65];
  int c = 1, i;
  long long length = 0;
  int strsz;
  static char final[40];
  int *hashval;
  hashval = (int *)malloc(20);
  sha_init(hashval);
  strsz = strlen(str);
  if (strsz == 0) {
    memset(read_buffer, 0, 65);
    read_buffer[0] = 0x80;
    sha_hash((int *)read_buffer, hashval);
  }
  while (strsz > 0) {
    memset(read_buffer, 0, 65);
    strncpy((char *)read_buffer, str, 64);
    c = strlen((char *)read_buffer);
    length += c;
    strsz -= c;
    if (strsz <= 0) {
      length <<= 3;
      read_buffer[c] = (char)0x80;
      for (i = c + 1; i < 64; i++)
        read_buffer[i] = 0;
      if (c > 55) {
        sha_hash((int *)read_buffer, hashval);
        for (i = 0; i < 14; i++)
          ((int *)read_buffer)[i] = 0;
      }
      for (i = 0; i < 8; i++) {
        read_buffer[56 + i] = (char)(length >> (56 - (i * 8))) & 0xff;
      }
    }
    sha_hash((int *)read_buffer, hashval);
    str += 64;
  }
  strprintsha((char *) final, hashval);
  free(hashval);
  return (char *) final;
}
```