#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_ASN1_METHOD;

/* Variables and functions */
int /*<<< orphan*/ *EVP_PKEY_asn1_get0(int);
int /*<<< orphan*/ EVP_PKEY_asn1_get0_info(int *, int /*<<< orphan*/ *,
                                           int /*<<< orphan*/ *, char const **,
                                           int /*<<< orphan*/ *,
                                           int /*<<< orphan*/ const *);
int EVP_PKEY_asn1_get_count();
int /*<<< orphan*/ OBJ_nid2ln(int);
int /*<<< orphan*/ test_error(char *, int, char *);
int /*<<< orphan*/ test_note(char *, int, int /*<<< orphan*/, char const *);
int test_asn1_meths(void) {
  int i;
  int prev = -1;
  int good = 1;
  int pkey_id;
  const EVP_PKEY_ASN1_METHOD *ameth;
  for (i = 0; i < EVP_PKEY_asn1_get_count(); i++) {
    ameth = EVP_PKEY_asn1_get0(i);
    EVP_PKEY_asn1_get0_info(&pkey_id, NULL, NULL, NULL, NULL, ameth);
    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/papyrussolution/OpenPapyrus/"
               "refs/heads/master/Src/OSF/OpenSSL-111/test/pkey_meth_test.c",
               35, "EVP_PKEY_ASN1_METHOD table out of order");
    for (i = 0; i < EVP_PKEY_asn1_get_count(); i++) {
      const char *info;
      ameth = EVP_PKEY_asn1_get0(i);
      EVP_PKEY_asn1_get0_info(&pkey_id, NULL, NULL, &info, NULL, ameth);
      if (info == NULL)
        info = "<NO NAME>";
      test_note("%d : %s : %s", pkey_id, OBJ_nid2ln(pkey_id), info);
    }
  }
  return good;
}


x86 assembly (clang, -O0):
<test_asn1_meths>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0xffffffff,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    $0x0,%al
call   1080 <EVP_PKEY_asn1_get_count@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
cmp    %ecx,%eax
jge    11e5 <test_asn1_meths+0x85>
mov    -0x4(%rbp),%edi
call   1030 <EVP_PKEY_asn1_get0@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%r9
lea    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%r8d
mov    %r8,%rsi
mov    %r8,%rdx
mov    %r8,%rcx
call   1050 <EVP_PKEY_asn1_get0_info@plt>
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11d1 <test_asn1_meths+0x71>
movl   $0x0,-0xc(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    117d <test_asn1_meths+0x1d>
cmpl   $0x0,-0xc(%rbp)
jne    129c <test_asn1_meths+0x13c>
lea    0xe0a(%rip),%rdi
mov    $0x23,%esi
lea    0xeb0(%rip),%rdx
call   1070 <test_error@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    $0x0,%al
call   1080 <EVP_PKEY_asn1_get_count@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
cmp    %ecx,%eax
jge    1297 <test_asn1_meths+0x137>
mov    -0x4(%rbp),%edi
call   1030 <EVP_PKEY_asn1_get0@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%r9
lea    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%r8d
lea    -0x20(%rbp),%rcx
mov    %r8,%rsi
mov    %r8,%rdx
call   1050 <EVP_PKEY_asn1_get0_info@plt>
cmpq   $0x0,-0x20(%rbp)
jne    1266 <test_asn1_meths+0x106>
lea    0xe78(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%edi
call   1040 <OBJ_nid2ln@plt>
mov    -0x2c(%rbp),%esi
mov    %eax,%edx
mov    -0x20(%rbp),%rcx
lea    0xe60(%rip),%rdi
call   1060 <test_note@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    120e <test_asn1_meths+0xae>
jmp    129c <test_asn1_meths+0x13c>
mov    -0xc(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_asn1_meths>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
xor    %r15d,%r15d
xor    %eax,%eax
call   1080 <EVP_PKEY_asn1_get_count@plt>
test   %eax,%eax
jle    11d1 <test_asn1_meths+0x71>
mov    $0xffffffff,%r13d
mov    $0x1,%r12d
lea    0xc(%rsp),%r14
xor    %ebp,%ebp
nop
mov    %ebp,%edi
call   1030 <EVP_PKEY_asn1_get0@plt>
mov    %r14,%rdi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
mov    %rax,%r9
call   1050 <EVP_PKEY_asn1_get0_info@plt>
mov    0xc(%rsp),%ebx
cmp    %r13d,%ebx
cmovl  %r15d,%r12d
add    $0x1,%ebp
xor    %eax,%eax
call   1080 <EVP_PKEY_asn1_get_count@plt>
mov    %ebx,%r13d
cmp    %eax,%ebp
jl     1190 <test_asn1_meths+0x30>
test   %r12d,%r12d
je     11e7 <test_asn1_meths+0x87>
mov    %r12d,%ebp
jmp    11d6 <test_asn1_meths+0x76>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe12(%rip),%rdi
lea    0xebd(%rip),%rdx
mov    $0x23,%esi
call   1070 <test_error@plt>
xor    %ebp,%ebp
xor    %eax,%eax
call   1080 <EVP_PKEY_asn1_get_count@plt>
test   %eax,%eax
jle    11d6 <test_asn1_meths+0x76>
lea    0xc(%rsp),%r14
lea    0x10(%rsp),%r15
lea    0xec7(%rip),%rbx
xor    %ebp,%ebp
jmp    1261 <test_asn1_meths+0x101>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0xc(%rsp),%r13d
mov    %r13d,%edi
call   1040 <OBJ_nid2ln@plt>
mov    0x10(%rsp),%rcx
mov    %rbx,%rdi
mov    %r13d,%esi
mov    %eax,%edx
call   1060 <test_note@plt>
add    $0x1,%ebp
xor    %eax,%eax
call   1080 <EVP_PKEY_asn1_get_count@plt>
cmp    %eax,%ebp
jge    11cc <test_asn1_meths+0x6c>
mov    %ebp,%edi
call   1030 <EVP_PKEY_asn1_get0@plt>
mov    %r14,%rdi
xor    %esi,%esi
xor    %edx,%edx
mov    %r15,%rcx
xor    %r8d,%r8d
mov    %rax,%r9
call   1050 <EVP_PKEY_asn1_get0_info@plt>
cmpq   $0x0,0x10(%rsp)
jne    1230 <test_asn1_meths+0xd0>
lea    0xe4e(%rip),%rax
mov    %rax,0x10(%rsp)
jmp    1230 <test_asn1_meths+0xd0>

LLVM IR (-O0):
@.str = [178 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/papyrussolution/OpenPapyrus/refs/heads/master/Src/OSF/OpenSSL-111/test/pkey_meth_test.c\00"
@.str.1 = [40 x i8] c"EVP_PKEY_ASN1_METHOD table out of order\00"
@.str.2 = [10 x i8] c"<NO NAME>\00"
@.str.3 = [13 x i8] c"%d : %s : %s\00"
define i32 @test_asn1_meths() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i8*
store i32 -1, i32* %2
store i32 1, i32* %3
store i32 0, i32* %1
br label %7
7: ; preds = %22, %0
%8 = load i32, i32* %1
%9 = call i32 (...) @EVP_PKEY_asn1_get_count()
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %25
11: ; preds = %7
%12 = load i32, i32* %1
%13 = call i32* @EVP_PKEY_asn1_get0(i32 %12)
store i32* %13, i32** %5
%14 = load i32*, i32** %5
%15 = call i32 @EVP_PKEY_asn1_get0_info(i32* %4, i32* null, i32* null, i8** null, i32* null, i32* %14)
%16 = load i32, i32* %4
%17 = load i32, i32* %2
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %20
19: ; preds = %11
store i32 0, i32* %3
br label %20
20: ; preds = %19, %11
%21 = load i32, i32* %4
store i32 %21, i32* %2
br label %22
22: ; preds = %20
%23 = load i32, i32* %1
%24 = add nsw i32 %23, 1
store i32 %24, i32* %1
br label %7
25: ; preds = %7
%26 = load i32, i32* %3
%27 = icmp ne i32 %26, 0
br i1 %27, label %52, label %28
28: ; preds = %25
%29 = call i32 @test_error(i8* getelementptr inbounds ([178 x i8], [178 x i8]* @.str, i64 0, i64 0), i32 35, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %1
br label %30
30: ; preds = %48, %28
%31 = load i32, i32* %1
%32 = call i32 (...) @EVP_PKEY_asn1_get_count()
%33 = icmp slt i32 %31, %32
br i1 %33, label %34, label %51
34: ; preds = %30
%35 = load i32, i32* %1
%36 = call i32* @EVP_PKEY_asn1_get0(i32 %35)
store i32* %36, i32** %5
%37 = load i32*, i32** %5
%38 = call i32 @EVP_PKEY_asn1_get0_info(i32* %4, i32* null, i32* null, i8** %6, i32* null, i32* %37)
%39 = load i8*, i8** %6
%40 = icmp eq i8* %39, null
br i1 %40, label %41, label %42
41: ; preds = %34
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8** %6
br label %42
42: ; preds = %41, %34
%43 = load i32, i32* %4
%44 = load i32, i32* %4
%45 = call i32 @OBJ_nid2ln(i32 %44)
%46 = load i8*, i8** %6
%47 = call i32 @test_note(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %43, i32 %45, i8* %46)
br label %48
48: ; preds = %42
%49 = load i32, i32* %1
%50 = add nsw i32 %49, 1
store i32 %50, i32* %1
br label %30
51: ; preds = %30
br label %52
52: ; preds = %51, %25
%53 = load i32, i32* %3
ret i32 %53
}

LLVM IR (-O2):
@.str = [178 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/papyrussolution/OpenPapyrus/refs/heads/master/Src/OSF/OpenSSL-111/test/pkey_meth_test.c\00"
@.str.1 = [40 x i8] c"EVP_PKEY_ASN1_METHOD table out of order\00"
@.str.2 = [10 x i8] c"<NO NAME>\00"
@.str.3 = [13 x i8] c"%d : %s : %s\00"
define i32 @test_asn1_meths() {
%1 = alloca i32
%2 = alloca i8*
%3 = bitcast i32* %1 to i8*
%4 = call i32 (...) @EVP_PKEY_asn1_get_count()
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %41
6: ; preds = %0, %6
%7 = phi i32 [ %14, %6 ], [ 1, %0 ]
%8 = phi i32 [ %12, %6 ], [ -1, %0 ]
%9 = phi i32 [ %15, %6 ], [ 0, %0 ]
%10 = call i32* @EVP_PKEY_asn1_get0(i32 %9)
%11 = call i32 @EVP_PKEY_asn1_get0_info(i32* %1, i32* null, i32* null, i8** null, i32* null, i32* %10)
%12 = load i32, i32* %1
%13 = icmp slt i32 %12, %8
%14 = select i1 %13, i32 0, i32 %7
%15 = add nuw nsw i32 %9, 1
%16 = call i32 (...) @EVP_PKEY_asn1_get_count()
%17 = icmp slt i32 %15, %16
br i1 %17, label %6, label %18
18: ; preds = %6
%19 = icmp eq i32 %14, 0
br i1 %19, label %20, label %41
20: ; preds = %18
%21 = call i32 @test_error(i8* getelementptr inbounds ([178 x i8], [178 x i8]* @.str, i64 0, i64 0), i32 35, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0))
%22 = call i32 (...) @EVP_PKEY_asn1_get_count()
%23 = icmp sgt i32 %22, 0
br i1 %23, label %24, label %41
24: ; preds = %20
%25 = bitcast i8** %2 to i8*
br label %26
26: ; preds = %24, %33
%27 = phi i32 [ 0, %24 ], [ %38, %33 ]
%28 = call i32* @EVP_PKEY_asn1_get0(i32 %27)
%29 = call i32 @EVP_PKEY_asn1_get0_info(i32* %1, i32* null, i32* null, i8** %2, i32* null, i32* %28)
%30 = load i8*, i8** %2
%31 = icmp eq i8* %30, null
br i1 %31, label %32, label %33
32: ; preds = %26
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %33
33: ; preds = %32, %26
%34 = load i32, i32* %1
%35 = call i32 @OBJ_nid2ln(i32 %34)
%36 = load i8*, i8** %2
%37 = call i32 @test_note(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %34, i32 %35, i8* %36)
%38 = add nuw nsw i32 %27, 1
%39 = call i32 (...) @EVP_PKEY_asn1_get_count()
%40 = icmp slt i32 %38, %39
br i1 %40, label %26, label %41
41: ; preds = %33, %0, %20, %18
%42 = phi i32 [ 0, %20 ], [ %14, %18 ], [ 1, %0 ], [ %14, %33 ]
ret i32 %42
}