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

/* Variables and functions */
int /*<<< orphan*/ BIO_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ *BIO_new_file(char *, char *);
int /*<<< orphan*/ *PEM_read_bio_DHparams(int /*<<< orphan*/ *,
                                          int /*<<< orphan*/ *,
                                          int /*<<< orphan*/ *,
                                          int /*<<< orphan*/ *);
scalar_t__ SSL_CTX_set_tmp_dh(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ ssl_berr_exit(char *);
void load_dh_params(SSL_CTX *ctx, char *file) {
  DH *ret = 0;
  BIO *bio;
  if ((bio = BIO_new_file(file, "r")) == NULL)
    ssl_berr_exit("Couldn't open DH file");
  ret = PEM_read_bio_DHparams(bio, NULL, NULL, NULL);
  BIO_free(bio);
  if (SSL_CTX_set_tmp_dh(ctx, ret) < 0)
    ssl_berr_exit("Couldn't set DH parameters");
}


x86 assembly (clang, -O0):
<load_dh_params>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe8d(%rip),%rsi
call   1070 <BIO_new_file@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    1192 <load_dh_params+0x42>
lea    0xe75(%rip),%rdi
call   1060 <ssl_berr_exit@plt>
mov    -0x20(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%ecx
mov    %rcx,%rsi
mov    %rcx,%rdx
call   1030 <PEM_read_bio_DHparams@plt>
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <BIO_free@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <SSL_CTX_set_tmp_dh@plt>
cmp    $0x0,%rax
jge    11d5 <load_dh_params+0x85>
lea    0xe48(%rip),%rdi
call   1060 <ssl_berr_exit@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<load_dh_params>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%rax
mov    %rdi,%r14
lea    0xe9e(%rip),%rsi
mov    %rax,%rdi
call   1070 <BIO_new_file@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    117e <load_dh_params+0x2e>
lea    0xe89(%rip),%rdi
call   1060 <ssl_berr_exit@plt>
mov    %rbx,%rdi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
call   1030 <PEM_read_bio_DHparams@plt>
mov    %rax,%r15
mov    %rbx,%rdi
call   1050 <BIO_free@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <SSL_CTX_set_tmp_dh@plt>
test   %rax,%rax
js     11ad <load_dh_params+0x5d>
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xe64(%rip),%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1060 <ssl_berr_exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [22 x i8] c"Couldn't open DH file\00"
@.str.2 = [27 x i8] c"Couldn't set DH parameters\00"
define void @load_dh_params(i32* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32*
store i32* %0, i32** %3
store i8* %1, i8** %4
store i32* null, i32** %5
%7 = load i8*, i8** %4
%8 = call i32* @BIO_new_file(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %8, i32** %6
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = call i32 @ssl_berr_exit(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
br label %12
12: ; preds = %10, %2
%13 = load i32*, i32** %6
%14 = call i32* @PEM_read_bio_DHparams(i32* %13, i32* null, i32* null, i32* null)
store i32* %14, i32** %5
%15 = load i32*, i32** %6
%16 = call i32 @BIO_free(i32* %15)
%17 = load i32*, i32** %3
%18 = load i32*, i32** %5
%19 = call i64 @SSL_CTX_set_tmp_dh(i32* %17, i32* %18)
%20 = icmp slt i64 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %12
%22 = call i32 @ssl_berr_exit(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
br label %23
23: ; preds = %21, %12
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [22 x i8] c"Couldn't open DH file\00"
@.str.2 = [27 x i8] c"Couldn't set DH parameters\00"
define void @load_dh_params(i32* %0, i8* %1) {
%3 = tail call i32* @BIO_new_file(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 @ssl_berr_exit(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
br label %7
7: ; preds = %5, %2
%8 = tail call i32* @PEM_read_bio_DHparams(i32* %3, i32* null, i32* null, i32* null)
%9 = tail call i32 @BIO_free(i32* %3)
%10 = tail call i64 @SSL_CTX_set_tmp_dh(i32* %0, i32* %8)
%11 = icmp slt i64 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %7
%13 = tail call i32 @ssl_berr_exit(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
br label %14
14: ; preds = %12, %7
ret void
}