#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 */
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
typedef int /*<<< orphan*/ X509;
struct TYPE_3__ {
  int /*<<< orphan*/ length;
  int /*<<< orphan*/ data;
};
typedef int /*<<< orphan*/ EVP_MD;
typedef TYPE_1__ ASN1_BIT_STRING;

/* Variables and functions */
int EVP_Digest(int /*<<< orphan*/, int /*<<< orphan*/, unsigned char *,
               unsigned int *, int /*<<< orphan*/ const *,
               int /*<<< orphan*/ *);
TYPE_1__ *X509_get0_pubkey_bitstr(int /*<<< orphan*/ const *);
int X509_pubkey_digest(const X509 *data, const EVP_MD *type, unsigned char *md,
                       unsigned int *len) {
  ASN1_BIT_STRING *key;
  key = X509_get0_pubkey_bitstr(data);
  if (!key)
    return 0;
  return EVP_Digest(key->data, key->length, md, len, type, NULL);
}


x86 assembly (clang, -O0):
<X509_pubkey_digest>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <X509_get0_pubkey_bitstr@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    115c <X509_pubkey_digest+0x3c>
movl   $0x0,-0x4(%rbp)
jmp    1182 <X509_pubkey_digest+0x62>
mov    -0x30(%rbp),%rax
mov    0x4(%rax),%edi
mov    -0x30(%rbp),%rax
mov    (%rax),%esi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x18(%rbp),%r8
xor    %eax,%eax
mov    %eax,%r9d
call   1040 <EVP_Digest@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<X509_pubkey_digest>:
push   %r15
push   %r14
push   %rbx
mov    %rcx,%r14
mov    %rdx,%rbx
mov    %rsi,%r15
call   1030 <X509_get0_pubkey_bitstr@plt>
test   %rax,%rax
je     1153 <X509_pubkey_digest+0x33>
mov    (%rax),%esi
mov    0x4(%rax),%edi
mov    %rbx,%rdx
mov    %r14,%rcx
mov    %r15,%r8
xor    %r9d,%r9d
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <EVP_Digest@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { i32, i32 }
define i32 @X509_pubkey_digest(i32* %0, i32* %1, i8* %2, i32* %3) {
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i8*
%9 = alloca i32*
%10 = alloca %struct.TYPE_3__*
store i32* %0, i32** %6
store i32* %1, i32** %7
store i8* %2, i8** %8
store i32* %3, i32** %9
%11 = load i32*, i32** %6
%12 = call %struct.TYPE_3__* @X509_get0_pubkey_bitstr(i32* %11)
store %struct.TYPE_3__* %12, %struct.TYPE_3__** %10
%13 = load %struct.TYPE_3__*, %struct.TYPE_3__** %10
%14 = icmp ne %struct.TYPE_3__* %13, null
br i1 %14, label %16, label %15
15: ; preds = %4
store i32 0, i32* %5
br label %27
16: ; preds = %4
%17 = load %struct.TYPE_3__*, %struct.TYPE_3__** %10
%18 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %17, i32 0, i32 1
%19 = load i32, i32* %18
%20 = load %struct.TYPE_3__*, %struct.TYPE_3__** %10
%21 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %20, i32 0, i32 0
%22 = load i32, i32* %21
%23 = load i8*, i8** %8
%24 = load i32*, i32** %9
%25 = load i32*, i32** %7
%26 = call i32 @EVP_Digest(i32 %19, i32 %22, i8* %23, i32* %24, i32* %25, i32* null)
store i32 %26, i32* %5
br label %27
27: ; preds = %16, %15
%28 = load i32, i32* %5
ret i32 %28
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i32, i32 }
define i32 @X509_pubkey_digest(i32* %0, i32* %1, i8* %2, i32* %3) {
%5 = tail call %struct.TYPE_3__* @X509_get0_pubkey_bitstr(i32* %0)
%6 = icmp eq %struct.TYPE_3__* %5, null
br i1 %6, label %13, label %7
7: ; preds = %4
%8 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %5, i64 0, i32 1
%9 = load i32, i32* %8
%10 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %5, i64 0, i32 0
%11 = load i32, i32* %10
%12 = tail call i32 @EVP_Digest(i32 %9, i32 %11, i8* %2, i32* %3, i32* %1, i32* null)
br label %13
13: ; preds = %4, %7
%14 = phi i32 [ %12, %7 ], [ 0, %4 ]
ret i32 %14
}