#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 */
char *strstr(char *, char *);
char *XTL_FindComment(char *line) {
  char *p;
  if (line == NULL || *line == 0)
    return NULL;
  if (*line == '%')
    return line;
  p = strstr(line, "%");
  if (p == NULL)
    return NULL;
  if (*(p - 1) == '\\')
    p = XTL_FindComment(p + 1);
  return p;
}


x86 assembly (clang, -O0):
<XTL_FindComment>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1147 <XTL_FindComment+0x27>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1154 <XTL_FindComment+0x34>
movq   $0x0,-0x8(%rbp)
jmp    11c7 <XTL_FindComment+0xa7>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x25,%eax
jne    1171 <XTL_FindComment+0x51>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11c7 <XTL_FindComment+0xa7>
mov    -0x10(%rbp),%rdi
lea    0xe84(%rip),%rsi
call   1040 <strstr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    119d <XTL_FindComment+0x7d>
movq   $0x0,-0x8(%rbp)
jmp    11c7 <XTL_FindComment+0xa7>
mov    -0x18(%rbp),%rax
movsbl -0x1(%rax),%eax
cmp    $0x5c,%eax
jne    11bf <XTL_FindComment+0x9f>
mov    -0x18(%rbp),%rdi
add    $0x1,%rdi
call   1030 <XTL_FindComment@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<XTL_FindComment>:
push   %rax
test   %rdi,%rdi
je     114a <XTL_FindComment+0x3a>
mov    %rdi,%rax
nopl   0x0(%rax)
movzbl (%rax),%ecx
test   %cl,%cl
je     114a <XTL_FindComment+0x3a>
cmp    $0x25,%cl
je     114c <XTL_FindComment+0x3c>
mov    %rax,%rdi
mov    $0x25,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     114a <XTL_FindComment+0x3a>
cmpb   $0x5c,-0x1(%rax)
jne    114c <XTL_FindComment+0x3c>
add    $0x1,%rax
jmp    1120 <XTL_FindComment+0x10>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [2 x i8] c"%\00"
define i8* @XTL_FindComment(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = icmp eq i8* %5, null
br i1 %6, label %12, label %7
7: ; preds = %1
%8 = load i8*, i8** %3
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %7, %1
store i8* null, i8** %2
br label %38
13: ; preds = %7
%14 = load i8*, i8** %3
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 37
br i1 %17, label %18, label %20
18: ; preds = %13
%19 = load i8*, i8** %3
store i8* %19, i8** %2
br label %38
20: ; preds = %13
%21 = load i8*, i8** %3
%22 = call i8* @strstr(i8* %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %22, i8** %4
%23 = load i8*, i8** %4
%24 = icmp eq i8* %23, null
br i1 %24, label %25, label %26
25: ; preds = %20
store i8* null, i8** %2
br label %38
26: ; preds = %20
%27 = load i8*, i8** %4
%28 = getelementptr inbounds i8, i8* %27, i64 -1
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = icmp eq i32 %30, 92
br i1 %31, label %32, label %36
32: ; preds = %26
%33 = load i8*, i8** %4
%34 = getelementptr inbounds i8, i8* %33, i64 1
%35 = call i8* @XTL_FindComment(i8* %34)
store i8* %35, i8** %4
br label %36
36: ; preds = %32, %26
%37 = load i8*, i8** %4
store i8* %37, i8** %2
br label %38
38: ; preds = %36, %25, %18, %12
%39 = load i8*, i8** %2
ret i8* %39
}

LLVM IR (-O2):
define i8* @XTL_FindComment(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %17, label %3
3: ; preds = %1, %13
%4 = phi i8* [ %14, %13 ], [ %0, %1 ]
%5 = load i8, i8* %4
switch i8 %5, label %6 [
i8 0, label %15
i8 37, label %17
]
6: ; preds = %3
%7 = tail call i8* @strchr(i8* %4, i32 37)
%8 = icmp eq i8* %7, null
br i1 %8, label %15, label %9
9: ; preds = %6
%10 = getelementptr inbounds i8, i8* %7, i64 -1
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 92
br i1 %12, label %13, label %15
13: ; preds = %9
%14 = getelementptr inbounds i8, i8* %7, i64 1
br label %3
15: ; preds = %9, %6, %3
%16 = phi i8* [ null, %3 ], [ null, %6 ], [ %7, %9 ]
br label %17
17: ; preds = %3, %15, %1
%18 = phi i8* [ null, %1 ], [ %16, %15 ], [ %4, %3 ]
ret i8* %18
}