#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 *);
int /*<<< orphan*/ HandleTag(char *);
int /*<<< orphan*/ TracePrintf(char *, char *);
char *TrimWhitespace(char *);
char *XTL_FindClosingCurlyBrace(char *, int *);
char *strtok(char *, char *);
void ParseTags(char *line) {
  char *p;
  int Count = 1;
  TracePrintf("BuildHeader - processing tags: %s\n", line);
  p = XTL_FindClosingCurlyBrace(line, &Count);
  if (p != 0)
    *p = 0;
  p = strtok(line, ",");
  while (p != NULL) {
    p = TrimWhitespace(p);
    if (*p != 0) {
      if (*p == '{' || *p == '}' || *p == '[' || *p == ']')
        ++p;
      HandleTag(p);
    }
    p = strtok(NULL, ",");
  }
  DoTrace("Done Parsing Tags");
}


x86 assembly (clang, -O0):
<ParseTags>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xe82(%rip),%rdi
call   1070 <TracePrintf@plt>
mov    -0x8(%rbp),%rdi
lea    -0x14(%rbp),%rsi
call   1050 <XTL_FindClosingCurlyBrace@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11a6 <ParseTags+0x46>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%rdi
lea    0xe72(%rip),%rsi
call   1060 <strtok@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1250 <ParseTags+0xf0>
mov    -0x10(%rbp),%rdi
call   1040 <TrimWhitespace@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1237 <ParseTags+0xd7>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x7b,%eax
je     1222 <ParseTags+0xc2>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x7d,%eax
je     1222 <ParseTags+0xc2>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5b,%eax
je     1222 <ParseTags+0xc2>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5d,%eax
jne    122e <ParseTags+0xce>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1080 <HandleTag@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xde1(%rip),%rsi
call   1060 <strtok@plt>
mov    %rax,-0x10(%rbp)
jmp    11ba <ParseTags+0x5a>
lea    0xdce(%rip),%rdi
call   1030 <DoTrace@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ParseTags>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
movl   $0x1,0x4(%rsp)
lea    0xe8a(%rip),%rdi
mov    %rbx,%rsi
call   1070 <TracePrintf@plt>
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <XTL_FindClosingCurlyBrace@plt>
test   %rax,%rax
je     1193 <ParseTags+0x33>
movb   $0x0,(%rax)
lea    0xe89(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strtok@plt>
test   %rax,%rax
je     11fd <ParseTags+0x9d>
lea    0xe75(%rip),%rbx
movabs $0x500000005,%r14
jmp    11e4 <ParseTags+0x84>
nopw   0x0(%rax,%rax,1)
movzbl %dl,%edx
bt     %rdx,%r14
jae    11f7 <ParseTags+0x97>
add    $0x1,%rax
mov    %rax,%rdi
call   1080 <HandleTag@plt>
xor    %edi,%edi
mov    %rbx,%rsi
call   1060 <strtok@plt>
test   %rax,%rax
je     11fd <ParseTags+0x9d>
mov    %rax,%rdi
call   1040 <TrimWhitespace@plt>
movzbl (%rax),%ecx
lea    -0x5b(%rcx),%edx
cmp    $0x22,%dl
jbe    11c0 <ParseTags+0x60>
test   %cl,%cl
jne    11cd <ParseTags+0x6d>
jmp    11d5 <ParseTags+0x75>
lea    0xe21(%rip),%rdi
call   1030 <DoTrace@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [35 x i8] c"BuildHeader - processing tags: %s\0A\00"
@.str.1 = [2 x i8] c",\00"
@.str.2 = [18 x i8] c"Done Parsing Tags\00"
define void @ParseTags(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %2
store i32 1, i32* %4
%5 = load i8*, i8** %2
%6 = call i32 @TracePrintf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = load i8*, i8** %2
%8 = call i8* @XTL_FindClosingCurlyBrace(i8* %7, i32* %4)
store i8* %8, i8** %3
%9 = load i8*, i8** %3
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %13
11: ; preds = %1
%12 = load i8*, i8** %3
store i8 0, i8* %12
br label %13
13: ; preds = %11, %1
%14 = load i8*, i8** %2
%15 = call i8* @strtok(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %15, i8** %3
br label %16
16: ; preds = %52, %13
%17 = load i8*, i8** %3
%18 = icmp ne i8* %17, null
br i1 %18, label %19, label %54
19: ; preds = %16
%20 = load i8*, i8** %3
%21 = call i8* @TrimWhitespace(i8* %20)
store i8* %21, i8** %3
%22 = load i8*, i8** %3
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %52
26: ; preds = %19
%27 = load i8*, i8** %3
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp eq i32 %29, 123
br i1 %30, label %46, label %31
31: ; preds = %26
%32 = load i8*, i8** %3
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = icmp eq i32 %34, 125
br i1 %35, label %46, label %36
36: ; preds = %31
%37 = load i8*, i8** %3
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = icmp eq i32 %39, 91
br i1 %40, label %46, label %41
41: ; preds = %36
%42 = load i8*, i8** %3
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = icmp eq i32 %44, 93
br i1 %45, label %46, label %49
46: ; preds = %41, %36, %31, %26
%47 = load i8*, i8** %3
%48 = getelementptr inbounds i8, i8* %47, i32 1
store i8* %48, i8** %3
br label %49
49: ; preds = %46, %41
%50 = load i8*, i8** %3
%51 = call i32 @HandleTag(i8* %50)
br label %52
52: ; preds = %49, %19
%53 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %53, i8** %3
br label %16
54: ; preds = %16
%55 = call i32 @DoTrace(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [35 x i8] c"BuildHeader - processing tags: %s\0A\00"
@.str.1 = [2 x i8] c",\00"
@.str.2 = [18 x i8] c"Done Parsing Tags\00"
define void @ParseTags(i8* %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
store i32 1, i32* %2
%4 = tail call i32 @TracePrintf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8* %0)
%5 = call i8* @XTL_FindClosingCurlyBrace(i8* %0, i32* %2)
%6 = icmp eq i8* %5, null
br i1 %6, label %8, label %7
7: ; preds = %1
store i8 0, i8* %5
br label %8
8: ; preds = %7, %1
%9 = call i8* @strtok(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i8* %9, null
br i1 %10, label %23, label %11
11: ; preds = %8, %20
%12 = phi i8* [ %21, %20 ], [ %9, %8 ]
%13 = call i8* @TrimWhitespace(i8* %12)
%14 = load i8, i8* %13
switch i8 %14, label %17 [
i8 0, label %20
i8 123, label %15
i8 125, label %15
i8 91, label %15
i8 93, label %15
]
15: ; preds = %11, %11, %11, %11
%16 = getelementptr inbounds i8, i8* %13, i64 1
br label %17
17: ; preds = %11, %15
%18 = phi i8* [ %16, %15 ], [ %13, %11 ]
%19 = call i32 @HandleTag(i8* %18)
br label %20
20: ; preds = %11, %17
%21 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%22 = icmp eq i8* %21, null
br i1 %22, label %23, label %11
23: ; preds = %20, %8
%24 = call i32 @DoTrace(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
ret void
}