#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 void ASN1_STRING;
typedef void ASN1_OBJECT;

/* Variables and functions */
void *ASN1_STRING_dup(void const *);
int /*<<< orphan*/ ASN1_TYPE_set(int /*<<< orphan*/ *, int, void *);
void *OBJ_dup(void const *);
int V_ASN1_BOOLEAN;
int V_ASN1_OBJECT;
int ASN1_TYPE_set1(ASN1_TYPE *a, int type, const void *value) {
  if (!value || (type == V_ASN1_BOOLEAN)) {
    void *p = (void *)value;
    ASN1_TYPE_set(a, type, p);
  } else if (type == V_ASN1_OBJECT) {
    ASN1_OBJECT *odup;
    odup = OBJ_dup(value);
    if (!odup)
      return 0;
    ASN1_TYPE_set(a, type, odup);
  } else {
    ASN1_STRING *sdup;
    sdup = ASN1_STRING_dup(value);
    if (!sdup)
      return 0;
    ASN1_TYPE_set(a, type, sdup);
  }
  return 1;
}


x86 assembly (clang, -O0):
<ASN1_TYPE_set1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1160 <ASN1_TYPE_set1+0x30>
mov    -0x14(%rbp),%eax
mov    0x2e80(%rip),%rcx
cmp    (%rcx),%eax
jne    117d <ASN1_TYPE_set1+0x4d>
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x28(%rbp),%rdx
call   1050 <ASN1_TYPE_set@plt>
jmp    1201 <ASN1_TYPE_set1+0xd1>
mov    -0x14(%rbp),%eax
mov    0x2e61(%rip),%rcx
cmp    (%rcx),%eax
jne    11c8 <ASN1_TYPE_set1+0x98>
mov    -0x20(%rbp),%rdi
call   1040 <OBJ_dup@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    11b3 <ASN1_TYPE_set1+0x83>
movl   $0x0,-0x4(%rbp)
jmp    1208 <ASN1_TYPE_set1+0xd8>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x30(%rbp),%rdx
call   1050 <ASN1_TYPE_set@plt>
jmp    11fc <ASN1_TYPE_set1+0xcc>
mov    -0x20(%rbp),%rdi
call   1030 <ASN1_STRING_dup@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    11ec <ASN1_TYPE_set1+0xbc>
movl   $0x0,-0x4(%rbp)
jmp    1208 <ASN1_TYPE_set1+0xd8>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x38(%rbp),%rdx
call   1050 <ASN1_TYPE_set@plt>
jmp    1201 <ASN1_TYPE_set1+0xd1>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ASN1_TYPE_set1>:
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %rdi,%r14
test   %rdx,%rdx
je     1165 <ASN1_TYPE_set1+0x35>
mov    0x2e93(%rip),%rax
cmp    %ebx,(%rax)
je     1165 <ASN1_TYPE_set1+0x35>
mov    0x2e98(%rip),%rax
cmp    %ebx,(%rax)
jne    116c <ASN1_TYPE_set1+0x3c>
mov    %rdx,%rdi
call   1040 <OBJ_dup@plt>
test   %rax,%rax
jne    1179 <ASN1_TYPE_set1+0x49>
xor    %eax,%eax
jmp    118b <ASN1_TYPE_set1+0x5b>
mov    %r14,%rdi
mov    %ebx,%esi
jmp    1181 <ASN1_TYPE_set1+0x51>
mov    %rdx,%rdi
call   1030 <ASN1_STRING_dup@plt>
test   %rax,%rax
je     1161 <ASN1_TYPE_set1+0x31>
mov    %r14,%rdi
mov    %ebx,%esi
mov    %rax,%rdx
call   1050 <ASN1_TYPE_set@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@V_ASN1_BOOLEAN = global i32 0
@V_ASN1_OBJECT = global i32 0
define i32 @ASN1_TYPE_set1(i32* %0, i32 %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
store i32* %0, i32** %5
store i32 %1, i32* %6
store i8* %2, i8** %7
%11 = load i8*, i8** %7
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %17
13: ; preds = %3
%14 = load i32, i32* %6
%15 = load i32, i32* @V_ASN1_BOOLEAN
%16 = icmp eq i32 %14, %15
br i1 %16, label %17, label %23
17: ; preds = %13, %3
%18 = load i8*, i8** %7
store i8* %18, i8** %8
%19 = load i32*, i32** %5
%20 = load i32, i32* %6
%21 = load i8*, i8** %8
%22 = call i32 @ASN1_TYPE_set(i32* %19, i32 %20, i8* %21)
br label %50
23: ; preds = %13
%24 = load i32, i32* %6
%25 = load i32, i32* @V_ASN1_OBJECT
%26 = icmp eq i32 %24, %25
br i1 %26, label %27, label %38
27: ; preds = %23
%28 = load i8*, i8** %7
%29 = call i8* @OBJ_dup(i8* %28)
store i8* %29, i8** %9
%30 = load i8*, i8** %9
%31 = icmp ne i8* %30, null
br i1 %31, label %33, label %32
32: ; preds = %27
store i32 0, i32* %4
br label %51
33: ; preds = %27
%34 = load i32*, i32** %5
%35 = load i32, i32* %6
%36 = load i8*, i8** %9
%37 = call i32 @ASN1_TYPE_set(i32* %34, i32 %35, i8* %36)
br label %49
38: ; preds = %23
%39 = load i8*, i8** %7
%40 = call i8* @ASN1_STRING_dup(i8* %39)
store i8* %40, i8** %10
%41 = load i8*, i8** %10
%42 = icmp ne i8* %41, null
br i1 %42, label %44, label %43
43: ; preds = %38
store i32 0, i32* %4
br label %51
44: ; preds = %38
%45 = load i32*, i32** %5
%46 = load i32, i32* %6
%47 = load i8*, i8** %10
%48 = call i32 @ASN1_TYPE_set(i32* %45, i32 %46, i8* %47)
br label %49
49: ; preds = %44, %33
br label %50
50: ; preds = %49, %17
store i32 1, i32* %4
br label %51
51: ; preds = %50, %43, %32
%52 = load i32, i32* %4
ret i32 %52
}

LLVM IR (-O2):
@V_ASN1_BOOLEAN = global i32 0
@V_ASN1_OBJECT = global i32 0
define i32 @ASN1_TYPE_set1(i32* %0, i32 %1, i8* %2) {
%4 = icmp eq i8* %2, null
%5 = load i32, i32* @V_ASN1_BOOLEAN
%6 = icmp eq i32 %5, %1
%7 = select i1 %4, i1 true, i1 %6
br i1 %7, label %8, label %10
8: ; preds = %3
%9 = tail call i32 @ASN1_TYPE_set(i32* %0, i32 %1, i8* %2)
br label %23
10: ; preds = %3
%11 = load i32, i32* @V_ASN1_OBJECT
%12 = icmp eq i32 %11, %1
br i1 %12, label %13, label %18
13: ; preds = %10
%14 = tail call i8* @OBJ_dup(i8* %2)
%15 = icmp eq i8* %14, null
br i1 %15, label %23, label %16
16: ; preds = %13
%17 = tail call i32 @ASN1_TYPE_set(i32* %0, i32 %1, i8* %14)
br label %23
18: ; preds = %10
%19 = tail call i8* @ASN1_STRING_dup(i8* %2)
%20 = icmp eq i8* %19, null
br i1 %20, label %23, label %21
21: ; preds = %18
%22 = tail call i32 @ASN1_TYPE_set(i32* %0, i32 %1, i8* %19)
br label %23
23: ; preds = %8, %16, %21, %18, %13
%24 = phi i32 [ 0, %13 ], [ 0, %18 ], [ 1, %21 ], [ 1, %16 ], [ 1, %8 ]
ret i32 %24
}