#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*/ dh1024_p;
typedef int /*<<< orphan*/ dh1024_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*/ *);
int /*<<< orphan*/ DH_set_length(int /*<<< orphan*/ *, int);
DH *get_dh1024dsa(void) {
  static unsigned char dh1024_p[] = {
      0xC8, 0x00, 0xF7, 0x08, 0x07, 0x89, 0x4D, 0x90, 0x53, 0xF3, 0xD5, 0x00,
      0x21, 0x1B, 0xF7, 0x31, 0xA6, 0xA2, 0xDA, 0x23, 0x9A, 0xC7, 0x87, 0x19,
      0x3B, 0x47, 0xB6, 0x8C, 0x04, 0x6F, 0xFF, 0xC6, 0x9B, 0xB8, 0x65, 0xD2,
      0xC2, 0x5F, 0x31, 0x83, 0x4A, 0xA7, 0x5F, 0x2F, 0x88, 0x38, 0xB6, 0x55,
      0xCF, 0xD9, 0x87, 0x6D, 0x6F, 0x9F, 0xDA, 0xAC, 0xA6, 0x48, 0xAF, 0xFC,
      0x33, 0x84, 0x37, 0x5B, 0x82, 0x4A, 0x31, 0x5D, 0xE7, 0xBD, 0x52, 0x97,
      0xA1, 0x77, 0xBF, 0x10, 0x9E, 0x37, 0xEA, 0x64, 0xFA, 0xCA, 0x28, 0x8D,
      0x9D, 0x3B, 0xD2, 0x6E, 0x09, 0x5C, 0x68, 0xC7, 0x45, 0x90, 0xFD, 0xBB,
      0x70, 0xC9, 0x3A, 0xBB, 0xDF, 0xD4, 0x21, 0x0F, 0xC4, 0x6A, 0x3C, 0xF6,
      0x61, 0xCF, 0x3F, 0xD6, 0x13, 0xF1, 0x5F, 0xBC, 0xCF, 0xBC, 0x26, 0x9E,
      0xBC, 0x0B, 0xBD, 0xAB, 0x5D, 0xC9, 0x54, 0x39,
  };
  static unsigned char dh1024_g[] = {
      0x3B, 0x40, 0x86, 0xE7, 0xF3, 0x6C, 0xDE, 0x67, 0x1C, 0xCC, 0x80, 0x05,
      0x5A, 0xDF, 0xFE, 0xBD, 0x20, 0x27, 0x74, 0x6C, 0x24, 0xC9, 0x03, 0xF3,
      0xE1, 0x8D, 0xC3, 0x7D, 0x98, 0x27, 0x40, 0x08, 0xB8, 0x8C, 0x6A, 0xE9,
      0xBB, 0x1A, 0x3A, 0xD6, 0x86, 0x83, 0x5E, 0x72, 0x41, 0xCE, 0x85, 0x3C,
      0xD2, 0xB3, 0xFC, 0x13, 0xCE, 0x37, 0x81, 0x9E, 0x4C, 0x1C, 0x7B, 0x65,
      0xD3, 0xE6, 0xA6, 0x00, 0xF5, 0x5A, 0x95, 0x43, 0x5E, 0x81, 0xCF, 0x60,
      0xA2, 0x23, 0xFC, 0x36, 0xA7, 0x5D, 0x7A, 0x4C, 0x06, 0x91, 0x6E, 0xF6,
      0x57, 0xEE, 0x36, 0xCB, 0x06, 0xEA, 0xF5, 0x3D, 0x95, 0x49, 0xCB, 0xA7,
      0xDD, 0x81, 0xDF, 0x80, 0x09, 0x4A, 0x97, 0x4D, 0xA8, 0x22, 0x72, 0xA1,
      0x7F, 0xC4, 0x70, 0x56, 0x70, 0xE8, 0x20, 0x10, 0x18, 0x8F, 0x2E, 0x60,
      0x07, 0xE7, 0x68, 0x1A, 0x82, 0x5D, 0x32, 0xA2,
  };
  DH *dh;
  BIGNUM *p, *g;
  if ((dh = DH_new()) == NULL)
    return NULL;
  p = BN_bin2bn(dh1024_p, sizeof(dh1024_p), NULL);
  g = BN_bin2bn(dh1024_g, sizeof(dh1024_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;
  }
  DH_set_length(dh, 160);
  return dh;
}


x86 assembly (clang, -O0):
<get_dh1024dsa>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x0,%al
call   1050 <DH_new@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    118a <get_dh1024dsa+0x2a>
movq   $0x0,-0x8(%rbp)
jmp    122e <get_dh1024dsa+0xce>
lea    0x2ecf(%rip),%rdi
mov    $0x80,%esi
xor    %eax,%eax
mov    %eax,%edx
call   1040 <BN_bin2bn@plt>
mov    %rax,-0x18(%rbp)
lea    0x2f36(%rip),%rdi
mov    $0x80,%esi
xor    %eax,%eax
mov    %eax,%edx
call   1040 <BN_bin2bn@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11f0 <get_dh1024dsa+0x90>
cmpq   $0x0,-0x20(%rbp)
je     11f0 <get_dh1024dsa+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    1218 <get_dh1024dsa+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    122e <get_dh1024dsa+0xce>
mov    -0x10(%rbp),%rdi
mov    $0xa0,%esi
call   1080 <DH_set_length@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_dh1024dsa>:
push   %r15
push   %r14
push   %rbx
xor    %eax,%eax
call   1050 <DH_new@plt>
test   %rax,%rax
je     11e5 <get_dh1024dsa+0x85>
mov    %rax,%rbx
lea    0x2ee5(%rip),%rdi
mov    $0x80,%esi
xor    %edx,%edx
call   1040 <BN_bin2bn@plt>
mov    %rax,%r14
lea    0x2f4f(%rip),%rdi
mov    $0x80,%esi
xor    %edx,%edx
call   1040 <BN_bin2bn@plt>
mov    %rax,%r15
test   %r14,%r14
je     11cd <get_dh1024dsa+0x6d>
test   %r15,%r15
je     11cd <get_dh1024dsa+0x6d>
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %edx,%edx
mov    %r15,%rcx
call   1030 <DH_set0_pqg@plt>
test   %eax,%eax
je     11cd <get_dh1024dsa+0x6d>
mov    %rbx,%rdi
mov    $0xa0,%esi
call   1080 <DH_set_length@plt>
jmp    11e7 <get_dh1024dsa+0x87>
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_dh1024dsa.dh1024_p = internal global [128 x i8] c"\C8\00\F7\08\07\89M\90S\F3\D5\00!\1B\F71\A6\A2\DA#\9A\C7\87\19;G\B6\8C\04o\FF\C6\9B\B8e\D2\C2_1\83J\A7_/\888\B6U\CF\D9\87mo\9F\DA\AC\A6H\AF\FC3\847[\82J1]\E7\BDR\97\A1w\BF\10\9E7\EAd\FA\CA(\8D\9D;\D2n\09\\h\C7E\90\FD\BBp\C9:\BB\DF\D4!\0F\C4j<\F6a\CF?\D6\13\F1_\BC\CF\BC&\9E\BC\0B\BD\AB]\C9T9"
@get_dh1024dsa.dh1024_g = internal global [128 x i8] c";@\86\E7\F3l\DEg\1C\CC\80\05Z\DF\FE\BD 'tl$\C9\03\F3\E1\8D\C3}\98'@\08\B8\8Cj\E9\BB\1A:\D6\86\83^rA\CE\85<\D2\B3\FC\13\CE7\81\9EL\1C{e\D3\E6\A6\00\F5Z\95C^\81\CF`\A2#\FC6\A7]zL\06\91n\F6W\EE6\CB\06\EA\F5=\95I\CB\A7\DD\81\DF\80\09J\97M\A8\22r\A1\7F\C4pVp\E8 \10\18\8F.`\07\E7h\1A\82]2\A2"
define i32* @get_dh1024dsa() {
%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 %33
8: ; preds = %0
%9 = call i32* @BN_bin2bn(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @get_dh1024dsa.dh1024_p, i64 0, i64 0), i32 128, i32* null)
store i32* %9, i32** %3
%10 = call i32* @BN_bin2bn(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @get_dh1024dsa.dh1024_g, i64 0, i64 0), i32 128, 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 %33
29: ; preds = %16
%30 = load i32*, i32** %2
%31 = call i32 @DH_set_length(i32* %30, i32 160)
%32 = load i32*, i32** %2
store i32* %32, i32** %1
br label %33
33: ; preds = %29, %22, %7
%34 = load i32*, i32** %1
ret i32* %34
}

LLVM IR (-O2):
@get_dh1024dsa.dh1024_p = internal global [128 x i8] c"\C8\00\F7\08\07\89M\90S\F3\D5\00!\1B\F71\A6\A2\DA#\9A\C7\87\19;G\B6\8C\04o\FF\C6\9B\B8e\D2\C2_1\83J\A7_/\888\B6U\CF\D9\87mo\9F\DA\AC\A6H\AF\FC3\847[\82J1]\E7\BDR\97\A1w\BF\10\9E7\EAd\FA\CA(\8D\9D;\D2n\09\\h\C7E\90\FD\BBp\C9:\BB\DF\D4!\0F\C4j<\F6a\CF?\D6\13\F1_\BC\CF\BC&\9E\BC\0B\BD\AB]\C9T9"
@get_dh1024dsa.dh1024_g = internal global [128 x i8] c";@\86\E7\F3l\DEg\1C\CC\80\05Z\DF\FE\BD 'tl$\C9\03\F3\E1\8D\C3}\98'@\08\B8\8Cj\E9\BB\1A:\D6\86\83^rA\CE\85<\D2\B3\FC\13\CE7\81\9EL\1C{e\D3\E6\A6\00\F5Z\95C^\81\CF`\A2#\FC6\A7]zL\06\91n\F6W\EE6\CB\06\EA\F5=\95I\CB\A7\DD\81\DF\80\09J\97M\A8\22r\A1\7F\C4pVp\E8 \10\18\8F.`\07\E7h\1A\82]2\A2"
define i32* @get_dh1024dsa() {
%1 = tail call i32* (...) @DH_new()
%2 = icmp eq i32* %1, null
br i1 %2, label %18, label %3
3: ; preds = %0
%4 = tail call i32* @BN_bin2bn(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @get_dh1024dsa.dh1024_p, i64 0, i64 0), i32 128, i32* null)
%5 = tail call i32* @BN_bin2bn(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @get_dh1024dsa.dh1024_g, i64 0, i64 0), i32 128, 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 %18
16: ; preds = %9
%17 = tail call i32 @DH_set_length(i32* %1, i32 160)
br label %18
18: ; preds = %0, %16, %12
%19 = phi i32* [ null, %12 ], [ %1, %16 ], [ null, %0 ]
ret i32* %19
}