#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_OBJECT;

/* Variables and functions */
scalar_t__ ASN1_OBJECT_create(int /*<<< orphan*/, unsigned char *, int,
                              char const *, char const *);
int /*<<< orphan*/ ASN1_OBJECT_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ ERR_R_MALLOC_FAILURE;
int /*<<< orphan*/ OBJ_F_OBJ_CREATE;
int OBJ_add_object(int /*<<< orphan*/ *);
int /*<<< orphan*/ OBJ_new_nid(int);
int /*<<< orphan*/ OBJerr(int /*<<< orphan*/, int /*<<< orphan*/);
int a2d_ASN1_OBJECT(unsigned char *, int, char const *, int);
int /*<<< orphan*/ free(unsigned char *);
unsigned char *malloc(int);
int OBJ_create(const char *oid, const char *sn, const char *ln) {
  int ok = 0;
  ASN1_OBJECT *op = NULL;
  unsigned char *buf;
  int i;
  i = a2d_ASN1_OBJECT(NULL, 0, oid, -1);
  if (i <= 0)
    return (0);
  if ((buf = malloc(i)) == NULL) {
    OBJerr(OBJ_F_OBJ_CREATE, ERR_R_MALLOC_FAILURE);
    return (0);
  }
  i = a2d_ASN1_OBJECT(buf, i, oid, -1);
  if (i == 0)
    goto err;
  op = (ASN1_OBJECT *)ASN1_OBJECT_create(OBJ_new_nid(1), buf, i, sn, ln);
  if (op == NULL)
    goto err;
  ok = OBJ_add_object(op);
err:
  ASN1_OBJECT_free(op);
  free(buf);
  return (ok);
}


x86 assembly (clang, -O0):
<OBJ_create>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x10(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%edi
xor    %esi,%esi
mov    $0xffffffff,%ecx
call   1040 <a2d_ASN1_OBJECT@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
jg     11d0 <OBJ_create+0x50>
movl   $0x0,-0x4(%rbp)
jmp    1288 <OBJ_create+0x108>
mov    -0x3c(%rbp),%edi
call   1060 <malloc@plt>
mov    %rax,-0x38(%rbp)
cmp    $0x0,%rax
jne    1209 <OBJ_create+0x89>
mov    0x2deb(%rip),%rax
mov    (%rax),%edi
mov    0x2df2(%rip),%rax
mov    (%rax),%esi
call   1070 <OBJerr@plt>
movl   $0x0,-0x4(%rbp)
jmp    1288 <OBJ_create+0x108>
mov    -0x38(%rbp),%rdi
mov    -0x3c(%rbp),%esi
mov    -0x10(%rbp),%rdx
mov    $0xffffffff,%ecx
call   1040 <a2d_ASN1_OBJECT@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
jne    1230 <OBJ_create+0xb0>
jmp    1270 <OBJ_create+0xf0>
mov    $0x1,%edi
call   1050 <OBJ_new_nid@plt>
mov    %eax,%edi
mov    -0x38(%rbp),%rsi
mov    -0x3c(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%r8
call   1090 <ASN1_OBJECT_create@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1264 <OBJ_create+0xe4>
jmp    1270 <OBJ_create+0xf0>
mov    -0x30(%rbp),%rdi
call   10a0 <OBJ_add_object@plt>
mov    %eax,-0x24(%rbp)
mov    -0x30(%rbp),%rdi
call   1080 <ASN1_OBJECT_free@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<OBJ_create>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%rbx
xor    %r13d,%r13d
xor    %edi,%edi
xor    %esi,%esi
mov    %rbx,%rdx
mov    $0xffffffff,%ecx
call   1040 <a2d_ASN1_OBJECT@plt>
test   %eax,%eax
jle    1238 <OBJ_create+0xb8>
mov    %eax,%ebp
mov    %eax,%edi
call   1060 <malloc@plt>
test   %rax,%rax
je     120a <OBJ_create+0x8a>
mov    %rax,%r14
mov    %rax,%rdi
mov    %ebp,%esi
mov    %rbx,%rdx
mov    $0xffffffff,%ecx
call   1040 <a2d_ASN1_OBJECT@plt>
test   %eax,%eax
je     1223 <OBJ_create+0xa3>
mov    %eax,%ebx
mov    $0x1,%edi
call   1050 <OBJ_new_nid@plt>
mov    %eax,%edi
mov    %r14,%rsi
mov    %ebx,%edx
mov    %r12,%rcx
mov    %r15,%r8
call   1090 <ASN1_OBJECT_create@plt>
test   %rax,%rax
je     1223 <OBJ_create+0xa3>
mov    %rax,%rbx
mov    %rax,%rdi
call   10a0 <OBJ_add_object@plt>
mov    %eax,%r13d
jmp    1228 <OBJ_create+0xa8>
mov    0x2dc7(%rip),%rax
mov    (%rax),%edi
mov    0x2dce(%rip),%rax
mov    (%rax),%esi
call   1070 <OBJerr@plt>
jmp    1238 <OBJ_create+0xb8>
xor    %r13d,%r13d
xor    %ebx,%ebx
mov    %rbx,%rdi
call   1080 <ASN1_OBJECT_free@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %r13d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@OBJ_F_OBJ_CREATE = global i32 0
@ERR_R_MALLOC_FAILURE = global i32 0
define i32 @OBJ_create(i8* %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32*
%10 = alloca i8*
%11 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i32 0, i32* %8
store i32* null, i32** %9
%12 = load i8*, i8** %5
%13 = call i32 @a2d_ASN1_OBJECT(i8* null, i32 0, i8* %12, i32 -1)
store i32 %13, i32* %11
%14 = load i32, i32* %11
%15 = icmp sle i32 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %3
store i32 0, i32* %4
br label %53
17: ; preds = %3
%18 = load i32, i32* %11
%19 = call i8* @malloc(i32 %18)
store i8* %19, i8** %10
%20 = icmp eq i8* %19, null
br i1 %20, label %21, label %25
21: ; preds = %17
%22 = load i32, i32* @OBJ_F_OBJ_CREATE
%23 = load i32, i32* @ERR_R_MALLOC_FAILURE
%24 = call i32 @OBJerr(i32 %22, i32 %23)
store i32 0, i32* %4
br label %53
25: ; preds = %17
%26 = load i8*, i8** %10
%27 = load i32, i32* %11
%28 = load i8*, i8** %5
%29 = call i32 @a2d_ASN1_OBJECT(i8* %26, i32 %27, i8* %28, i32 -1)
store i32 %29, i32* %11
%30 = load i32, i32* %11
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %33
32: ; preds = %25
br label %47
33: ; preds = %25
%34 = call i32 @OBJ_new_nid(i32 1)
%35 = load i8*, i8** %10
%36 = load i32, i32* %11
%37 = load i8*, i8** %6
%38 = load i8*, i8** %7
%39 = call i64 @ASN1_OBJECT_create(i32 %34, i8* %35, i32 %36, i8* %37, i8* %38)
%40 = inttoptr i64 %39 to i32*
store i32* %40, i32** %9
%41 = load i32*, i32** %9
%42 = icmp eq i32* %41, null
br i1 %42, label %43, label %44
43: ; preds = %33
br label %47
44: ; preds = %33
%45 = load i32*, i32** %9
%46 = call i32 @OBJ_add_object(i32* %45)
store i32 %46, i32* %8
br label %47
47: ; preds = %44, %43, %32
%48 = load i32*, i32** %9
%49 = call i32 @ASN1_OBJECT_free(i32* %48)
%50 = load i8*, i8** %10
%51 = call i32 @free(i8* %50)
%52 = load i32, i32* %8
store i32 %52, i32* %4
br label %53
53: ; preds = %47, %21, %16
%54 = load i32, i32* %4
ret i32 %54
}

LLVM IR (-O2):
@OBJ_F_OBJ_CREATE = global i32 0
@ERR_R_MALLOC_FAILURE = global i32 0
define i32 @OBJ_create(i8* %0, i8* %1, i8* %2) {
%4 = tail call i32 @a2d_ASN1_OBJECT(i8* null, i32 0, i8* %0, i32 -1)
%5 = icmp slt i32 %4, 1
br i1 %5, label %28, label %6
6: ; preds = %3
%7 = tail call i8* @malloc(i32 %4)
%8 = icmp eq i8* %7, null
br i1 %8, label %9, label %13
9: ; preds = %6
%10 = load i32, i32* @OBJ_F_OBJ_CREATE
%11 = load i32, i32* @ERR_R_MALLOC_FAILURE
%12 = tail call i32 @OBJerr(i32 %10, i32 %11)
br label %28
13: ; preds = %6
%14 = tail call i32 @a2d_ASN1_OBJECT(i8* %7, i32 %4, i8* %0, i32 -1)
%15 = icmp eq i32 %14, 0
br i1 %15, label %23, label %16
16: ; preds = %13
%17 = tail call i32 @OBJ_new_nid(i32 1)
%18 = tail call i64 @ASN1_OBJECT_create(i32 %17, i8* %7, i32 %14, i8* %1, i8* %2)
%19 = inttoptr i64 %18 to i32*
%20 = icmp eq i64 %18, 0
br i1 %20, label %23, label %21
21: ; preds = %16
%22 = tail call i32 @OBJ_add_object(i32* %19)
br label %23
23: ; preds = %16, %13, %21
%24 = phi i32 [ 0, %13 ], [ 0, %16 ], [ %22, %21 ]
%25 = phi i32* [ null, %13 ], [ null, %16 ], [ %19, %21 ]
%26 = tail call i32 @ASN1_OBJECT_free(i32* %25)
%27 = tail call i32 @free(i8* %7)
br label %28
28: ; preds = %3, %23, %9
%29 = phi i32 [ 0, %9 ], [ %24, %23 ], [ 0, %3 ]
ret i32 %29
}