#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 OBJ_add_object(int /*<<< orphan*/ *);
int /*<<< orphan*/ OBJ_new_nid(int);
int /*<<< orphan*/ OBJerror(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) {
    OBJerror(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    127f <OBJ_create+0xff>
mov    -0x3c(%rbp),%edi
call   1060 <malloc@plt>
mov    %rax,-0x38(%rbp)
cmp    $0x0,%rax
jne    1200 <OBJ_create+0x80>
mov    0x2dfb(%rip),%rax
mov    (%rax),%edi
call   1090 <OBJerror@plt>
movl   $0x0,-0x4(%rbp)
jmp    127f <OBJ_create+0xff>
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    1227 <OBJ_create+0xa7>
jmp    1267 <OBJ_create+0xe7>
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   1080 <ASN1_OBJECT_create@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    125b <OBJ_create+0xdb>
jmp    1267 <OBJ_create+0xe7>
mov    -0x30(%rbp),%rdi
call   10a0 <OBJ_add_object@plt>
mov    %eax,-0x24(%rbp)
mov    -0x30(%rbp),%rdi
call   1070 <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    122b <OBJ_create+0xab>
mov    %eax,%ebp
mov    %eax,%edi
call   1060 <malloc@plt>
test   %rax,%rax
je     1206 <OBJ_create+0x86>
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     1216 <OBJ_create+0x96>
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   1080 <ASN1_OBJECT_create@plt>
test   %rax,%rax
je     1216 <OBJ_create+0x96>
mov    %rax,%rbx
mov    %rax,%rdi
call   10a0 <OBJ_add_object@plt>
mov    %eax,%r13d
jmp    121b <OBJ_create+0x9b>
mov    0x2ddb(%rip),%rax
mov    (%rax),%edi
call   1090 <OBJerror@plt>
jmp    122b <OBJ_create+0xab>
xor    %r13d,%r13d
xor    %ebx,%ebx
mov    %rbx,%rdi
call   1070 <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):
@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 %52
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 %24
21: ; preds = %17
%22 = load i32, i32* @ERR_R_MALLOC_FAILURE
%23 = call i32 @OBJerror(i32 %22)
store i32 0, i32* %4
br label %52
24: ; preds = %17
%25 = load i8*, i8** %10
%26 = load i32, i32* %11
%27 = load i8*, i8** %5
%28 = call i32 @a2d_ASN1_OBJECT(i8* %25, i32 %26, i8* %27, i32 -1)
store i32 %28, i32* %11
%29 = load i32, i32* %11
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %32
31: ; preds = %24
br label %46
32: ; preds = %24
%33 = call i32 @OBJ_new_nid(i32 1)
%34 = load i8*, i8** %10
%35 = load i32, i32* %11
%36 = load i8*, i8** %6
%37 = load i8*, i8** %7
%38 = call i64 @ASN1_OBJECT_create(i32 %33, i8* %34, i32 %35, i8* %36, i8* %37)
%39 = inttoptr i64 %38 to i32*
store i32* %39, i32** %9
%40 = load i32*, i32** %9
%41 = icmp eq i32* %40, null
br i1 %41, label %42, label %43
42: ; preds = %32
br label %46
43: ; preds = %32
%44 = load i32*, i32** %9
%45 = call i32 @OBJ_add_object(i32* %44)
store i32 %45, i32* %8
br label %46
46: ; preds = %43, %42, %31
%47 = load i32*, i32** %9
%48 = call i32 @ASN1_OBJECT_free(i32* %47)
%49 = load i8*, i8** %10
%50 = call i32 @free(i8* %49)
%51 = load i32, i32* %8
store i32 %51, i32* %4
br label %52
52: ; preds = %46, %21, %16
%53 = load i32, i32* %4
ret i32 %53
}

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