#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 */
struct cymkd_parser {
  int dummy;
};

/* Variables and functions */
int consume(struct cymkd_parser *);
scalar_t__ isspace(int);
char lookahead(struct cymkd_parser *, int);
int /*<<< orphan*/ match(struct cymkd_parser *, char);
int match_string(struct cymkd_parser *, char *);
int next(struct cymkd_parser *);
int /*<<< orphan*/ parser_emit_char(struct cymkd_parser *, int);
int /*<<< orphan*/ parser_emit_string(struct cymkd_parser *, char *);
bool literal_html_comment(struct cymkd_parser *parser) {
  bool done = false;
  int ch;
  if (match_string(parser, "<!--") != 4) {
    return false;
  }
  parser_emit_string(parser, "<!--");
  while (!done) {
    ch = consume(parser);
    if (ch == '-' && next(parser) == '-' && lookahead(parser, 1) == '>') {
      match(parser, '-');
      match(parser, '>');
      done = true;
      parser_emit_string(parser, "-->");
    } else if (ch == -1) {
      done = true;
    } else {
      parser_emit_char(parser, ch);
    }
  }
  while (isspace(next(parser)) && next(parser) != -1) {
    ch = consume(parser);
    parser_emit_char(parser, ch);
  }
  return true;
}


x86 assembly (clang, -O0):
<literal_html_comment>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe62(%rip),%rsi
call   1030 <match_string@plt>
cmp    $0x4,%eax
je     11b8 <literal_html_comment+0x38>
movl   $0x0,-0x4(%rbp)
jmp    12f1 <literal_html_comment+0x171>
mov    -0x10(%rbp),%rdi
lea    0xe3d(%rip),%rsi
call   1070 <parser_emit_string@plt>
cmpl   $0x0,-0x14(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11de <literal_html_comment+0x5e>
jmp    1284 <literal_html_comment+0x104>
mov    -0x10(%rbp),%rdi
call   1060 <consume@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x2d,-0x18(%rbp)
jne    1258 <literal_html_comment+0xd8>
mov    -0x10(%rbp),%rdi
call   1050 <next@plt>
cmp    $0x2d,%eax
jne    1258 <literal_html_comment+0xd8>
mov    -0x10(%rbp),%rdi
mov    $0x1,%esi
call   1090 <lookahead@plt>
movsbl %al,%eax
cmp    $0x3e,%eax
jne    1258 <literal_html_comment+0xd8>
mov    -0x10(%rbp),%rdi
mov    $0x2d,%esi
call   1080 <match@plt>
mov    -0x10(%rbp),%rdi
mov    $0x3e,%esi
call   1080 <match@plt>
movl   $0x1,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xdb7(%rip),%rsi
call   1070 <parser_emit_string@plt>
jmp    127f <literal_html_comment+0xff>
cmpl   $0xffffffff,-0x18(%rbp)
jne    126e <literal_html_comment+0xee>
movl   $0x1,-0x14(%rbp)
jmp    127a <literal_html_comment+0xfa>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%esi
call   10a0 <parser_emit_char@plt>
jmp    127f <literal_html_comment+0xff>
jmp    11c8 <literal_html_comment+0x48>
jmp    1289 <literal_html_comment+0x109>
mov    -0x10(%rbp),%rdi
call   1050 <next@plt>
mov    %eax,%edi
call   1040 <isspace@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x19(%rbp)
je     12bd <literal_html_comment+0x13d>
mov    -0x10(%rbp),%rdi
call   1050 <next@plt>
cmp    $0xffffffff,%eax
setne  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    12cd <literal_html_comment+0x14d>
jmp    12ea <literal_html_comment+0x16a>
mov    -0x10(%rbp),%rdi
call   1060 <consume@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%esi
call   10a0 <parser_emit_char@plt>
jmp    1289 <literal_html_comment+0x109>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<literal_html_comment>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xe73(%rip),%rsi
call   1030 <match_string@plt>
xor    %ebp,%ebp
cmp    $0x4,%eax
jne    1263 <literal_html_comment+0xe3>
lea    0xe5c(%rip),%rsi
mov    %rbx,%rdi
call   1070 <parser_emit_string@plt>
jmp    11bf <literal_html_comment+0x3f>
xchg   %ax,%ax
cmp    $0xffffffff,%ebp
je     1215 <literal_html_comment+0x95>
mov    %rbx,%rdi
mov    %ebp,%esi
call   10a0 <parser_emit_char@plt>
mov    %rbx,%rdi
call   1060 <consume@plt>
mov    %eax,%ebp
cmp    $0x2d,%eax
jne    11b0 <literal_html_comment+0x30>
mov    %rbx,%rdi
call   1050 <next@plt>
cmp    $0x2d,%eax
jne    11b5 <literal_html_comment+0x35>
mov    %rbx,%rdi
mov    $0x1,%esi
call   1090 <lookahead@plt>
cmp    $0x3e,%al
jne    11b5 <literal_html_comment+0x35>
mov    %rbx,%rdi
mov    $0x2d,%esi
call   1080 <match@plt>
mov    %rbx,%rdi
mov    $0x3e,%esi
call   1080 <match@plt>
lea    0xdf8(%rip),%rsi
mov    %rbx,%rdi
call   1070 <parser_emit_string@plt>
mov    %rbx,%rdi
call   1050 <next@plt>
mov    %eax,%edi
call   1040 <isspace@plt>
mov    $0x1,%ebp
test   %rax,%rax
je     1263 <literal_html_comment+0xe3>
xchg   %ax,%ax
mov    %rbx,%rdi
call   1050 <next@plt>
cmp    $0xffffffff,%eax
je     1263 <literal_html_comment+0xe3>
mov    %rbx,%rdi
call   1060 <consume@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   10a0 <parser_emit_char@plt>
mov    %rbx,%rdi
call   1050 <next@plt>
mov    %eax,%edi
call   1040 <isspace@plt>
test   %rax,%rax
jne    1230 <literal_html_comment+0xb0>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.cymkd_parser = type { i32 }
@.str = [5 x i8] c"<!--\00"
@.str.1 = [4 x i8] c"-->\00"
define i32 @literal_html_comment(%struct.cymkd_parser* %0) {
%2 = alloca i32
%3 = alloca %struct.cymkd_parser*
%4 = alloca i32
%5 = alloca i32
store %struct.cymkd_parser* %0, %struct.cymkd_parser** %3
store i32 0, i32* %4
%6 = load %struct.cymkd_parser*, %struct.cymkd_parser** %3
%7 = call i32 @match_string(%struct.cymkd_parser* %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%8 = icmp ne i32 %7, 4
br i1 %8, label %9, label %10
9: ; preds = %1
store i32 0, i32* %2
br label %67
10: ; preds = %1
%11 = load %struct.cymkd_parser*, %struct.cymkd_parser** %3
%12 = call i32 @parser_emit_string(%struct.cymkd_parser* %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; preds = %47, %10
%14 = load i32, i32* %4
%15 = icmp ne i32 %14, 0
%16 = xor i1 %15, true
br i1 %16, label %17, label %48
17: ; preds = %13
%18 = load %struct.cymkd_parser*, %struct.cymkd_parser** %3
%19 = call i32 @consume(%struct.cymkd_parser* %18)
store i32 %19, i32* %5
%20 = load i32, i32* %5
%21 = icmp eq i32 %20, 45
br i1 %21, label %22, label %38
22: ; preds = %17
%23 = load %struct.cymkd_parser*, %struct.cymkd_parser** %3
%24 = call i32 @next(%struct.cymkd_parser* %23)
%25 = icmp eq i32 %24, 45
br i1 %25, label %26, label %38
26: ; preds = %22
%27 = load %struct.cymkd_parser*, %struct.cymkd_parser** %3
%28 = call signext i8 @lookahead(%struct.cymkd_parser* %27, i32 1)
%29 = sext i8 %28 to i32
%30 = icmp eq i32 %29, 62
br i1 %30, label %31, label %38
31: ; preds = %26
%32 = load %struct.cymkd_parser*, %struct.cymkd_parser** %3
%33 = call i32 @match(%struct.cymkd_parser* %32, i8 signext 45)
%34 = load %struct.cymkd_parser*, %struct.cymkd_parser** %3
%35 = call i32 @match(%struct.cymkd_parser* %34, i8 signext 62)
store i32 1, i32* %4
%36 = load %struct.cymkd_parser*, %struct.cymkd_parser** %3
%37 = call i32 @parser_emit_string(%struct.cymkd_parser* %36, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
br label %47
38: ; preds = %26, %22, %17
%39 = load i32, i32* %5
%40 = icmp eq i32 %39, -1
br i1 %40, label %41, label %42
41: ; preds = %38
store i32 1, i32* %4
br label %46
42: ; preds = %38
%43 = load %struct.cymkd_parser*, %struct.cymkd_parser** %3
%44 = load i32, i32* %5
%45 = call i32 @parser_emit_char(%struct.cymkd_parser* %43, i32 %44)
br label %46
46: ; preds = %42, %41
br label %47
47: ; preds = %46, %31
br label %13
48: ; preds = %13
br label %49
49: ; preds = %60, %48
%50 = load %struct.cymkd_parser*, %struct.cymkd_parser** %3
%51 = call i32 @next(%struct.cymkd_parser* %50)
%52 = call i64 @isspace(i32 %51)
%53 = icmp ne i64 %52, 0
br i1 %53, label %54, label %58
54: ; preds = %49
%55 = load %struct.cymkd_parser*, %struct.cymkd_parser** %3
%56 = call i32 @next(%struct.cymkd_parser* %55)
%57 = icmp ne i32 %56, -1
br label %58
58: ; preds = %54, %49
%59 = phi i1 [ false, %49 ], [ %57, %54 ]
br i1 %59, label %60, label %66
60: ; preds = %58
%61 = load %struct.cymkd_parser*, %struct.cymkd_parser** %3
%62 = call i32 @consume(%struct.cymkd_parser* %61)
store i32 %62, i32* %5
%63 = load %struct.cymkd_parser*, %struct.cymkd_parser** %3
%64 = load i32, i32* %5
%65 = call i32 @parser_emit_char(%struct.cymkd_parser* %63, i32 %64)
br label %49
66: ; preds = %58
store i32 1, i32* %2
br label %67
67: ; preds = %66, %9
%68 = load i32, i32* %2
ret i32 %68
}

LLVM IR (-O2):
%struct.cymkd_parser = type { i32 }
@.str = [5 x i8] c"<!--\00"
@.str.1 = [4 x i8] c"-->\00"
define i32 @literal_html_comment(%struct.cymkd_parser* %0) {
%2 = tail call i32 @match_string(%struct.cymkd_parser* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i32 %2, 4
br i1 %3, label %4, label %33
4: ; preds = %1
%5 = tail call i32 @parser_emit_string(%struct.cymkd_parser* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %10
6: ; preds = %10, %18
%7 = tail call i32 @next(%struct.cymkd_parser* %0)
%8 = tail call i64 @isspace(i32 %7)
%9 = icmp eq i64 %8, 0
br i1 %9, label %33, label %24
10: ; preds = %22, %4
%11 = tail call i32 @consume(%struct.cymkd_parser* %0)
switch i32 %11, label %22 [
i32 45, label %12
i32 -1, label %6
]
12: ; preds = %10
%13 = tail call i32 @next(%struct.cymkd_parser* %0)
%14 = icmp eq i32 %13, 45
br i1 %14, label %15, label %22
15: ; preds = %12
%16 = tail call signext i8 @lookahead(%struct.cymkd_parser* %0, i32 1)
%17 = icmp eq i8 %16, 62
br i1 %17, label %18, label %22
18: ; preds = %15
%19 = tail call i32 @match(%struct.cymkd_parser* %0, i8 signext 45)
%20 = tail call i32 @match(%struct.cymkd_parser* %0, i8 signext 62)
%21 = tail call i32 @parser_emit_string(%struct.cymkd_parser* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
br label %6
22: ; preds = %10, %15, %12
%23 = tail call i32 @parser_emit_char(%struct.cymkd_parser* %0, i32 %11)
br label %10
24: ; preds = %6, %27
%25 = tail call i32 @next(%struct.cymkd_parser* %0)
%26 = icmp eq i32 %25, -1
br i1 %26, label %33, label %27
27: ; preds = %24
%28 = tail call i32 @consume(%struct.cymkd_parser* %0)
%29 = tail call i32 @parser_emit_char(%struct.cymkd_parser* %0, i32 %28)
%30 = tail call i32 @next(%struct.cymkd_parser* %0)
%31 = tail call i64 @isspace(i32 %30)
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %24
33: ; preds = %27, %24, %6, %1
%34 = phi i32 [ 0, %1 ], [ 1, %6 ], [ 1, %24 ], [ 1, %27 ]
ret i32 %34
}