#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*/ 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*/ *);
DH *load_dh_param(char *dhfile) {
  DH *ret = NULL;
  BIO *bio;
  if ((bio = BIO_new_file(dhfile, "r")) == NULL)
    goto err;
  ret = PEM_read_bio_DHparams(bio, NULL, NULL, NULL);
err:
  if (bio != NULL)
    BIO_free(bio);
  return (ret);
}


x86 assembly (clang, -O0):
<load_dh_param>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xeb1(%rip),%rsi
call   1050 <BIO_new_file@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1167 <load_dh_param+0x37>
jmp    117e <load_dh_param+0x4e>
mov    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%ecx
mov    %rcx,%rsi
mov    %rcx,%rdx
call   1030 <PEM_read_bio_DHparams@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1192 <load_dh_param+0x62>
mov    -0x18(%rbp),%rdi
call   1040 <BIO_free@plt>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<load_dh_param>:
push   %r14
push   %rbx
push   %rax
lea    0xec5(%rip),%rsi
call   1050 <BIO_new_file@plt>
test   %rax,%rax
je     1166 <load_dh_param+0x36>
mov    %rax,%rbx
mov    %rax,%rdi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
call   1030 <PEM_read_bio_DHparams@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1040 <BIO_free@plt>
mov    %r14,%rax
jmp    1168 <load_dh_param+0x38>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
define i32* @load_dh_param(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca i32*
store i8* %0, i8** %2
store i32* null, i32** %3
%5 = load i8*, i8** %2
%6 = call i32* @BIO_new_file(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %6, i32** %4
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %9
8: ; preds = %1
br label %12
9: ; preds = %1
%10 = load i32*, i32** %4
%11 = call i32* @PEM_read_bio_DHparams(i32* %10, i32* null, i32* null, i32* null)
store i32* %11, i32** %3
br label %12
12: ; preds = %9, %8
%13 = load i32*, i32** %4
%14 = icmp ne i32* %13, null
br i1 %14, label %15, label %18
15: ; preds = %12
%16 = load i32*, i32** %4
%17 = call i32 @BIO_free(i32* %16)
br label %18
18: ; preds = %15, %12
%19 = load i32*, i32** %3
ret i32* %19
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
define i32* @load_dh_param(i8* %0) {
%2 = tail call i32* @BIO_new_file(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i32* %2, null
br i1 %3, label %7, label %4
4: ; preds = %1
%5 = tail call i32* @PEM_read_bio_DHparams(i32* %2, i32* null, i32* null, i32* null)
%6 = tail call i32 @BIO_free(i32* %2)
br label %7
7: ; preds = %1, %4
%8 = phi i32* [ %5, %4 ], [ null, %1 ]
ret i32* %8
}