#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 */
struct stack_st_X509_NAME {
  int dummy;
};
typedef int /*<<< orphan*/ SSL_CTX;

/* Variables and functions */
int SSL_CTX_load_verify_locations(int /*<<< orphan*/ *, char const *,
                                  char const *);
int /*<<< orphan*/ SSL_CTX_set_client_CA_list(int /*<<< orphan*/ *,
                                              struct stack_st_X509_NAME *);
struct stack_st_X509_NAME *SSL_load_client_CA_file(char const *);
int /*<<< orphan*/ printSSLErr(char *);
void configCAStack(const char *cafile, const char *capath, SSL_CTX *ctx) {
  int status;
  status = SSL_CTX_load_verify_locations(ctx, cafile, capath);
  if (status != 1) {
    printSSLErr(
        "SSL_CTX_load_verify_locations() error: unable to set CA location");
  }
  struct stack_st_X509_NAME *cert_names = SSL_load_client_CA_file(cafile);
  if (cert_names != NULL) {
    SSL_CTX_set_client_CA_list(ctx, cert_names);
  } else {
    printSSLErr("configCAStack() error: cert_names is NULL");
  }
}


x86 assembly (clang, -O0):
<configCAStack>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
call   1040 <SSL_CTX_load_verify_locations@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x1,-0x1c(%rbp)
je     117e <configCAStack+0x3e>
lea    0xe87(%rip),%rdi
call   1060 <printSSLErr@plt>
mov    -0x8(%rbp),%rdi
call   1050 <SSL_load_client_CA_file@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11a8 <configCAStack+0x68>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1030 <SSL_CTX_set_client_CA_list@plt>
jmp    11b4 <configCAStack+0x74>
lea    0xe92(%rip),%rdi
call   1060 <printSSLErr@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<configCAStack>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%rdx
mov    %rdi,%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <SSL_CTX_load_verify_locations@plt>
cmp    $0x1,%eax
je     1169 <configCAStack+0x29>
lea    0xe9c(%rip),%rdi
call   1060 <printSSLErr@plt>
mov    %rbx,%rdi
call   1050 <SSL_load_client_CA_file@plt>
test   %rax,%rax
je     1188 <configCAStack+0x48>
mov    %r14,%rdi
mov    %rax,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <SSL_CTX_set_client_CA_list@plt>
lea    0xeb2(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1060 <printSSLErr@plt>

LLVM IR (-O0):
%struct.stack_st_X509_NAME = type { i32 }
@.str = [65 x i8] c"SSL_CTX_load_verify_locations() error: unable to set CA location\00"
@.str.1 = [42 x i8] c"configCAStack() error: cert_names is NULL\00"
define void @configCAStack(i8* %0, i8* %1, i32* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca %struct.stack_st_X509_NAME*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32* %2, i32** %6
%9 = load i32*, i32** %6
%10 = load i8*, i8** %4
%11 = load i8*, i8** %5
%12 = call i32 @SSL_CTX_load_verify_locations(i32* %9, i8* %10, i8* %11)
store i32 %12, i32* %7
%13 = load i32, i32* %7
%14 = icmp ne i32 %13, 1
br i1 %14, label %15, label %17
15: ; preds = %3
%16 = call i32 @printSSLErr(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0))
br label %17
17: ; preds = %15, %3
%18 = load i8*, i8** %4
%19 = call %struct.stack_st_X509_NAME* @SSL_load_client_CA_file(i8* %18)
store %struct.stack_st_X509_NAME* %19, %struct.stack_st_X509_NAME** %8
%20 = load %struct.stack_st_X509_NAME*, %struct.stack_st_X509_NAME** %8
%21 = icmp ne %struct.stack_st_X509_NAME* %20, null
br i1 %21, label %22, label %26
22: ; preds = %17
%23 = load i32*, i32** %6
%24 = load %struct.stack_st_X509_NAME*, %struct.stack_st_X509_NAME** %8
%25 = call i32 @SSL_CTX_set_client_CA_list(i32* %23, %struct.stack_st_X509_NAME* %24)
br label %28
26: ; preds = %17
%27 = call i32 @printSSLErr(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0))
br label %28
28: ; preds = %26, %22
ret void
}

LLVM IR (-O2):
%struct.stack_st_X509_NAME = type { i32 }
@.str = [65 x i8] c"SSL_CTX_load_verify_locations() error: unable to set CA location\00"
@.str.1 = [42 x i8] c"configCAStack() error: cert_names is NULL\00"
define void @configCAStack(i8* %0, i8* %1, i32* %2) {
%4 = tail call i32 @SSL_CTX_load_verify_locations(i32* %2, i8* %0, i8* %1)
%5 = icmp eq i32 %4, 1
br i1 %5, label %8, label %6
6: ; preds = %3
%7 = tail call i32 @printSSLErr(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %6, %3
%9 = tail call %struct.stack_st_X509_NAME* @SSL_load_client_CA_file(i8* %0)
%10 = icmp eq %struct.stack_st_X509_NAME* %9, null
br i1 %10, label %13, label %11
11: ; preds = %8
%12 = tail call i32 @SSL_CTX_set_client_CA_list(i32* %2, %struct.stack_st_X509_NAME* %9)
br label %15
13: ; preds = %8
%14 = tail call i32 @printSSLErr(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0))
br label %15
15: ; preds = %13, %11
ret void
}