#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*/ DH_free(int /*<<< orphan*/ *);
int DH_generate_parameters_ex(int /*<<< orphan*/ *, int, int,
                              int /*<<< orphan*/ *);
int /*<<< orphan*/ *DH_new();
int /*<<< orphan*/ ERR_free_strings();
int /*<<< orphan*/ ERR_load_crypto_strings();
int /*<<< orphan*/ ERR_print_errors_fp(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int i2d_DHparams_fp(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int main(void) {
  FILE *fd;
  int ret;
  DH *dh;
  ERR_load_crypto_strings();
  dh = DH_new();
  if (!dh) {
    ERR_print_errors_fp(stderr);
    return 1;
  }
  ret = DH_generate_parameters_ex(dh, 2048, 2, NULL);
  if (!ret) {
    ERR_print_errors_fp(stderr);
    return 1;
  }
  fd = fopen("params.der", "w");
  ret = i2d_DHparams_fp(fd, dh);
  if (!ret) {
    ERR_print_errors_fp(stderr);
    return 1;
  }
  fclose(fd);
  DH_free(dh);
  ERR_free_strings();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   10a0 <ERR_load_crypto_strings@plt>
mov    $0x0,%al
call   1050 <DH_new@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11d6 <main+0x46>
mov    0x2e1d(%rip),%rax
mov    (%rax),%edi
call   10b0 <ERR_print_errors_fp@plt>
movl   $0x1,-0x4(%rbp)
jmp    127f <main+0xef>
mov    -0x20(%rbp),%rdi
mov    $0x800,%esi
mov    $0x2,%edx
xor    %eax,%eax
mov    %eax,%ecx
call   1030 <DH_generate_parameters_ex@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    1214 <main+0x84>
mov    0x2ddf(%rip),%rax
mov    (%rax),%edi
call   10b0 <ERR_print_errors_fp@plt>
movl   $0x1,-0x4(%rbp)
jmp    127f <main+0xef>
lea    0xde5(%rip),%rdi
lea    0xde9(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1060 <i2d_DHparams_fp@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    125f <main+0xcf>
mov    0x2d94(%rip),%rax
mov    (%rax),%edi
call   10b0 <ERR_print_errors_fp@plt>
movl   $0x1,-0x4(%rbp)
jmp    127f <main+0xef>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1080 <DH_free@plt>
mov    $0x0,%al
call   1070 <ERR_free_strings@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   10a0 <ERR_load_crypto_strings@plt>
xor    %eax,%eax
call   1050 <DH_new@plt>
test   %rax,%rax
je     1202 <main+0x72>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0x800,%esi
mov    $0x2,%edx
xor    %ecx,%ecx
call   1030 <DH_generate_parameters_ex@plt>
test   %eax,%eax
je     1202 <main+0x72>
lea    0xe37(%rip),%rdi
lea    0xe3b(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%r14
mov    %rax,%rdi
mov    %rbx,%rsi
call   1060 <i2d_DHparams_fp@plt>
test   %eax,%eax
je     1202 <main+0x72>
mov    %r14,%rdi
call   1040 <fclose@plt>
mov    %rbx,%rdi
call   1080 <DH_free@plt>
xor    %ebx,%ebx
xor    %eax,%eax
call   1070 <ERR_free_strings@plt>
jmp    1215 <main+0x85>
mov    0x2dd7(%rip),%rax
mov    (%rax),%edi
call   10b0 <ERR_print_errors_fp@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [11 x i8] c"params.der\00"
@.str.1 = [2 x i8] c"w\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32*
store i32 0, i32* %1
%5 = call i32 (...) @ERR_load_crypto_strings()
%6 = call i32* (...) @DH_new()
store i32* %6, i32** %4
%7 = load i32*, i32** %4
%8 = icmp ne i32* %7, null
br i1 %8, label %12, label %9
9: ; preds = %0
%10 = load i32, i32* @stderr
%11 = call i32 @ERR_print_errors_fp(i32 %10)
store i32 1, i32* %1
br label %36
12: ; preds = %0
%13 = load i32*, i32** %4
%14 = call i32 @DH_generate_parameters_ex(i32* %13, i32 2048, i32 2, i32* null)
store i32 %14, i32* %3
%15 = load i32, i32* %3
%16 = icmp ne i32 %15, 0
br i1 %16, label %20, label %17
17: ; preds = %12
%18 = load i32, i32* @stderr
%19 = call i32 @ERR_print_errors_fp(i32 %18)
store i32 1, i32* %1
br label %36
20: ; preds = %12
%21 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %21, i32** %2
%22 = load i32*, i32** %2
%23 = load i32*, i32** %4
%24 = call i32 @i2d_DHparams_fp(i32* %22, i32* %23)
store i32 %24, i32* %3
%25 = load i32, i32* %3
%26 = icmp ne i32 %25, 0
br i1 %26, label %30, label %27
27: ; preds = %20
%28 = load i32, i32* @stderr
%29 = call i32 @ERR_print_errors_fp(i32 %28)
store i32 1, i32* %1
br label %36
30: ; preds = %20
%31 = load i32*, i32** %2
%32 = call i32 @fclose(i32* %31)
%33 = load i32*, i32** %4
%34 = call i32 @DH_free(i32* %33)
%35 = call i32 (...) @ERR_free_strings()
store i32 0, i32* %1
br label %36
36: ; preds = %30, %27, %17, %9
%37 = load i32, i32* %1
ret i32 %37
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [11 x i8] c"params.der\00"
@.str.1 = [2 x i8] c"w\00"
define i32 @main() {
%1 = tail call i32 (...) @ERR_load_crypto_strings()
%2 = tail call i32* (...) @DH_new()
%3 = icmp eq i32* %2, null
br i1 %3, label %4, label %7
4: ; preds = %0
%5 = load i32, i32* @stderr
%6 = tail call i32 @ERR_print_errors_fp(i32 %5)
br label %24
7: ; preds = %0
%8 = tail call i32 @DH_generate_parameters_ex(i32* %2, i32 2048, i32 2, i32* null)
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %7
%11 = load i32, i32* @stderr
%12 = tail call i32 @ERR_print_errors_fp(i32 %11)
br label %24
13: ; preds = %7
%14 = tail call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%15 = tail call i32 @i2d_DHparams_fp(i32* %14, i32* %2)
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %13
%18 = load i32, i32* @stderr
%19 = tail call i32 @ERR_print_errors_fp(i32 %18)
br label %24
20: ; preds = %13
%21 = tail call i32 @fclose(i32* %14)
%22 = tail call i32 @DH_free(i32* %2)
%23 = tail call i32 (...) @ERR_free_strings()
br label %24
24: ; preds = %20, %17, %10, %4
%25 = phi i32 [ 0, %20 ], [ 1, %17 ], [ 1, %10 ], [ 1, %4 ]
ret i32 %25
}