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

/* Variables and functions */
scalar_t__ EVP_PBE_find(int, int, int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                        int /*<<< orphan*/);
scalar_t__ EVP_PBE_get(int *, int *, size_t);
char *OBJ_nid2sn(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int, int, char *,
                           char *);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  size_t i;
  int rv = 0;
  int pbe_type, pbe_nid;
  int last_type = -1, last_nid = -1;
  for (i = 0; EVP_PBE_get(&pbe_type, &pbe_nid, i) != 0; i++) {
    if (EVP_PBE_find(pbe_type, pbe_nid, NULL, NULL, 0) == 0) {
      rv = 1;
      break;
    }
  }
  if (rv == 0)
    return 0;
  for (i = 0; EVP_PBE_get(&pbe_type, &pbe_nid, i) != 0; i++) {
    if (pbe_type > last_type)
      rv = 0;
    else if (pbe_type < last_type || pbe_nid < last_nid)
      rv = 1;
    else
      rv = 0;
    fprintf(stderr, "PBE type=%d %d (%s): %s\n", pbe_type, pbe_nid,
            OBJ_nid2sn(pbe_nid), rv ? "ERROR" : "OK");
    last_type = pbe_type;
    last_nid = pbe_nid;
  }
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0xffffffff,-0x28(%rbp)
movl   $0xffffffff,-0x2c(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rdx
lea    -0x20(%rbp),%rdi
lea    -0x24(%rbp),%rsi
call   1050 <EVP_PBE_get@plt>
cmp    $0x0,%rax
je     11cf <main+0x8f>
mov    -0x20(%rbp),%edi
mov    -0x24(%rbp),%esi
xor    %eax,%eax
mov    %eax,%ecx
xor    %r8d,%r8d
mov    %rcx,%rdx
call   1030 <EVP_PBE_find@plt>
cmp    $0x0,%rax
jne    11b9 <main+0x79>
movl   $0x1,-0x1c(%rbp)
jmp    11cf <main+0x8f>
jmp    11be <main+0x7e>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1173 <main+0x33>
cmpl   $0x0,-0x1c(%rbp)
jne    11e5 <main+0xa5>
movl   $0x0,-0x4(%rbp)
jmp    12c4 <main+0x184>
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rdx
lea    -0x20(%rbp),%rdi
lea    -0x24(%rbp),%rsi
call   1050 <EVP_PBE_get@plt>
cmp    $0x0,%rax
je     12bd <main+0x17d>
mov    -0x20(%rbp),%eax
cmp    -0x28(%rbp),%eax
jle    1220 <main+0xe0>
movl   $0x0,-0x1c(%rbp)
jmp    1250 <main+0x110>
mov    -0x20(%rbp),%eax
cmp    -0x28(%rbp),%eax
jl     1238 <main+0xf8>
mov    -0x24(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    1244 <main+0x104>
movl   $0x1,-0x1c(%rbp)
jmp    124b <main+0x10b>
movl   $0x0,-0x1c(%rbp)
jmp    1250 <main+0x110>
mov    0x2d89(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x38(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x24(%rbp),%edi
call   1040 <OBJ_nid2sn@plt>
mov    -0x38(%rbp),%edi
mov    -0x34(%rbp),%edx
mov    -0x30(%rbp),%ecx
mov    %rax,%r8
mov    -0x1c(%rbp),%esi
lea    0xd99(%rip),%r9
lea    0xd8c(%rip),%rax
cmp    $0x0,%esi
cmovne %rax,%r9
lea    0xd65(%rip),%rsi
call   1060 <fprintf@plt>
mov    -0x20(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    11ed <main+0xad>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %ebx,%ebx
lea    0x4(%rsp),%rdi
mov    %rsp,%rsi
xor    %edx,%edx
call   1050 <EVP_PBE_get@plt>
test   %rax,%rax
je     127a <main+0x13a>
mov    $0x1,%ebx
lea    0x4(%rsp),%r14
mov    %rsp,%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x4(%rsp),%edi
mov    (%rsp),%esi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1030 <EVP_PBE_find@plt>
test   %rax,%rax
je     11b6 <main+0x76>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1050 <EVP_PBE_get@plt>
add    $0x1,%rbx
test   %rax,%rax
jne    1180 <main+0x40>
xor    %ebx,%ebx
jmp    127a <main+0x13a>
lea    0x4(%rsp),%rdi
mov    %rsp,%rsi
xor    %edx,%edx
call   1050 <EVP_PBE_get@plt>
mov    $0x1,%ebx
test   %rax,%rax
je     127a <main+0x13a>
mov    $0xffffffff,%r15d
mov    $0x1,%ebx
mov    $0xffffffff,%ebp
jmp    125e <main+0x11e>
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%rsp),%r14d
cmp    %r15d,%r14d
lea    0xe21(%rip),%r15
lea    0xe14(%rip),%rax
cmovl  %rax,%r15
cmp    %ebp,%r13d
cmovl  %rax,%r15
mov    0x2dc9(%rip),%rax
mov    (%rax),%r12d
mov    %r14d,%edi
call   1040 <OBJ_nid2sn@plt>
mov    %r12d,%edi
lea    0xdd4(%rip),%rsi
mov    %r13d,%edx
mov    %r14d,%ecx
mov    %rax,%r8
mov    %r15,%r9
call   1060 <fprintf@plt>
mov    0x4(%rsp),%ebp
mov    (%rsp),%r15d
lea    0x4(%rsp),%rdi
mov    %rsp,%rsi
mov    %rbx,%rdx
call   1050 <EVP_PBE_get@plt>
add    $0x1,%rbx
test   %rax,%rax
je     1275 <main+0x135>
mov    0x4(%rsp),%r13d
cmp    %ebp,%r13d
jle    11f0 <main+0xb0>
mov    (%rsp),%r14d
lea    0xdac(%rip),%r15
jmp    1210 <main+0xd0>
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):
@stderr = global i32 0
@.str = [25 x i8] c"PBE type=%d %d (%s): %s\0A\00"
@.str.1 = [6 x i8] c"ERROR\00"
@.str.2 = [3 x i8] c"OK\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
store i32 -1, i32* %10
store i32 -1, i32* %11
store i64 0, i64* %6
br label %12
12: ; preds = %23, %2
%13 = load i64, i64* %6
%14 = call i64 @EVP_PBE_get(i32* %8, i32* %9, i64 %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %26
16: ; preds = %12
%17 = load i32, i32* %8
%18 = load i32, i32* %9
%19 = call i64 @EVP_PBE_find(i32 %17, i32 %18, i32* null, i32* null, i32 0)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %16
store i32 1, i32* %7
br label %26
22: ; preds = %16
br label %23
23: ; preds = %22
%24 = load i64, i64* %6
%25 = add i64 %24, 1
store i64 %25, i64* %6
br label %12
26: ; preds = %21, %12
%27 = load i32, i32* %7
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %30
29: ; preds = %26
store i32 0, i32* %3
br label %68
30: ; preds = %26
store i64 0, i64* %6
br label %31
31: ; preds = %64, %30
%32 = load i64, i64* %6
%33 = call i64 @EVP_PBE_get(i32* %8, i32* %9, i64 %32)
%34 = icmp ne i64 %33, 0
br i1 %34, label %35, label %67
35: ; preds = %31
%36 = load i32, i32* %8
%37 = load i32, i32* %10
%38 = icmp sgt i32 %36, %37
br i1 %38, label %39, label %40
39: ; preds = %35
store i32 0, i32* %7
br label %51
40: ; preds = %35
%41 = load i32, i32* %8
%42 = load i32, i32* %10
%43 = icmp slt i32 %41, %42
br i1 %43, label %48, label %44
44: ; preds = %40
%45 = load i32, i32* %9
%46 = load i32, i32* %11
%47 = icmp slt i32 %45, %46
br i1 %47, label %48, label %49
48: ; preds = %44, %40
store i32 1, i32* %7
br label %50
49: ; preds = %44
store i32 0, i32* %7
br label %50
50: ; preds = %49, %48
br label %51
51: ; preds = %50, %39
%52 = load i32, i32* @stderr
%53 = load i32, i32* %8
%54 = load i32, i32* %9
%55 = load i32, i32* %9
%56 = call i8* @OBJ_nid2sn(i32 %55)
%57 = load i32, i32* %7
%58 = icmp ne i32 %57, 0
%59 = zext i1 %58 to i64
%60 = select i1 %58, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0)
%61 = call i32 @fprintf(i32 %52, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %53, i32 %54, i8* %56, i8* %60)
%62 = load i32, i32* %8
store i32 %62, i32* %10
%63 = load i32, i32* %9
store i32 %63, i32* %11
br label %64
64: ; preds = %51
%65 = load i64, i64* %6
%66 = add i64 %65, 1
store i64 %66, i64* %6
br label %31
67: ; preds = %31
store i32 1, i32* %3
br label %68
68: ; preds = %67, %29
%69 = load i32, i32* %3
ret i32 %69
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [25 x i8] c"PBE type=%d %d (%s): %s\0A\00"
@.str.1 = [6 x i8] c"ERROR\00"
@.str.2 = [3 x i8] c"OK\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %3 to i8*
%6 = bitcast i32* %4 to i8*
%7 = call i64 @EVP_PBE_get(i32* %3, i32* %4, i64 0)
%8 = icmp eq i64 %7, 0
br i1 %8, label %47, label %12
9: ; preds = %12
%10 = call i64 @EVP_PBE_get(i32* %3, i32* %4, i64 %18)
%11 = icmp eq i64 %10, 0
br i1 %11, label %47, label %12
12: ; preds = %2, %9
%13 = phi i64 [ %18, %9 ], [ 0, %2 ]
%14 = load i32, i32* %3
%15 = load i32, i32* %4
%16 = call i64 @EVP_PBE_find(i32 %14, i32 %15, i32* null, i32* null, i32 0)
%17 = icmp eq i64 %16, 0
%18 = add i64 %13, 1
br i1 %17, label %19, label %9
19: ; preds = %12
%20 = call i64 @EVP_PBE_get(i32* %3, i32* %4, i64 0)
%21 = icmp eq i64 %20, 0
br i1 %21, label %47, label %22
22: ; preds = %19, %36
%23 = phi i32 [ %43, %36 ], [ -1, %19 ]
%24 = phi i32 [ %42, %36 ], [ -1, %19 ]
%25 = phi i64 [ %44, %36 ], [ 0, %19 ]
%26 = load i32, i32* %3
%27 = icmp sgt i32 %26, %24
br i1 %27, label %28, label %30
28: ; preds = %22
%29 = load i32, i32* %4
br label %36
30: ; preds = %22
%31 = icmp slt i32 %26, %24
%32 = load i32, i32* %4
%33 = icmp slt i32 %32, %23
%34 = select i1 %31, i1 true, i1 %33
%35 = select i1 %34, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0)
br label %36
36: ; preds = %28, %30
%37 = phi i32 [ %29, %28 ], [ %32, %30 ]
%38 = phi i8* [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), %28 ], [ %35, %30 ]
%39 = load i32, i32* @stderr
%40 = call i8* @OBJ_nid2sn(i32 %37)
%41 = call i32 @fprintf(i32 %39, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %26, i32 %37, i8* %40, i8* %38)
%42 = load i32, i32* %3
%43 = load i32, i32* %4
%44 = add i64 %25, 1
%45 = call i64 @EVP_PBE_get(i32* %3, i32* %4, i64 %44)
%46 = icmp eq i64 %45, 0
br i1 %46, label %47, label %22
47: ; preds = %9, %36, %2, %19
%48 = phi i32 [ 1, %19 ], [ 0, %2 ], [ 1, %36 ], [ 0, %9 ]
ret i32 %48
}