#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int /*<<< orphan*/ EVP_PKEY_ASN1_METHOD;
typedef int /*<<< orphan*/ BIO;

/* Variables and functions */
int ASN1_PKEY_ALIAS;
int ASN1_PKEY_DYNAMIC;
int /*<<< orphan*/ BIO_printf(int /*<<< orphan*/ *, char *, char const *);
int /*<<< orphan*/ *EVP_PKEY_asn1_get0(int);
int /*<<< orphan*/ EVP_PKEY_asn1_get0_info(int *, int *, int *, char const **,
                                           char const **,
                                           int /*<<< orphan*/ const *);
int EVP_PKEY_asn1_get_count();
char const *OBJ_nid2ln(int);
void list_pkey(BIO *out) {
  int i;
  for (i = 0; i < EVP_PKEY_asn1_get_count(); i++) {
    const EVP_PKEY_ASN1_METHOD *ameth;
    int pkey_id, pkey_base_id, pkey_flags;
    const char *pinfo, *pem_str;
    ameth = EVP_PKEY_asn1_get0(i);
    EVP_PKEY_asn1_get0_info(&pkey_id, &pkey_base_id, &pkey_flags, &pinfo,
                            &pem_str, ameth);
    if (pkey_flags & ASN1_PKEY_ALIAS) {
      BIO_printf(out, "Name: %s\n", OBJ_nid2ln(pkey_id));
      BIO_printf(out, "\tType: Alias to %s\n", OBJ_nid2ln(pkey_base_id));
    } else {
      BIO_printf(out, "Name: %s\n", pinfo);
      BIO_printf(out, "\tType: %s Algorithm\n",
                 pkey_flags & ASN1_PKEY_DYNAMIC ? "External" : "Builtin");
      BIO_printf(out, "\tOID: %s\n", OBJ_nid2ln(pkey_id));
      if (pem_str == NULL)
        pem_str = "(none)";
      BIO_printf(out, "\tPEM string: %s\n", pem_str);
    }
  }
}


x86 assembly (clang, -O0):
<list_pkey>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    $0x0,%al
call   1070 <EVP_PKEY_asn1_get_count@plt>
mov    %eax,%ecx
mov    -0x3c(%rbp),%eax
cmp    %ecx,%eax
jge    12ab <list_pkey+0x15b>
mov    -0xc(%rbp),%edi
call   1040 <EVP_PKEY_asn1_get0@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%r9
lea    -0x1c(%rbp),%rdi
lea    -0x20(%rbp),%rsi
lea    -0x24(%rbp),%rdx
lea    -0x30(%rbp),%rcx
lea    -0x38(%rbp),%r8
call   1060 <EVP_PKEY_asn1_get0_info@plt>
mov    -0x24(%rbp),%eax
mov    0x2e38(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1206 <list_pkey+0xb6>
mov    -0x8(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x1c(%rbp),%edi
call   1050 <OBJ_nid2ln@plt>
mov    -0x50(%rbp),%rdi
mov    %rax,%rdx
lea    0xe27(%rip),%rsi
call   1030 <BIO_printf@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x20(%rbp),%edi
call   1050 <OBJ_nid2ln@plt>
mov    -0x48(%rbp),%rdi
mov    %rax,%rdx
lea    0xe0e(%rip),%rsi
call   1030 <BIO_printf@plt>
jmp    1298 <list_pkey+0x148>
mov    -0x8(%rbp),%rdi
mov    -0x30(%rbp),%rdx
lea    0xdeb(%rip),%rsi
call   1030 <BIO_printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x24(%rbp),%ecx
mov    0x2db0(%rip),%rax
and    (%rax),%ecx
lea    0xe0b(%rip),%rdx
lea    0xdfb(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdx
lea    0xdd8(%rip),%rsi
call   1030 <BIO_printf@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x1c(%rbp),%edi
call   1050 <OBJ_nid2ln@plt>
mov    -0x58(%rbp),%rdi
mov    %rax,%rdx
lea    0xddb(%rip),%rsi
call   1030 <BIO_printf@plt>
cmpq   $0x0,-0x38(%rbp)
jne    1284 <list_pkey+0x134>
lea    0xdce(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x38(%rbp),%rdx
lea    0xdc2(%rip),%rsi
call   1030 <BIO_printf@plt>
jmp    129d <list_pkey+0x14d>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1163 <list_pkey+0x13>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<list_pkey>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rdi,%rbx
xor    %eax,%eax
call   1070 <EVP_PKEY_asn1_get_count@plt>
test   %eax,%eax
jle    1281 <list_pkey+0x131>
lea    0x20(%rsp),%r13
lea    0x18(%rsp),%rbp
mov    0x2e67(%rip),%r12
lea    0xe78(%rip),%r14
xor    %r15d,%r15d
jmp    11d6 <list_pkey+0x86>
nopl   (%rax)
mov    0x10(%rsp),%edi
call   1050 <OBJ_nid2ln@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %rax,%rdx
call   1030 <BIO_printf@plt>
mov    0x14(%rsp),%edi
call   1050 <OBJ_nid2ln@plt>
mov    %rbx,%rdi
lea    0xe50(%rip),%rsi
mov    %rax,%rdx
call   1030 <BIO_printf@plt>
add    $0x1,%r15d
xor    %eax,%eax
call   1070 <EVP_PKEY_asn1_get_count@plt>
cmp    %eax,%r15d
jge    1281 <list_pkey+0x131>
mov    %r15d,%edi
call   1040 <EVP_PKEY_asn1_get0@plt>
lea    0x10(%rsp),%rdi
lea    0x14(%rsp),%rsi
lea    0xc(%rsp),%rdx
mov    %r13,%rcx
mov    %rbp,%r8
mov    %rax,%r9
call   1060 <EVP_PKEY_asn1_get0_info@plt>
mov    (%r12),%eax
test   %eax,0xc(%rsp)
jne    1190 <list_pkey+0x40>
mov    0x20(%rsp),%rdx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <BIO_printf@plt>
mov    0x2dbc(%rip),%rax
mov    (%rax),%eax
lea    0xe17(%rip),%rdx
and    0xc(%rsp),%eax
je     1232 <list_pkey+0xe2>
lea    0xe01(%rip),%rdx
mov    %rbx,%rdi
lea    0xde2(%rip),%rsi
call   1030 <BIO_printf@plt>
mov    0x10(%rsp),%edi
call   1050 <OBJ_nid2ln@plt>
mov    %rbx,%rdi
lea    0xdf0(%rip),%rsi
mov    %rax,%rdx
call   1030 <BIO_printf@plt>
mov    0x18(%rsp),%rdx
test   %rdx,%rdx
jne    1272 <list_pkey+0x122>
lea    0xde1(%rip),%rdx
mov    %rdx,0x18(%rsp)
mov    %rbx,%rdi
lea    0xdd9(%rip),%rsi
jmp    11bd <list_pkey+0x6d>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@ASN1_PKEY_ALIAS = global i32 0
@.str = [10 x i8] c"Name: %s\0A\00"
@.str.1 = [20 x i8] c"\09Type: Alias to %s\0A\00"
@.str.2 = [21 x i8] c"\09Type: %s Algorithm\0A\00"
@ASN1_PKEY_DYNAMIC = global i32 0
@.str.3 = [9 x i8] c"External\00"
@.str.4 = [8 x i8] c"Builtin\00"
@.str.5 = [10 x i8] c"\09OID: %s\0A\00"
@.str.6 = [7 x i8] c"(none)\00"
@.str.7 = [17 x i8] c"\09PEM string: %s\0A\00"
define void @list_pkey(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
store i32* %0, i32** %2
store i32 0, i32* %3
br label %10
10: ; preds = %56, %1
%11 = load i32, i32* %3
%12 = call i32 (...) @EVP_PKEY_asn1_get_count()
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %59
14: ; preds = %10
%15 = load i32, i32* %3
%16 = call i32* @EVP_PKEY_asn1_get0(i32 %15)
store i32* %16, i32** %4
%17 = load i32*, i32** %4
%18 = call i32 @EVP_PKEY_asn1_get0_info(i32* %5, i32* %6, i32* %7, i8** %8, i8** %9, i32* %17)
%19 = load i32, i32* %7
%20 = load i32, i32* @ASN1_PKEY_ALIAS
%21 = and i32 %19, %20
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %32
23: ; preds = %14
%24 = load i32*, i32** %2
%25 = load i32, i32* %5
%26 = call i8* @OBJ_nid2ln(i32 %25)
%27 = call i32 @BIO_printf(i32* %24, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %26)
%28 = load i32*, i32** %2
%29 = load i32, i32* %6
%30 = call i8* @OBJ_nid2ln(i32 %29)
%31 = call i32 @BIO_printf(i32* %28, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %30)
br label %55
32: ; preds = %14
%33 = load i32*, i32** %2
%34 = load i8*, i8** %8
%35 = call i32 @BIO_printf(i32* %33, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %34)
%36 = load i32*, i32** %2
%37 = load i32, i32* %7
%38 = load i32, i32* @ASN1_PKEY_DYNAMIC
%39 = and i32 %37, %38
%40 = icmp ne i32 %39, 0
%41 = zext i1 %40 to i64
%42 = select i1 %40, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0)
%43 = call i32 @BIO_printf(i32* %36, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %42)
%44 = load i32*, i32** %2
%45 = load i32, i32* %5
%46 = call i8* @OBJ_nid2ln(i32 %45)
%47 = call i32 @BIO_printf(i32* %44, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i8* %46)
%48 = load i8*, i8** %9
%49 = icmp eq i8* %48, null
br i1 %49, label %50, label %51
50: ; preds = %32
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8** %9
br label %51
51: ; preds = %50, %32
%52 = load i32*, i32** %2
%53 = load i8*, i8** %9
%54 = call i32 @BIO_printf(i32* %52, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0), i8* %53)
br label %55
55: ; preds = %51, %23
br label %56
56: ; preds = %55
%57 = load i32, i32* %3
%58 = add nsw i32 %57, 1
store i32 %58, i32* %3
br label %10
59: ; preds = %10
ret void
}

LLVM IR (-O2):
@ASN1_PKEY_ALIAS = global i32 0
@.str = [10 x i8] c"Name: %s\0A\00"
@.str.1 = [20 x i8] c"\09Type: Alias to %s\0A\00"
@.str.2 = [21 x i8] c"\09Type: %s Algorithm\0A\00"
@ASN1_PKEY_DYNAMIC = global i32 0
@.str.3 = [9 x i8] c"External\00"
@.str.4 = [8 x i8] c"Builtin\00"
@.str.5 = [10 x i8] c"\09OID: %s\0A\00"
@.str.6 = [7 x i8] c"(none)\00"
@.str.7 = [17 x i8] c"\09PEM string: %s\0A\00"
define void @list_pkey(i32* %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = call i32 (...) @EVP_PKEY_asn1_get_count()
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %52
9: ; preds = %1
%10 = bitcast i32* %2 to i8*
%11 = bitcast i32* %3 to i8*
%12 = bitcast i32* %4 to i8*
%13 = bitcast i8** %5 to i8*
%14 = bitcast i8** %6 to i8*
br label %15
15: ; preds = %9, %48
%16 = phi i32 [ 0, %9 ], [ %49, %48 ]
%17 = call i32* @EVP_PKEY_asn1_get0(i32 %16)
%18 = call i32 @EVP_PKEY_asn1_get0_info(i32* %2, i32* %3, i32* %4, i8** %5, i8** %6, i32* %17)
%19 = load i32, i32* %4
%20 = load i32, i32* @ASN1_PKEY_ALIAS
%21 = and i32 %20, %19
%22 = icmp eq i32 %21, 0
br i1 %22, label %30, label %23
23: ; preds = %15
%24 = load i32, i32* %2
%25 = call i8* @OBJ_nid2ln(i32 %24)
%26 = call i32 @BIO_printf(i32* %0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %25)
%27 = load i32, i32* %3
%28 = call i8* @OBJ_nid2ln(i32 %27)
%29 = call i32 @BIO_printf(i32* %0, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %28)
br label %48
30: ; preds = %15
%31 = load i8*, i8** %5
%32 = call i32 @BIO_printf(i32* %0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %31)
%33 = load i32, i32* %4
%34 = load i32, i32* @ASN1_PKEY_DYNAMIC
%35 = and i32 %34, %33
%36 = icmp eq i32 %35, 0
%37 = select i1 %36, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0)
%38 = call i32 @BIO_printf(i32* %0, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %37)
%39 = load i32, i32* %2
%40 = call i8* @OBJ_nid2ln(i32 %39)
%41 = call i32 @BIO_printf(i32* %0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i8* %40)
%42 = load i8*, i8** %6
%43 = icmp eq i8* %42, null
br i1 %43, label %44, label %45
44: ; preds = %30
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8** %6
br label %45
45: ; preds = %44, %30
%46 = phi i8* [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), %44 ], [ %42, %30 ]
%47 = call i32 @BIO_printf(i32* %0, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0), i8* %46)
br label %48
48: ; preds = %45, %23
%49 = add nuw nsw i32 %16, 1
%50 = call i32 (...) @EVP_PKEY_asn1_get_count()
%51 = icmp slt i32 %49, %50
br i1 %51, label %15, label %52
52: ; preds = %48, %1
ret void
}