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

/* Variables and functions */
int /*<<< orphan*/ *BN_bin2bn(unsigned char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ BN_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ DH_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ *DH_new();
int /*<<< orphan*/ DH_set0_pqg(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                               int /*<<< orphan*/ *, int /*<<< orphan*/ *);
DH *get_dh512(void) {
  static unsigned char dh512_p[] = {
      0xCB, 0xC8, 0xE1, 0x86, 0xD0, 0x1F, 0x94, 0x17, 0xA6, 0x99, 0xF0,
      0xC6, 0x1F, 0x0D, 0xAC, 0xB6, 0x25, 0x3E, 0x06, 0x39, 0xCA, 0x72,
      0x04, 0xB0, 0x6E, 0xDA, 0xC0, 0x61, 0xE6, 0x7A, 0x77, 0x25, 0xE8,
      0x3B, 0xB9, 0x5F, 0x9A, 0xB6, 0xB5, 0xFE, 0x99, 0x0B, 0xA1, 0x93,
      0x4E, 0x35, 0x33, 0xB8, 0xE1, 0xF1, 0x13, 0x4F, 0x59, 0x1A, 0xD2,
      0x57, 0xC0, 0x26, 0x21, 0x33, 0x02, 0xC5, 0xAE, 0x23,
  };
  static unsigned char dh512_g[] = {
      0x02,
  };
  DH *dh;
  BIGNUM *p, *g;
  if ((dh = DH_new()) == NULL)
    return NULL;
  p = BN_bin2bn(dh512_p, sizeof(dh512_p), NULL);
  g = BN_bin2bn(dh512_g, sizeof(dh512_g), NULL);
  if ((p == NULL) || (g == NULL) || !DH_set0_pqg(dh, p, NULL, g)) {
    DH_free(dh);
    BN_free(p);
    BN_free(g);
    return NULL;
  }
  return dh;
}


x86 assembly (clang, -O0):
<get_dh512>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x0,%al
call   1050 <DH_new@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    117a <get_dh512+0x2a>
movq   $0x0,-0x8(%rbp)
jmp    1210 <get_dh512+0xc0>
lea    0x2ecf(%rip),%rdi
mov    $0x40,%esi
xor    %eax,%eax
mov    %eax,%edx
call   1040 <BN_bin2bn@plt>
mov    %rax,-0x18(%rbp)
lea    0x2ef6(%rip),%rdi
mov    $0x1,%esi
xor    %eax,%eax
mov    %eax,%edx
call   1040 <BN_bin2bn@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11e0 <get_dh512+0x90>
cmpq   $0x0,-0x20(%rbp)
je     11e0 <get_dh512+0x90>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rcx
xor    %eax,%eax
mov    %eax,%edx
call   1030 <DH_set0_pqg@plt>
cmp    $0x0,%eax
jne    1208 <get_dh512+0xb8>
mov    -0x10(%rbp),%rdi
call   1070 <DH_free@plt>
mov    -0x18(%rbp),%rdi
call   1060 <BN_free@plt>
mov    -0x20(%rbp),%rdi
call   1060 <BN_free@plt>
movq   $0x0,-0x8(%rbp)
jmp    1210 <get_dh512+0xc0>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_dh512>:
push   %r15
push   %r14
push   %rbx
xor    %eax,%eax
call   1050 <DH_new@plt>
test   %rax,%rax
je     11c6 <get_dh512+0x76>
mov    %rax,%rbx
lea    0x2ee5(%rip),%rdi
mov    $0x40,%esi
xor    %edx,%edx
call   1040 <BN_bin2bn@plt>
mov    %rax,%r14
lea    0x2f0f(%rip),%rdi
mov    $0x1,%esi
xor    %edx,%edx
call   1040 <BN_bin2bn@plt>
mov    %rax,%r15
test   %r14,%r14
je     11ae <get_dh512+0x5e>
test   %r15,%r15
je     11ae <get_dh512+0x5e>
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %edx,%edx
mov    %r15,%rcx
call   1030 <DH_set0_pqg@plt>
test   %eax,%eax
jne    11c8 <get_dh512+0x78>
mov    %rbx,%rdi
call   1070 <DH_free@plt>
mov    %r14,%rdi
call   1060 <BN_free@plt>
mov    %r15,%rdi
call   1060 <BN_free@plt>
xor    %ebx,%ebx
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@get_dh512.dh512_p = internal global [64 x i8] c"\CB\C8\E1\86\D0\1F\94\17\A6\99\F0\C6\1F\0D\AC\B6%>\069\CAr\04\B0n\DA\C0a\E6zw%\E8;\B9_\9A\B6\B5\FE\99\0B\A1\93N53\B8\E1\F1\13OY\1A\D2W\C0&!3\02\C5\AE#"
@get_dh512.dh512_g = internal global [1 x i8] c"\02"
define i32* @get_dh512() {
%1 = alloca i32*
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca i32*
%5 = call i32* (...) @DH_new()
store i32* %5, i32** %2
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %8
7: ; preds = %0
store i32* null, i32** %1
br label %31
8: ; preds = %0
%9 = call i32* @BN_bin2bn(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @get_dh512.dh512_p, i64 0, i64 0), i32 64, i32* null)
store i32* %9, i32** %3
%10 = call i32* @BN_bin2bn(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @get_dh512.dh512_g, i64 0, i64 0), i32 1, i32* null)
store i32* %10, i32** %4
%11 = load i32*, i32** %3
%12 = icmp eq i32* %11, null
br i1 %12, label %22, label %13
13: ; preds = %8
%14 = load i32*, i32** %4
%15 = icmp eq i32* %14, null
br i1 %15, label %22, label %16
16: ; preds = %13
%17 = load i32*, i32** %2
%18 = load i32*, i32** %3
%19 = load i32*, i32** %4
%20 = call i32 @DH_set0_pqg(i32* %17, i32* %18, i32* null, i32* %19)
%21 = icmp ne i32 %20, 0
br i1 %21, label %29, label %22
22: ; preds = %16, %13, %8
%23 = load i32*, i32** %2
%24 = call i32 @DH_free(i32* %23)
%25 = load i32*, i32** %3
%26 = call i32 @BN_free(i32* %25)
%27 = load i32*, i32** %4
%28 = call i32 @BN_free(i32* %27)
store i32* null, i32** %1
br label %31
29: ; preds = %16
%30 = load i32*, i32** %2
store i32* %30, i32** %1
br label %31
31: ; preds = %29, %22, %7
%32 = load i32*, i32** %1
ret i32* %32
}

LLVM IR (-O2):
@get_dh512.dh512_p = internal global [64 x i8] c"\CB\C8\E1\86\D0\1F\94\17\A6\99\F0\C6\1F\0D\AC\B6%>\069\CAr\04\B0n\DA\C0a\E6zw%\E8;\B9_\9A\B6\B5\FE\99\0B\A1\93N53\B8\E1\F1\13OY\1A\D2W\C0&!3\02\C5\AE#"
@get_dh512.dh512_g = internal global [1 x i8] c"\02"
define i32* @get_dh512() {
%1 = tail call i32* (...) @DH_new()
%2 = icmp eq i32* %1, null
br i1 %2, label %16, label %3
3: ; preds = %0
%4 = tail call i32* @BN_bin2bn(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @get_dh512.dh512_p, i64 0, i64 0), i32 64, i32* null)
%5 = tail call i32* @BN_bin2bn(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @get_dh512.dh512_g, i64 0, i64 0), i32 1, i32* null)
%6 = icmp eq i32* %4, null
%7 = icmp eq i32* %5, null
%8 = select i1 %6, i1 true, i1 %7
br i1 %8, label %12, label %9
9: ; preds = %3
%10 = tail call i32 @DH_set0_pqg(i32* %1, i32* %4, i32* null, i32* %5)
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %9, %3
%13 = tail call i32 @DH_free(i32* %1)
%14 = tail call i32 @BN_free(i32* %4)
%15 = tail call i32 @BN_free(i32* %5)
br label %16
16: ; preds = %9, %0, %12
%17 = phi i32* [ null, %12 ], [ null, %0 ], [ %1, %9 ]
ret i32* %17
}