#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*/ X509_REVOKED;
typedef int /*<<< orphan*/ ASN1_TIME;
typedef int /*<<< orphan*/ ASN1_OBJECT;
typedef int /*<<< orphan*/ ASN1_GENERALIZEDTIME;
typedef int /*<<< orphan*/ ASN1_ENUMERATED;

/* Variables and functions */
int /*<<< orphan*/ ASN1_ENUMERATED_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ *ASN1_ENUMERATED_new();
int /*<<< orphan*/ ASN1_ENUMERATED_set(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ ASN1_GENERALIZEDTIME_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ ASN1_OBJECT_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ ASN1_TIME_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ NID_crl_reason;
int /*<<< orphan*/ NID_hold_instruction_code;
int /*<<< orphan*/ NID_invalidity_date;
int OCSP_REVOKED_STATUS_NOSTATUS;
int /*<<< orphan*/ OPENSSL_free(char *);
int /*<<< orphan*/ X509_REVOKED_add1_ext_i2d(int /*<<< orphan*/ *,
                                             int /*<<< orphan*/,
                                             int /*<<< orphan*/ *,
                                             int /*<<< orphan*/,
                                             int /*<<< orphan*/);
int /*<<< orphan*/ X509_REVOKED_set_revocationDate(int /*<<< orphan*/ *,
                                                   int /*<<< orphan*/ *);
int unpack_revinfo(int /*<<< orphan*/ **, int *, int /*<<< orphan*/ **,
                   int /*<<< orphan*/ **, char const *);
int make_revoked(X509_REVOKED *rev, const char *str) {
  char *tmp = NULL;
  int reason_code = -1;
  int i, ret = 0;
  ASN1_OBJECT *hold = NULL;
  ASN1_GENERALIZEDTIME *comp_time = NULL;
  ASN1_ENUMERATED *rtmp = NULL;
  ASN1_TIME *revDate = NULL;
  i = unpack_revinfo(&revDate, &reason_code, &hold, &comp_time, str);
  if (i == 0)
    goto err;
  if (rev && !X509_REVOKED_set_revocationDate(rev, revDate))
    goto err;
  if (rev && (reason_code != OCSP_REVOKED_STATUS_NOSTATUS)) {
    rtmp = ASN1_ENUMERATED_new();
    if (!rtmp || !ASN1_ENUMERATED_set(rtmp, reason_code))
      goto err;
    if (!X509_REVOKED_add1_ext_i2d(rev, NID_crl_reason, rtmp, 0, 0))
      goto err;
  }
  if (rev && comp_time) {
    if (!X509_REVOKED_add1_ext_i2d(rev, NID_invalidity_date, comp_time, 0, 0))
      goto err;
  }
  if (rev && hold) {
    if (!X509_REVOKED_add1_ext_i2d(rev, NID_hold_instruction_code, hold, 0, 0))
      goto err;
  }
  if (reason_code != OCSP_REVOKED_STATUS_NOSTATUS)
    ret = 2;
  else
    ret = 1;
err:
  if (tmp)
    OPENSSL_free(tmp);
  ASN1_OBJECT_free(hold);
  ASN1_GENERALIZEDTIME_free(comp_time);
  ASN1_ENUMERATED_free(rtmp);
  ASN1_TIME_free(revDate);
  return ret;
}


x86 assembly (clang, -O0):
<make_revoked>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movl   $0xffffffff,-0x1c(%rbp)
movl   $0x0,-0x24(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
movq   $0x0,-0x40(%rbp)
movq   $0x0,-0x48(%rbp)
mov    -0x10(%rbp),%r8
lea    -0x48(%rbp),%rdi
lea    -0x1c(%rbp),%rsi
lea    -0x30(%rbp),%rdx
lea    -0x38(%rbp),%rcx
call   1050 <unpack_revinfo@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jne    1211 <make_revoked+0x71>
jmp    1367 <make_revoked+0x1c7>
cmpq   $0x0,-0x8(%rbp)
je     1237 <make_revoked+0x97>
mov    -0x8(%rbp),%rdi
mov    -0x48(%rbp),%rsi
call   1040 <X509_REVOKED_set_revocationDate@plt>
cmp    $0x0,%eax
jne    1237 <make_revoked+0x97>
jmp    1367 <make_revoked+0x1c7>
cmpq   $0x0,-0x8(%rbp)
je     12b3 <make_revoked+0x113>
mov    -0x1c(%rbp),%eax
mov    0x2d74(%rip),%rcx
cmp    (%rcx),%eax
je     12b3 <make_revoked+0x113>
mov    $0x0,%al
call   1080 <ASN1_ENUMERATED_new@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
je     127f <make_revoked+0xdf>
mov    -0x40(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1030 <ASN1_ENUMERATED_set@plt>
cmp    $0x0,%eax
jne    1284 <make_revoked+0xe4>
jmp    1367 <make_revoked+0x1c7>
mov    -0x8(%rbp),%rdi
mov    0x2d39(%rip),%rax
mov    (%rax),%esi
mov    -0x40(%rbp),%rdx
xor    %r8d,%r8d
mov    %r8d,%ecx
call   1090 <X509_REVOKED_add1_ext_i2d@plt>
cmp    $0x0,%eax
jne    12ae <make_revoked+0x10e>
jmp    1367 <make_revoked+0x1c7>
jmp    12b3 <make_revoked+0x113>
cmpq   $0x0,-0x8(%rbp)
je     12f8 <make_revoked+0x158>
cmpq   $0x0,-0x38(%rbp)
je     12f8 <make_revoked+0x158>
mov    -0x8(%rbp),%rdi
mov    0x2d0c(%rip),%rax
mov    (%rax),%esi
mov    -0x38(%rbp),%rdx
xor    %r8d,%r8d
mov    %r8d,%ecx
call   1090 <X509_REVOKED_add1_ext_i2d@plt>
cmp    $0x0,%eax
jne    12f3 <make_revoked+0x153>
jmp    1367 <make_revoked+0x1c7>
jmp    12f8 <make_revoked+0x158>
cmpq   $0x0,-0x8(%rbp)
je     133d <make_revoked+0x19d>
cmpq   $0x0,-0x30(%rbp)
je     133d <make_revoked+0x19d>
mov    -0x8(%rbp),%rdi
mov    0x2ccf(%rip),%rax
mov    (%rax),%esi
mov    -0x30(%rbp),%rdx
xor    %r8d,%r8d
mov    %r8d,%ecx
call   1090 <X509_REVOKED_add1_ext_i2d@plt>
cmp    $0x0,%eax
jne    1338 <make_revoked+0x198>
jmp    1367 <make_revoked+0x1c7>
jmp    133d <make_revoked+0x19d>
mov    -0x1c(%rbp),%eax
mov    0x2c79(%rip),%rcx
cmp    (%rcx),%eax
je     135b <make_revoked+0x1bb>
movl   $0x2,-0x24(%rbp)
jmp    1362 <make_revoked+0x1c2>
movl   $0x1,-0x24(%rbp)
jmp    1367 <make_revoked+0x1c7>
cmpq   $0x0,-0x18(%rbp)
je     137b <make_revoked+0x1db>
mov    -0x18(%rbp),%rdi
call   10b0 <OPENSSL_free@plt>
mov    -0x30(%rbp),%rdi
call   10a0 <ASN1_OBJECT_free@plt>
mov    -0x38(%rbp),%rdi
call   1070 <ASN1_GENERALIZEDTIME_free@plt>
mov    -0x40(%rbp),%rdi
call   1060 <ASN1_ENUMERATED_free@plt>
mov    -0x48(%rbp),%rdi
call   10c0 <ASN1_TIME_free@plt>
mov    -0x24(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_revoked>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rsi,%r8
mov    %rdi,%r15
movl   $0xffffffff,0x4(%rsp)
ff
movq   $0x0,0x18(%rsp)
movq   $0x0,0x10(%rsp)
movq   $0x0,0x8(%rsp)
lea    0x8(%rsp),%rdi
lea    0x4(%rsp),%rsi
lea    0x18(%rsp),%rdx
lea    0x10(%rsp),%rcx
call   1050 <unpack_revinfo@plt>
xor    %ebx,%ebx
test   %eax,%eax
je     12c7 <make_revoked+0x137>
test   %r15,%r15
je     1265 <make_revoked+0xd5>
mov    0x8(%rsp),%rsi
mov    %r15,%rdi
call   1040 <X509_REVOKED_set_revocationDate@plt>
test   %eax,%eax
je     12c7 <make_revoked+0x137>
mov    0x4(%rsp),%eax
mov    0x2db6(%rip),%rcx
xor    %ebx,%ebx
cmp    (%rcx),%eax
jne    1283 <make_revoked+0xf3>
xor    %r14d,%r14d
mov    0x10(%rsp),%rdx
test   %rdx,%rdx
je     123d <make_revoked+0xad>
mov    0x2dbc(%rip),%rax
mov    (%rax),%esi
xor    %ebx,%ebx
mov    %r15,%rdi
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1090 <X509_REVOKED_add1_ext_i2d@plt>
test   %eax,%eax
je     12ca <make_revoked+0x13a>
mov    0x18(%rsp),%rdx
test   %rdx,%rdx
je     1268 <make_revoked+0xd8>
mov    0x2d9a(%rip),%rax
mov    (%rax),%esi
xor    %ebx,%ebx
mov    %r15,%rdi
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1090 <X509_REVOKED_add1_ext_i2d@plt>
test   %eax,%eax
jne    1268 <make_revoked+0xd8>
jmp    12ca <make_revoked+0x13a>
xor    %r14d,%r14d
mov    0x4(%rsp),%eax
mov    0x2d4d(%rip),%rcx
xor    %edx,%edx
cmp    (%rcx),%eax
sete   %dl
mov    $0x2,%ebx
sub    %edx,%ebx
jmp    12ca <make_revoked+0x13a>
xor    %eax,%eax
call   1080 <ASN1_ENUMERATED_new@plt>
test   %rax,%rax
je     12c7 <make_revoked+0x137>
mov    %rax,%r14
mov    0x4(%rsp),%esi
mov    %rax,%rdi
call   1030 <ASN1_ENUMERATED_set@plt>
test   %eax,%eax
je     12ca <make_revoked+0x13a>
mov    0x2d1f(%rip),%rax
mov    (%rax),%esi
xor    %ebx,%ebx
mov    %r15,%rdi
mov    %r14,%rdx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1090 <X509_REVOKED_add1_ext_i2d@plt>
test   %eax,%eax
jne    1213 <make_revoked+0x83>
jmp    12ca <make_revoked+0x13a>
xor    %r14d,%r14d
mov    0x18(%rsp),%rdi
call   10a0 <ASN1_OBJECT_free@plt>
mov    0x10(%rsp),%rdi
call   1070 <ASN1_GENERALIZEDTIME_free@plt>
mov    %r14,%rdi
call   1060 <ASN1_ENUMERATED_free@plt>
mov    0x8(%rsp),%rdi
call   10b0 <ASN1_TIME_free@plt>
mov    %ebx,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@OCSP_REVOKED_STATUS_NOSTATUS = global i32 0
@NID_crl_reason = global i32 0
@NID_invalidity_date = global i32 0
@NID_hold_instruction_code = global i32 0
define i32 @make_revoked(i32* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca i32*
%12 = alloca i32*
store i32* %0, i32** %3
store i8* %1, i8** %4
store i8* null, i8** %5
store i32 -1, i32* %6
store i32 0, i32* %8
store i32* null, i32** %9
store i32* null, i32** %10
store i32* null, i32** %11
store i32* null, i32** %12
%13 = load i8*, i8** %4
%14 = call i32 @unpack_revinfo(i32** %12, i32* %6, i32** %9, i32** %10, i8* %13)
store i32 %14, i32* %7
%15 = load i32, i32* %7
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %2
br label %87
18: ; preds = %2
%19 = load i32*, i32** %3
%20 = icmp ne i32* %19, null
br i1 %20, label %21, label %27
21: ; preds = %18
%22 = load i32*, i32** %3
%23 = load i32*, i32** %12
%24 = call i32 @X509_REVOKED_set_revocationDate(i32* %22, i32* %23)
%25 = icmp ne i32 %24, 0
br i1 %25, label %27, label %26
26: ; preds = %21
br label %87
27: ; preds = %21, %18
%28 = load i32*, i32** %3
%29 = icmp ne i32* %28, null
br i1 %29, label %30, label %52
30: ; preds = %27
%31 = load i32, i32* %6
%32 = load i32, i32* @OCSP_REVOKED_STATUS_NOSTATUS
%33 = icmp ne i32 %31, %32
br i1 %33, label %34, label %52
34: ; preds = %30
%35 = call i32* (...) @ASN1_ENUMERATED_new()
store i32* %35, i32** %11
%36 = load i32*, i32** %11
%37 = icmp ne i32* %36, null
br i1 %37, label %38, label %43
38: ; preds = %34
%39 = load i32*, i32** %11
%40 = load i32, i32* %6
%41 = call i32 @ASN1_ENUMERATED_set(i32* %39, i32 %40)
%42 = icmp ne i32 %41, 0
br i1 %42, label %44, label %43
43: ; preds = %38, %34
br label %87
44: ; preds = %38
%45 = load i32*, i32** %3
%46 = load i32, i32* @NID_crl_reason
%47 = load i32*, i32** %11
%48 = call i32 @X509_REVOKED_add1_ext_i2d(i32* %45, i32 %46, i32* %47, i32 0, i32 0)
%49 = icmp ne i32 %48, 0
br i1 %49, label %51, label %50
50: ; preds = %44
br label %87
51: ; preds = %44
br label %52
52: ; preds = %51, %30, %27
%53 = load i32*, i32** %3
%54 = icmp ne i32* %53, null
br i1 %54, label %55, label %66
55: ; preds = %52
%56 = load i32*, i32** %10
%57 = icmp ne i32* %56, null
br i1 %57, label %58, label %66
58: ; preds = %55
%59 = load i32*, i32** %3
%60 = load i32, i32* @NID_invalidity_date
%61 = load i32*, i32** %10
%62 = call i32 @X509_REVOKED_add1_ext_i2d(i32* %59, i32 %60, i32* %61, i32 0, i32 0)
%63 = icmp ne i32 %62, 0
br i1 %63, label %65, label %64
64: ; preds = %58
br label %87
65: ; preds = %58
br label %66
66: ; preds = %65, %55, %52
%67 = load i32*, i32** %3
%68 = icmp ne i32* %67, null
br i1 %68, label %69, label %80
69: ; preds = %66
%70 = load i32*, i32** %9
%71 = icmp ne i32* %70, null
br i1 %71, label %72, label %80
72: ; preds = %69
%73 = load i32*, i32** %3
%74 = load i32, i32* @NID_hold_instruction_code
%75 = load i32*, i32** %9
%76 = call i32 @X509_REVOKED_add1_ext_i2d(i32* %73, i32 %74, i32* %75, i32 0, i32 0)
%77 = icmp ne i32 %76, 0
br i1 %77, label %79, label %78
78: ; preds = %72
br label %87
79: ; preds = %72
br label %80
80: ; preds = %79, %69, %66
%81 = load i32, i32* %6
%82 = load i32, i32* @OCSP_REVOKED_STATUS_NOSTATUS
%83 = icmp ne i32 %81, %82
br i1 %83, label %84, label %85
84: ; preds = %80
store i32 2, i32* %8
br label %86
85: ; preds = %80
store i32 1, i32* %8
br label %86
86: ; preds = %85, %84
br label %87
87: ; preds = %86, %78, %64, %50, %43, %26, %17
%88 = load i8*, i8** %5
%89 = icmp ne i8* %88, null
br i1 %89, label %90, label %93
90: ; preds = %87
%91 = load i8*, i8** %5
%92 = call i32 @OPENSSL_free(i8* %91)
br label %93
93: ; preds = %90, %87
%94 = load i32*, i32** %9
%95 = call i32 @ASN1_OBJECT_free(i32* %94)
%96 = load i32*, i32** %10
%97 = call i32 @ASN1_GENERALIZEDTIME_free(i32* %96)
%98 = load i32*, i32** %11
%99 = call i32 @ASN1_ENUMERATED_free(i32* %98)
%100 = load i32*, i32** %12
%101 = call i32 @ASN1_TIME_free(i32* %100)
%102 = load i32, i32* %8
ret i32 %102
}

LLVM IR (-O2):
@OCSP_REVOKED_STATUS_NOSTATUS = global i32 0
@NID_crl_reason = global i32 0
@NID_invalidity_date = global i32 0
@NID_hold_instruction_code = global i32 0
define i32 @make_revoked(i32* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32*
%7 = bitcast i32* %3 to i8*
store i32 -1, i32* %3
%8 = bitcast i32** %4 to i8*
store i32* null, i32** %4
%9 = bitcast i32** %5 to i8*
store i32* null, i32** %5
%10 = bitcast i32** %6 to i8*
store i32* null, i32** %6
%11 = call i32 @unpack_revinfo(i32** %6, i32* %3, i32** %4, i32** %5, i8* %1)
%12 = icmp eq i32 %11, 0
br i1 %12, label %55, label %13
13: ; preds = %2
%14 = icmp eq i32* %0, null
br i1 %14, label %49, label %15
15: ; preds = %13
%16 = load i32*, i32** %6
%17 = call i32 @X509_REVOKED_set_revocationDate(i32* %0, i32* %16)
%18 = icmp eq i32 %17, 0
br i1 %18, label %55, label %19
19: ; preds = %15
%20 = load i32, i32* %3
%21 = load i32, i32* @OCSP_REVOKED_STATUS_NOSTATUS
%22 = icmp eq i32 %20, %21
br i1 %22, label %34, label %23
23: ; preds = %19
%24 = call i32* (...) @ASN1_ENUMERATED_new()
%25 = icmp eq i32* %24, null
br i1 %25, label %55, label %26
26: ; preds = %23
%27 = load i32, i32* %3
%28 = call i32 @ASN1_ENUMERATED_set(i32* %24, i32 %27)
%29 = icmp eq i32 %28, 0
br i1 %29, label %55, label %30
30: ; preds = %26
%31 = load i32, i32* @NID_crl_reason
%32 = call i32 @X509_REVOKED_add1_ext_i2d(i32* %0, i32 %31, i32* %24, i32 0, i32 0)
%33 = icmp eq i32 %32, 0
br i1 %33, label %55, label %34
34: ; preds = %30, %19
%35 = phi i32* [ %24, %30 ], [ null, %19 ]
%36 = load i32*, i32** %5
%37 = icmp eq i32* %36, null
br i1 %37, label %42, label %38
38: ; preds = %34
%39 = load i32, i32* @NID_invalidity_date
%40 = call i32 @X509_REVOKED_add1_ext_i2d(i32* %0, i32 %39, i32* %36, i32 0, i32 0)
%41 = icmp eq i32 %40, 0
br i1 %41, label %55, label %42
42: ; preds = %38, %34
%43 = load i32*, i32** %4
%44 = icmp eq i32* %43, null
br i1 %44, label %49, label %45
45: ; preds = %42
%46 = load i32, i32* @NID_hold_instruction_code
%47 = call i32 @X509_REVOKED_add1_ext_i2d(i32* %0, i32 %46, i32* %43, i32 0, i32 0)
%48 = icmp eq i32 %47, 0
br i1 %48, label %55, label %49
49: ; preds = %13, %45, %42
%50 = phi i32* [ %35, %45 ], [ %35, %42 ], [ null, %13 ]
%51 = load i32, i32* %3
%52 = load i32, i32* @OCSP_REVOKED_STATUS_NOSTATUS
%53 = icmp eq i32 %51, %52
%54 = select i1 %53, i32 1, i32 2
br label %55
55: ; preds = %2, %15, %26, %23, %30, %38, %45, %49
%56 = phi i32 [ 0, %2 ], [ 0, %45 ], [ 0, %38 ], [ 0, %30 ], [ 0, %26 ], [ 0, %23 ], [ 0, %15 ], [ %54, %49 ]
%57 = phi i32* [ null, %2 ], [ %35, %45 ], [ %35, %38 ], [ %24, %30 ], [ %24, %26 ], [ null, %23 ], [ null, %15 ], [ %50, %49 ]
%58 = load i32*, i32** %4
%59 = call i32 @ASN1_OBJECT_free(i32* %58)
%60 = load i32*, i32** %5
%61 = call i32 @ASN1_GENERALIZEDTIME_free(i32* %60)
%62 = call i32 @ASN1_ENUMERATED_free(i32* %57)
%63 = load i32*, i32** %6
%64 = call i32 @ASN1_TIME_free(i32* %63)
ret i32 %56
}