#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 */
typedef struct TYPE_5__ TYPE_1__;

/* Type definitions */
struct TYPE_5__ {
  int nid;
};
typedef TYPE_1__ EC_builtin_curve;
typedef int /*<<< orphan*/ EC_GROUP;

/* Variables and functions */
int /*<<< orphan*/ EC_GROUP_check(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ EC_GROUP_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ *EC_GROUP_new_by_curve_name(int);
size_t EC_get_builtin_curves(TYPE_1__ *, size_t);
int /*<<< orphan*/ ERR_print_errors_fp(int /*<<< orphan*/);
char *OBJ_nid2sn(int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ free(TYPE_1__ *);
TYPE_1__ *reallocarray(int /*<<< orphan*/ *, int, size_t);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
void internal_curve_test(void) {
  EC_builtin_curve *curves = NULL;
  size_t crv_len = 0, n = 0;
  int ok = 1;
  crv_len = EC_get_builtin_curves(NULL, 0);
  curves = reallocarray(NULL, sizeof(EC_builtin_curve), crv_len);
  if (curves == NULL)
    return;
  if (!EC_get_builtin_curves(curves, crv_len)) {
    free(curves);
    return;
  }
  fprintf(stdout, "testing internal curves: ");
  for (n = 0; n < crv_len; n++) {
    EC_GROUP *group = NULL;
    int nid = curves[n].nid;
    if ((group = EC_GROUP_new_by_curve_name(nid)) == NULL) {
      ok = 0;
      fprintf(stdout,
              "\nEC_GROUP_new_curve_name() failed with"
              " curve %s\n",
              OBJ_nid2sn(nid));
      continue;
    }
    if (!EC_GROUP_check(group, NULL)) {
      ok = 0;
      fprintf(stdout,
              "\nEC_GROUP_check() failed with"
              " curve %s\n",
              OBJ_nid2sn(nid));
      EC_GROUP_free(group);
      continue;
    }
    fprintf(stdout, ".");
    fflush(stdout);
    EC_GROUP_free(group);
  }
  if (ok)
    fprintf(stdout, " ok\n\n");
  else {
    fprintf(stdout, " failed\n\n");
    do {
      fflush(stdout);
      fprintf(stderr, "%s:%d: ABORT\n",
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/GaloisInc/hacrypto/refs/heads/master/"
              "src/C/libressl/libressl-2.3.1/tests/ectest.c",
              1359);
      ERR_print_errors_fp(stderr);
      exit(1);
    } while (0);
  }
  free(curves);
  return;
}


x86 assembly (clang, -O0):
<internal_curve_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movq   $0x0,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
xor    %eax,%eax
mov    %eax,%esi
mov    %rsi,%rdi
call   10b0 <EC_get_builtin_curves@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%edi
mov    $0x4,%esi
call   1050 <reallocarray@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    120d <internal_curve_test+0x5d>
jmp    13e0 <internal_curve_test+0x230>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   10b0 <EC_get_builtin_curves@plt>
cmp    $0x0,%rax
jne    1232 <internal_curve_test+0x82>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
jmp    13e0 <internal_curve_test+0x230>
mov    0x2d9f(%rip),%rax
mov    (%rax),%edi
lea    0xdbe(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    1351 <internal_curve_test+0x1a1>
movq   $0x0,-0x28(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%edi
call   1070 <EC_GROUP_new_by_curve_name@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    12bf <internal_curve_test+0x10f>
movl   $0x0,-0x1c(%rbp)
mov    0x2d3f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x30(%rbp)
mov    -0x2c(%rbp),%edi
call   1060 <OBJ_nid2sn@plt>
mov    -0x30(%rbp),%edi
mov    %rax,%rdx
lea    0xd67(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
jmp    1340 <internal_curve_test+0x190>
mov    -0x28(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1080 <EC_GROUP_check@plt>
cmp    $0x0,%eax
jne    1312 <internal_curve_test+0x162>
movl   $0x0,-0x1c(%rbp)
mov    0x2cf5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    -0x2c(%rbp),%edi
call   1060 <OBJ_nid2sn@plt>
mov    -0x34(%rbp),%edi
mov    %rax,%rdx
lea    0xd4e(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x28(%rbp),%rdi
call   1040 <EC_GROUP_free@plt>
jmp    1340 <internal_curve_test+0x190>
mov    0x2cbf(%rip),%rax
mov    (%rax),%edi
lea    0xd51(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x2ca8(%rip),%rax
mov    (%rax),%edi
call   10a0 <fflush@plt>
mov    -0x28(%rbp),%rdi
call   1040 <EC_GROUP_free@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1251 <internal_curve_test+0xa1>
cmpl   $0x0,-0x1c(%rbp)
je     1377 <internal_curve_test+0x1c7>
mov    0x2c76(%rip),%rax
mov    (%rax),%edi
lea    0xd0a(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
jmp    13d7 <internal_curve_test+0x227>
mov    0x2c5a(%rip),%rax
mov    (%rax),%edi
lea    0xcf4(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x2c43(%rip),%rax
mov    (%rax),%edi
call   10a0 <fflush@plt>
mov    0x2c3d(%rip),%rax
mov    (%rax),%edi
lea    0xcd9(%rip),%rsi
lea    0xce0(%rip),%rdx
mov    $0x54f,%ecx
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x2c1a(%rip),%rax
mov    (%rax),%edi
call   10d0 <ERR_print_errors_fp@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<internal_curve_test>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
xor    %edi,%edi
xor    %esi,%esi
call   10b0 <EC_get_builtin_curves@plt>
mov    %rax,%r14
xor    %edi,%edi
mov    $0x4,%esi
mov    %rax,%rdx
call   1050 <reallocarray@plt>
test   %rax,%rax
je     12e9 <internal_curve_test+0x139>
mov    %rax,%r15
mov    %rax,%rdi
mov    %r14,%rsi
call   10b0 <EC_get_builtin_curves@plt>
test   %rax,%rax
je     130f <internal_curve_test+0x15f>
mov    0x2dd8(%rip),%rbx
mov    (%rbx),%edi
lea    0xdf7(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
test   %r14,%r14
je     12ff <internal_curve_test+0x14f>
movl   $0x1,0xc(%rsp)
xor    %r13d,%r13d
mov    %r14,0x10(%rsp)
jmp    1262 <internal_curve_test+0xb2>
nopl   0x0(%rax,%rax,1)
mov    (%rbx),%ebp
mov    %r12d,%edi
call   1060 <OBJ_nid2sn@plt>
movl   $0x0,0xc(%rsp)
mov    %ebp,%edi
lea    0xdcf(%rip),%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1090 <fprintf@plt>
add    $0x1,%r13
cmp    %r13,%r14
je     12f8 <internal_curve_test+0x148>
mov    (%r15,%r13,4),%r12d
mov    %r12d,%edi
call   1070 <EC_GROUP_new_by_curve_name@plt>
test   %rax,%rax
je     1230 <internal_curve_test+0x80>
mov    %rax,%rbp
mov    %r15,%r14
mov    %rax,%rdi
xor    %esi,%esi
call   1080 <EC_GROUP_check@plt>
mov    (%rbx),%r15d
test   %eax,%eax
je     12b0 <internal_curve_test+0x100>
mov    %r15d,%edi
lea    0xddf(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    (%rbx),%edi
call   10a0 <fflush@plt>
jmp    12d4 <internal_curve_test+0x124>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r12d,%edi
call   1060 <OBJ_nid2sn@plt>
movl   $0x0,0xc(%rsp)
mov    %r15d,%edi
lea    0xd81(%rip),%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    %rbp,%rdi
call   1040 <EC_GROUP_free@plt>
mov    %r14,%r15
mov    0x10(%rsp),%r14
jmp    1255 <internal_curve_test+0xa5>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
cmpl   $0x0,0xc(%rsp)
je     1325 <internal_curve_test+0x175>
mov    (%rbx),%edi
lea    0xd6d(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    %r15,%rdi
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>
mov    (%rbx),%edi
lea    0xd4d(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    (%rbx),%edi
call   10a0 <fflush@plt>
mov    0x2c9d(%rip),%rbx
mov    (%rbx),%edi
lea    0xd39(%rip),%rsi
lea    0xd40(%rip),%rdx
mov    $0x54f,%ecx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    (%rbx),%edi
call   10d0 <ERR_print_errors_fp@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
%struct.TYPE_5__ = type { i32 }
@stdout = global i32 0
@.str = [26 x i8] c"testing internal curves: \00"
@.str.1 = [49 x i8] c"\0AEC_GROUP_new_curve_name() failed with curve %s\0A\00"
@.str.2 = [40 x i8] c"\0AEC_GROUP_check() failed with curve %s\0A\00"
@.str.3 = [2 x i8] c".\00"
@.str.4 = [6 x i8] c" ok\0A\0A\00"
@.str.5 = [10 x i8] c" failed\0A\0A\00"
@stderr = global i32 0
@.str.6 = [14 x i8] c"%s:%d: ABORT\0A\00"
@.str.7 = [172 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/GaloisInc/hacrypto/refs/heads/master/src/C/libressl/libressl-2.3.1/tests/ectest.c\00"
define void @internal_curve_test() {
%1 = alloca %struct.TYPE_5__*
%2 = alloca i64
%3 = alloca i64
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32
store %struct.TYPE_5__* null, %struct.TYPE_5__** %1
store i64 0, i64* %2
store i64 0, i64* %3
store i32 1, i32* %4
%7 = call i64 @EC_get_builtin_curves(%struct.TYPE_5__* null, i64 0)
store i64 %7, i64* %2
%8 = load i64, i64* %2
%9 = call %struct.TYPE_5__* @reallocarray(i32* null, i32 4, i64 %8)
store %struct.TYPE_5__* %9, %struct.TYPE_5__** %1
%10 = load %struct.TYPE_5__*, %struct.TYPE_5__** %1
%11 = icmp eq %struct.TYPE_5__* %10, null
br i1 %11, label %12, label %13
12: ; preds = %0
br label %84
13: ; preds = %0
%14 = load %struct.TYPE_5__*, %struct.TYPE_5__** %1
%15 = load i64, i64* %2
%16 = call i64 @EC_get_builtin_curves(%struct.TYPE_5__* %14, i64 %15)
%17 = icmp ne i64 %16, 0
br i1 %17, label %21, label %18
18: ; preds = %13
%19 = load %struct.TYPE_5__*, %struct.TYPE_5__** %1
%20 = call i32 @free(%struct.TYPE_5__* %19)
br label %84
21: ; preds = %13
%22 = load i32, i32* @stdout
%23 = call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
store i64 0, i64* %3
br label %24
24: ; preds = %60, %21
%25 = load i64, i64* %3
%26 = load i64, i64* %2
%27 = icmp ult i64 %25, %26
br i1 %27, label %28, label %63
28: ; preds = %24
store i32* null, i32** %5
%29 = load %struct.TYPE_5__*, %struct.TYPE_5__** %1
%30 = load i64, i64* %3
%31 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %29, i64 %30
%32 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %31, i32 0, i32 0
%33 = load i32, i32* %32
store i32 %33, i32* %6
%34 = load i32, i32* %6
%35 = call i32* @EC_GROUP_new_by_curve_name(i32 %34)
store i32* %35, i32** %5
%36 = icmp eq i32* %35, null
br i1 %36, label %37, label %42
37: ; preds = %28
store i32 0, i32* %4
%38 = load i32, i32* @stdout
%39 = load i32, i32* %6
%40 = call i8* @OBJ_nid2sn(i32 %39)
%41 = call i32 (i32, i8*, ...) @fprintf(i32 %38, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0), i8* %40)
br label %60
42: ; preds = %28
%43 = load i32*, i32** %5
%44 = call i32 @EC_GROUP_check(i32* %43, i32* null)
%45 = icmp ne i32 %44, 0
br i1 %45, label %53, label %46
46: ; preds = %42
store i32 0, i32* %4
%47 = load i32, i32* @stdout
%48 = load i32, i32* %6
%49 = call i8* @OBJ_nid2sn(i32 %48)
%50 = call i32 (i32, i8*, ...) @fprintf(i32 %47, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0), i8* %49)
%51 = load i32*, i32** %5
%52 = call i32 @EC_GROUP_free(i32* %51)
br label %60
53: ; preds = %42
%54 = load i32, i32* @stdout
%55 = call i32 (i32, i8*, ...) @fprintf(i32 %54, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%56 = load i32, i32* @stdout
%57 = call i32 @fflush(i32 %56)
%58 = load i32*, i32** %5
%59 = call i32 @EC_GROUP_free(i32* %58)
br label %60
60: ; preds = %53, %46, %37
%61 = load i64, i64* %3
%62 = add i64 %61, 1
store i64 %62, i64* %3
br label %24
63: ; preds = %24
%64 = load i32, i32* %4
%65 = icmp ne i32 %64, 0
br i1 %65, label %66, label %69
66: ; preds = %63
%67 = load i32, i32* @stdout
%68 = call i32 (i32, i8*, ...) @fprintf(i32 %67, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
br label %81
69: ; preds = %63
%70 = load i32, i32* @stdout
%71 = call i32 (i32, i8*, ...) @fprintf(i32 %70, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
br label %72
72: ; preds = %69
%73 = load i32, i32* @stdout
%74 = call i32 @fflush(i32 %73)
%75 = load i32, i32* @stderr
%76 = call i32 (i32, i8*, ...) @fprintf(i32 %75, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([172 x i8], [172 x i8]* @.str.7, i64 0, i64 0), i32 1359)
%77 = load i32, i32* @stderr
%78 = call i32 @ERR_print_errors_fp(i32 %77)
%79 = call i32 @exit(i32 1)
unreachable
80: ; No predecessors!
br label %81
81: ; preds = %80, %66
%82 = load %struct.TYPE_5__*, %struct.TYPE_5__** %1
%83 = call i32 @free(%struct.TYPE_5__* %82)
br label %84
84: ; preds = %81, %18, %12
ret void
}

LLVM IR (-O2):
%struct.TYPE_5__ = type { i32 }
@stdout = global i32 0
@.str = [26 x i8] c"testing internal curves: \00"
@.str.1 = [49 x i8] c"\0AEC_GROUP_new_curve_name() failed with curve %s\0A\00"
@.str.2 = [40 x i8] c"\0AEC_GROUP_check() failed with curve %s\0A\00"
@.str.3 = [2 x i8] c".\00"
@.str.4 = [6 x i8] c" ok\0A\0A\00"
@.str.5 = [10 x i8] c" failed\0A\0A\00"
@stderr = global i32 0
@.str.6 = [14 x i8] c"%s:%d: ABORT\0A\00"
@.str.7 = [172 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/GaloisInc/hacrypto/refs/heads/master/src/C/libressl/libressl-2.3.1/tests/ectest.c\00"
define void @internal_curve_test() {
%1 = tail call i64 @EC_get_builtin_curves(%struct.TYPE_5__* null, i64 0)
%2 = tail call %struct.TYPE_5__* @reallocarray(i32* null, i32 4, i64 %1)
%3 = icmp eq %struct.TYPE_5__* %2, null
br i1 %3, label %56, label %4
4: ; preds = %0
%5 = tail call i64 @EC_get_builtin_curves(%struct.TYPE_5__* %2, i64 %1)
%6 = icmp eq i64 %5, 0
br i1 %6, label %54, label %7
7: ; preds = %4
%8 = load i32, i32* @stdout
%9 = tail call i32 (i32, i8*, ...) @fprintf(i32 %8, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i64 %1, 0
br i1 %10, label %41, label %11
11: ; preds = %7, %35
%12 = phi i32 [ %36, %35 ], [ 1, %7 ]
%13 = phi i64 [ %37, %35 ], [ 0, %7 ]
%14 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %2, i64 %13, i32 0
%15 = load i32, i32* %14
%16 = tail call i32* @EC_GROUP_new_by_curve_name(i32 %15)
%17 = icmp eq i32* %16, null
br i1 %17, label %18, label %22
18: ; preds = %11
%19 = load i32, i32* @stdout
%20 = tail call i8* @OBJ_nid2sn(i32 %15)
%21 = tail call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0), i8* %20)
br label %35
22: ; preds = %11
%23 = tail call i32 @EC_GROUP_check(i32* %16, i32* null)
%24 = icmp eq i32 %23, 0
%25 = load i32, i32* @stdout
br i1 %24, label %26, label %30
26: ; preds = %22
%27 = tail call i8* @OBJ_nid2sn(i32 %15)
%28 = tail call i32 (i32, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0), i8* %27)
%29 = tail call i32 @EC_GROUP_free(i32* %16)
br label %35
30: ; preds = %22
%31 = tail call i32 (i32, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%32 = load i32, i32* @stdout
%33 = tail call i32 @fflush(i32 %32)
%34 = tail call i32 @EC_GROUP_free(i32* %16)
br label %35
35: ; preds = %30, %26, %18
%36 = phi i32 [ 0, %18 ], [ %12, %30 ], [ 0, %26 ]
%37 = add nuw i64 %13, 1
%38 = icmp eq i64 %37, %1
br i1 %38, label %39, label %11
39: ; preds = %35
%40 = icmp eq i32 %36, 0
br i1 %40, label %44, label %41
41: ; preds = %7, %39
%42 = load i32, i32* @stdout
%43 = tail call i32 (i32, i8*, ...) @fprintf(i32 %42, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
br label %54
44: ; preds = %39
%45 = load i32, i32* @stdout
%46 = tail call i32 (i32, i8*, ...) @fprintf(i32 %45, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
%47 = load i32, i32* @stdout
%48 = tail call i32 @fflush(i32 %47)
%49 = load i32, i32* @stderr
%50 = tail call i32 (i32, i8*, ...) @fprintf(i32 %49, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([172 x i8], [172 x i8]* @.str.7, i64 0, i64 0), i32 1359)
%51 = load i32, i32* @stderr
%52 = tail call i32 @ERR_print_errors_fp(i32 %51)
%53 = tail call i32 @exit(i32 1)
unreachable
54: ; preds = %4, %41
%55 = tail call i32 @free(%struct.TYPE_5__* %2)
br label %56
56: ; preds = %54, %0
ret void
}