#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*/ OPENSSL_free(TYPE_1__ *);
TYPE_1__ *OPENSSL_malloc(int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
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 = OPENSSL_malloc(sizeof(EC_builtin_curve) * crv_len);
  if (curves == NULL)
    return;
  if (!EC_get_builtin_curves(curves, crv_len)) {
    OPENSSL_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/sim9108/SDKS/refs/heads/master/"
              "LibOpenSSL/src/ec/ectest.c",
              1303);
      ERR_print_errors_fp(stderr);
      exit(1);
    } while (0);
  }
  OPENSSL_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   10a0 <EC_get_builtin_curves@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1090 <OPENSSL_malloc@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    120a <internal_curve_test+0x5a>
jmp    13dd <internal_curve_test+0x22d>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   10a0 <EC_get_builtin_curves@plt>
cmp    $0x0,%rax
jne    122f <internal_curve_test+0x7f>
mov    -0x8(%rbp),%rdi
call   10b0 <OPENSSL_free@plt>
jmp    13dd <internal_curve_test+0x22d>
mov    0x2da2(%rip),%rax
mov    (%rax),%edi
lea    0xdc1(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    134e <internal_curve_test+0x19e>
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   1050 <EC_GROUP_new_by_curve_name@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    12bc <internal_curve_test+0x10c>
movl   $0x0,-0x1c(%rbp)
mov    0x2d42(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x30(%rbp)
mov    -0x2c(%rbp),%edi
call   1040 <OBJ_nid2sn@plt>
mov    -0x30(%rbp),%edi
mov    %rax,%rdx
lea    0xd6a(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
jmp    133d <internal_curve_test+0x18d>
mov    -0x28(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1060 <EC_GROUP_check@plt>
cmp    $0x0,%eax
jne    130f <internal_curve_test+0x15f>
movl   $0x0,-0x1c(%rbp)
mov    0x2cf8(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    -0x2c(%rbp),%edi
call   1040 <OBJ_nid2sn@plt>
mov    -0x34(%rbp),%edi
mov    %rax,%rdx
lea    0xd51(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x28(%rbp),%rdi
call   1030 <EC_GROUP_free@plt>
jmp    133d <internal_curve_test+0x18d>
mov    0x2cc2(%rip),%rax
mov    (%rax),%edi
lea    0xd54(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2cab(%rip),%rax
mov    (%rax),%edi
call   1080 <fflush@plt>
mov    -0x28(%rbp),%rdi
call   1030 <EC_GROUP_free@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    124e <internal_curve_test+0x9e>
cmpl   $0x0,-0x1c(%rbp)
je     1374 <internal_curve_test+0x1c4>
mov    0x2c79(%rip),%rax
mov    (%rax),%edi
lea    0xd0d(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
jmp    13d4 <internal_curve_test+0x224>
mov    0x2c5d(%rip),%rax
mov    (%rax),%edi
lea    0xcf7(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2c46(%rip),%rax
mov    (%rax),%edi
call   1080 <fflush@plt>
mov    0x2c40(%rip),%rax
mov    (%rax),%edi
lea    0xcdc(%rip),%rsi
lea    0xce3(%rip),%rdx
mov    $0x517,%ecx
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2c1d(%rip),%rax
mov    (%rax),%edi
call   10d0 <ERR_print_errors_fp@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    -0x8(%rbp),%rdi
call   10b0 <OPENSSL_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   10a0 <EC_get_builtin_curves@plt>
mov    %rax,%r14
lea    0x0(,%rax,4),%edi
call   1090 <OPENSSL_malloc@plt>
test   %rax,%rax
je     12e9 <internal_curve_test+0x139>
mov    %rax,%r15
mov    %rax,%rdi
mov    %r14,%rsi
call   10a0 <EC_get_builtin_curves@plt>
test   %rax,%rax
je     130f <internal_curve_test+0x15f>
mov    0x2ddb(%rip),%rbx
mov    (%rbx),%edi
lea    0xdfa(%rip),%rsi
xor    %eax,%eax
call   1070 <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   1040 <OBJ_nid2sn@plt>
movl   $0x0,0xc(%rsp)
mov    %ebp,%edi
lea    0xdcf(%rip),%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1070 <fprintf@plt>
add    $0x1,%r13
cmp    %r13,%r14
je     12f8 <internal_curve_test+0x148>
mov    (%r15,%r13,4),%r12d
mov    %r12d,%edi
call   1050 <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   1060 <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   1070 <fprintf@plt>
mov    (%rbx),%edi
call   1080 <fflush@plt>
jmp    12d4 <internal_curve_test+0x124>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r12d,%edi
call   1040 <OBJ_nid2sn@plt>
movl   $0x0,0xc(%rsp)
mov    %r15d,%edi
lea    0xd81(%rip),%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    %rbp,%rdi
call   1030 <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   1070 <fprintf@plt>
mov    %r15,%rdi
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    10b0 <OPENSSL_free@plt>
mov    (%rbx),%edi
lea    0xd4d(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    (%rbx),%edi
call   1080 <fflush@plt>
mov    0x2c9d(%rip),%rbx
mov    (%rbx),%edi
lea    0xd39(%rip),%rsi
lea    0xd40(%rip),%rdx
mov    $0x517,%ecx
xor    %eax,%eax
call   1070 <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 = [148 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/sim9108/SDKS/refs/heads/master/LibOpenSSL/src/ec/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 = mul i64 4, %8
%10 = trunc i64 %9 to i32
%11 = call %struct.TYPE_5__* @OPENSSL_malloc(i32 %10)
store %struct.TYPE_5__* %11, %struct.TYPE_5__** %1
%12 = load %struct.TYPE_5__*, %struct.TYPE_5__** %1
%13 = icmp eq %struct.TYPE_5__* %12, null
br i1 %13, label %14, label %15
14: ; preds = %0
br label %86
15: ; preds = %0
%16 = load %struct.TYPE_5__*, %struct.TYPE_5__** %1
%17 = load i64, i64* %2
%18 = call i64 @EC_get_builtin_curves(%struct.TYPE_5__* %16, i64 %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %23, label %20
20: ; preds = %15
%21 = load %struct.TYPE_5__*, %struct.TYPE_5__** %1
%22 = call i32 @OPENSSL_free(%struct.TYPE_5__* %21)
br label %86
23: ; preds = %15
%24 = load i32, i32* @stdout
%25 = call i32 (i32, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
store i64 0, i64* %3
br label %26
26: ; preds = %62, %23
%27 = load i64, i64* %3
%28 = load i64, i64* %2
%29 = icmp ult i64 %27, %28
br i1 %29, label %30, label %65
30: ; preds = %26
store i32* null, i32** %5
%31 = load %struct.TYPE_5__*, %struct.TYPE_5__** %1
%32 = load i64, i64* %3
%33 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %31, i64 %32
%34 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %33, i32 0, i32 0
%35 = load i32, i32* %34
store i32 %35, i32* %6
%36 = load i32, i32* %6
%37 = call i32* @EC_GROUP_new_by_curve_name(i32 %36)
store i32* %37, i32** %5
%38 = icmp eq i32* %37, null
br i1 %38, label %39, label %44
39: ; preds = %30
store i32 0, i32* %4
%40 = load i32, i32* @stdout
%41 = load i32, i32* %6
%42 = call i8* @OBJ_nid2sn(i32 %41)
%43 = call i32 (i32, i8*, ...) @fprintf(i32 %40, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0), i8* %42)
br label %62
44: ; preds = %30
%45 = load i32*, i32** %5
%46 = call i32 @EC_GROUP_check(i32* %45, i32* null)
%47 = icmp ne i32 %46, 0
br i1 %47, label %55, label %48
48: ; preds = %44
store i32 0, i32* %4
%49 = load i32, i32* @stdout
%50 = load i32, i32* %6
%51 = call i8* @OBJ_nid2sn(i32 %50)
%52 = call i32 (i32, i8*, ...) @fprintf(i32 %49, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0), i8* %51)
%53 = load i32*, i32** %5
%54 = call i32 @EC_GROUP_free(i32* %53)
br label %62
55: ; preds = %44
%56 = load i32, i32* @stdout
%57 = call i32 (i32, i8*, ...) @fprintf(i32 %56, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%58 = load i32, i32* @stdout
%59 = call i32 @fflush(i32 %58)
%60 = load i32*, i32** %5
%61 = call i32 @EC_GROUP_free(i32* %60)
br label %62
62: ; preds = %55, %48, %39
%63 = load i64, i64* %3
%64 = add i64 %63, 1
store i64 %64, i64* %3
br label %26
65: ; preds = %26
%66 = load i32, i32* %4
%67 = icmp ne i32 %66, 0
br i1 %67, label %68, label %71
68: ; preds = %65
%69 = load i32, i32* @stdout
%70 = call i32 (i32, i8*, ...) @fprintf(i32 %69, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
br label %83
71: ; preds = %65
%72 = load i32, i32* @stdout
%73 = call i32 (i32, i8*, ...) @fprintf(i32 %72, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
br label %74
74: ; preds = %71
%75 = load i32, i32* @stdout
%76 = call i32 @fflush(i32 %75)
%77 = load i32, i32* @stderr
%78 = call i32 (i32, i8*, ...) @fprintf(i32 %77, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([148 x i8], [148 x i8]* @.str.7, i64 0, i64 0), i32 1303)
%79 = load i32, i32* @stderr
%80 = call i32 @ERR_print_errors_fp(i32 %79)
%81 = call i32 @exit(i32 1)
unreachable
82: ; No predecessors!
br label %83
83: ; preds = %82, %68
%84 = load %struct.TYPE_5__*, %struct.TYPE_5__** %1
%85 = call i32 @OPENSSL_free(%struct.TYPE_5__* %84)
br label %86
86: ; preds = %83, %20, %14
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 = [148 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/sim9108/SDKS/refs/heads/master/LibOpenSSL/src/ec/ectest.c\00"
define void @internal_curve_test() {
%1 = tail call i64 @EC_get_builtin_curves(%struct.TYPE_5__* null, i64 0)
%2 = trunc i64 %1 to i32
%3 = shl i32 %2, 2
%4 = tail call %struct.TYPE_5__* @OPENSSL_malloc(i32 %3)
%5 = icmp eq %struct.TYPE_5__* %4, null
br i1 %5, label %58, label %6
6: ; preds = %0
%7 = tail call i64 @EC_get_builtin_curves(%struct.TYPE_5__* %4, i64 %1)
%8 = icmp eq i64 %7, 0
br i1 %8, label %56, label %9
9: ; preds = %6
%10 = load i32, i32* @stdout
%11 = tail call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%12 = icmp eq i64 %1, 0
br i1 %12, label %43, label %13
13: ; preds = %9, %37
%14 = phi i32 [ %38, %37 ], [ 1, %9 ]
%15 = phi i64 [ %39, %37 ], [ 0, %9 ]
%16 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %4, i64 %15, i32 0
%17 = load i32, i32* %16
%18 = tail call i32* @EC_GROUP_new_by_curve_name(i32 %17)
%19 = icmp eq i32* %18, null
br i1 %19, label %20, label %24
20: ; preds = %13
%21 = load i32, i32* @stdout
%22 = tail call i8* @OBJ_nid2sn(i32 %17)
%23 = tail call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0), i8* %22)
br label %37
24: ; preds = %13
%25 = tail call i32 @EC_GROUP_check(i32* %18, i32* null)
%26 = icmp eq i32 %25, 0
%27 = load i32, i32* @stdout
br i1 %26, label %28, label %32
28: ; preds = %24
%29 = tail call i8* @OBJ_nid2sn(i32 %17)
%30 = tail call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0), i8* %29)
%31 = tail call i32 @EC_GROUP_free(i32* %18)
br label %37
32: ; preds = %24
%33 = tail call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%34 = load i32, i32* @stdout
%35 = tail call i32 @fflush(i32 %34)
%36 = tail call i32 @EC_GROUP_free(i32* %18)
br label %37
37: ; preds = %32, %28, %20
%38 = phi i32 [ 0, %20 ], [ %14, %32 ], [ 0, %28 ]
%39 = add nuw i64 %15, 1
%40 = icmp eq i64 %39, %1
br i1 %40, label %41, label %13
41: ; preds = %37
%42 = icmp eq i32 %38, 0
br i1 %42, label %46, label %43
43: ; preds = %9, %41
%44 = load i32, i32* @stdout
%45 = tail call i32 (i32, i8*, ...) @fprintf(i32 %44, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
br label %56
46: ; preds = %41
%47 = load i32, i32* @stdout
%48 = tail call i32 (i32, i8*, ...) @fprintf(i32 %47, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
%49 = load i32, i32* @stdout
%50 = tail call i32 @fflush(i32 %49)
%51 = load i32, i32* @stderr
%52 = tail call i32 (i32, i8*, ...) @fprintf(i32 %51, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([148 x i8], [148 x i8]* @.str.7, i64 0, i64 0), i32 1303)
%53 = load i32, i32* @stderr
%54 = tail call i32 @ERR_print_errors_fp(i32 %53)
%55 = tail call i32 @exit(i32 1)
unreachable
56: ; preds = %6, %43
%57 = tail call i32 @OPENSSL_free(%struct.TYPE_5__* %4)
br label %58
58: ; preds = %56, %0
ret void
}