#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 const *, char *);
int /*<<< orphan*/ *PEM_read_bio_DHparams(int /*<<< orphan*/ *,
                                          int /*<<< orphan*/ *,
                                          int /*<<< orphan*/ *,
                                          int /*<<< orphan*/ *);
DH *load_dh_param(const 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:
  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)
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>
mov    %rax,%rbx
test   %rax,%rax
je     115b <load_dh_param+0x2b>
mov    %rbx,%rdi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
call   1030 <PEM_read_bio_DHparams@plt>
mov    %rax,%r14
jmp    115e <load_dh_param+0x2e>
xor    %r14d,%r14d
mov    %rbx,%rdi
call   1040 <BIO_free@plt>
mov    %r14,%rax
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 = call i32 @BIO_free(i32* %13)
%15 = load i32*, i32** %3
ret i32* %15
}

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 %6, label %4
4: ; preds = %1
%5 = tail call i32* @PEM_read_bio_DHparams(i32* %2, i32* null, i32* null, i32* null)
br label %6
6: ; preds = %1, %4
%7 = phi i32* [ null, %1 ], [ %5, %4 ]
%8 = tail call i32 @BIO_free(i32* %2)
ret i32* %7
}