#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();
scalar_t__ ASN1_OCTET_STRING_set(int /*<<< orphan*/ *, unsigned char const *,
                                 int);
int /*<<< orphan*/ EVP_PKEY_HMAC;
scalar_t__ 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 == NULL)
    goto err;
  if (ASN1_OCTET_STRING_set(os, *pder, derlen) == 0)
    goto err;
  if (EVP_PKEY_assign(pkey, EVP_PKEY_HMAC, os) == 0)
    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)
jne    116e <old_hmac_decode+0x2e>
jmp    11c1 <old_hmac_decode+0x81>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
mov    -0x1c(%rbp),%edx
call   1050 <ASN1_OCTET_STRING_set@plt>
cmp    $0x0,%rax
jne    1190 <old_hmac_decode+0x50>
jmp    11c1 <old_hmac_decode+0x81>
mov    -0x10(%rbp),%rdi
mov    0x2e4d(%rip),%rax
mov    (%rax),%esi
mov    -0x28(%rbp),%rdx
call   1060 <EVP_PKEY_assign@plt>
cmp    $0x0,%rax
jne    11b5 <old_hmac_decode+0x75>
jmp    11c1 <old_hmac_decode+0x81>
movl   $0x1,-0x4(%rbp)
jmp    11d1 <old_hmac_decode+0x91>
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     1194 <old_hmac_decode+0x54>
mov    0x0(%rbp),%rsi
mov    %rbx,%rdi
mov    %r15d,%edx
call   1050 <ASN1_OCTET_STRING_set@plt>
test   %rax,%rax
je     1194 <old_hmac_decode+0x54>
mov    0x2e6e(%rip),%rax
mov    (%rax),%esi
mov    %r14,%rdi
mov    %rbx,%rdx
call   1060 <EVP_PKEY_assign@plt>
mov    %rax,%rcx
mov    $0x1,%eax
test   %rcx,%rcx
jne    119e <old_hmac_decode+0x5e>
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 eq i32* %10, null
br i1 %11, label %12, label %13
12: ; preds = %3
br label %29
13: ; preds = %3
%14 = load i32*, i32** %8
%15 = load i8**, i8*** %6
%16 = load i8*, i8** %15
%17 = load i32, i32* %7
%18 = call i64 @ASN1_OCTET_STRING_set(i32* %14, i8* %16, i32 %17)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %13
br label %29
21: ; preds = %13
%22 = load i32*, i32** %5
%23 = load i32, i32* @EVP_PKEY_HMAC
%24 = load i32*, i32** %8
%25 = call i64 @EVP_PKEY_assign(i32* %22, i32 %23, i32* %24)
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %21
br label %29
28: ; preds = %21
store i32 1, i32* %4
br label %32
29: ; preds = %27, %20, %12
%30 = load i32*, i32** %8
%31 = call i32 @ASN1_OCTET_STRING_free(i32* %30)
store i32 0, i32* %4
br label %32
32: ; preds = %29, %28
%33 = load i32, i32* %4
ret i32 %33
}

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 i64 @ASN1_OCTET_STRING_set(i32* %4, i8* %7, i32 %2)
%9 = icmp eq i64 %8, 0
br i1 %9, label %14, label %10
10: ; preds = %6
%11 = load i32, i32* @EVP_PKEY_HMAC
%12 = tail call i64 @EVP_PKEY_assign(i32* %0, i32 %11, i32* %4)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %10, %6, %3
%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
}