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

/* Variables and functions */
scalar_t__ strncmp(char *, char *, int);
int optima_found_lb(char *str, int32_t len) {
  int i = 0;
  for (i = 0; i < len; i++) {
    while (1) {
      char *tmp = str++;
      if (*tmp == '\0')
        return -1;
      if (strncmp(tmp, "LB", 2) == 0)
        return 1;
      if (strncmp(tmp, "PCP", 3) == 0)
        return 1;
      if (strncmp(tmp, "PLIMM", 5) == 0)
        return 1;
      if (strncmp(tmp, "PAPSMEM", 7) == 0)
        return 1;
      if (strncmp(tmp, "PAPLMEM", 7) == 0)
        return 1;
      if (*tmp == '\n')
        break;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<optima_found_lb>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1271 <optima_found_lb+0x161>
jmp    113e <optima_found_lb+0x2e>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    116d <optima_found_lb+0x5d>
movl   $0xffffffff,-0x4(%rbp)
jmp    1278 <optima_found_lb+0x168>
mov    -0x20(%rbp),%rdi
lea    0xe88(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1198 <optima_found_lb+0x88>
movl   $0x1,-0x4(%rbp)
jmp    1278 <optima_found_lb+0x168>
mov    -0x20(%rbp),%rdi
lea    0xe60(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    11c3 <optima_found_lb+0xb3>
movl   $0x1,-0x4(%rbp)
jmp    1278 <optima_found_lb+0x168>
mov    -0x20(%rbp),%rdi
lea    0xe39(%rip),%rsi
mov    $0x5,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    11ee <optima_found_lb+0xde>
movl   $0x1,-0x4(%rbp)
jmp    1278 <optima_found_lb+0x168>
mov    -0x20(%rbp),%rdi
lea    0xe14(%rip),%rsi
mov    $0x7,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1219 <optima_found_lb+0x109>
movl   $0x1,-0x4(%rbp)
jmp    1278 <optima_found_lb+0x168>
mov    -0x20(%rbp),%rdi
lea    0xdf1(%rip),%rsi
mov    $0x7,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1244 <optima_found_lb+0x134>
movl   $0x1,-0x4(%rbp)
jmp    1278 <optima_found_lb+0x168>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
jne    1259 <optima_found_lb+0x149>
jmp    125e <optima_found_lb+0x14e>
jmp    113e <optima_found_lb+0x2e>
jmp    1263 <optima_found_lb+0x153>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    112d <optima_found_lb+0x1d>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<optima_found_lb>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
jle    11fa <optima_found_lb+0xea>
mov    %esi,0x4(%rsp)
movl   $0x0,(%rsp)
lea    0xecb(%rip),%rbx
lea    0xec7(%rip),%rbp
lea    0xec4(%rip),%r15
lea    0xec3(%rip),%r12
mov    %rdi,%r14
nopl   (%rax)
cmpb   $0x0,(%r14)
je     11ff <optima_found_lb+0xef>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
mov    $0x1,%r13d
test   %rax,%rax
je     1205 <optima_found_lb+0xf5>
mov    %r14,%rdi
mov    %rbp,%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1205 <optima_found_lb+0xf5>
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x5,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1205 <optima_found_lb+0xf5>
mov    %r14,%rdi
mov    %r12,%rsi
mov    $0x7,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1205 <optima_found_lb+0xf5>
mov    %r14,%rdi
lea    0xe53(%rip),%rsi
mov    $0x7,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1205 <optima_found_lb+0xf5>
lea    0x1(%r14),%rdi
cmpb   $0xa,(%r14)
mov    %rdi,%r14
jne    1150 <optima_found_lb+0x40>
mov    (%rsp),%eax
add    $0x1,%eax
xor    %r13d,%r13d
mov    %eax,(%rsp)
cmp    0x4(%rsp),%eax
jne    114a <optima_found_lb+0x3a>
jmp    1205 <optima_found_lb+0xf5>
xor    %r13d,%r13d
jmp    1205 <optima_found_lb+0xf5>
mov    $0xffffffff,%r13d
mov    %r13d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"LB\00"
@.str.1 = [4 x i8] c"PCP\00"
@.str.2 = [6 x i8] c"PLIMM\00"
@.str.3 = [8 x i8] c"PAPSMEM\00"
@.str.4 = [8 x i8] c"PAPLMEM\00"
define i32 @optima_found_lb(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 0, i32* %6
store i32 0, i32* %6
br label %8
8: ; preds = %54, %2
%9 = load i32, i32* %6
%10 = load i32, i32* %5
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %57
12: ; preds = %8
br label %13
13: ; preds = %12, %52
%14 = load i8*, i8** %4
%15 = getelementptr inbounds i8, i8* %14, i32 1
store i8* %15, i8** %4
store i8* %14, i8** %7
%16 = load i8*, i8** %7
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %13
store i32 -1, i32* %3
br label %58
21: ; preds = %13
%22 = load i8*, i8** %7
%23 = call i64 @strncmp(i8* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %21
store i32 1, i32* %3
br label %58
26: ; preds = %21
%27 = load i8*, i8** %7
%28 = call i64 @strncmp(i8* %27, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 3)
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %31
30: ; preds = %26
store i32 1, i32* %3
br label %58
31: ; preds = %26
%32 = load i8*, i8** %7
%33 = call i64 @strncmp(i8* %32, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 5)
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %36
35: ; preds = %31
store i32 1, i32* %3
br label %58
36: ; preds = %31
%37 = load i8*, i8** %7
%38 = call i64 @strncmp(i8* %37, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 7)
%39 = icmp eq i64 %38, 0
br i1 %39, label %40, label %41
40: ; preds = %36
store i32 1, i32* %3
br label %58
41: ; preds = %36
%42 = load i8*, i8** %7
%43 = call i64 @strncmp(i8* %42, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 7)
%44 = icmp eq i64 %43, 0
br i1 %44, label %45, label %46
45: ; preds = %41
store i32 1, i32* %3
br label %58
46: ; preds = %41
%47 = load i8*, i8** %7
%48 = load i8, i8* %47
%49 = sext i8 %48 to i32
%50 = icmp eq i32 %49, 10
br i1 %50, label %51, label %52
51: ; preds = %46
br label %53
52: ; preds = %46
br label %13
53: ; preds = %51
br label %54
54: ; preds = %53
%55 = load i32, i32* %6
%56 = add nsw i32 %55, 1
store i32 %56, i32* %6
br label %8
57: ; preds = %8
store i32 0, i32* %3
br label %58
58: ; preds = %57, %45, %40, %35, %30, %25, %20
%59 = load i32, i32* %3
ret i32 %59
}

LLVM IR (-O2):
@.str = [3 x i8] c"LB\00"
@.str.1 = [4 x i8] c"PCP\00"
@.str.2 = [6 x i8] c"PLIMM\00"
@.str.3 = [8 x i8] c"PAPSMEM\00"
@.str.4 = [8 x i8] c"PAPLMEM\00"
define i32 @optima_found_lb(i8* %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %4, label %33
4: ; preds = %2, %30
%5 = phi i32 [ %31, %30 ], [ 0, %2 ]
%6 = phi i8* [ %9, %30 ], [ %0, %2 ]
br label %7
7: ; preds = %4, %27
%8 = phi i8* [ %9, %27 ], [ %6, %4 ]
%9 = getelementptr inbounds i8, i8* %8, i64 1
%10 = load i8, i8* %8
%11 = icmp eq i8 %10, 0
br i1 %11, label %33, label %12
12: ; preds = %7
%13 = tail call i64 @strncmp(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
%14 = icmp eq i64 %13, 0
br i1 %14, label %33, label %15
15: ; preds = %12
%16 = tail call i64 @strncmp(i8* %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 3)
%17 = icmp eq i64 %16, 0
br i1 %17, label %33, label %18
18: ; preds = %15
%19 = tail call i64 @strncmp(i8* %8, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 5)
%20 = icmp eq i64 %19, 0
br i1 %20, label %33, label %21
21: ; preds = %18
%22 = tail call i64 @strncmp(i8* %8, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 7)
%23 = icmp eq i64 %22, 0
br i1 %23, label %33, label %24
24: ; preds = %21
%25 = tail call i64 @strncmp(i8* %8, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 7)
%26 = icmp eq i64 %25, 0
br i1 %26, label %33, label %27
27: ; preds = %24
%28 = load i8, i8* %8
%29 = icmp eq i8 %28, 10
br i1 %29, label %30, label %7
30: ; preds = %27
%31 = add nuw nsw i32 %5, 1
%32 = icmp eq i32 %31, %1
br i1 %32, label %33, label %4
33: ; preds = %30, %24, %21, %18, %15, %12, %7, %2
%34 = phi i32 [ 0, %2 ], [ -1, %7 ], [ 1, %12 ], [ 1, %15 ], [ 1, %18 ], [ 1, %21 ], [ 1, %24 ], [ 0, %30 ]
ret i32 %34
}