#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_OCTET_STRING;
typedef int /*<<< orphan*/ ASN1_ITEM;

/* Variables and functions */
int /*<<< orphan*/ ASN1_OCTET_STRING_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ *ASN1_TYPE_new();
int /*<<< orphan*/ ASN1_TYPE_set(int /*<<< orphan*/ *, int /*<<< orphan*/,
                                 int /*<<< orphan*/ *);
int /*<<< orphan*/ *ASN1_item_pack(void *, int /*<<< orphan*/ const *,
                                   int /*<<< orphan*/ *);
int /*<<< orphan*/ V_ASN1_SEQUENCE;
ASN1_TYPE *ASN1_TYPE_pack_sequence(const ASN1_ITEM *it, void *s,
                                   ASN1_TYPE **t) {
  ASN1_OCTET_STRING *oct;
  ASN1_TYPE *rt;
  oct = ASN1_item_pack(s, it, NULL);
  if (oct == NULL)
    return NULL;
  if (t && *t) {
    rt = *t;
  } else {
    rt = ASN1_TYPE_new();
    if (rt == NULL) {
      ASN1_OCTET_STRING_free(oct);
      return NULL;
    }
    if (t)
      *t = rt;
  }
  ASN1_TYPE_set(rt, V_ASN1_SEQUENCE, oct);
  return rt;
}


x86 assembly (clang, -O0):
<ASN1_TYPE_pack_sequence>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1040 <ASN1_item_pack@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1181 <ASN1_TYPE_pack_sequence+0x41>
movq   $0x0,-0x8(%rbp)
jmp    120f <ASN1_TYPE_pack_sequence+0xcf>
cmpq   $0x0,-0x20(%rbp)
je     11aa <ASN1_TYPE_pack_sequence+0x6a>
mov    -0x20(%rbp),%rax
cmpq   $0x0,(%rax)
je     11aa <ASN1_TYPE_pack_sequence+0x6a>
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
jmp    11f1 <ASN1_TYPE_pack_sequence+0xb1>
mov    $0x0,%al
call   1030 <ASN1_TYPE_new@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    11d6 <ASN1_TYPE_pack_sequence+0x96>
mov    -0x28(%rbp),%rdi
call   1050 <ASN1_OCTET_STRING_free@plt>
movq   $0x0,-0x8(%rbp)
jmp    120f <ASN1_TYPE_pack_sequence+0xcf>
cmpq   $0x0,-0x20(%rbp)
je     11ec <ASN1_TYPE_pack_sequence+0xac>
mov    -0x30(%rbp),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
jmp    11f1 <ASN1_TYPE_pack_sequence+0xb1>
mov    -0x30(%rbp),%rdi
mov    0x2ddc(%rip),%rax
mov    (%rax),%esi
mov    -0x28(%rbp),%rdx
call   1060 <ASN1_TYPE_set@plt>
mov    -0x30(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ASN1_TYPE_pack_sequence>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r15
mov    %rdi,%rax
xor    %ebx,%ebx
mov    %rsi,%rdi
mov    %rax,%rsi
xor    %edx,%edx
call   1040 <ASN1_item_pack@plt>
test   %rax,%rax
je     11b2 <ASN1_TYPE_pack_sequence+0x72>
mov    %rax,%r14
test   %r15,%r15
je     1183 <ASN1_TYPE_pack_sequence+0x43>
mov    (%r15),%rbx
test   %rbx,%rbx
jne    1192 <ASN1_TYPE_pack_sequence+0x52>
xor    %eax,%eax
call   1030 <ASN1_TYPE_new@plt>
test   %rax,%rax
je     11a8 <ASN1_TYPE_pack_sequence+0x68>
mov    %rax,%rbx
mov    %rax,(%r15)
jmp    1192 <ASN1_TYPE_pack_sequence+0x52>
xor    %eax,%eax
call   1030 <ASN1_TYPE_new@plt>
mov    %rax,%rbx
test   %rax,%rax
je     11a8 <ASN1_TYPE_pack_sequence+0x68>
mov    0x2e3f(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
mov    %r14,%rdx
call   1060 <ASN1_TYPE_set@plt>
jmp    11b2 <ASN1_TYPE_pack_sequence+0x72>
mov    %r14,%rdi
call   1050 <ASN1_OCTET_STRING_free@plt>
xor    %ebx,%ebx
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@V_ASN1_SEQUENCE = global i32 0
define i32* @ASN1_TYPE_pack_sequence(i32* %0, i8* %1, i32** %2) {
%4 = tail call i32* @ASN1_item_pack(i8* %1, i32* %0, i32* null)
%5 = icmp eq i32* %4, null
br i1 %5, label %24, label %6
6: ; preds = %3
%7 = icmp eq i32** %2, null
br i1 %7, label %11, label %8
8: ; preds = %6
%9 = load i32*, i32** %2
%10 = icmp eq i32* %9, null
br i1 %10, label %14, label %20
11: ; preds = %6
%12 = tail call i32* (...) @ASN1_TYPE_new()
%13 = icmp eq i32* %12, null
br i1 %13, label %17, label %20
14: ; preds = %8
%15 = tail call i32* (...) @ASN1_TYPE_new()
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %19
17: ; preds = %14, %11
%18 = tail call i32 @ASN1_OCTET_STRING_free(i32* %4)
br label %24
19: ; preds = %14
store i32* %15, i32** %2
br label %20
20: ; preds = %11, %8, %19
%21 = phi i32* [ %15, %19 ], [ %9, %8 ], [ %12, %11 ]
%22 = load i32, i32* @V_ASN1_SEQUENCE
%23 = tail call i32 @ASN1_TYPE_set(i32* %21, i32 %22, i32* %4)
br label %24
24: ; preds = %3, %20, %17
%25 = phi i32* [ %21, %20 ], [ null, %17 ], [ null, %3 ]
ret i32* %25
}