#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 */
scalar_t__ strncmp(char const *, char *, int);
unsigned xml__parse_comment(const char *source) {
  if (!source)
    return 0;
  if (strncmp(source, "<!--", 4) != 0)
    return 0;
  unsigned i;
  for (i = 4; source[i] != '\0'; i++) {
    if (strncmp(&source[i], "-->", 3) == 0) {
      i += 3;
      break;
    }
  }
  return i;
}


x86 assembly (clang, -O0):
<xml__parse_comment>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1133 <xml__parse_comment+0x23>
movl   $0x0,-0x4(%rbp)
jmp    11c5 <xml__parse_comment+0xb5>
mov    -0x10(%rbp),%rdi
lea    0xec2(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     115e <xml__parse_comment+0x4e>
movl   $0x0,-0x4(%rbp)
jmp    11c5 <xml__parse_comment+0xb5>
movl   $0x4,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     11bf <xml__parse_comment+0xaf>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%eax
add    %rax,%rdi
lea    0xe7b(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    11ac <xml__parse_comment+0x9c>
mov    -0x14(%rbp),%eax
add    $0x3,%eax
mov    %eax,-0x14(%rbp)
jmp    11bf <xml__parse_comment+0xaf>
jmp    11b1 <xml__parse_comment+0xa1>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1165 <xml__parse_comment+0x55>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xml__parse_comment>:
push   %r15
push   %r14
push   %rbx
xor    %ebx,%ebx
test   %rdi,%rdi
je     1135 <xml__parse_comment+0x25>
mov    %rdi,%r14
lea    0xeda(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     113d <xml__parse_comment+0x2d>
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %r15
ret
cmpb   $0x0,0x4(%r14)
mov    $0x4,%ebx
je     1135 <xml__parse_comment+0x25>
lea    0x4(%r14),%rdi
mov    $0x7,%ebx
lea    0xeac(%rip),%r15
nopl   0x0(%rax)
mov    %r15,%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1135 <xml__parse_comment+0x25>
lea    -0x2(%rbx),%eax
lea    (%r14,%rax,1),%rdi
add    $0x1,%ebx
cmpb   $0x0,(%r14,%rax,1)
jne    1160 <xml__parse_comment+0x50>
add    $0xfffffffd,%ebx
jmp    1135 <xml__parse_comment+0x25>

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

LLVM IR (-O2):
@.str = [5 x i8] c"<!--\00"
@.str.1 = [4 x i8] c"-->\00"
define i32 @xml__parse_comment(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %23, label %3
3: ; preds = %1
%4 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 4)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %23
6: ; preds = %3
%7 = getelementptr inbounds i8, i8* %0, i64 4
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, 0
br i1 %9, label %23, label %10
10: ; preds = %6, %17
%11 = phi i8* [ %20, %17 ], [ %7, %6 ]
%12 = phi i32 [ %18, %17 ], [ 4, %6 ]
%13 = tail call i64 @strncmp(i8* %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 3)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %10
%16 = add i32 %12, 3
br label %23
17: ; preds = %10
%18 = add i32 %12, 1
%19 = zext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %0, i64 %19
%21 = load i8, i8* %20
%22 = icmp eq i8 %21, 0
br i1 %22, label %23, label %10
23: ; preds = %17, %6, %15, %3, %1
%24 = phi i32 [ 0, %1 ], [ 0, %3 ], [ %16, %15 ], [ 4, %6 ], [ %18, %17 ]
ret i32 %24
}