#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*/ DoTrace(char *);
char *XTL_FindComment(char *);
char *XTL_FindClosingCurlyBrace(char *line, int *Braces) {
  char *p;
  char *comment;
  if (line == NULL || *line == 0 || Braces == NULL || *Braces < 1)
    return NULL;
  DoTrace("In - XTL_FindClosingCurlyBrace");
  comment = XTL_FindComment(line);
  for (p = line; *p != 0; p++) {
    switch (*p) {
    case '\\':
      ++p;
      if (*p == 0)
        --p;
      break;
    case '{':
      ++(*Braces);
      break;
    case '}':
      --(*Braces);
      if (*Braces == 0) {
        DoTrace("out1 - XTL_FindClosingCurlyBrace");
        return p;
      }
      break;
    case '%':
      if (comment != NULL && p == comment) {
        DoTrace("out2 - XTL_FindClosingCurlyBrace");
        return NULL;
      }
      break;
    }
  }
  DoTrace("out0 - XTL_FindClosingCurlyBrace");
  return NULL;
}


x86 assembly (clang, -O0):
<XTL_FindClosingCurlyBrace>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1163 <XTL_FindClosingCurlyBrace+0x43>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1163 <XTL_FindClosingCurlyBrace+0x43>
cmpq   $0x0,-0x18(%rbp)
je     1163 <XTL_FindClosingCurlyBrace+0x43>
mov    -0x18(%rbp),%rax
cmpl   $0x1,(%rax)
jge    1170 <XTL_FindClosingCurlyBrace+0x50>
movq   $0x0,-0x8(%rbp)
jmp    12c0 <XTL_FindClosingCurlyBrace+0x1a0>
lea    0xe89(%rip),%rdi
call   1030 <DoTrace@plt>
mov    -0x10(%rbp),%rdi
call   1040 <XTL_FindComment@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     12ac <XTL_FindClosingCurlyBrace+0x18c>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x2c(%rbp)
sub    $0x25,%eax
je     125f <XTL_FindClosingCurlyBrace+0x13f>
jmp    11b9 <XTL_FindClosingCurlyBrace+0x99>
mov    -0x2c(%rbp),%eax
sub    $0x5c,%eax
je     11ec <XTL_FindClosingCurlyBrace+0xcc>
jmp    11ca <XTL_FindClosingCurlyBrace+0xaa>
mov    -0x2c(%rbp),%eax
sub    $0x7b,%eax
je     1219 <XTL_FindClosingCurlyBrace+0xf9>
jmp    11db <XTL_FindClosingCurlyBrace+0xbb>
mov    -0x2c(%rbp),%eax
sub    $0x7d,%eax
je     1229 <XTL_FindClosingCurlyBrace+0x109>
jmp    1296 <XTL_FindClosingCurlyBrace+0x176>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1214 <XTL_FindClosingCurlyBrace+0xf4>
mov    -0x20(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x20(%rbp)
jmp    1296 <XTL_FindClosingCurlyBrace+0x176>
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
jmp    1296 <XTL_FindClosingCurlyBrace+0x176>
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
add    $0xffffffff,%ecx
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
cmpl   $0x0,(%rax)
jne    125a <XTL_FindClosingCurlyBrace+0x13a>
lea    0xdd7(%rip),%rdi
call   1030 <DoTrace@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    12c0 <XTL_FindClosingCurlyBrace+0x1a0>
jmp    1296 <XTL_FindClosingCurlyBrace+0x176>
cmpq   $0x0,-0x28(%rbp)
je     1291 <XTL_FindClosingCurlyBrace+0x171>
mov    -0x20(%rbp),%rax
cmp    -0x28(%rbp),%rax
jne    1291 <XTL_FindClosingCurlyBrace+0x171>
lea    0xdc1(%rip),%rdi
call   1030 <DoTrace@plt>
movq   $0x0,-0x8(%rbp)
jmp    12c0 <XTL_FindClosingCurlyBrace+0x1a0>
jmp    1296 <XTL_FindClosingCurlyBrace+0x176>
jmp    129b <XTL_FindClosingCurlyBrace+0x17b>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1191 <XTL_FindClosingCurlyBrace+0x71>
lea    0xdae(%rip),%rdi
call   1030 <DoTrace@plt>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<XTL_FindClosingCurlyBrace>:
push   %r14
push   %rbx
push   %rax
test   %rdi,%rdi
je     11f9 <XTL_FindClosingCurlyBrace+0xd9>
mov    %rsi,%r14
xor    %eax,%eax
test   %rsi,%rsi
je     11fb <XTL_FindClosingCurlyBrace+0xdb>
mov    %rdi,%rbx
cmpb   $0x0,(%rdi)
je     11fb <XTL_FindClosingCurlyBrace+0xdb>
cmpl   $0x0,(%r14)
jle    11f9 <XTL_FindClosingCurlyBrace+0xd9>
lea    0xea8(%rip),%rdi
call   1030 <DoTrace@plt>
mov    %rbx,%rdi
call   1040 <XTL_FindComment@plt>
mov    (%rbx),%cl
lea    0xef3(%rip),%rdi
test   %cl,%cl
je     11ed <XTL_FindClosingCurlyBrace+0xcd>
lea    0xec7(%rip),%rsi
lea    0xe9f(%rip),%rdx
jmp    11a0 <XTL_FindClosingCurlyBrace+0x80>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
addl   $0x1,(%r14)
movzbl 0x1(%rbx),%ecx
add    $0x1,%rbx
test   %cl,%cl
je     11ed <XTL_FindClosingCurlyBrace+0xcd>
movsbl %cl,%ecx
cmp    $0x7a,%ecx
jg     11c0 <XTL_FindClosingCurlyBrace+0xa0>
cmp    $0x25,%ecx
je     11e0 <XTL_FindClosingCurlyBrace+0xc0>
cmp    $0x5c,%ecx
jne    1194 <XTL_FindClosingCurlyBrace+0x74>
cmpb   $0x0,0x1(%rbx)
je     1194 <XTL_FindClosingCurlyBrace+0x74>
add    $0x1,%rbx
jmp    1194 <XTL_FindClosingCurlyBrace+0x74>
xchg   %ax,%ax
cmp    $0x7b,%ecx
je     1190 <XTL_FindClosingCurlyBrace+0x70>
cmp    $0x7d,%ecx
jne    1194 <XTL_FindClosingCurlyBrace+0x74>
addl   $0xffffffff,(%r14)
jne    1194 <XTL_FindClosingCurlyBrace+0x74>
jmp    1203 <XTL_FindClosingCurlyBrace+0xe3>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
test   %rax,%rax
je     1194 <XTL_FindClosingCurlyBrace+0x74>
cmp    %rax,%rbx
jne    1194 <XTL_FindClosingCurlyBrace+0x74>
mov    %rsi,%rdi
xor    %ebx,%ebx
call   1030 <DoTrace@plt>
mov    %rbx,%rax
jmp    11fb <XTL_FindClosingCurlyBrace+0xdb>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    %rdx,%rdi
jmp    11ef <XTL_FindClosingCurlyBrace+0xcf>

LLVM IR (-O0):
@.str = [31 x i8] c"In - XTL_FindClosingCurlyBrace\00"
@.str.1 = [33 x i8] c"out1 - XTL_FindClosingCurlyBrace\00"
@.str.2 = [33 x i8] c"out2 - XTL_FindClosingCurlyBrace\00"
@.str.3 = [33 x i8] c"out0 - XTL_FindClosingCurlyBrace\00"
define i8* @XTL_FindClosingCurlyBrace(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i8*
store i8* %0, i8** %4
store i32* %1, i32** %5
%8 = load i8*, i8** %4
%9 = icmp eq i8* %8, null
br i1 %9, label %22, label %10
10: ; preds = %2
%11 = load i8*, i8** %4
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp eq i32 %13, 0
br i1 %14, label %22, label %15
15: ; preds = %10
%16 = load i32*, i32** %5
%17 = icmp eq i32* %16, null
br i1 %17, label %22, label %18
18: ; preds = %15
%19 = load i32*, i32** %5
%20 = load i32, i32* %19
%21 = icmp slt i32 %20, 1
br i1 %21, label %22, label %23
22: ; preds = %18, %15, %10, %2
store i8* null, i8** %3
br label %79
23: ; preds = %18
%24 = call i32 @DoTrace(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%25 = load i8*, i8** %4
%26 = call i8* @XTL_FindComment(i8* %25)
store i8* %26, i8** %7
%27 = load i8*, i8** %4
store i8* %27, i8** %6
br label %28
28: ; preds = %74, %23
%29 = load i8*, i8** %6
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %77
33: ; preds = %28
%34 = load i8*, i8** %6
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
switch i32 %36, label %73 [
i32 92, label %37
i32 123, label %48
i32 125, label %52
i32 37, label %63
]
37: ; preds = %33
%38 = load i8*, i8** %6
%39 = getelementptr inbounds i8, i8* %38, i32 1
store i8* %39, i8** %6
%40 = load i8*, i8** %6
%41 = load i8, i8* %40
%42 = sext i8 %41 to i32
%43 = icmp eq i32 %42, 0
br i1 %43, label %44, label %47
44: ; preds = %37
%45 = load i8*, i8** %6
%46 = getelementptr inbounds i8, i8* %45, i32 -1
store i8* %46, i8** %6
br label %47
47: ; preds = %44, %37
br label %73
48: ; preds = %33
%49 = load i32*, i32** %5
%50 = load i32, i32* %49
%51 = add nsw i32 %50, 1
store i32 %51, i32* %49
br label %73
52: ; preds = %33
%53 = load i32*, i32** %5
%54 = load i32, i32* %53
%55 = add nsw i32 %54, -1
store i32 %55, i32* %53
%56 = load i32*, i32** %5
%57 = load i32, i32* %56
%58 = icmp eq i32 %57, 0
br i1 %58, label %59, label %62
59: ; preds = %52
%60 = call i32 @DoTrace(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
%61 = load i8*, i8** %6
store i8* %61, i8** %3
br label %79
62: ; preds = %52
br label %73
63: ; preds = %33
%64 = load i8*, i8** %7
%65 = icmp ne i8* %64, null
br i1 %65, label %66, label %72
66: ; preds = %63
%67 = load i8*, i8** %6
%68 = load i8*, i8** %7
%69 = icmp eq i8* %67, %68
br i1 %69, label %70, label %72
70: ; preds = %66
%71 = call i32 @DoTrace(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
store i8* null, i8** %3
br label %79
72: ; preds = %66, %63
br label %73
73: ; preds = %33, %72, %62, %48, %47
br label %74
74: ; preds = %73
%75 = load i8*, i8** %6
%76 = getelementptr inbounds i8, i8* %75, i32 1
store i8* %76, i8** %6
br label %28
77: ; preds = %28
%78 = call i32 @DoTrace(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0))
store i8* null, i8** %3
br label %79
79: ; preds = %77, %70, %59, %22
%80 = load i8*, i8** %3
ret i8* %80
}

LLVM IR (-O2):
@.str = [31 x i8] c"In - XTL_FindClosingCurlyBrace\00"
@.str.1 = [33 x i8] c"out1 - XTL_FindClosingCurlyBrace\00"
@.str.2 = [33 x i8] c"out2 - XTL_FindClosingCurlyBrace\00"
@.str.3 = [33 x i8] c"out0 - XTL_FindClosingCurlyBrace\00"
define i8* @XTL_FindClosingCurlyBrace(i8* %0, i32* %1) {
%3 = icmp eq i8* %0, null
br i1 %3, label %47, label %4
4: ; preds = %2
%5 = load i8, i8* %0
%6 = icmp eq i8 %5, 0
%7 = icmp eq i32* %1, null
%8 = or i1 %7, %6
br i1 %8, label %47, label %9
9: ; preds = %4
%10 = load i32, i32* %1
%11 = icmp slt i32 %10, 1
br i1 %11, label %47, label %12
12: ; preds = %9
%13 = tail call i32 @DoTrace(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%14 = tail call i8* @XTL_FindComment(i8* %0)
%15 = load i8, i8* %0
%16 = icmp eq i8 %15, 0
br i1 %16, label %43, label %17
17: ; preds = %12
%18 = icmp ne i8* %14, null
br label %19
19: ; preds = %17, %38
%20 = phi i8 [ %15, %17 ], [ %41, %38 ]
%21 = phi i8* [ %0, %17 ], [ %40, %38 ]
%22 = sext i8 %20 to i32
switch i32 %22, label %38 [
i32 92, label %23
i32 123, label %28
i32 125, label %31
i32 37, label %35
]
23: ; preds = %19
%24 = getelementptr inbounds i8, i8* %21, i64 1
%25 = load i8, i8* %24
%26 = icmp eq i8 %25, 0
%27 = select i1 %26, i8* %21, i8* %24
br label %38
28: ; preds = %19
%29 = load i32, i32* %1
%30 = add nsw i32 %29, 1
store i32 %30, i32* %1
br label %38
31: ; preds = %19
%32 = load i32, i32* %1
%33 = add nsw i32 %32, -1
store i32 %33, i32* %1
%34 = icmp eq i32 %33, 0
br i1 %34, label %43, label %38
35: ; preds = %19
%36 = icmp eq i8* %21, %14
%37 = and i1 %18, %36
br i1 %37, label %43, label %38
38: ; preds = %23, %28, %19, %31, %35
%39 = phi i8* [ %21, %19 ], [ %21, %35 ], [ %21, %31 ], [ %21, %28 ], [ %27, %23 ]
%40 = getelementptr inbounds i8, i8* %39, i64 1
%41 = load i8, i8* %40
%42 = icmp eq i8 %41, 0
br i1 %42, label %43, label %19
43: ; preds = %38, %35, %31, %12
%44 = phi i8* [ getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), %12 ], [ getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), %31 ], [ getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), %35 ], [ getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), %38 ]
%45 = phi i8* [ null, %12 ], [ %21, %31 ], [ null, %35 ], [ null, %38 ]
%46 = tail call i32 @DoTrace(i8* %44)
br label %47
47: ; preds = %43, %2, %4, %9
%48 = phi i8* [ null, %9 ], [ null, %4 ], [ null, %2 ], [ %45, %43 ]
ret i8* %48
}