#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__ is_bullet(int);
scalar_t__ isdigit(int);
scalar_t__ isspace(char);
scalar_t__ match(struct cymkd_parser *, int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
char next(struct cymkd_parser *);
int ordered_list_internal(struct cymkd_parser *, char *);
int /*<<< orphan*/ parser_emit_string(struct cymkd_parser *, char *);
int strlen(char const *);
int /*<<< orphan*/ text_and_inline(struct cymkd_parser *);
int /*<<< orphan*/ unconsume(struct cymkd_parser *);
int unordered_list_internal(struct cymkd_parser *, int, char *);
bool unordered_list_line(struct cymkd_parser *parser, int bullet,
                         const char *curr_indent) {
  char indent[1024];
  int ch;
  int i;
  size_t curr_indent_len = strlen(curr_indent);
  size_t indent_len = 0;
  memset(indent, 0, 1024);
  while (isspace(next(parser)) && indent_len < 1024 - 1) {
    ch = consume(parser);
    indent[indent_len++] = ch;
  }
  if (indent_len != curr_indent_len) {
    ch = next(parser);
    for (i = 0; i < strlen(indent); i++) {
      unconsume(parser);
    }
    if (is_bullet(ch) && indent_len > curr_indent_len) {
      return unordered_list_internal(parser, bullet, indent);
    } else if (isdigit(ch) && indent_len > curr_indent_len) {
      return ordered_list_internal(parser, indent);
    } else if (indent_len < curr_indent_len) {
      return false;
    }
  }
  if (match(parser, bullet)) {
    parser_emit_string(parser, "<li>");
    while (next(parser) == ' ') {
      consume(parser);
    }
    if (!text_and_inline(parser)) {
      return false;
    }
    parser_emit_string(parser, "</li>");
    return true;
  }
  return false;
}


x86 assembly (clang, -O0):
<unordered_list_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x440,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <strlen@plt>
cltq
mov    %rax,-0x430(%rbp)
movq   $0x0,-0x438(%rbp)
lea    -0x420(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1070 <memset@plt>
mov    -0x10(%rbp),%rdi
call   1090 <next@plt>
movsbl %al,%edi
call   1080 <isspace@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x439(%rbp)
je     1250 <unordered_list_line+0x80>
cmpq   $0x3ff,-0x438(%rbp)
setb   %al
mov    %al,-0x439(%rbp)
mov    -0x439(%rbp),%al
test   $0x1,%al
jne    1263 <unordered_list_line+0x93>
jmp    129b <unordered_list_line+0xcb>
mov    -0x10(%rbp),%rdi
call   10b0 <consume@plt>
mov    %eax,-0x424(%rbp)
mov    -0x424(%rbp),%eax
mov    %al,%cl
mov    -0x438(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x438(%rbp)
mov    %cl,-0x420(%rbp,%rax,1)
jmp    1216 <unordered_list_line+0x46>
mov    -0x438(%rbp),%rax
cmp    -0x430(%rbp),%rax
je     13c4 <unordered_list_line+0x1f4>
mov    -0x10(%rbp),%rdi
call   1090 <next@plt>
movsbl %al,%eax
mov    %eax,-0x424(%rbp)
movl   $0x0,-0x428(%rbp)
mov    -0x428(%rbp),%eax
mov    %eax,-0x440(%rbp)
lea    -0x420(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x440(%rbp),%eax
cmp    %ecx,%eax
jge    1310 <unordered_list_line+0x140>
mov    -0x10(%rbp),%rdi
call   1060 <unconsume@plt>
mov    -0x428(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x428(%rbp)
jmp    12cb <unordered_list_line+0xfb>
mov    -0x424(%rbp),%edi
call   1040 <is_bullet@plt>
cmp    $0x0,%rax
je     1354 <unordered_list_line+0x184>
mov    -0x438(%rbp),%rax
cmp    -0x430(%rbp),%rax
jbe    1354 <unordered_list_line+0x184>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
lea    -0x420(%rbp),%rdx
call   10f0 <unordered_list_internal@plt>
mov    %eax,-0x4(%rbp)
jmp    144e <unordered_list_line+0x27e>
mov    -0x424(%rbp),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     1395 <unordered_list_line+0x1c5>
mov    -0x438(%rbp),%rax
cmp    -0x430(%rbp),%rax
jbe    1395 <unordered_list_line+0x1c5>
mov    -0x10(%rbp),%rdi
lea    -0x420(%rbp),%rsi
call   10a0 <ordered_list_internal@plt>
mov    %eax,-0x4(%rbp)
jmp    144e <unordered_list_line+0x27e>
mov    -0x438(%rbp),%rax
cmp    -0x430(%rbp),%rax
jae    13b5 <unordered_list_line+0x1e5>
movl   $0x0,-0x4(%rbp)
jmp    144e <unordered_list_line+0x27e>
jmp    13ba <unordered_list_line+0x1ea>
jmp    13bf <unordered_list_line+0x1ef>
jmp    13c4 <unordered_list_line+0x1f4>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   10e0 <match@plt>
cmp    $0x0,%rax
je     1447 <unordered_list_line+0x277>
mov    -0x10(%rbp),%rdi
lea    0xc1b(%rip),%rsi
call   10d0 <parser_emit_string@plt>
mov    -0x10(%rbp),%rdi
call   1090 <next@plt>
movsbl %al,%eax
cmp    $0x20,%eax
jne    140d <unordered_list_line+0x23d>
mov    -0x10(%rbp),%rdi
call   10b0 <consume@plt>
jmp    13ea <unordered_list_line+0x21a>
mov    -0x10(%rbp),%rdi
call   10c0 <text_and_inline@plt>
cmp    $0x0,%eax
jne    142b <unordered_list_line+0x25b>
movl   $0x0,-0x4(%rbp)
jmp    144e <unordered_list_line+0x27e>
mov    -0x10(%rbp),%rdi
lea    0xbcf(%rip),%rsi
call   10d0 <parser_emit_string@plt>
movl   $0x1,-0x4(%rbp)
jmp    144e <unordered_list_line+0x27e>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x440,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<unordered_list_line>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x418,%rsp
mov    %esi,%r13d
mov    %rdi,%rbx
mov    %rdx,%rdi
call   1050 <strlen@plt>
movslq %eax,%r12
lea    0x10(%rsp),%rdi
xor    %r14d,%r14d
xor    %esi,%esi
mov    $0x400,%edx
call   1070 <memset@plt>
mov    %rbx,%rdi
call   1090 <next@plt>
movsbl %al,%edi
call   1080 <isspace@plt>
test   %rax,%rax
je     1251 <unordered_list_line+0x81>
xor    %ebp,%ebp
nopl   (%rax)
mov    %rbx,%rdi
call   10b0 <consume@plt>
lea    0x1(%rbp),%r14
mov    %al,0x10(%rsp,%rbp,1)
mov    %rbx,%rdi
call   1090 <next@plt>
movsbl %al,%edi
call   1080 <isspace@plt>
test   %rax,%rax
je     1251 <unordered_list_line+0x81>
cmp    $0x3fe,%rbp
mov    %r14,%rbp
jb     1220 <unordered_list_line+0x50>
cmp    %r12,%r14
jne    1296 <unordered_list_line+0xc6>
mov    %rbx,%rdi
mov    %r13d,%esi
call   10e0 <match@plt>
xor    %r15d,%r15d
test   %rax,%rax
je     1354 <unordered_list_line+0x184>
lea    0xd8c(%rip),%rsi
mov    %rbx,%rdi
call   10d0 <parser_emit_string@plt>
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1090 <next@plt>
mov    %rbx,%rdi
cmp    $0x20,%al
jne    12ff <unordered_list_line+0x12f>
call   10b0 <consume@plt>
jmp    1280 <unordered_list_line+0xb0>
mov    %r13d,0xc(%rsp)
mov    %rbx,%rdi
call   1090 <next@plt>
movsbl %al,%r15d
lea    0x10(%rsp),%rdi
call   1050 <strlen@plt>
test   %eax,%eax
jle    12d7 <unordered_list_line+0x107>
xor    %ebp,%ebp
lea    0x10(%rsp),%r13
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1060 <unconsume@plt>
add    $0x1,%ebp
mov    %r13,%rdi
call   1050 <strlen@plt>
cmp    %eax,%ebp
jl     12c0 <unordered_list_line+0xf0>
mov    %r15d,%edi
call   1040 <is_bullet@plt>
test   %rax,%rax
je     131f <unordered_list_line+0x14f>
cmp    %r12,%r14
jbe    131f <unordered_list_line+0x14f>
lea    0x10(%rsp),%rdx
mov    %rbx,%rdi
mov    0xc(%rsp),%esi
call   10f0 <unordered_list_internal@plt>
mov    %eax,%r15d
jmp    1354 <unordered_list_line+0x184>
call   10c0 <text_and_inline@plt>
test   %eax,%eax
je     1354 <unordered_list_line+0x184>
lea    0xcf6(%rip),%rsi
mov    %rbx,%rdi
call   10d0 <parser_emit_string@plt>
mov    $0x1,%r15d
jmp    1354 <unordered_list_line+0x184>
mov    %r15d,%edi
call   1030 <isdigit@plt>
test   %rax,%rax
mov    0xc(%rsp),%r13d
je     1348 <unordered_list_line+0x178>
cmp    %r12,%r14
jbe    1348 <unordered_list_line+0x178>
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   10a0 <ordered_list_internal@plt>
mov    %eax,%r15d
jmp    1354 <unordered_list_line+0x184>
xor    %r15d,%r15d
cmp    %r12,%r14
jae    1256 <unordered_list_line+0x86>
mov    %r15d,%eax
add    $0x418,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.cymkd_parser = type { i32 }
@.str = [5 x i8] c"<li>\00"
@.str.1 = [6 x i8] c"</li>\00"
define i32 @unordered_list_line(%struct.cymkd_parser* %0, i32 %1, i8* %2) {
%4 = alloca i32
%5 = alloca %struct.cymkd_parser*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca [1024 x i8]
%9 = alloca i32
%10 = alloca i32
%11 = alloca i64
%12 = alloca i64
store %struct.cymkd_parser* %0, %struct.cymkd_parser** %5
store i32 %1, i32* %6
store i8* %2, i8** %7
%13 = load i8*, i8** %7
%14 = call i32 @strlen(i8* %13)
%15 = sext i32 %14 to i64
store i64 %15, i64* %11
store i64 0, i64* %12
%16 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%17 = call i32 @memset(i8* %16, i32 0, i32 1024)
br label %18
18: ; preds = %28, %3
%19 = load %struct.cymkd_parser*, %struct.cymkd_parser** %5
%20 = call signext i8 @next(%struct.cymkd_parser* %19)
%21 = call i64 @isspace(i8 signext %20)
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %18
%24 = load i64, i64* %12
%25 = icmp ult i64 %24, 1023
br label %26
26: ; preds = %23, %18
%27 = phi i1 [ false, %18 ], [ %25, %23 ]
br i1 %27, label %28, label %36
28: ; preds = %26
%29 = load %struct.cymkd_parser*, %struct.cymkd_parser** %5
%30 = call i32 @consume(%struct.cymkd_parser* %29)
store i32 %30, i32* %9
%31 = load i32, i32* %9
%32 = trunc i32 %31 to i8
%33 = load i64, i64* %12
%34 = add i64 %33, 1
store i64 %34, i64* %12
%35 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 %33
store i8 %32, i8* %35
br label %18
36: ; preds = %26
%37 = load i64, i64* %12
%38 = load i64, i64* %11
%39 = icmp ne i64 %37, %38
br i1 %39, label %40, label %88
40: ; preds = %36
%41 = load %struct.cymkd_parser*, %struct.cymkd_parser** %5
%42 = call signext i8 @next(%struct.cymkd_parser* %41)
%43 = sext i8 %42 to i32
store i32 %43, i32* %9
store i32 0, i32* %10
br label %44
44: ; preds = %52, %40
%45 = load i32, i32* %10
%46 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%47 = call i32 @strlen(i8* %46)
%48 = icmp slt i32 %45, %47
br i1 %48, label %49, label %55
49: ; preds = %44
%50 = load %struct.cymkd_parser*, %struct.cymkd_parser** %5
%51 = call i32 @unconsume(%struct.cymkd_parser* %50)
br label %52
52: ; preds = %49
%53 = load i32, i32* %10
%54 = add nsw i32 %53, 1
store i32 %54, i32* %10
br label %44
55: ; preds = %44
%56 = load i32, i32* %9
%57 = call i64 @is_bullet(i32 %56)
%58 = icmp ne i64 %57, 0
br i1 %58, label %59, label %68
59: ; preds = %55
%60 = load i64, i64* %12
%61 = load i64, i64* %11
%62 = icmp ugt i64 %60, %61
br i1 %62, label %63, label %68
63: ; preds = %59
%64 = load %struct.cymkd_parser*, %struct.cymkd_parser** %5
%65 = load i32, i32* %6
%66 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%67 = call i32 @unordered_list_internal(%struct.cymkd_parser* %64, i32 %65, i8* %66)
store i32 %67, i32* %4
br label %113
68: ; preds = %59, %55
%69 = load i32, i32* %9
%70 = call i64 @isdigit(i32 %69)
%71 = icmp ne i64 %70, 0
br i1 %71, label %72, label %80
72: ; preds = %68
%73 = load i64, i64* %12
%74 = load i64, i64* %11
%75 = icmp ugt i64 %73, %74
br i1 %75, label %76, label %80
76: ; preds = %72
%77 = load %struct.cymkd_parser*, %struct.cymkd_parser** %5
%78 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%79 = call i32 @ordered_list_internal(%struct.cymkd_parser* %77, i8* %78)
store i32 %79, i32* %4
br label %113
80: ; preds = %72, %68
%81 = load i64, i64* %12
%82 = load i64, i64* %11
%83 = icmp ult i64 %81, %82
br i1 %83, label %84, label %85
84: ; preds = %80
store i32 0, i32* %4
br label %113
85: ; preds = %80
br label %86
86: ; preds = %85
br label %87
87: ; preds = %86
br label %88
88: ; preds = %87, %36
%89 = load %struct.cymkd_parser*, %struct.cymkd_parser** %5
%90 = load i32, i32* %6
%91 = call i64 @match(%struct.cymkd_parser* %89, i32 %90)
%92 = icmp ne i64 %91, 0
br i1 %92, label %93, label %112
93: ; preds = %88
%94 = load %struct.cymkd_parser*, %struct.cymkd_parser** %5
%95 = call i32 @parser_emit_string(%struct.cymkd_parser* %94, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %96
96: ; preds = %101, %93
%97 = load %struct.cymkd_parser*, %struct.cymkd_parser** %5
%98 = call signext i8 @next(%struct.cymkd_parser* %97)
%99 = sext i8 %98 to i32
%100 = icmp eq i32 %99, 32
br i1 %100, label %101, label %104
101: ; preds = %96
%102 = load %struct.cymkd_parser*, %struct.cymkd_parser** %5
%103 = call i32 @consume(%struct.cymkd_parser* %102)
br label %96
104: ; preds = %96
%105 = load %struct.cymkd_parser*, %struct.cymkd_parser** %5
%106 = call i32 @text_and_inline(%struct.cymkd_parser* %105)
%107 = icmp ne i32 %106, 0
br i1 %107, label %109, label %108
108: ; preds = %104
store i32 0, i32* %4
br label %113
109: ; preds = %104
%110 = load %struct.cymkd_parser*, %struct.cymkd_parser** %5
%111 = call i32 @parser_emit_string(%struct.cymkd_parser* %110, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %4
br label %113
112: ; preds = %88
store i32 0, i32* %4
br label %113
113: ; preds = %112, %109, %108, %84, %76, %63
%114 = load i32, i32* %4
ret i32 %114
}

LLVM IR (-O2):
%struct.cymkd_parser = type { i32 }
@.str = [5 x i8] c"<li>\00"
@.str.1 = [6 x i8] c"</li>\00"
define i32 @unordered_list_line(%struct.cymkd_parser* %0, i32 %1, i8* %2) {
%4 = alloca [1024 x i8]
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%6 = tail call i32 @strlen(i8* %2)
%7 = sext i32 %6 to i64
%8 = call i32 @memset(i8* %5, i32 0, i32 1024)
%9 = call signext i8 @next(%struct.cymkd_parser* %0)
%10 = call i64 @isspace(i8 signext %9)
%11 = icmp eq i64 %10, 0
br i1 %11, label %23, label %12
12: ; preds = %3, %12
%13 = phi i64 [ %16, %12 ], [ 0, %3 ]
%14 = call i32 @consume(%struct.cymkd_parser* %0)
%15 = trunc i32 %14 to i8
%16 = add nuw nsw i64 %13, 1
%17 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 %13
store i8 %15, i8* %17
%18 = call signext i8 @next(%struct.cymkd_parser* %0)
%19 = call i64 @isspace(i8 signext %18)
%20 = icmp ne i64 %19, 0
%21 = icmp ult i64 %13, 1022
%22 = select i1 %20, i1 %21, i1 false
br i1 %22, label %12, label %23
23: ; preds = %12, %3
%24 = phi i64 [ 0, %3 ], [ %16, %12 ]
%25 = icmp eq i64 %24, %7
br i1 %25, label %52, label %26
26: ; preds = %23
%27 = call signext i8 @next(%struct.cymkd_parser* %0)
%28 = sext i8 %27 to i32
%29 = call i32 @strlen(i8* %5)
%30 = icmp sgt i32 %29, 0
br i1 %30, label %31, label %37
31: ; preds = %26, %31
%32 = phi i32 [ %34, %31 ], [ 0, %26 ]
%33 = call i32 @unconsume(%struct.cymkd_parser* %0)
%34 = add nuw nsw i32 %32, 1
%35 = call i32 @strlen(i8* %5)
%36 = icmp slt i32 %34, %35
br i1 %36, label %31, label %37
37: ; preds = %31, %26
%38 = call i64 @is_bullet(i32 %28)
%39 = icmp ne i64 %38, 0
%40 = icmp ugt i64 %24, %7
%41 = select i1 %39, i1 %40, i1 false
br i1 %41, label %42, label %44
42: ; preds = %37
%43 = call i32 @unordered_list_internal(%struct.cymkd_parser* %0, i32 %1, i8* %5)
br label %68
44: ; preds = %37
%45 = call i64 @isdigit(i32 %28)
%46 = icmp ne i64 %45, 0
%47 = select i1 %46, i1 %40, i1 false
br i1 %47, label %48, label %50
48: ; preds = %44
%49 = call i32 @ordered_list_internal(%struct.cymkd_parser* %0, i8* %5)
br label %68
50: ; preds = %44
%51 = icmp ult i64 %24, %7
br i1 %51, label %68, label %52
52: ; preds = %50, %23
%53 = call i64 @match(%struct.cymkd_parser* %0, i32 %1)
%54 = icmp eq i64 %53, 0
br i1 %54, label %68, label %55
55: ; preds = %52
%56 = call i32 @parser_emit_string(%struct.cymkd_parser* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%57 = call signext i8 @next(%struct.cymkd_parser* %0)
%58 = icmp eq i8 %57, 32
br i1 %58, label %59, label %63
59: ; preds = %55, %59
%60 = call i32 @consume(%struct.cymkd_parser* %0)
%61 = call signext i8 @next(%struct.cymkd_parser* %0)
%62 = icmp eq i8 %61, 32
br i1 %62, label %59, label %63
63: ; preds = %59, %55
%64 = call i32 @text_and_inline(%struct.cymkd_parser* %0)
%65 = icmp eq i32 %64, 0
br i1 %65, label %68, label %66
66: ; preds = %63
%67 = call i32 @parser_emit_string(%struct.cymkd_parser* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %68
68: ; preds = %52, %63, %50, %66, %48, %42
%69 = phi i32 [ %43, %42 ], [ %49, %48 ], [ 1, %66 ], [ 0, %50 ], [ 0, %63 ], [ 0, %52 ]
ret i32 %69
}