#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 */
int /*<<< orphan*/ strncmp(char const *, char const *, int);
int osc_match_curly_brace(const char *pattern, const char *address) {
  pattern++;
  const char *ptr = pattern;
  while (*ptr != '}' && *ptr != '\0' && *ptr != '/') {
    while (*ptr != '}' && *ptr != '\0' && *ptr != '/' && *ptr != ',') {
      ptr++;
    }
    int n = ptr - pattern;
    if (!strncmp(pattern, address, n)) {
      return n;
    } else {
      ptr++;
      pattern = ptr;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<osc_match_curly_brace>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x7d,%ecx
mov    %al,-0x25(%rbp)
je     116e <osc_match_curly_brace+0x5e>
mov    -0x20(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x25(%rbp)
je     116e <osc_match_curly_brace+0x5e>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
setne  %al
mov    %al,-0x25(%rbp)
mov    -0x25(%rbp),%al
test   $0x1,%al
jne    117e <osc_match_curly_brace+0x6e>
jmp    123e <osc_match_curly_brace+0x12e>
jmp    1183 <osc_match_curly_brace+0x73>
mov    -0x20(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x7d,%ecx
mov    %al,-0x26(%rbp)
je     11d2 <osc_match_curly_brace+0xc2>
mov    -0x20(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x26(%rbp)
je     11d2 <osc_match_curly_brace+0xc2>
mov    -0x20(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x2f,%ecx
mov    %al,-0x26(%rbp)
je     11d2 <osc_match_curly_brace+0xc2>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2c,%eax
setne  %al
mov    %al,-0x26(%rbp)
mov    -0x26(%rbp),%al
test   $0x1,%al
jne    11e2 <osc_match_curly_brace+0xd2>
jmp    11f3 <osc_match_curly_brace+0xe3>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1183 <osc_match_curly_brace+0x73>
mov    -0x20(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    1225 <osc_match_curly_brace+0x115>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1245 <osc_match_curly_brace+0x135>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x10(%rbp)
jmp    1134 <osc_match_curly_brace+0x24>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<osc_match_curly_brace>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
movabs $0x900000000001,%r15
jmp    113e <osc_match_curly_brace+0x2e>
nopl   0x0(%rax)
mov    %r14,%rsi
mov    %ebp,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     1180 <osc_match_curly_brace+0x70>
mov    0x1(%rbx),%al
test   %al,%al
je     117e <osc_match_curly_brace+0x6e>
cmp    $0x2f,%al
je     117e <osc_match_curly_brace+0x6e>
cmp    $0x7d,%al
je     117e <osc_match_curly_brace+0x6e>
mov    %rbx,%rdi
add    $0x1,%rdi
xor    %ebp,%ebp
mov    %rdi,%rbx
cmp    $0x2f,%al
ja     1169 <osc_match_curly_brace+0x59>
nopl   (%rax)
movzbl %al,%ecx
bt     %rcx,%r15
jb     1130 <osc_match_curly_brace+0x20>
cmp    $0x7d,%al
je     1130 <osc_match_curly_brace+0x20>
movzbl 0x1(%rbx),%eax
add    $0x1,%rbx
add    $0x1,%ebp
cmp    $0x2f,%al
jbe    1160 <osc_match_curly_brace+0x50>
jmp    1169 <osc_match_curly_brace+0x59>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @osc_match_curly_brace(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
%9 = getelementptr inbounds i8, i8* %8, i32 1
store i8* %9, i8** %4
%10 = load i8*, i8** %4
store i8* %10, i8** %6
br label %11
11: ; preds = %72, %2
%12 = load i8*, i8** %6
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp ne i32 %14, 125
br i1 %15, label %16, label %26
16: ; preds = %11
%17 = load i8*, i8** %6
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %26
21: ; preds = %16
%22 = load i8*, i8** %6
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp ne i32 %24, 47
br label %26
26: ; preds = %21, %16, %11
%27 = phi i1 [ false, %16 ], [ false, %11 ], [ %25, %21 ]
br i1 %27, label %28, label %73
28: ; preds = %26
br label %29
29: ; preds = %51, %28
%30 = load i8*, i8** %6
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp ne i32 %32, 125
br i1 %33, label %34, label %49
34: ; preds = %29
%35 = load i8*, i8** %6
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = icmp ne i32 %37, 0
br i1 %38, label %39, label %49
39: ; preds = %34
%40 = load i8*, i8** %6
%41 = load i8, i8* %40
%42 = sext i8 %41 to i32
%43 = icmp ne i32 %42, 47
br i1 %43, label %44, label %49
44: ; preds = %39
%45 = load i8*, i8** %6
%46 = load i8, i8* %45
%47 = sext i8 %46 to i32
%48 = icmp ne i32 %47, 44
br label %49
49: ; preds = %44, %39, %34, %29
%50 = phi i1 [ false, %39 ], [ false, %34 ], [ false, %29 ], [ %48, %44 ]
br i1 %50, label %51, label %54
51: ; preds = %49
%52 = load i8*, i8** %6
%53 = getelementptr inbounds i8, i8* %52, i32 1
store i8* %53, i8** %6
br label %29
54: ; preds = %49
%55 = load i8*, i8** %6
%56 = load i8*, i8** %4
%57 = ptrtoint i8* %55 to i64
%58 = ptrtoint i8* %56 to i64
%59 = sub i64 %57, %58
%60 = trunc i64 %59 to i32
store i32 %60, i32* %7
%61 = load i8*, i8** %4
%62 = load i8*, i8** %5
%63 = load i32, i32* %7
%64 = call i32 @strncmp(i8* %61, i8* %62, i32 %63)
%65 = icmp ne i32 %64, 0
br i1 %65, label %68, label %66
66: ; preds = %54
%67 = load i32, i32* %7
store i32 %67, i32* %3
br label %74
68: ; preds = %54
%69 = load i8*, i8** %6
%70 = getelementptr inbounds i8, i8* %69, i32 1
store i8* %70, i8** %6
%71 = load i8*, i8** %6
store i8* %71, i8** %4
br label %72
72: ; preds = %68
br label %11
73: ; preds = %26
store i32 0, i32* %3
br label %74
74: ; preds = %73, %66
%75 = load i32, i32* %3
ret i32 %75
}

LLVM IR (-O2):
define i32 @osc_match_curly_brace(i8* %0, i8* %1) {
br label %3
3: ; preds = %13, %2
%4 = phi i8* [ %0, %2 ], [ %9, %13 ]
%5 = getelementptr inbounds i8, i8* %4, i64 1
%6 = load i8, i8* %5
switch i8 %6, label %7 [
i8 125, label %22
i8 0, label %22
i8 47, label %22
]
7: ; preds = %3, %10
%8 = phi i8 [ %12, %10 ], [ %6, %3 ]
%9 = phi i8* [ %11, %10 ], [ %5, %3 ]
switch i8 %8, label %10 [
i8 125, label %13
i8 0, label %13
i8 47, label %13
i8 44, label %13
]
10: ; preds = %7
%11 = getelementptr inbounds i8, i8* %9, i64 1
%12 = load i8, i8* %11
br label %7
13: ; preds = %7, %7, %7, %7
%14 = ptrtoint i8* %9 to i64
%15 = ptrtoint i8* %5 to i64
%16 = sub i64 %14, %15
%17 = trunc i64 %16 to i32
%18 = tail call i32 @strncmp(i8* %5, i8* %1, i32 %17)
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %3
20: ; preds = %13
%21 = trunc i64 %16 to i32
br label %22
22: ; preds = %3, %3, %3, %20
%23 = phi i32 [ %21, %20 ], [ 0, %3 ], [ 0, %3 ], [ 0, %3 ]
ret i32 %23
}