#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_STORE_CTX;
typedef int /*<<< orphan*/ X509_POLICY_TREE;
typedef int /*<<< orphan*/ BIO;

/* Variables and functions */
int /*<<< orphan*/ BIO_NOCLOSE;
int /*<<< orphan*/ BIO_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ *BIO_new_fp(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ BIO_printf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ *X509_STORE_CTX_get0_policy_tree(int /*<<< orphan*/ *);
int X509_STORE_CTX_get_explicit_policy(int /*<<< orphan*/ *);
int /*<<< orphan*/ X509_policy_tree_get0_policies(int /*<<< orphan*/ *);
int /*<<< orphan*/ X509_policy_tree_get0_user_policies(int /*<<< orphan*/ *);
int /*<<< orphan*/ nodes_print(int /*<<< orphan*/ *, char *,
                               int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
void policies_print(BIO *out, X509_STORE_CTX *ctx) {
  X509_POLICY_TREE *tree;
  int explicit_policy;
  int free_out = 0;
  if (out == NULL) {
    out = BIO_new_fp(stderr, BIO_NOCLOSE);
    free_out = 1;
  }
  tree = X509_STORE_CTX_get0_policy_tree(ctx);
  explicit_policy = X509_STORE_CTX_get_explicit_policy(ctx);
  BIO_printf(out, "Require explicit Policy: %s\n",
             explicit_policy ? "True" : "False");
  nodes_print(out, "Authority", X509_policy_tree_get0_policies(tree));
  nodes_print(out, "User", X509_policy_tree_get0_user_policies(tree));
  if (free_out)
    BIO_free(out);
}


x86 assembly (clang, -O0):
<policies_print>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x20(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    11c4 <policies_print+0x44>
mov    0x2e2f(%rip),%rax
mov    (%rax),%edi
mov    0x2e36(%rip),%rax
mov    (%rax),%esi
call   1030 <BIO_new_fp@plt>
mov    %rax,-0x8(%rbp)
movl   $0x1,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <X509_STORE_CTX_get0_policy_tree@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <X509_STORE_CTX_get_explicit_policy@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x1c(%rbp),%ecx
lea    0xe37(%rip),%rdx
lea    0xe2b(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdx
lea    0xe00(%rip),%rsi
call   1050 <BIO_printf@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
call   1080 <X509_policy_tree_get0_policies@plt>
mov    -0x30(%rbp),%rdi
mov    %eax,%edx
lea    0xe05(%rip),%rsi
call   1070 <nodes_print@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1090 <X509_policy_tree_get0_user_policies@plt>
mov    -0x28(%rbp),%rdi
mov    %eax,%edx
lea    0xdec(%rip),%rsi
call   1070 <nodes_print@plt>
cmpl   $0x0,-0x20(%rbp)
je     125e <policies_print+0xde>
mov    -0x8(%rbp),%rdi
call   10a0 <BIO_free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<policies_print>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rdi,%r12
test   %rdi,%rdi
jne    11b0 <policies_print+0x30>
mov    0x2e3b(%rip),%rax
mov    (%rax),%edi
mov    0x2e42(%rip),%rax
mov    (%rax),%esi
call   1030 <BIO_new_fp@plt>
mov    %rax,%r12
mov    %rbx,%rdi
call   1060 <X509_STORE_CTX_get0_policy_tree@plt>
mov    %rax,%r15
mov    %rbx,%rdi
call   1040 <X509_STORE_CTX_get_explicit_policy@plt>
test   %eax,%eax
lea    0xe56(%rip),%rax
lea    0xe4a(%rip),%rdx
cmove  %rax,%rdx
lea    0xe22(%rip),%rsi
mov    %r12,%rdi
call   1050 <BIO_printf@plt>
mov    %r15,%rdi
call   1080 <X509_policy_tree_get0_policies@plt>
lea    0xe33(%rip),%rsi
mov    %r12,%rdi
mov    %eax,%edx
call   1070 <nodes_print@plt>
mov    %r15,%rdi
call   1090 <X509_policy_tree_get0_user_policies@plt>
lea    0xe24(%rip),%rsi
mov    %r12,%rdi
mov    %eax,%edx
call   1070 <nodes_print@plt>
test   %r14,%r14
je     1229 <policies_print+0xa9>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
mov    %r12,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    10a0 <BIO_free@plt>

LLVM IR (-O0):
@stderr = global i32 0
@BIO_NOCLOSE = global i32 0
@.str = [29 x i8] c"Require explicit Policy: %s\0A\00"
@.str.1 = [5 x i8] c"True\00"
@.str.2 = [6 x i8] c"False\00"
@.str.3 = [10 x i8] c"Authority\00"
@.str.4 = [5 x i8] c"User\00"
define void @policies_print(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
store i32* %0, i32** %3
store i32* %1, i32** %4
store i32 0, i32* %7
%8 = load i32*, i32** %3
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %14
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = load i32, i32* @BIO_NOCLOSE
%13 = call i32* @BIO_new_fp(i32 %11, i32 %12)
store i32* %13, i32** %3
store i32 1, i32* %7
br label %14
14: ; preds = %10, %2
%15 = load i32*, i32** %4
%16 = call i32* @X509_STORE_CTX_get0_policy_tree(i32* %15)
store i32* %16, i32** %5
%17 = load i32*, i32** %4
%18 = call i32 @X509_STORE_CTX_get_explicit_policy(i32* %17)
store i32 %18, i32* %6
%19 = load i32*, i32** %3
%20 = load i32, i32* %6
%21 = icmp ne i32 %20, 0
%22 = zext i1 %21 to i64
%23 = select i1 %21, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0)
%24 = call i32 @BIO_printf(i32* %19, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %23)
%25 = load i32*, i32** %3
%26 = load i32*, i32** %5
%27 = call i32 @X509_policy_tree_get0_policies(i32* %26)
%28 = call i32 @nodes_print(i32* %25, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %27)
%29 = load i32*, i32** %3
%30 = load i32*, i32** %5
%31 = call i32 @X509_policy_tree_get0_user_policies(i32* %30)
%32 = call i32 @nodes_print(i32* %29, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 %31)
%33 = load i32, i32* %7
%34 = icmp ne i32 %33, 0
br i1 %34, label %35, label %38
35: ; preds = %14
%36 = load i32*, i32** %3
%37 = call i32 @BIO_free(i32* %36)
br label %38
38: ; preds = %35, %14
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@BIO_NOCLOSE = global i32 0
@.str = [29 x i8] c"Require explicit Policy: %s\0A\00"
@.str.1 = [5 x i8] c"True\00"
@.str.2 = [6 x i8] c"False\00"
@.str.3 = [10 x i8] c"Authority\00"
@.str.4 = [5 x i8] c"User\00"
define void @policies_print(i32* %0, i32* %1) {
%3 = icmp eq i32* %0, null
br i1 %3, label %4, label %8
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = load i32, i32* @BIO_NOCLOSE
%7 = tail call i32* @BIO_new_fp(i32 %5, i32 %6)
br label %8
8: ; preds = %4, %2
%9 = phi i32* [ %7, %4 ], [ %0, %2 ]
%10 = tail call i32* @X509_STORE_CTX_get0_policy_tree(i32* %1)
%11 = tail call i32 @X509_STORE_CTX_get_explicit_policy(i32* %1)
%12 = icmp eq i32 %11, 0
%13 = select i1 %12, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0)
%14 = tail call i32 @BIO_printf(i32* %9, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = tail call i32 @X509_policy_tree_get0_policies(i32* %10)
%16 = tail call i32 @nodes_print(i32* %9, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %15)
%17 = tail call i32 @X509_policy_tree_get0_user_policies(i32* %10)
%18 = tail call i32 @nodes_print(i32* %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 %17)
br i1 %3, label %19, label %21
19: ; preds = %8
%20 = tail call i32 @BIO_free(i32* %9)
br label %21
21: ; preds = %19, %8
ret void
}