#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 */

/* Variables and functions */
int /*<<< orphan*/ OpenSSL_add_all_algorithms();
char *dh_init();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stderr;
scalar_t__ thread_support();
int cipher_init(void) {
  const char *err;
  OpenSSL_add_all_algorithms();
  if (thread_support()) {
    fprintf(stderr, "failed to initialize thread support.\n");
    return -1;
  }
  if ((err = dh_init()) != NULL) {
    fprintf(stderr, "failed to initialize DH %s\n", err);
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<cipher_init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1050 <OpenSSL_add_all_algorithms@plt>
mov    $0x0,%al
call   1030 <thread_support@plt>
cmp    $0x0,%rax
je     1183 <cipher_init+0x43>
mov    0x2e79(%rip),%rax
mov    (%rax),%edi
lea    0xe90(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c6 <cipher_init+0x86>
mov    $0x0,%al
call   1060 <dh_init@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     11bf <cipher_init+0x7f>
mov    0x2e41(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe7a(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c6 <cipher_init+0x86>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cipher_init>:
push   %rbx
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <OpenSSL_add_all_algorithms@plt>
xor    %eax,%eax
call   1030 <thread_support@plt>
test   %rax,%rax
je     116f <cipher_init+0x2f>
mov    0x2e83(%rip),%rax
mov    (%rax),%edi
lea    0xe9a(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
jmp    1195 <cipher_init+0x55>
xor    %eax,%eax
call   1060 <dh_init@plt>
test   %rax,%rax
je     119a <cipher_init+0x5a>
mov    0x2e5e(%rip),%rcx
mov    (%rcx),%edi
lea    0xe9b(%rip),%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [38 x i8] c"failed to initialize thread support.\0A\00"
@.str.1 = [28 x i8] c"failed to initialize DH %s\0A\00"
define i32 @cipher_init() {
%1 = alloca i32
%2 = alloca i8*
%3 = call i32 (...) @OpenSSL_add_all_algorithms()
%4 = call i64 (...) @thread_support()
%5 = icmp ne i64 %4, 0
br i1 %5, label %6, label %9
6: ; preds = %0
%7 = load i32, i32* @stderr
%8 = call i32 (i32, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %1
br label %17
9: ; preds = %0
%10 = call i8* (...) @dh_init()
store i8* %10, i8** %2
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %16
12: ; preds = %9
%13 = load i32, i32* @stderr
%14 = load i8*, i8** %2
%15 = call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %14)
store i32 -1, i32* %1
br label %17
16: ; preds = %9
store i32 0, i32* %1
br label %17
17: ; preds = %16, %12, %6
%18 = load i32, i32* %1
ret i32 %18
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [38 x i8] c"failed to initialize thread support.\0A\00"
@.str.1 = [28 x i8] c"failed to initialize DH %s\0A\00"
define i32 @cipher_init() {
%1 = tail call i32 (...) @OpenSSL_add_all_algorithms()
%2 = tail call i64 (...) @thread_support()
%3 = icmp eq i64 %2, 0
br i1 %3, label %7, label %4
4: ; preds = %0
%5 = load i32, i32* @stderr
%6 = tail call i32 (i32, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
br label %13
7: ; preds = %0
%8 = tail call i8* (...) @dh_init()
%9 = icmp eq i8* %8, null
br i1 %9, label %13, label %10
10: ; preds = %7
%11 = load i32, i32* @stderr
%12 = tail call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %8)
br label %13
13: ; preds = %7, %10, %4
%14 = phi i32 [ -1, %4 ], [ -1, %10 ], [ 0, %7 ]
ret i32 %14
}