#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 */
typedef struct TYPE_12__ TYPE_7__;
typedef struct TYPE_11__ TYPE_4__;
typedef struct TYPE_10__ TYPE_3__;
typedef struct TYPE_9__ TYPE_2__;
typedef struct TYPE_8__ TYPE_1__;

/* Type definitions */
typedef int /*<<< orphan*/ X509_NAME;
typedef int /*<<< orphan*/ X509;
struct TYPE_12__ {
  int type;
};
struct TYPE_11__ {
  int dp_reasons;
  TYPE_7__ *distpoint;
  int /*<<< orphan*/ CRLissuer;
  TYPE_1__ *reasons;
};
struct TYPE_9__ {
  int /*<<< orphan*/ *directoryName;
};
struct TYPE_10__ {
  scalar_t__ type;
  TYPE_2__ d;
};
struct TYPE_8__ {
  int length;
  int *data;
};
typedef TYPE_3__ GENERAL_NAME;
typedef TYPE_4__ DIST_POINT;

/* Variables and functions */
int CRLDP_ALL_REASONS;
int /*<<< orphan*/ DIST_POINT_set_dpname(TYPE_7__ *, int /*<<< orphan*/ *);
scalar_t__ GEN_DIRNAME;
int /*<<< orphan*/ *X509_get_issuer_name(int /*<<< orphan*/ *);
int sk_GENERAL_NAME_num(int /*<<< orphan*/);
TYPE_3__ *sk_GENERAL_NAME_value(int /*<<< orphan*/, int);
void setup_dp(X509 *x, DIST_POINT *dp) {
  X509_NAME *iname = NULL;
  int i;
  if (dp->reasons) {
    if (dp->reasons->length > 0)
      dp->dp_reasons = dp->reasons->data[0];
    if (dp->reasons->length > 1)
      dp->dp_reasons |= (dp->reasons->data[1] << 8);
    dp->dp_reasons &= CRLDP_ALL_REASONS;
  } else
    dp->dp_reasons = CRLDP_ALL_REASONS;
  if (!dp->distpoint || (dp->distpoint->type != 1))
    return;
  for (i = 0; i < sk_GENERAL_NAME_num(dp->CRLissuer); i++) {
    GENERAL_NAME *gen = sk_GENERAL_NAME_value(dp->CRLissuer, i);
    if (gen->type == GEN_DIRNAME) {
      iname = gen->d.directoryName;
      break;
    }
  }
  if (!iname)
    iname = X509_get_issuer_name(x);
  DIST_POINT_set_dpname(dp->distpoint, iname);
}


x86 assembly (clang, -O0):
<setup_dp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x18(%rax)
je     11cd <setup_dp+0x8d>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
cmpl   $0x0,(%rax)
jle    118c <setup_dp+0x4c>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
mov    0x8(%rax),%rax
mov    (%rax),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
cmpl   $0x1,(%rax)
jle    11b7 <setup_dp+0x77>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
mov    0x8(%rax),%rax
mov    0x4(%rax),%ecx
shl    $0x8,%ecx
mov    -0x10(%rbp),%rax
or     (%rax),%ecx
mov    %ecx,(%rax)
mov    0x2e22(%rip),%rax
mov    (%rax),%ecx
mov    -0x10(%rbp),%rax
and    (%rax),%ecx
mov    %ecx,(%rax)
jmp    11dc <setup_dp+0x9c>
mov    0x2e0c(%rip),%rax
mov    (%rax),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x8(%rax)
je     11fc <setup_dp+0xbc>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
cmpl   $0x1,(%rax)
je     1201 <setup_dp+0xc1>
jmp    129e <setup_dp+0x15e>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%edi
call   1030 <sk_GENERAL_NAME_num@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
cmp    %ecx,%eax
jge    1275 <setup_dp+0x135>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%edi
mov    -0x1c(%rbp),%esi
call   1060 <sk_GENERAL_NAME_value@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    (%rax),%rax
mov    0x2da0(%rip),%rcx
cmp    (%rcx),%rax
jne    1262 <setup_dp+0x122>
mov    -0x28(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
jmp    1275 <setup_dp+0x135>
jmp    1267 <setup_dp+0x127>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1208 <setup_dp+0xc8>
cmpq   $0x0,-0x18(%rbp)
jne    128d <setup_dp+0x14d>
mov    -0x8(%rbp),%rdi
call   1050 <X509_get_issuer_name@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <DIST_POINT_set_dpname@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setup_dp>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    0x18(%rsi),%rax
test   %rax,%rax
je     1175 <setup_dp+0x35>
mov    (%rax),%ecx
test   %ecx,%ecx
jle    1180 <setup_dp+0x40>
mov    0x8(%rax),%rdx
mov    (%rdx),%eax
mov    %eax,(%rbx)
cmp    $0x1,%ecx
je     1182 <setup_dp+0x42>
mov    0x4(%rdx),%ecx
shl    $0x8,%ecx
or     %ecx,%eax
mov    %eax,(%rbx)
jmp    1182 <setup_dp+0x42>
mov    0x2e64(%rip),%rax
mov    (%rax),%eax
jmp    118b <setup_dp+0x4b>
mov    (%rbx),%eax
mov    0x2e57(%rip),%rcx
and    (%rcx),%eax
mov    %eax,(%rbx)
mov    0x8(%rbx),%rax
test   %rax,%rax
je     11d3 <setup_dp+0x93>
cmpl   $0x1,(%rax)
jne    11d3 <setup_dp+0x93>
mov    0x10(%rbx),%edi
call   1030 <sk_GENERAL_NAME_num@plt>
test   %eax,%eax
jle    11e7 <setup_dp+0xa7>
xor    %ebp,%ebp
mov    0x2e38(%rip),%r15
mov    0x10(%rbx),%edi
mov    %ebp,%esi
call   1060 <sk_GENERAL_NAME_value@plt>
mov    (%rax),%rcx
cmp    (%r15),%rcx
je     11de <setup_dp+0x9e>
add    $0x1,%ebp
mov    0x10(%rbx),%edi
call   1030 <sk_GENERAL_NAME_num@plt>
cmp    %eax,%ebp
jl     11b0 <setup_dp+0x70>
jmp    11e7 <setup_dp+0xa7>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x8(%rax),%rsi
test   %rsi,%rsi
jne    11f2 <setup_dp+0xb2>
mov    %r14,%rdi
call   1050 <X509_get_issuer_name@plt>
mov    %rax,%rsi
mov    0x8(%rbx),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <DIST_POINT_set_dpname@plt>

LLVM IR (-O0):
%struct.TYPE_11__ = type { i32, %struct.TYPE_12__*, i32, %struct.TYPE_8__* }
%struct.TYPE_12__ = type { i32 }
%struct.TYPE_8__ = type { i32, i32* }
%struct.TYPE_10__ = type { i64, %struct.TYPE_9__ }
%struct.TYPE_9__ = type { i32* }
@CRLDP_ALL_REASONS = global i32 0
@GEN_DIRNAME = global i64 0
define void @setup_dp(i32* %0, %struct.TYPE_11__* %1) {
%3 = alloca i32*
%4 = alloca %struct.TYPE_11__*
%5 = alloca i32*
%6 = alloca i32
%7 = alloca %struct.TYPE_10__*
store i32* %0, i32** %3
store %struct.TYPE_11__* %1, %struct.TYPE_11__** %4
store i32* null, i32** %5
%8 = load %struct.TYPE_11__*, %struct.TYPE_11__** %4
%9 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %8, i32 0, i32 3
%10 = load %struct.TYPE_8__*, %struct.TYPE_8__** %9
%11 = icmp ne %struct.TYPE_8__* %10, null
br i1 %11, label %12, label %55
12: ; preds = %2
%13 = load %struct.TYPE_11__*, %struct.TYPE_11__** %4
%14 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %13, i32 0, i32 3
%15 = load %struct.TYPE_8__*, %struct.TYPE_8__** %14
%16 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %15, i32 0, i32 0
%17 = load i32, i32* %16
%18 = icmp sgt i32 %17, 0
br i1 %18, label %19, label %29
19: ; preds = %12
%20 = load %struct.TYPE_11__*, %struct.TYPE_11__** %4
%21 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %20, i32 0, i32 3
%22 = load %struct.TYPE_8__*, %struct.TYPE_8__** %21
%23 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %22, i32 0, i32 1
%24 = load i32*, i32** %23
%25 = getelementptr inbounds i32, i32* %24, i64 0
%26 = load i32, i32* %25
%27 = load %struct.TYPE_11__*, %struct.TYPE_11__** %4
%28 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %27, i32 0, i32 0
store i32 %26, i32* %28
br label %29
29: ; preds = %19, %12
%30 = load %struct.TYPE_11__*, %struct.TYPE_11__** %4
%31 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %30, i32 0, i32 3
%32 = load %struct.TYPE_8__*, %struct.TYPE_8__** %31
%33 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %32, i32 0, i32 0
%34 = load i32, i32* %33
%35 = icmp sgt i32 %34, 1
br i1 %35, label %36, label %49
36: ; preds = %29
%37 = load %struct.TYPE_11__*, %struct.TYPE_11__** %4
%38 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %37, i32 0, i32 3
%39 = load %struct.TYPE_8__*, %struct.TYPE_8__** %38
%40 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %39, i32 0, i32 1
%41 = load i32*, i32** %40
%42 = getelementptr inbounds i32, i32* %41, i64 1
%43 = load i32, i32* %42
%44 = shl i32 %43, 8
%45 = load %struct.TYPE_11__*, %struct.TYPE_11__** %4
%46 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %45, i32 0, i32 0
%47 = load i32, i32* %46
%48 = or i32 %47, %44
store i32 %48, i32* %46
br label %49
49: ; preds = %36, %29
%50 = load i32, i32* @CRLDP_ALL_REASONS
%51 = load %struct.TYPE_11__*, %struct.TYPE_11__** %4
%52 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %51, i32 0, i32 0
%53 = load i32, i32* %52
%54 = and i32 %53, %50
store i32 %54, i32* %52
br label %59
55: ; preds = %2
%56 = load i32, i32* @CRLDP_ALL_REASONS
%57 = load %struct.TYPE_11__*, %struct.TYPE_11__** %4
%58 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %57, i32 0, i32 0
store i32 %56, i32* %58
br label %59
59: ; preds = %55, %49
%60 = load %struct.TYPE_11__*, %struct.TYPE_11__** %4
%61 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %60, i32 0, i32 1
%62 = load %struct.TYPE_12__*, %struct.TYPE_12__** %61
%63 = icmp ne %struct.TYPE_12__* %62, null
br i1 %63, label %64, label %71
64: ; preds = %59
%65 = load %struct.TYPE_11__*, %struct.TYPE_11__** %4
%66 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %65, i32 0, i32 1
%67 = load %struct.TYPE_12__*, %struct.TYPE_12__** %66
%68 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %67, i32 0, i32 0
%69 = load i32, i32* %68
%70 = icmp ne i32 %69, 1
br i1 %70, label %71, label %72
71: ; preds = %64, %59
br label %112
72: ; preds = %64
store i32 0, i32* %6
br label %73
73: ; preds = %97, %72
%74 = load i32, i32* %6
%75 = load %struct.TYPE_11__*, %struct.TYPE_11__** %4
%76 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %75, i32 0, i32 2
%77 = load i32, i32* %76
%78 = call i32 @sk_GENERAL_NAME_num(i32 %77)
%79 = icmp slt i32 %74, %78
br i1 %79, label %80, label %100
80: ; preds = %73
%81 = load %struct.TYPE_11__*, %struct.TYPE_11__** %4
%82 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %81, i32 0, i32 2
%83 = load i32, i32* %82
%84 = load i32, i32* %6
%85 = call %struct.TYPE_10__* @sk_GENERAL_NAME_value(i32 %83, i32 %84)
store %struct.TYPE_10__* %85, %struct.TYPE_10__** %7
%86 = load %struct.TYPE_10__*, %struct.TYPE_10__** %7
%87 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %86, i32 0, i32 0
%88 = load i64, i64* %87
%89 = load i64, i64* @GEN_DIRNAME
%90 = icmp eq i64 %88, %89
br i1 %90, label %91, label %96
91: ; preds = %80
%92 = load %struct.TYPE_10__*, %struct.TYPE_10__** %7
%93 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %92, i32 0, i32 1
%94 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %93, i32 0, i32 0
%95 = load i32*, i32** %94
store i32* %95, i32** %5
br label %100
96: ; preds = %80
br label %97
97: ; preds = %96
%98 = load i32, i32* %6
%99 = add nsw i32 %98, 1
store i32 %99, i32* %6
br label %73
100: ; preds = %91, %73
%101 = load i32*, i32** %5
%102 = icmp ne i32* %101, null
br i1 %102, label %106, label %103
103: ; preds = %100
%104 = load i32*, i32** %3
%105 = call i32* @X509_get_issuer_name(i32* %104)
store i32* %105, i32** %5
br label %106
106: ; preds = %103, %100
%107 = load %struct.TYPE_11__*, %struct.TYPE_11__** %4
%108 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %107, i32 0, i32 1
%109 = load %struct.TYPE_12__*, %struct.TYPE_12__** %108
%110 = load i32*, i32** %5
%111 = call i32 @DIST_POINT_set_dpname(%struct.TYPE_12__* %109, i32* %110)
br label %112
112: ; preds = %106, %71
ret void
}

LLVM IR (-O2):
%struct.TYPE_11__ = type { i32, %struct.TYPE_12__*, i32, %struct.TYPE_8__* }
%struct.TYPE_12__ = type { i32 }
%struct.TYPE_8__ = type { i32, i32* }
%struct.TYPE_10__ = type { i64, %struct.TYPE_9__ }
%struct.TYPE_9__ = type { i32* }
@CRLDP_ALL_REASONS = global i32 0
@GEN_DIRNAME = global i64 0
define void @setup_dp(i32* %0, %struct.TYPE_11__* nocapture %1) {
%3 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %1, i64 0, i32 3
%4 = load %struct.TYPE_8__*, %struct.TYPE_8__** %3
%5 = icmp eq %struct.TYPE_8__* %4, null
br i1 %5, label %29, label %6
6: ; preds = %2
%7 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %4, i64 0, i32 0
%8 = load i32, i32* %7
%9 = icmp sgt i32 %8, 0
br i1 %9, label %13, label %10
10: ; preds = %6
%11 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %1, i64 0, i32 0
%12 = load i32, i32* %11
br label %24
13: ; preds = %6
%14 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %4, i64 0, i32 1
%15 = load i32*, i32** %14
%16 = load i32, i32* %15
%17 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %1, i64 0, i32 0
store i32 %16, i32* %17
%18 = icmp eq i32 %8, 1
br i1 %18, label %24, label %19
19: ; preds = %13
%20 = getelementptr inbounds i32, i32* %15, i64 1
%21 = load i32, i32* %20
%22 = shl i32 %21, 8
%23 = or i32 %16, %22
store i32 %23, i32* %17
br label %24
24: ; preds = %10, %19, %13
%25 = phi i32 [ %12, %10 ], [ %23, %19 ], [ %16, %13 ]
%26 = load i32, i32* @CRLDP_ALL_REASONS
%27 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %1, i64 0, i32 0
%28 = and i32 %25, %26
store i32 %28, i32* %27
br label %32
29: ; preds = %2
%30 = load i32, i32* @CRLDP_ALL_REASONS
%31 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %1, i64 0, i32 0
store i32 %30, i32* %31
br label %32
32: ; preds = %29, %24
%33 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %1, i64 0, i32 1
%34 = load %struct.TYPE_12__*, %struct.TYPE_12__** %33
%35 = icmp eq %struct.TYPE_12__* %34, null
br i1 %35, label %68, label %36
36: ; preds = %32
%37 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %34, i64 0, i32 0
%38 = load i32, i32* %37
%39 = icmp eq i32 %38, 1
br i1 %39, label %40, label %68
40: ; preds = %36
%41 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %1, i64 0, i32 2
%42 = load i32, i32* %41
%43 = tail call i32 @sk_GENERAL_NAME_num(i32 %42)
%44 = icmp sgt i32 %43, 0
br i1 %44, label %49, label %62
45: ; preds = %49
%46 = load i32, i32* %41
%47 = tail call i32 @sk_GENERAL_NAME_num(i32 %46)
%48 = icmp slt i32 %57, %47
br i1 %48, label %49, label %62
49: ; preds = %40, %45
%50 = phi i32 [ %57, %45 ], [ 0, %40 ]
%51 = load i32, i32* %41
%52 = tail call %struct.TYPE_10__* @sk_GENERAL_NAME_value(i32 %51, i32 %50)
%53 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %52, i64 0, i32 0
%54 = load i64, i64* %53
%55 = load i64, i64* @GEN_DIRNAME
%56 = icmp eq i64 %54, %55
%57 = add nuw nsw i32 %50, 1
br i1 %56, label %58, label %45
58: ; preds = %49
%59 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %52, i64 0, i32 1, i32 0
%60 = load i32*, i32** %59
%61 = icmp eq i32* %60, null
br i1 %61, label %62, label %64
62: ; preds = %45, %40, %58
%63 = tail call i32* @X509_get_issuer_name(i32* %0)
br label %64
64: ; preds = %62, %58
%65 = phi i32* [ %60, %58 ], [ %63, %62 ]
%66 = load %struct.TYPE_12__*, %struct.TYPE_12__** %33
%67 = tail call i32 @DIST_POINT_set_dpname(%struct.TYPE_12__* %66, i32* %65)
br label %68
68: ; preds = %32, %36, %64
ret void
}