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

/* Variables and functions */
int /*<<< orphan*/ *PEM_read_DHparams(int /*<<< orphan*/ *,
                                      int /*<<< orphan*/ *,
                                      int /*<<< orphan*/ *,
                                      int /*<<< orphan*/ *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int ssl_init();
DH *ssl_dh_load(const char *filename) {
  DH *dh;
  FILE *fh;
  if (ssl_init() == -1)
    return NULL;
  if (!(fh = fopen(filename, "r"))) {
    return NULL;
  }
  dh = PEM_read_DHparams(fh, NULL, NULL, NULL);
  fclose(fh);
  return dh;
}


x86 assembly (clang, -O0):
<ssl_dh_load>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    $0x0,%al
call   1050 <ssl_init@plt>
cmp    $0xffffffff,%eax
jne    1169 <ssl_dh_load+0x29>
movq   $0x0,-0x8(%rbp)
jmp    11bc <ssl_dh_load+0x7c>
mov    -0x10(%rbp),%rdi
lea    0xe8c(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    1194 <ssl_dh_load+0x54>
movq   $0x0,-0x8(%rbp)
jmp    11bc <ssl_dh_load+0x7c>
mov    -0x20(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%ecx
mov    %rcx,%rsi
mov    %rcx,%rdx
call   1060 <PEM_read_DHparams@plt>
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ssl_dh_load>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
xor    %eax,%eax
call   1050 <ssl_init@plt>
cmp    $0xffffffff,%eax
je     1188 <ssl_dh_load+0x48>
lea    0xea6(%rip),%rsi
mov    %rbx,%rdi
call   1040 <fopen@plt>
test   %rax,%rax
je     1188 <ssl_dh_load+0x48>
mov    %rax,%rbx
mov    %rax,%rdi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
call   1060 <PEM_read_DHparams@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1030 <fclose@plt>
mov    %r14,%rax
jmp    118a <ssl_dh_load+0x4a>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
define i32* @ssl_dh_load(i8* nocapture %0) {
%2 = tail call i32 (...) @ssl_init()
%3 = icmp eq i32 %2, -1
br i1 %3, label %10, label %4
4: ; preds = %1
%5 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %10, label %7
7: ; preds = %4
%8 = tail call i32* @PEM_read_DHparams(i32* %5, i32* null, i32* null, i32* null)
%9 = tail call i32 @fclose(i32* %5)
br label %10
10: ; preds = %4, %1, %7
%11 = phi i32* [ %8, %7 ], [ null, %1 ], [ null, %4 ]
ret i32* %11
}