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

```asm
<genkey>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  lea    D101(%rip),%r13
  push   %r12
  mov    %rdx,%r12
  push   %rbp
  mov    %edi,%ebp
  mov    %rsi,%rdi
  mov    %r13,%rsi
  push   %rbx
  sub    $0x428,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x418(%rsp)
  xor    %eax,%eax
  call   <fopen@plt>
  mov    %rax,%r14
  test   %rax,%rax
  je     L92
L127:
  mov    %r13,%rsi
  mov    %r12,%rdi
  call   <fopen@plt>
  mov    %rax,0x8(%rsp)
  test   %rax,%rax
  je     L6
L140:
  lea    D31(%rip),%rdi
  call   <puts@plt>
  xor    %eax,%eax
  call   <RSA_new@plt>
  mov    %rax,%r12
  test   %rax,%rax
  je     L34
L129:
  xor    %eax,%eax
  call   <BN_new@plt>
  mov    $0x11,%esi
  mov    %rax,%r15
  mov    %rax,%rdi
  call   <BN_set_word@plt>
  xor    %ecx,%ecx
  mov    %r15,%rdx
  mov    %ebp,%esi
  mov    %r12,%rdi
  call   <RSA_generate_key_ex@plt>
  test   %rax,%rax
  je     L101
L84:
  lea    D80(%rip),%rdi
  lea    0x10(%rsp),%rbx
  call   <puts@plt>
  xor    %eax,%eax
  lea    D69(%rip),%r13
  call   <BIO_s_mem@plt>
  mov    %eax,%edi
  call   <BIO_new@plt>
  mov    $0x4,%edx
  mov    %r12,%rsi
  mov    %rax,%rdi
  mov    %rax,%rbp
  call   <RSA_print@plt>
  mov    $0x400,%edx
  xor    %esi,%esi
  mov    %rbx,%rdi
  call   <memset@plt>
  jmp    L106
  nopl   0x0(%rax)
L116:
  mov    %rbx,%rsi
  mov    %r13,%rdi
  xor    %eax,%eax
  call   <printf@plt>
  mov    $0x400,%edx
  xor    %esi,%esi
  mov    %rbx,%rdi
  call   <memset@plt>
L106:
  mov    $0x400,%edx
  mov    %rbx,%rsi
  mov    %rbp,%rdi
  call   <BIO_read@plt>
  test   %rax,%rax
  jg     L116
  lea    D85(%rip),%rdi
  call   <puts@plt>
  mov    0x8(%rsp),%rdi
  mov    %r12,%rsi
  call   <PEM_write_RSA_PUBKEY@plt>
  test   %eax,%eax
  je     L78
L137:
  xor    %eax,%eax
  call   <EVP_aes_128_cbc@plt>
  sub    $0x8,%rsp
  xor    %r9d,%r9d
  xor    %r8d,%r8d
  push   $0x0
  mov    %eax,%edx
  xor    %ecx,%ecx
  mov    %r12,%rsi
  mov    %r14,%rdi
  call   <PEM_write_RSAPrivateKey@plt>
  mov    %eax,%r13d
  pop    %rax
  pop    %rdx
  test   %r13d,%r13d
  je     L39
L25:
  mov    %r12,%rdi
  call   <RSA_free@plt>
  mov    %r15,%rdi
  call   <BN_free@plt>
  mov    %r14,%rdi
  call   <fclose@plt>
  mov    0x8(%rsp),%rdi
  call   <fclose@plt>
  mov    0x418(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L49
  add    $0x428,%rsp
  mov    %r13d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L101:
  lea    D36(%rip),%rdi
  call   <puts@plt>
  mov    %r12,%rdi
  call   <RSA_free@plt>
  mov    $0x1,%edi
  call   <exit@plt>
  jmp    L84
  nopl   0x0(%rax,%rax,1)
L39:
  lea    D33(%rip),%rdi
  call   <puts@plt>
  jmp    L25
  nopl   0x0(%rax)
L78:
  lea    D18(%rip),%rdi
  call   <puts@plt>
  jmp    L137
  nopl   0x0(%rax)
L34:
  lea    D84(%rip),%rdi
  call   <puts@plt>
  mov    $0x1,%edi
  call   <exit@plt>
  jmp    L129
  nopl   0x0(%rax,%rax,1)
L92:
  lea    D37(%rip),%rdi
  call   <puts@plt>
  mov    $0x1,%edi
  call   <exit@plt>
  jmp    L127
  nopl   0x0(%rax,%rax,1)
L6:
  lea    D37(%rip),%rdi
  call   <puts@plt>
  mov    $0x1,%edi
  call   <exit@plt>
  jmp    L140
L49:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: read_data
arguments: data_tag: D101
type: string
name: read_data
arguments: data_tag: D31
type: string
name: read_data
arguments: data_tag: D80
type: string
name: read_data
arguments: data_tag: D69
type: string
name: read_data
arguments: data_tag: D85
type: string
name: read_data
arguments: data_tag: D36
type: string
name: read_data
arguments: data_tag: D33
type: string
name: read_data
arguments: data_tag: D18
type: string
name: read_data
arguments: data_tag: D84
type: string
name: read_data
arguments: data_tag: D37
type: string

tool: D101: wb

tool: D31: Starting generating RSA key pair...

tool: D80: Key pair generated successfully!

tool: D69: %s

tool: D85: Writing keys to files...

tool: D36: Error during generation of RSA key pair!

tool: D33: Error occured when trying to store private key!

tool: D18: Error occured when trying to store public key!

tool: D84: Error during generation of RSA structure!

tool: D37: Open file error occurred

assistant: ```c
int genkey(int keyLength, const char *privKey, const char *pubKey) {
  int result = 0;
  unsigned char buffer[1024];
  RSA *rsa = NULL;
  BIO *bio = NULL;
  BIGNUM *bigNum = NULL;
  FILE *privKeyFile;
  FILE *pubKeyFile;
  if ((privKeyFile = fopen(privKey, "wb")) == NULL) {
    printf("Open file error occurred\n");
    exit(1);
  }
  if ((pubKeyFile = fopen(pubKey, "wb")) == NULL) {
    printf("Open file error occurred\n");
    exit(1);
  }
  printf("Starting generating RSA key pair...\n");
  rsa = RSA_new();
  if (rsa == NULL) {
    printf("Error during generation of RSA structure!\n");
    exit(1);
  }
  bigNum = BN_new();
  BN_set_word(bigNum, 17);
  if (RSA_generate_key_ex(rsa, keyLength, bigNum, NULL) == 0) {
    printf("Error during generation of RSA key pair!\n");
    RSA_free(rsa);
    exit(1);
  }
  printf("Key pair generated successfully!\n");
  bio = BIO_new(BIO_s_mem());
  RSA_print(bio, rsa, 4);
  memset(buffer, 0, 1024);
  while (BIO_read(bio, buffer, 1024) > 0) {
    printf("%s", buffer);
    memset(buffer, 0, 1024);
  }
  printf("Writing keys to files...\n");
  result = PEM_write_RSA_PUBKEY(pubKeyFile, rsa);
  if (result == 0) {
    printf("Error occured when trying to store public key!\n");
  }
  result = PEM_write_RSAPrivateKey(privKeyFile, rsa, EVP_aes_128_cbc(), NULL, 0, 0, NULL);
  if (result == 0) {
    printf("Error occured when trying to store private key!\n");
  }
  RSA_free(rsa);
  BN_free(bigNum);
  fclose(privKeyFile);
  fclose(pubKeyFile);
  return result;
}
```