#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*/ dhp_512;
typedef int /*<<< orphan*/ dhg_512;
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() {
  static unsigned char dhp_512[] = {
      0xED, 0x78, 0x7E, 0x95, 0xB9, 0x05, 0xD5, 0x00, 0x38, 0xC6, 0x6B,
      0x49, 0x78, 0x22, 0x78, 0x43, 0x8D, 0xCC, 0xF9, 0x83, 0x18, 0xBB,
      0x6E, 0xFE, 0xCD, 0x90, 0xC3, 0x84, 0xA8, 0x5C, 0x04, 0x84, 0xEB,
      0x85, 0x1D, 0x5B, 0x81, 0x68, 0xA1, 0xB5, 0xCC, 0x09, 0x10, 0x46,
      0x04, 0x8B, 0x0A, 0x06, 0xA5, 0xA7, 0x10, 0x7D, 0x43, 0x1B, 0x6F,
      0xAD, 0xA8, 0xA1, 0xB0, 0xD3, 0xD9, 0x23, 0xD1, 0x83,
  };
  static unsigned char dhg_512[] = {
      0x02,
  };
  DH *dh;
  BIGNUM *dhp_bn, *dhg_bn;
  if ((dh = DH_new()) == NULL)
    return (NULL);
  dhp_bn = BN_bin2bn(dhp_512, sizeof(dhp_512), NULL);
  dhg_bn = BN_bin2bn(dhg_512, sizeof(dhg_512), NULL);
  if (!DH_set0_pqg(dh, dhp_bn, NULL, dhg_bn)) {
    DH_free(dh);
    BN_free(dhp_bn);
    BN_free(dhg_bn);
    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    11fa <get_dh512+0xaa>
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)
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    11f2 <get_dh512+0xa2>
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    11fa <get_dh512+0xaa>
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     11bc <get_dh512+0x6c>
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
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %edx,%edx
mov    %rax,%rcx
call   1030 <DH_set0_pqg@plt>
test   %eax,%eax
jne    11be <get_dh512+0x6e>
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.dhp_512 = internal global [64 x i8] c"\EDx~\95\B9\05\D5\008\C6kIx\22xC\8D\CC\F9\83\18\BBn\FE\CD\90\C3\84\A8\\\04\84\EB\85\1D[\81h\A1\B5\CC\09\10F\04\8B\0A\06\A5\A7\10}C\1Bo\AD\A8\A1\B0\D3\D9#\D1\83"
@get_dh512.dhg_512 = 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 %25
8: ; preds = %0
%9 = call i32* @BN_bin2bn(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @get_dh512.dhp_512, 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.dhg_512, i64 0, i64 0), i32 1, i32* null)
store i32* %10, i32** %4
%11 = load i32*, i32** %2
%12 = load i32*, i32** %3
%13 = load i32*, i32** %4
%14 = call i32 @DH_set0_pqg(i32* %11, i32* %12, i32* null, i32* %13)
%15 = icmp ne i32 %14, 0
br i1 %15, label %23, label %16
16: ; preds = %8
%17 = load i32*, i32** %2
%18 = call i32 @DH_free(i32* %17)
%19 = load i32*, i32** %3
%20 = call i32 @BN_free(i32* %19)
%21 = load i32*, i32** %4
%22 = call i32 @BN_free(i32* %21)
store i32* null, i32** %1
br label %25
23: ; preds = %8
%24 = load i32*, i32** %2
store i32* %24, i32** %1
br label %25
25: ; preds = %23, %16, %7
%26 = load i32*, i32** %1
ret i32* %26
}

LLVM IR (-O2):
@get_dh512.dhp_512 = internal global [64 x i8] c"\EDx~\95\B9\05\D5\008\C6kIx\22xC\8D\CC\F9\83\18\BBn\FE\CD\90\C3\84\A8\\\04\84\EB\85\1D[\81h\A1\B5\CC\09\10F\04\8B\0A\06\A5\A7\10}C\1Bo\AD\A8\A1\B0\D3\D9#\D1\83"
@get_dh512.dhg_512 = 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 %12, label %3
3: ; preds = %0
%4 = tail call i32* @BN_bin2bn(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @get_dh512.dhp_512, 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.dhg_512, i64 0, i64 0), i32 1, i32* null)
%6 = tail call i32 @DH_set0_pqg(i32* %1, i32* %4, i32* null, i32* %5)
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %12
8: ; preds = %3
%9 = tail call i32 @DH_free(i32* %1)
%10 = tail call i32 @BN_free(i32* %4)
%11 = tail call i32 @BN_free(i32* %5)
br label %12
12: ; preds = %3, %0, %8
%13 = phi i32* [ null, %8 ], [ null, %0 ], [ %1, %3 ]
ret i32* %13
}