// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movl $0x0, -0x4(%rbp)
movq 0xdfa(%rip), %rax       # 0x2010
movq %rax, -0x20(%rbp)
movq 0xdf7(%rip), %rax       # 0x2018
movq %rax, -0x18(%rbp)
movl 0xdf5(%rip), %eax       # 0x2020
movl %eax, -0x10(%rbp)
movw 0xdef(%rip), %ax        # 0x2024
movw %ax, -0xc(%rbp)
movb 0xde7(%rip), %al        # 0x2026
movb %al, -0xa(%rbp)
movq $0x0, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
callq 0x1050
movq %rax, %rdi
callq 0x10d0
movq %rax, -0x28(%rbp)
movq 0x2d56(%rip), %rax      # 0x3fd0
movq (%rax), %rdi
xorl %esi, %esi
callq 0x1080
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rdi
leaq -0x20(%rbp), %rcx
movl $0x6c, %esi
movl $0x3, %edx
callq 0x1040
movq -0x28(%rbp), %rdi
xorl %eax, %eax
movl %eax, %ecx
movq %rcx, %rsi
movq %rcx, %rdx
callq 0x10e0
movq %rax, -0x38(%rbp)
cmpq $0x0, %rax
jne 0x12dc
movq -0x30(%rbp), %rdi
leaq -0x20(%rbp), %rdx
leaq 0xd5c(%rip), %rsi       # 0x2027
movb $0x0, %al
callq 0x10f0
movl $0x1, %edi
callq 0x10b0
movq -0x30(%rbp), %rdi
leaq 0xd64(%rip), %rsi       # 0x204b
movb $0x0, %al
callq 0x10f0
callq 0x1090
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rdi
callq 0x10a0
movq %rax, -0x40(%rbp)
movq -0x30(%rbp), %rdi
movq -0x40(%rbp), %rsi
xorl %edx, %edx
movl $0x2a40006, %ecx        # imm = 0x2A40006
callq 0x1030
movq -0x30(%rbp), %rdi
leaq 0xd3e(%rip), %rsi       # 0x2061
movb $0x0, %al
callq 0x10f0
callq 0x13a0
movq -0x30(%rbp), %rdi
leaq 0xd2a(%rip), %rsi       # 0x2064
movb $0x0, %al
callq 0x10f0
callq 0x1090
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rdi
callq 0x10a0
movq %rax, -0x40(%rbp)
movq -0x30(%rbp), %rdi
movq -0x40(%rbp), %rsi
xorl %edx, %edx
movl $0x2a40006, %ecx        # imm = 0x2A40006
callq 0x1030
movq -0x30(%rbp), %rdi
leaq 0xcec(%rip), %rsi       # 0x2062
movb $0x0, %al
callq 0x10f0
movq -0x38(%rbp), %rdi
callq 0x1070
movq -0x28(%rbp), %rdi
callq 0x1060
movq -0x30(%rbp), %rdi
callq 0x1060
xorl %edi, %edi
callq 0x10b0
nop