#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__ strncmp(char const *, char *, int);
const int find_obs_fold(const char *buf, const int len) {
  int i = 0;
  for (; i < (len - 2); i++) {
    if (strncmp(buf + i, "\r\n ", 3) == 0 ||
        strncmp(buf + i, "\r\n\t", 3) == 0 || strncmp(buf + i, "\n ", 2) == 0 ||
        strncmp(buf + i, "\n\t", 2) == 0) {
      return i;
    }
  }
  return -1;
}


x86 assembly (clang, -O0):
<find_obs_fold>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    $0x2,%ecx
cmp    %ecx,%eax
jge    11ed <find_obs_fold+0xdd>
mov    -0x10(%rbp),%rdi
movslq -0x18(%rbp),%rax
add    %rax,%rdi
lea    0xeb7(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     11cf <find_obs_fold+0xbf>
mov    -0x10(%rbp),%rdi
movslq -0x18(%rbp),%rax
add    %rax,%rdi
lea    0xe95(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     11cf <find_obs_fold+0xbf>
mov    -0x10(%rbp),%rdi
movslq -0x18(%rbp),%rax
add    %rax,%rdi
lea    0xe6c(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     11cf <find_obs_fold+0xbf>
mov    -0x10(%rbp),%rdi
movslq -0x18(%rbp),%rax
add    %rax,%rdi
lea    0xe4a(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    11da <find_obs_fold+0xca>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11f4 <find_obs_fold+0xe4>
jmp    11df <find_obs_fold+0xcf>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1126 <find_obs_fold+0x16>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_obs_fold>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0xffffffff,%eax
cmp    $0x3,%esi
jl     11c5 <find_obs_fold+0xb5>
mov    %esi,%ebx
mov    %rdi,%rbp
add    $0xfffffffe,%ebx
xor    %r13d,%r13d
lea    0xec5(%rip),%r15
lea    0xec2(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbp,%r14
add    %r13,%r14
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11c2 <find_obs_fold+0xb2>
mov    %r14,%rdi
mov    %r12,%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11c2 <find_obs_fold+0xb2>
mov    %r14,%rdi
lea    0xe77(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11c2 <find_obs_fold+0xb2>
mov    %r14,%rdi
lea    0xe62(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11c2 <find_obs_fold+0xb2>
add    $0x1,%r13
cmp    %r13,%rbx
jne    1150 <find_obs_fold+0x40>
mov    $0xffffffff,%eax
jmp    11c5 <find_obs_fold+0xb5>
mov    %r13d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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