#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__ strstr(char const *, char *);
int checkpri(const char *opt, int sys, int code, int freq) {
  int nex = 0;
  if (sys == 0x01) {
    if (strstr(opt, "-GL1P"))
      return code == 2 ? 0 : -1;
    if (strstr(opt, "-GL2X"))
      return code == 18 ? 1 : -1;
    if (code == 2)
      return nex < 1 ? -1 : 3;
    if (code == 18)
      return nex < 2 ? -1 : 3 + 1;
  } else if (sys == 0x04) {
    if (strstr(opt, "-RL2C"))
      return code == 14 ? 1 : -1;
    if (code == 14)
      return nex < 1 ? -1 : 3;
  } else if (sys == 0x08) {
    if (strstr(opt, "-EL1B"))
      return code == 11 ? 0 : -1;
    if (code == 11)
      return nex < 1 ? -1 : 3;
    if (code == 28)
      return nex < 2 ? -1 : 3 + 1;
    if (code == 38)
      return nex < 3 ? -1 : 3 + 2;
  }
  return freq < 3 ? freq : -1;
}


x86 assembly (clang, -O0):
<checkpri>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
cmpl   $0x1,-0x14(%rbp)
jne    11ec <checkpri+0xdc>
mov    -0x10(%rbp),%rdi
lea    0xebf(%rip),%rsi
call   1030 <strstr@plt>
cmp    $0x0,%rax
je     1168 <checkpri+0x58>
mov    -0x18(%rbp),%edx
mov    $0xffffffff,%eax
xor    %ecx,%ecx
cmp    $0x2,%edx
cmove  %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    1337 <checkpri+0x227>
mov    -0x10(%rbp),%rdi
lea    0xe93(%rip),%rsi
call   1030 <strstr@plt>
cmp    $0x0,%rax
je     119d <checkpri+0x8d>
mov    -0x18(%rbp),%edx
mov    $0xffffffff,%eax
mov    $0x1,%ecx
cmp    $0x12,%edx
cmove  %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    1337 <checkpri+0x227>
cmpl   $0x2,-0x18(%rbp)
jne    11c2 <checkpri+0xb2>
mov    -0x20(%rbp),%edx
mov    $0x3,%eax
mov    $0xffffffff,%ecx
cmp    $0x1,%edx
cmovl  %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    1337 <checkpri+0x227>
cmpl   $0x12,-0x18(%rbp)
jne    11e7 <checkpri+0xd7>
mov    -0x20(%rbp),%edx
mov    $0x4,%eax
mov    $0xffffffff,%ecx
cmp    $0x2,%edx
cmovl  %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    1337 <checkpri+0x227>
jmp    130f <checkpri+0x1ff>
cmpl   $0x4,-0x14(%rbp)
jne    1255 <checkpri+0x145>
mov    -0x10(%rbp),%rdi
lea    0xe0b(%rip),%rsi
call   1030 <strstr@plt>
cmp    $0x0,%rax
je     122b <checkpri+0x11b>
mov    -0x18(%rbp),%edx
mov    $0xffffffff,%eax
mov    $0x1,%ecx
cmp    $0xe,%edx
cmove  %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    1337 <checkpri+0x227>
cmpl   $0xe,-0x18(%rbp)
jne    1250 <checkpri+0x140>
mov    -0x20(%rbp),%edx
mov    $0x3,%eax
mov    $0xffffffff,%ecx
cmp    $0x1,%edx
cmovl  %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    1337 <checkpri+0x227>
jmp    130a <checkpri+0x1fa>
cmpl   $0x8,-0x14(%rbp)
jne    1305 <checkpri+0x1f5>
mov    -0x10(%rbp),%rdi
lea    0xda8(%rip),%rsi
call   1030 <strstr@plt>
cmp    $0x0,%rax
je     1291 <checkpri+0x181>
mov    -0x18(%rbp),%edx
mov    $0xffffffff,%eax
xor    %ecx,%ecx
cmp    $0xb,%edx
cmove  %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    1337 <checkpri+0x227>
cmpl   $0xb,-0x18(%rbp)
jne    12b6 <checkpri+0x1a6>
mov    -0x20(%rbp),%edx
mov    $0x3,%eax
mov    $0xffffffff,%ecx
cmp    $0x1,%edx
cmovl  %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    1337 <checkpri+0x227>
cmpl   $0x1c,-0x18(%rbp)
jne    12db <checkpri+0x1cb>
mov    -0x20(%rbp),%edx
mov    $0x4,%eax
mov    $0xffffffff,%ecx
cmp    $0x2,%edx
cmovl  %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    1337 <checkpri+0x227>
cmpl   $0x26,-0x18(%rbp)
jne    1300 <checkpri+0x1f0>
mov    -0x20(%rbp),%edx
mov    $0x5,%eax
mov    $0xffffffff,%ecx
cmp    $0x3,%edx
cmovl  %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    1337 <checkpri+0x227>
jmp    1305 <checkpri+0x1f5>
jmp    130a <checkpri+0x1fa>
jmp    130f <checkpri+0x1ff>
cmpl   $0x3,-0x1c(%rbp)
jge    1324 <checkpri+0x214>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x24(%rbp)
jmp    1331 <checkpri+0x221>
mov    $0xffffffff,%eax
mov    %eax,-0x24(%rbp)
jmp    1331 <checkpri+0x221>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkpri>:
push   %rbp
push   %r14
push   %rbx
mov    %ecx,%r14d
mov    %edx,%ebp
mov    %rdi,%rbx
cmp    $0x8,%esi
je     114a <checkpri+0x3a>
cmp    $0x4,%esi
je     116a <checkpri+0x5a>
cmp    $0x1,%esi
jne    11d0 <checkpri+0xc0>
lea    0xeca(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strstr@plt>
test   %rax,%rax
je     1185 <checkpri+0x75>
xor    %eax,%eax
cmp    $0x2,%ebp
jmp    1163 <checkpri+0x53>
lea    0xec1(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strstr@plt>
test   %rax,%rax
je     11a8 <checkpri+0x98>
xor    %eax,%eax
cmp    $0xb,%ebp
setne  %al
neg    %eax
jmp    11dd <checkpri+0xcd>
lea    0xe9b(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strstr@plt>
test   %rax,%rax
je     11c6 <checkpri+0xb6>
xor    %eax,%eax
cmp    $0xe,%ebp
jmp    119e <checkpri+0x8e>
lea    0xe7a(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strstr@plt>
test   %rax,%rax
je     11e2 <checkpri+0xd2>
xor    %eax,%eax
cmp    $0x12,%ebp
sete   %al
add    %eax,%eax
add    $0xffffffff,%eax
jmp    11dd <checkpri+0xcd>
cmp    $0x26,%ebp
ja     11d0 <checkpri+0xc0>
mov    $0xffffffff,%eax
mov    %ebp,%ecx
movabs $0x4010000800,%rdx
bt     %rcx,%rdx
jb     11dd <checkpri+0xcd>
jmp    11d0 <checkpri+0xc0>
mov    $0xffffffff,%eax
cmp    $0xe,%ebp
je     11dd <checkpri+0xcd>
cmp    $0x3,%r14d
mov    $0xffffffff,%eax
cmovl  %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    $0xffffffff,%eax
or     $0x10,%ebp
cmp    $0x12,%ebp
je     11dd <checkpri+0xcd>
jmp    11d0 <checkpri+0xc0>

LLVM IR (-O0):
@.str = [6 x i8] c"-GL1P\00"
@.str.1 = [6 x i8] c"-GL2X\00"
@.str.2 = [6 x i8] c"-RL2C\00"
@.str.3 = [6 x i8] c"-EL1B\00"
define i32 @checkpri(i8* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i8* %0, i8** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 0, i32* %10
%11 = load i32, i32* %7
%12 = icmp eq i32 %11, 1
br i1 %12, label %13, label %48
13: ; preds = %4
%14 = load i8*, i8** %6
%15 = call i64 @strstr(i8* %14, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %22
17: ; preds = %13
%18 = load i32, i32* %8
%19 = icmp eq i32 %18, 2
%20 = zext i1 %19 to i64
%21 = select i1 %19, i32 0, i32 -1
store i32 %21, i32* %5
br label %116
22: ; preds = %13
%23 = load i8*, i8** %6
%24 = call i64 @strstr(i8* %23, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %31
26: ; preds = %22
%27 = load i32, i32* %8
%28 = icmp eq i32 %27, 18
%29 = zext i1 %28 to i64
%30 = select i1 %28, i32 1, i32 -1
store i32 %30, i32* %5
br label %116
31: ; preds = %22
%32 = load i32, i32* %8
%33 = icmp eq i32 %32, 2
br i1 %33, label %34, label %39
34: ; preds = %31
%35 = load i32, i32* %10
%36 = icmp slt i32 %35, 1
%37 = zext i1 %36 to i64
%38 = select i1 %36, i32 -1, i32 3
store i32 %38, i32* %5
br label %116
39: ; preds = %31
%40 = load i32, i32* %8
%41 = icmp eq i32 %40, 18
br i1 %41, label %42, label %47
42: ; preds = %39
%43 = load i32, i32* %10
%44 = icmp slt i32 %43, 2
%45 = zext i1 %44 to i64
%46 = select i1 %44, i32 -1, i32 4
store i32 %46, i32* %5
br label %116
47: ; preds = %39
br label %108
48: ; preds = %4
%49 = load i32, i32* %7
%50 = icmp eq i32 %49, 4
br i1 %50, label %51, label %69
51: ; preds = %48
%52 = load i8*, i8** %6
%53 = call i64 @strstr(i8* %52, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%54 = icmp ne i64 %53, 0
br i1 %54, label %55, label %60
55: ; preds = %51
%56 = load i32, i32* %8
%57 = icmp eq i32 %56, 14
%58 = zext i1 %57 to i64
%59 = select i1 %57, i32 1, i32 -1
store i32 %59, i32* %5
br label %116
60: ; preds = %51
%61 = load i32, i32* %8
%62 = icmp eq i32 %61, 14
br i1 %62, label %63, label %68
63: ; preds = %60
%64 = load i32, i32* %10
%65 = icmp slt i32 %64, 1
%66 = zext i1 %65 to i64
%67 = select i1 %65, i32 -1, i32 3
store i32 %67, i32* %5
br label %116
68: ; preds = %60
br label %107
69: ; preds = %48
%70 = load i32, i32* %7
%71 = icmp eq i32 %70, 8
br i1 %71, label %72, label %106
72: ; preds = %69
%73 = load i8*, i8** %6
%74 = call i64 @strstr(i8* %73, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%75 = icmp ne i64 %74, 0
br i1 %75, label %76, label %81
76: ; preds = %72
%77 = load i32, i32* %8
%78 = icmp eq i32 %77, 11
%79 = zext i1 %78 to i64
%80 = select i1 %78, i32 0, i32 -1
store i32 %80, i32* %5
br label %116
81: ; preds = %72
%82 = load i32, i32* %8
%83 = icmp eq i32 %82, 11
br i1 %83, label %84, label %89
84: ; preds = %81
%85 = load i32, i32* %10
%86 = icmp slt i32 %85, 1
%87 = zext i1 %86 to i64
%88 = select i1 %86, i32 -1, i32 3
store i32 %88, i32* %5
br label %116
89: ; preds = %81
%90 = load i32, i32* %8
%91 = icmp eq i32 %90, 28
br i1 %91, label %92, label %97
92: ; preds = %89
%93 = load i32, i32* %10
%94 = icmp slt i32 %93, 2
%95 = zext i1 %94 to i64
%96 = select i1 %94, i32 -1, i32 4
store i32 %96, i32* %5
br label %116
97: ; preds = %89
%98 = load i32, i32* %8
%99 = icmp eq i32 %98, 38
br i1 %99, label %100, label %105
100: ; preds = %97
%101 = load i32, i32* %10
%102 = icmp slt i32 %101, 3
%103 = zext i1 %102 to i64
%104 = select i1 %102, i32 -1, i32 5
store i32 %104, i32* %5
br label %116
105: ; preds = %97
br label %106
106: ; preds = %105, %69
br label %107
107: ; preds = %106, %68
br label %108
108: ; preds = %107, %47
%109 = load i32, i32* %9
%110 = icmp slt i32 %109, 3
br i1 %110, label %111, label %113
111: ; preds = %108
%112 = load i32, i32* %9
br label %114
113: ; preds = %108
br label %114
114: ; preds = %113, %111
%115 = phi i32 [ %112, %111 ], [ -1, %113 ]
store i32 %115, i32* %5
br label %116
116: ; preds = %114, %100, %92, %84, %76, %63, %55, %42, %34, %26, %17
%117 = load i32, i32* %5
ret i32 %117
}

LLVM IR (-O2):
@.str = [6 x i8] c"-GL1P\00"
@.str.1 = [6 x i8] c"-GL2X\00"
@.str.2 = [6 x i8] c"-RL2C\00"
@.str.3 = [6 x i8] c"-EL1B\00"
define i32 @checkpri(i8* %0, i32 %1, i32 %2, i32 %3) {
switch i32 %1, label %32 [
i32 1, label %5
i32 4, label %18
i32 8, label %25
]
5: ; preds = %4
%6 = tail call i64 @strstr(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
br i1 %7, label %11, label %8
8: ; preds = %5
%9 = icmp ne i32 %2, 2
%10 = sext i1 %9 to i32
br label %35
11: ; preds = %5
%12 = tail call i64 @strstr(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %17, label %14
14: ; preds = %11
%15 = icmp eq i32 %2, 18
%16 = select i1 %15, i32 1, i32 -1
br label %35
17: ; preds = %11
switch i32 %2, label %32 [
i32 2, label %35
i32 18, label %35
]
18: ; preds = %4
%19 = tail call i64 @strstr(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
%21 = icmp eq i32 %2, 14
br i1 %20, label %24, label %22
22: ; preds = %18
%23 = select i1 %21, i32 1, i32 -1
br label %35
24: ; preds = %18
br i1 %21, label %35, label %32
25: ; preds = %4
%26 = tail call i64 @strstr(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %31, label %28
28: ; preds = %25
%29 = icmp ne i32 %2, 11
%30 = sext i1 %29 to i32
br label %35
31: ; preds = %25
switch i32 %2, label %32 [
i32 11, label %35
i32 28, label %35
i32 38, label %35
]
32: ; preds = %31, %4, %17, %24
%33 = icmp slt i32 %3, 3
%34 = select i1 %33, i32 %3, i32 -1
br label %35
35: ; preds = %31, %31, %31, %24, %17, %17, %32, %28, %22, %14, %8
%36 = phi i32 [ %10, %8 ], [ %16, %14 ], [ %34, %32 ], [ %23, %22 ], [ %30, %28 ], [ -1, %17 ], [ -1, %17 ], [ -1, %24 ], [ -1, %31 ], [ -1, %31 ], [ -1, %31 ]
ret i32 %36
}