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

/* Variables and functions */
scalar_t__ is_c_type_char(char const);
int /*<<< orphan*/ is_caps_var_char(char const);
int /*<<< orphan*/ is_starting_caps_var_char(char const);
int64_t match_caps_var(const char *str, const char *beginning_of_line) {
  const char *itr = str;
  if (!is_starting_caps_var_char(*itr))
    return 0;
  itr++;
  while (*itr) {
    if (!is_caps_var_char(*itr))
      break;
    itr++;
  }
  if (str > beginning_of_line) {
    if (is_c_type_char(*(str - 1)))
      return 0;
  }
  if (is_c_type_char(*itr))
    return 0;
  int64_t len = itr - str;
  if (len > 1)
    return len;
  return 0;
}


x86 assembly (clang, -O0):
<match_caps_var>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%edi
call   1050 <is_starting_caps_var_char@plt>
cmp    $0x0,%eax
jne    1169 <match_caps_var+0x39>
movl   $0x0,-0x4(%rbp)
jmp    122f <match_caps_var+0xff>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmpb   $0x0,(%rax)
je     11ad <match_caps_var+0x7d>
mov    -0x20(%rbp),%rax
movsbl (%rax),%edi
call   1040 <is_caps_var_char@plt>
cmp    $0x0,%eax
jne    119c <match_caps_var+0x6c>
jmp    11ad <match_caps_var+0x7d>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1175 <match_caps_var+0x45>
mov    -0x10(%rbp),%rax
cmp    -0x18(%rbp),%rax
jbe    11e3 <match_caps_var+0xb3>
mov    -0x10(%rbp),%rax
movsbl -0x1(%rax),%edi
call   1030 <is_c_type_char@plt>
cmp    $0x0,%rax
je     11de <match_caps_var+0xae>
movl   $0x0,-0x4(%rbp)
jmp    122f <match_caps_var+0xff>
jmp    11e3 <match_caps_var+0xb3>
mov    -0x20(%rbp),%rax
movsbl (%rax),%edi
call   1030 <is_c_type_char@plt>
cmp    $0x0,%rax
je     1205 <match_caps_var+0xd5>
movl   $0x0,-0x4(%rbp)
jmp    122f <match_caps_var+0xff>
mov    -0x20(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0x24(%rbp)
cmpl   $0x1,-0x24(%rbp)
jle    1228 <match_caps_var+0xf8>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    122f <match_caps_var+0xff>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<match_caps_var>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
movsbl (%rdi),%edi
call   1050 <is_starting_caps_var_char@plt>
xor    %r15d,%r15d
test   %eax,%eax
je     11a6 <match_caps_var+0x76>
mov    $0x1,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rcx,%rbp
movzbl (%rbx,%rcx,1),%eax
test   %al,%al
je     117b <match_caps_var+0x4b>
movsbl %al,%edi
call   1040 <is_caps_var_char@plt>
lea    0x1(%rbp),%rcx
test   %eax,%eax
jne    1160 <match_caps_var+0x30>
cmp    %r14,%rbx
jbe    118e <match_caps_var+0x5e>
movsbl -0x1(%rbx),%edi
call   1030 <is_c_type_char@plt>
test   %rax,%rax
jne    11a6 <match_caps_var+0x76>
movsbl (%rbx,%rbp,1),%edi
call   1030 <is_c_type_char@plt>
test   %rax,%rax
jne    11a6 <match_caps_var+0x76>
xor    %r15d,%r15d
cmp    $0x2,%ebp
cmovge %ebp,%r15d
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @match_caps_var(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
%8 = load i8*, i8** %4
store i8* %8, i8** %6
%9 = load i8*, i8** %6
%10 = load i8, i8* %9
%11 = call i32 @is_starting_caps_var_char(i8 signext %10)
%12 = icmp ne i32 %11, 0
br i1 %12, label %14, label %13
13: ; preds = %2
store i32 0, i32* %3
br label %60
14: ; preds = %2
%15 = load i8*, i8** %6
%16 = getelementptr inbounds i8, i8* %15, i32 1
store i8* %16, i8** %6
br label %17
17: ; preds = %27, %14
%18 = load i8*, i8** %6
%19 = load i8, i8* %18
%20 = icmp ne i8 %19, 0
br i1 %20, label %21, label %30
21: ; preds = %17
%22 = load i8*, i8** %6
%23 = load i8, i8* %22
%24 = call i32 @is_caps_var_char(i8 signext %23)
%25 = icmp ne i32 %24, 0
br i1 %25, label %27, label %26
26: ; preds = %21
br label %30
27: ; preds = %21
%28 = load i8*, i8** %6
%29 = getelementptr inbounds i8, i8* %28, i32 1
store i8* %29, i8** %6
br label %17
30: ; preds = %26, %17
%31 = load i8*, i8** %4
%32 = load i8*, i8** %5
%33 = icmp ugt i8* %31, %32
br i1 %33, label %34, label %42
34: ; preds = %30
%35 = load i8*, i8** %4
%36 = getelementptr inbounds i8, i8* %35, i64 -1
%37 = load i8, i8* %36
%38 = call i64 @is_c_type_char(i8 signext %37)
%39 = icmp ne i64 %38, 0
br i1 %39, label %40, label %41
40: ; preds = %34
store i32 0, i32* %3
br label %60
41: ; preds = %34
br label %42
42: ; preds = %41, %30
%43 = load i8*, i8** %6
%44 = load i8, i8* %43
%45 = call i64 @is_c_type_char(i8 signext %44)
%46 = icmp ne i64 %45, 0
br i1 %46, label %47, label %48
47: ; preds = %42
store i32 0, i32* %3
br label %60
48: ; preds = %42
%49 = load i8*, i8** %6
%50 = load i8*, i8** %4
%51 = ptrtoint i8* %49 to i64
%52 = ptrtoint i8* %50 to i64
%53 = sub i64 %51, %52
%54 = trunc i64 %53 to i32
store i32 %54, i32* %7
%55 = load i32, i32* %7
%56 = icmp sgt i32 %55, 1
br i1 %56, label %57, label %59
57: ; preds = %48
%58 = load i32, i32* %7
store i32 %58, i32* %3
br label %60
59: ; preds = %48
store i32 0, i32* %3
br label %60
60: ; preds = %59, %57, %47, %40, %13
%61 = load i32, i32* %3
ret i32 %61
}

LLVM IR (-O2):
define i32 @match_caps_var(i8* %0, i8* readnone %1) {
%3 = load i8, i8* %0
%4 = tail call i32 @is_starting_caps_var_char(i8 signext %3)
%5 = icmp eq i32 %4, 0
br i1 %5, label %32, label %6
6: ; preds = %2, %11
%7 = phi i8* [ %8, %11 ], [ %0, %2 ]
%8 = getelementptr inbounds i8, i8* %7, i64 1
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 0
br i1 %10, label %14, label %11
11: ; preds = %6
%12 = tail call i32 @is_caps_var_char(i8 signext %9)
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %6
14: ; preds = %11, %6
%15 = icmp ugt i8* %0, %1
br i1 %15, label %16, label %21
16: ; preds = %14
%17 = getelementptr inbounds i8, i8* %0, i64 -1
%18 = load i8, i8* %17
%19 = tail call i64 @is_c_type_char(i8 signext %18)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %32
21: ; preds = %16, %14
%22 = load i8, i8* %8
%23 = tail call i64 @is_c_type_char(i8 signext %22)
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %32
25: ; preds = %21
%26 = ptrtoint i8* %8 to i64
%27 = ptrtoint i8* %0 to i64
%28 = sub i64 %26, %27
%29 = trunc i64 %28 to i32
%30 = icmp sgt i32 %29, 1
%31 = select i1 %30, i32 %29, i32 0
br label %32
32: ; preds = %21, %16, %2, %25
%33 = phi i32 [ %31, %25 ], [ 0, %2 ], [ 0, %16 ], [ 0, %21 ]
ret i32 %33
}