#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;
typedef int /*<<< orphan*/ ASN1_OCTET_STRING;

/* Variables and functions */
int /*<<< orphan*/ ASN1_OCTET_STRING_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ *ASN1_OCTET_STRING_new();
int /*<<< orphan*/ ASN1_OCTET_STRING_set(int /*<<< orphan*/ *,
                                         unsigned char const *, int);
int /*<<< orphan*/ EVP_PKEY_HMAC;
int /*<<< orphan*/ EVP_PKEY_assign(int /*<<< orphan*/ *, int /*<<< orphan*/,
                                   int /*<<< orphan*/ *);
int old_hmac_decode(EVP_PKEY *pkey, const unsigned char **pder, int derlen) {
  ASN1_OCTET_STRING *os;
  os = ASN1_OCTET_STRING_new();
  if (!os || !ASN1_OCTET_STRING_set(os, *pder, derlen))
    goto err;
  if (!EVP_PKEY_assign(pkey, EVP_PKEY_HMAC, os))
    goto err;
  return 1;
err:
  ASN1_OCTET_STRING_free(os);
  return 0;
}


x86 assembly (clang, -O0):
<old_hmac_decode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    $0x0,%al
call   1030 <ASN1_OCTET_STRING_new@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1185 <old_hmac_decode+0x45>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
mov    -0x1c(%rbp),%edx
call   1050 <ASN1_OCTET_STRING_set@plt>
cmp    $0x0,%eax
jne    118a <old_hmac_decode+0x4a>
jmp    11ba <old_hmac_decode+0x7a>
mov    -0x10(%rbp),%rdi
mov    0x2e53(%rip),%rax
mov    (%rax),%esi
mov    -0x28(%rbp),%rdx
call   1060 <EVP_PKEY_assign@plt>
cmp    $0x0,%eax
jne    11ae <old_hmac_decode+0x6e>
jmp    11ba <old_hmac_decode+0x7a>
movl   $0x1,-0x4(%rbp)
jmp    11ca <old_hmac_decode+0x8a>
mov    -0x28(%rbp),%rdi
call   1040 <ASN1_OCTET_STRING_free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<old_hmac_decode>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r15d
mov    %rsi,%rbp
mov    %rdi,%r14
xor    %eax,%eax
call   1030 <ASN1_OCTET_STRING_new@plt>
mov    %rax,%rbx
test   %rax,%rax
je     1191 <old_hmac_decode+0x51>
mov    0x0(%rbp),%rsi
mov    %rbx,%rdi
mov    %r15d,%edx
call   1050 <ASN1_OCTET_STRING_set@plt>
test   %eax,%eax
je     1191 <old_hmac_decode+0x51>
mov    0x2e6f(%rip),%rax
mov    (%rax),%esi
mov    %r14,%rdi
mov    %rbx,%rdx
call   1060 <EVP_PKEY_assign@plt>
mov    %eax,%ecx
mov    $0x1,%eax
test   %ecx,%ecx
jne    119b <old_hmac_decode+0x5b>
mov    %rbx,%rdi
call   1040 <ASN1_OCTET_STRING_free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EVP_PKEY_HMAC = global i32 0
define i32 @old_hmac_decode(i32* %0, i8** %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i8**
%7 = alloca i32
%8 = alloca i32*
store i32* %0, i32** %5
store i8** %1, i8*** %6
store i32 %2, i32* %7
%9 = call i32* (...) @ASN1_OCTET_STRING_new()
store i32* %9, i32** %8
%10 = load i32*, i32** %8
%11 = icmp ne i32* %10, null
br i1 %11, label %12, label %19
12: ; preds = %3
%13 = load i32*, i32** %8
%14 = load i8**, i8*** %6
%15 = load i8*, i8** %14
%16 = load i32, i32* %7
%17 = call i32 @ASN1_OCTET_STRING_set(i32* %13, i8* %15, i32 %16)
%18 = icmp ne i32 %17, 0
br i1 %18, label %20, label %19
19: ; preds = %12, %3
br label %28
20: ; preds = %12
%21 = load i32*, i32** %5
%22 = load i32, i32* @EVP_PKEY_HMAC
%23 = load i32*, i32** %8
%24 = call i32 @EVP_PKEY_assign(i32* %21, i32 %22, i32* %23)
%25 = icmp ne i32 %24, 0
br i1 %25, label %27, label %26
26: ; preds = %20
br label %28
27: ; preds = %20
store i32 1, i32* %4
br label %31
28: ; preds = %26, %19
%29 = load i32*, i32** %8
%30 = call i32 @ASN1_OCTET_STRING_free(i32* %29)
store i32 0, i32* %4
br label %31
31: ; preds = %28, %27
%32 = load i32, i32* %4
ret i32 %32
}

LLVM IR (-O2):
@EVP_PKEY_HMAC = global i32 0
define i32 @old_hmac_decode(i32* %0, i8** nocapture %1, i32 %2) {
%4 = tail call i32* (...) @ASN1_OCTET_STRING_new()
%5 = icmp eq i32* %4, null
br i1 %5, label %14, label %6
6: ; preds = %3
%7 = load i8*, i8** %1
%8 = tail call i32 @ASN1_OCTET_STRING_set(i32* %4, i8* %7, i32 %2)
%9 = icmp eq i32 %8, 0
br i1 %9, label %14, label %10
10: ; preds = %6
%11 = load i32, i32* @EVP_PKEY_HMAC
%12 = tail call i32 @EVP_PKEY_assign(i32* %0, i32 %11, i32* %4)
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %10, %3, %6
%15 = tail call i32 @ASN1_OCTET_STRING_free(i32* %4)
br label %16
16: ; preds = %10, %14
%17 = phi i32 [ 0, %14 ], [ 1, %10 ]
ret i32 %17
}