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

/* Variables and functions */
int /*<<< orphan*/ ASN1_OCTET_STRING_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ *ASN1_OCTET_STRING_new();
int /*<<< orphan*/ ASN1_STRING_set(int /*<<< orphan*/ *, unsigned char *, int);
int /*<<< orphan*/ ASN1_TYPE_set(int /*<<< orphan*/ *, int /*<<< orphan*/,
                                 int /*<<< orphan*/ *);
int /*<<< orphan*/ V_ASN1_OCTET_STRING;
int ASN1_TYPE_set_octetstring(ASN1_TYPE *a, unsigned char *data, int len) {
  ASN1_STRING *os;
  if ((os = ASN1_OCTET_STRING_new()) == NULL)
    return (0);
  if (!ASN1_STRING_set(os, data, len)) {
    ASN1_OCTET_STRING_free(os);
    return (0);
  }
  ASN1_TYPE_set(a, V_ASN1_OCTET_STRING, os);
  return (1);
}


x86 assembly (clang, -O0):
<ASN1_TYPE_set_octetstring>:
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)
cmp    $0x0,%rax
jne    1174 <ASN1_TYPE_set_octetstring+0x34>
movl   $0x0,-0x4(%rbp)
jmp    11bf <ASN1_TYPE_set_octetstring+0x7f>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1050 <ASN1_STRING_set@plt>
cmp    $0x0,%eax
jne    11a2 <ASN1_TYPE_set_octetstring+0x62>
mov    -0x28(%rbp),%rdi
call   1040 <ASN1_OCTET_STRING_free@plt>
movl   $0x0,-0x4(%rbp)
jmp    11bf <ASN1_TYPE_set_octetstring+0x7f>
mov    -0x10(%rbp),%rdi
mov    0x2e33(%rip),%rax
mov    (%rax),%esi
mov    -0x28(%rbp),%rdx
call   1060 <ASN1_TYPE_set@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ASN1_TYPE_set_octetstring>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%r15d
mov    %rsi,%r12
mov    %rdi,%r14
xor    %ebp,%ebp
xor    %eax,%eax
call   1030 <ASN1_OCTET_STRING_new@plt>
test   %rax,%rax
je     1197 <ASN1_TYPE_set_octetstring+0x57>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r12,%rsi
mov    %r15d,%edx
call   1050 <ASN1_STRING_set@plt>
test   %eax,%eax
je     118f <ASN1_TYPE_set_octetstring+0x4f>
mov    0x2e65(%rip),%rax
mov    (%rax),%esi
mov    %r14,%rdi
mov    %rbx,%rdx
call   1060 <ASN1_TYPE_set@plt>
mov    $0x1,%ebp
jmp    1197 <ASN1_TYPE_set_octetstring+0x57>
mov    %rbx,%rdi
call   1040 <ASN1_OCTET_STRING_free@plt>
mov    %ebp,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@V_ASN1_OCTET_STRING = global i32 0
define i32 @ASN1_TYPE_set_octetstring(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 = icmp eq i32* %9, null
br i1 %10, label %11, label %12
11: ; preds = %3
store i32 0, i32* %4
br label %26
12: ; preds = %3
%13 = load i32*, i32** %8
%14 = load i8*, i8** %6
%15 = load i32, i32* %7
%16 = call i32 @ASN1_STRING_set(i32* %13, i8* %14, i32 %15)
%17 = icmp ne i32 %16, 0
br i1 %17, label %21, label %18
18: ; preds = %12
%19 = load i32*, i32** %8
%20 = call i32 @ASN1_OCTET_STRING_free(i32* %19)
store i32 0, i32* %4
br label %26
21: ; preds = %12
%22 = load i32*, i32** %5
%23 = load i32, i32* @V_ASN1_OCTET_STRING
%24 = load i32*, i32** %8
%25 = call i32 @ASN1_TYPE_set(i32* %22, i32 %23, i32* %24)
store i32 1, i32* %4
br label %26
26: ; preds = %21, %18, %11
%27 = load i32, i32* %4
ret i32 %27
}

LLVM IR (-O2):
@V_ASN1_OCTET_STRING = global i32 0
define i32 @ASN1_TYPE_set_octetstring(i32* %0, i8* %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 = tail call i32 @ASN1_STRING_set(i32* %4, i8* %1, i32 %2)
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %6
%10 = tail call i32 @ASN1_OCTET_STRING_free(i32* %4)
br label %14
11: ; preds = %6
%12 = load i32, i32* @V_ASN1_OCTET_STRING
%13 = tail call i32 @ASN1_TYPE_set(i32* %0, i32 %12, i32* %4)
br label %14
14: ; preds = %3, %11, %9
%15 = phi i32 [ 1, %11 ], [ 0, %9 ], [ 0, %3 ]
ret i32 %15
}