// File: /workspace/github_c_makefile_star2_O2/fm4dd[P]learn-ssl/add_ev_oids.c
// Function: main
int main() {

  const char cert_filestr[] = "./demo/evcert-file.pem";
  BIO              *certbio = NULL;
  BIO               *outbio = NULL;
  X509                *cert = NULL;
  X509_NAME    *certsubject = NULL;

  /* ---------------------------------------------------------- *
   * Create the Input/Output BIO's.                             *
   * ---------------------------------------------------------- */
  certbio = BIO_new(BIO_s_file());
  outbio  = BIO_new_fp(stdout, BIO_NOCLOSE);

  /* ---------------------------------------------------------- *
   * Load the certificate from file (PEM).                      *
   * ---------------------------------------------------------- */
  BIO_read_filename(certbio, cert_filestr);
  if (! (cert = PEM_read_bio_X509(certbio, NULL, 0, NULL))) {
    BIO_printf(outbio, "Error loading cert into memory: %s\n", cert_filestr);
    exit(1);
  }

  /* ---------------------------------------------------------- *
   * Print the certificate subject here                         *
   * ---------------------------------------------------------- */
  BIO_printf(outbio, "Before OBJ_create():\n");
  certsubject = X509_NAME_new();
  certsubject = X509_get_subject_name(cert);
  X509_NAME_print_ex(outbio, certsubject, 0, XN_FLAG_MULTILINE);
  BIO_printf(outbio, "\n\n");

  add_missing_ev_oids();

  BIO_printf(outbio, "After OBJ_create():\n");
  certsubject = X509_NAME_new();
  certsubject = X509_get_subject_name(cert);
  X509_NAME_print_ex(outbio, certsubject, 0, XN_FLAG_MULTILINE);
  BIO_printf(outbio, "\n");

  /* ---------------------------------------------------------- *
   * Free up all structures                                     *
   * ---------------------------------------------------------- */
  X509_free(cert);
  BIO_free_all(certbio);
  BIO_free_all(outbio);
  exit(0);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x20, %rsp
movaps 0xe04(%rip), %xmm0      # 0x2010
movq %rsp, %r15
movaps %xmm0, (%r15)
movabsq $0x6d65702e656c69, %rax # imm = 0x6D65702E656C69
movq %rax, 0xf(%r15)
callq 0x1050
movq %rax, %rdi
callq 0x10d0
movq %rax, %r14
movq 0x2d98(%rip), %rax      # 0x3fd0
movq (%rax), %rdi
xorl %esi, %esi
callq 0x1080
movq %rax, %rbx
pushq $0x6c
popq %rsi
pushq $0x3
popq %rdx
movq %r14, %rdi
movq %r15, %rcx
callq 0x1040
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x10e0
testq %rax, %rax
jne 0x1285
leaq 0xdb7(%rip), %rsi       # 0x2027
movq %rsp, %rdx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x10f0
pushq $0x1
popq %rdi
callq 0x10b0
movq %rax, %r15
leaq 0xdbc(%rip), %rsi       # 0x204b
movq %rbx, %rdi
xorl %eax, %eax
callq 0x10f0
callq 0x1090
movq %r15, %rdi
callq 0x10a0
movl $0x2a40006, %ecx        # imm = 0x2A40006
movq %rbx, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x1030
leaq 0xda2(%rip), %rsi       # 0x2061
movq %rbx, %rdi
xorl %eax, %eax
callq 0x10f0
callq 0x132e
leaq 0xd8f(%rip), %rsi       # 0x2064
movq %rbx, %rdi
xorl %eax, %eax
callq 0x10f0
callq 0x1090
movq %r15, %rdi
callq 0x10a0
movl $0x2a40006, %ecx        # imm = 0x2A40006
movq %rbx, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x1030
leaq 0xd5d(%rip), %rsi       # 0x2062
movq %rbx, %rdi
xorl %eax, %eax
callq 0x10f0
movq %r15, %rdi
callq 0x1070
movq %r14, %rdi
callq 0x1060
movq %rbx, %rdi
callq 0x1060
xorl %edi, %edi
callq 0x10b0