user: 请显示与下面列出的汇编代码相匹配的C语言实现:

```asm
<sign_by_pkey>:
  endbr64
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x20,%rsp
  mov    %rcx,%rbp
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  movq   $0x0,0x8(%rsp)
  mov    %rcx,%rbx
  test   %rcx,%rcx
  je     L93
  mov    %rsi,%r12
  mov    %rdx,%r13
  call   <get_evp_pkey@plt>
  mov    %rax,%rbx
  test   %rax,%rax
  je     L27
  mov    $0x0,%esi
  mov    %rax,%rdi
  call   <EVP_PKEY_CTX_new@plt>
  mov    %rax,%r14
  test   %rax,%rax
  je     L146
  mov    %rax,%rdi
  call   <EVP_PKEY_sign_init@plt>
  test   %rax,%rax
  jle    L16
  movq   $0x0,0x10(%rsp)
  lea    0x10(%rsp),%rsi
  mov    %r14,%rdi
  call   <EVP_PKEY_CTX_get_signature_md@plt>
  mov    %eax,%esi
  cmpq   $0x0,0x10(%rsp)
  lea    D69(%rip),%rdx
  lea    D27(%rip),%rax
  cmove  %rax,%rdx
  lea    D100(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0x0,%eax
  call   <EVP_sha256@plt>
  mov    %eax,%esi
  mov    %r14,%rdi
  call   <EVP_PKEY_CTX_set_signature_md@plt>
  test   %rax,%rax
  jle    L20
  lea    0x8(%rsp),%rdx
  mov    %r13,%r8
  mov    %r12,%rcx
  mov    $0x0,%esi
  mov    %r14,%rdi
  call   <EVP_PKEY_sign@plt>
  test   %rax,%rax
  jle    L155
  mov    0x8(%rsp),%rdi
  call   <malloc@plt>
  mov    %rax,%rsi
  mov    %rax,0x0(%rbp)
  test   %rax,%rax
  je     L38
  lea    0x8(%rsp),%rdx
  mov    %r13,%r8
  mov    %r12,%rcx
  mov    %r14,%rdi
  call   <EVP_PKEY_sign@plt>
  test   %rax,%rax
  jg     L93
  lea    D6(%rip),%rdi
  call   <puts@plt>
  jmp    L93
L27:
  lea    D71(%rip),%rdi
  call   <puts@plt>
L93:
  mov    %rbx,%rdi
  call   <EVP_PKEY_free@plt>
  mov    0x8(%rsp),%rsi
  lea    D72(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  cmpq   $0x0,0x8(%rsp)
  je     L34
  mov    $0x0,%ebx
  lea    D37(%rip),%r12
L152:
  mov    0x0(%rbp),%rax
  mov    (%rax,%rbx,4),%esi
  mov    %r12,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  add    $0x1,%rbx
  cmp    %rbx,0x8(%rsp)
  ja     L152
L34:
  mov    0x18(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L54
  mov    $0x0,%eax
  add    $0x20,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
L146:
  lea    D5(%rip),%rdi
  call   <puts@plt>
  jmp    L93
L16:
  lea    D61(%rip),%rdi
  call   <puts@plt>
  jmp    L93
L20:
  lea    D86(%rip),%rdi
  call   <puts@plt>
  jmp    L93
L155:
  lea    D119(%rip),%rdi
  call   <puts@plt>
  jmp    L93
L38:
  lea    D70(%rip),%rdi
  call   <puts@plt>
  jmp    L93
L54:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: parse_data
arguments: tag: D69
data_type: string
name: parse_data
arguments: tag: D27
data_type: string
name: parse_data
arguments: tag: D100
data_type: string
name: parse_data
arguments: tag: D6
data_type: string
name: parse_data
arguments: tag: D71
data_type: string
name: parse_data
arguments: tag: D72
data_type: string
name: parse_data
arguments: tag: D37
data_type: string
name: parse_data
arguments: tag: D5
data_type: string
name: parse_data
arguments: tag: D61
data_type: string
name: parse_data
arguments: tag: D86
data_type: string
name: parse_data
arguments: tag: D119
data_type: string
name: parse_data
arguments: tag: D70
data_type: string

tool: D69: not null

tool: D27: null

tool: D100: md_type = %d%s


tool: D6: Failed to sign with pkey

tool: D71: Failed to load private key.

tool: D72: sign_len = %d


tool: D37: %02x 

tool: D5: Failed to create pkey ctx

tool: D61: Failed to do sign init

tool: D86: Fail to set signature md

tool: D119: Failed to get sign len

tool: D70: Failed to allocate mem for sign

assistant: ```c
int sign_by_pkey(const char *pkey_file, uint8_t *sign_data, size_t sdata_len, uint8_t **out) {
  size_t sign_len = 0;
  EVP_PKEY_CTX *ctx;
  EVP_PKEY *pkey = NULL;
  do {
    if (!out)
      break;
    if (!(pkey = get_evp_pkey(pkey_file))) {
      printf("Failed to load private key."
             "\n");
      break;
    }
    ctx = EVP_PKEY_CTX_new(pkey, NULL);
    if (!ctx) {
      printf("Failed to create pkey ctx"
             "\n");
      break;
    }
    if (EVP_PKEY_sign_init(ctx) <= 0) {
      printf("Failed to do sign init"
             "\n");
      break;
    }
    EVP_MD *md_ptr = NULL;
    int md_type = EVP_PKEY_CTX_get_signature_md(ctx, &md_ptr);
    printf("md_type = %d%s\n", md_type, md_ptr ? "not null" : "null");
    if (EVP_PKEY_CTX_set_signature_md(ctx, EVP_sha256()) <= 0) {
      printf("Fail to set signature md"
             "\n");
      break;
    }
    if (EVP_PKEY_sign(ctx, NULL, &sign_len, sign_data, sdata_len) <= 0) {
      printf("Failed to get sign len"
             "\n");
      break;
    }
    *out = malloc(sign_len);
    if (!*out) {
      printf("Failed to allocate mem for sign"
             "\n");
      break;
    }
    if (EVP_PKEY_sign(ctx, *out, &sign_len, sign_data, sdata_len) <= 0) {
      printf("Failed to sign with pkey"
             "\n");
      break;
    }
  } while (0);
  EVP_PKEY_free(pkey);
  printf("sign_len = %d\n", sign_len);
  for (int i = 0; i < sign_len; i++) {
    printf("%02x ", (*out)[i]);
  }
  return 0;
}
```