#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 */
unsigned int strlen(char *);
int MeasurePattern(char *myPattern) {
  int j = 0;
  int size = 0;
  while ((unsigned int)j < strlen(myPattern)) {
    if (myPattern[j] == '[') {
      j++;
      while (myPattern[j] != ']') {
        j++;
      }
      size++;
    } else {
      size++;
    }
    j++;
  }
  return size;
}


x86 assembly (clang, -O0):
<MeasurePattern>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
cmp    %ecx,%eax
jae    11ac <MeasurePattern+0x9c>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x5b,%eax
jne    1195 <MeasurePattern+0x85>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x5d,%eax
je     1187 <MeasurePattern+0x77>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1164 <MeasurePattern+0x54>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    119e <MeasurePattern+0x8e>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    112a <MeasurePattern+0x1a>
mov    -0x10(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<MeasurePattern>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r15
call   1030 <strlen@plt>
test   %eax,%eax
je     115e <MeasurePattern+0x4e>
lea    0x1(%r15),%r14
xor    %ebp,%ebp
xor    %ebx,%ebx
jmp    1142 <MeasurePattern+0x32>
nopl   (%rax)
add    $0x1,%ebp
add    $0x1,%ebx
mov    %r15,%rdi
call   1030 <strlen@plt>
cmp    %eax,%ebx
jae    1160 <MeasurePattern+0x50>
movslq %ebx,%rax
cmpb   $0x5b,(%r15,%rax,1)
jne    1130 <MeasurePattern+0x20>
add    %r14,%rax
nop
add    $0x1,%ebx
cmpb   $0x5d,(%rax)
lea    0x1(%rax),%rax
jne    1150 <MeasurePattern+0x40>
jmp    1130 <MeasurePattern+0x20>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @MeasurePattern(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
store i32 0, i32* %4
br label %5
5: ; preds = %38, %1
%6 = load i32, i32* %3
%7 = load i8*, i8** %2
%8 = call i32 @strlen(i8* %7)
%9 = icmp ult i32 %6, %8
br i1 %9, label %10, label %41
10: ; preds = %5
%11 = load i8*, i8** %2
%12 = load i32, i32* %3
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %11, i64 %13
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 91
br i1 %17, label %18, label %35
18: ; preds = %10
%19 = load i32, i32* %3
%20 = add nsw i32 %19, 1
store i32 %20, i32* %3
br label %21
21: ; preds = %29, %18
%22 = load i8*, i8** %2
%23 = load i32, i32* %3
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %22, i64 %24
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp ne i32 %27, 93
br i1 %28, label %29, label %32
29: ; preds = %21
%30 = load i32, i32* %3
%31 = add nsw i32 %30, 1
store i32 %31, i32* %3
br label %21
32: ; preds = %21
%33 = load i32, i32* %4
%34 = add nsw i32 %33, 1
store i32 %34, i32* %4
br label %38
35: ; preds = %10
%36 = load i32, i32* %4
%37 = add nsw i32 %36, 1
store i32 %37, i32* %4
br label %38
38: ; preds = %35, %32
%39 = load i32, i32* %3
%40 = add nsw i32 %39, 1
store i32 %40, i32* %3
br label %5
41: ; preds = %5
%42 = load i32, i32* %4
ret i32 %42
}

LLVM IR (-O2):
define i32 @MeasurePattern(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp eq i32 %2, 0
br i1 %3, label %25, label %4
4: ; preds = %1, %19
%5 = phi i32 [ %21, %19 ], [ 0, %1 ]
%6 = phi i32 [ %22, %19 ], [ 0, %1 ]
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds i8, i8* %0, i64 %7
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 91
br i1 %10, label %11, label %19
11: ; preds = %4, %11
%12 = phi i64 [ %13, %11 ], [ %7, %4 ]
%13 = add i64 %12, 1
%14 = getelementptr inbounds i8, i8* %0, i64 %13
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 93
br i1 %16, label %17, label %11
17: ; preds = %11
%18 = trunc i64 %13 to i32
br label %19
19: ; preds = %17, %4
%20 = phi i32 [ %6, %4 ], [ %18, %17 ]
%21 = add nuw nsw i32 %5, 1
%22 = add nsw i32 %20, 1
%23 = tail call i32 @strlen(i8* %0)
%24 = icmp ult i32 %22, %23
br i1 %24, label %4, label %25
25: ; preds = %19, %1
%26 = phi i32 [ 0, %1 ], [ %21, %19 ]
ret i32 %26
}