#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*/ EVP_PKEY_METHOD;

/* Variables and functions */
int /*<<< orphan*/ *EVP_PKEY_meth_get0(size_t);
int /*<<< orphan*/ EVP_PKEY_meth_get0_info(int *, int /*<<< orphan*/ *,
                                           int /*<<< orphan*/ const *);
size_t EVP_PKEY_meth_get_count();
int /*<<< orphan*/ OBJ_nid2ln(int);
int /*<<< orphan*/ test_error(char *, int, char *);
int /*<<< orphan*/ test_note(char *, int, int /*<<< orphan*/);
int test_pkey_meths(void) {
  size_t i;
  int prev = -1;
  int good = 1;
  int pkey_id;
  const EVP_PKEY_METHOD *pmeth;
  for (i = 0; i < EVP_PKEY_meth_get_count(); i++) {
    pmeth = EVP_PKEY_meth_get0(i);
    EVP_PKEY_meth_get0_info(&pkey_id, NULL, pmeth);
    if (pkey_id < prev)
      good = 0;
    prev = pkey_id;
  }
  if (!good) {
    test_error(
        "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
        "2022-01-22/02-19-57/repos/artclarke/humble-video/refs/heads/master/"
        "humble-video-captive/src/main/gnu/openssl/csrc/test/pkey_meth_test.c",
        68, "EVP_PKEY_METHOD table out of order");
    for (i = 0; i < EVP_PKEY_meth_get_count(); i++) {
      pmeth = EVP_PKEY_meth_get0(i);
      EVP_PKEY_meth_get0_info(&pkey_id, NULL, pmeth);
      test_note("%d : %s", pkey_id, OBJ_nid2ln(pkey_id));
    }
  }
  return good;
}


x86 assembly (clang, -O0):
<test_pkey_meths>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0xffffffff,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    $0x0,%al
call   1060 <EVP_PKEY_meth_get_count@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
cmp    %rcx,%rax
jae    11e5 <test_pkey_meths+0x85>
mov    -0x8(%rbp),%rdi
call   1030 <EVP_PKEY_meth_get0@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdx
lea    -0x14(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <EVP_PKEY_meth_get0_info@plt>
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11ce <test_pkey_meths+0x6e>
movl   $0x0,-0x10(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    117e <test_pkey_meths+0x1e>
cmpl   $0x0,-0x10(%rbp)
jne    1281 <test_pkey_meths+0x121>
lea    0xe0a(%rip),%rdi
mov    $0x44,%esi
lea    0xec6(%rip),%rdx
call   1080 <test_error@plt>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    $0x0,%al
call   1060 <EVP_PKEY_meth_get_count@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
cmp    %rcx,%rax
jae    127c <test_pkey_meths+0x11c>
mov    -0x8(%rbp),%rdi
call   1030 <EVP_PKEY_meth_get0@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdx
lea    -0x14(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <EVP_PKEY_meth_get0_info@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x14(%rbp),%edi
call   1050 <OBJ_nid2ln@plt>
mov    -0x34(%rbp),%esi
mov    %eax,%edx
lea    0xe85(%rip),%rdi
call   1070 <test_note@plt>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    120f <test_pkey_meths+0xaf>
jmp    1281 <test_pkey_meths+0x121>
mov    -0x10(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_pkey_meths>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %r15d,%r15d
xor    %eax,%eax
call   1060 <EVP_PKEY_meth_get_count@plt>
test   %rax,%rax
je     1254 <test_pkey_meths+0xf4>
mov    $0xffffffff,%r12d
mov    $0x1,%r13d
lea    0x4(%rsp),%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1030 <EVP_PKEY_meth_get0@plt>
mov    %r14,%rdi
xor    %esi,%esi
mov    %rax,%rdx
call   1040 <EVP_PKEY_meth_get0_info@plt>
mov    0x4(%rsp),%ebp
cmp    %r12d,%ebp
cmovl  %r15d,%r13d
add    $0x1,%rbx
xor    %eax,%eax
call   1060 <EVP_PKEY_meth_get_count@plt>
mov    %ebp,%r12d
cmp    %rax,%rbx
jb     11a0 <test_pkey_meths+0x40>
test   %r13d,%r13d
jne    124f <test_pkey_meths+0xef>
lea    0xe21(%rip),%rdi
lea    0xee2(%rip),%rdx
mov    $0x44,%esi
call   1080 <test_error@plt>
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <EVP_PKEY_meth_get_count@plt>
test   %rax,%rax
je     1259 <test_pkey_meths+0xf9>
lea    0x4(%rsp),%r14
lea    0xee1(%rip),%r15
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1030 <EVP_PKEY_meth_get0@plt>
mov    %r14,%rdi
xor    %esi,%esi
mov    %rax,%rdx
call   1040 <EVP_PKEY_meth_get0_info@plt>
mov    0x4(%rsp),%r12d
mov    %r12d,%edi
call   1050 <OBJ_nid2ln@plt>
mov    %r15,%rdi
mov    %r12d,%esi
mov    %eax,%edx
call   1070 <test_note@plt>
add    $0x1,%rbx
xor    %eax,%eax
call   1060 <EVP_PKEY_meth_get_count@plt>
cmp    %rax,%rbx
jb     1210 <test_pkey_meths+0xb0>
mov    %r13d,%ebx
jmp    1259 <test_pkey_meths+0xf9>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [200 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/artclarke/humble-video/refs/heads/master/humble-video-captive/src/main/gnu/openssl/csrc/test/pkey_meth_test.c\00"
@.str.1 = [35 x i8] c"EVP_PKEY_METHOD table out of order\00"
@.str.2 = [8 x i8] c"%d : %s\00"
define i32 @test_pkey_meths() {
%1 = alloca i64
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32*
store i32 -1, i32* %2
store i32 1, i32* %3
store i64 0, i64* %1
br label %6
6: ; preds = %21, %0
%7 = load i64, i64* %1
%8 = call i64 (...) @EVP_PKEY_meth_get_count()
%9 = icmp ult i64 %7, %8
br i1 %9, label %10, label %24
10: ; preds = %6
%11 = load i64, i64* %1
%12 = call i32* @EVP_PKEY_meth_get0(i64 %11)
store i32* %12, i32** %5
%13 = load i32*, i32** %5
%14 = call i32 @EVP_PKEY_meth_get0_info(i32* %4, i32* null, i32* %13)
%15 = load i32, i32* %4
%16 = load i32, i32* %2
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %19
18: ; preds = %10
store i32 0, i32* %3
br label %19
19: ; preds = %18, %10
%20 = load i32, i32* %4
store i32 %20, i32* %2
br label %21
21: ; preds = %19
%22 = load i64, i64* %1
%23 = add i64 %22, 1
store i64 %23, i64* %1
br label %6
24: ; preds = %6
%25 = load i32, i32* %3
%26 = icmp ne i32 %25, 0
br i1 %26, label %46, label %27
27: ; preds = %24
%28 = call i32 @test_error(i8* getelementptr inbounds ([200 x i8], [200 x i8]* @.str, i64 0, i64 0), i32 68, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
store i64 0, i64* %1
br label %29
29: ; preds = %42, %27
%30 = load i64, i64* %1
%31 = call i64 (...) @EVP_PKEY_meth_get_count()
%32 = icmp ult i64 %30, %31
br i1 %32, label %33, label %45
33: ; preds = %29
%34 = load i64, i64* %1
%35 = call i32* @EVP_PKEY_meth_get0(i64 %34)
store i32* %35, i32** %5
%36 = load i32*, i32** %5
%37 = call i32 @EVP_PKEY_meth_get0_info(i32* %4, i32* null, i32* %36)
%38 = load i32, i32* %4
%39 = load i32, i32* %4
%40 = call i32 @OBJ_nid2ln(i32 %39)
%41 = call i32 @test_note(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %38, i32 %40)
br label %42
42: ; preds = %33
%43 = load i64, i64* %1
%44 = add i64 %43, 1
store i64 %44, i64* %1
br label %29
45: ; preds = %29
br label %46
46: ; preds = %45, %24
%47 = load i32, i32* %3
ret i32 %47
}

LLVM IR (-O2):
@.str = [200 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/artclarke/humble-video/refs/heads/master/humble-video-captive/src/main/gnu/openssl/csrc/test/pkey_meth_test.c\00"
@.str.1 = [35 x i8] c"EVP_PKEY_METHOD table out of order\00"
@.str.2 = [8 x i8] c"%d : %s\00"
define i32 @test_pkey_meths() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i64 (...) @EVP_PKEY_meth_get_count()
%4 = icmp eq i64 %3, 0
br i1 %4, label %33, label %5
5: ; preds = %0, %5
%6 = phi i32 [ %13, %5 ], [ 1, %0 ]
%7 = phi i32 [ %11, %5 ], [ -1, %0 ]
%8 = phi i64 [ %14, %5 ], [ 0, %0 ]
%9 = call i32* @EVP_PKEY_meth_get0(i64 %8)
%10 = call i32 @EVP_PKEY_meth_get0_info(i32* %1, i32* null, i32* %9)
%11 = load i32, i32* %1
%12 = icmp slt i32 %11, %7
%13 = select i1 %12, i32 0, i32 %6
%14 = add nuw i64 %8, 1
%15 = call i64 (...) @EVP_PKEY_meth_get_count()
%16 = icmp ult i64 %14, %15
br i1 %16, label %5, label %17
17: ; preds = %5
%18 = icmp eq i32 %13, 0
br i1 %18, label %19, label %33
19: ; preds = %17
%20 = call i32 @test_error(i8* getelementptr inbounds ([200 x i8], [200 x i8]* @.str, i64 0, i64 0), i32 68, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
%21 = call i64 (...) @EVP_PKEY_meth_get_count()
%22 = icmp eq i64 %21, 0
br i1 %22, label %33, label %23
23: ; preds = %19, %23
%24 = phi i64 [ %30, %23 ], [ 0, %19 ]
%25 = call i32* @EVP_PKEY_meth_get0(i64 %24)
%26 = call i32 @EVP_PKEY_meth_get0_info(i32* %1, i32* null, i32* %25)
%27 = load i32, i32* %1
%28 = call i32 @OBJ_nid2ln(i32 %27)
%29 = call i32 @test_note(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %27, i32 %28)
%30 = add nuw i64 %24, 1
%31 = call i64 (...) @EVP_PKEY_meth_get_count()
%32 = icmp ult i64 %30, %31
br i1 %32, label %23, label %33
33: ; preds = %23, %0, %19, %17
%34 = phi i32 [ 0, %19 ], [ %13, %17 ], [ 1, %0 ], [ %13, %23 ]
ret i32 %34
}