#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 */
scalar_t__ match(struct cymkd_parser *, char);
scalar_t__ next(struct cymkd_parser *);
int /*<<< orphan*/ parser_emit_string(struct cymkd_parser *, char *);
scalar_t__ unordered_list_line(struct cymkd_parser *, int, char const *);
bool unordered_list_internal(struct cymkd_parser *parser, int bullet,
                             const char *curr_indent) {
  parser_emit_string(parser, "<ul>");
  while (unordered_list_line(parser, bullet, curr_indent)) {
    while (match(parser, '\n') &&
           unordered_list_line(parser, bullet, curr_indent) &&
           next(parser) >= 0) {
      ;
    }
  }
  parser_emit_string(parser, "</ul>");
  return true;
}


x86 assembly (clang, -O0):
<unordered_list_internal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xea2(%rip),%rsi
call   1050 <parser_emit_string@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rdx
call   1040 <unordered_list_line@plt>
cmp    $0x0,%rax
je     11f1 <unordered_list_internal+0xb1>
jmp    1182 <unordered_list_internal+0x42>
mov    -0x8(%rbp),%rdi
mov    $0xa,%esi
call   1060 <match@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x19(%rbp)
je     11d7 <unordered_list_internal+0x97>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rdx
call   1040 <unordered_list_line@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x19(%rbp)
je     11d7 <unordered_list_internal+0x97>
mov    -0x8(%rbp),%rdi
call   1030 <next@plt>
cmp    $0x0,%rax
setge  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    11e7 <unordered_list_internal+0xa7>
jmp    11ec <unordered_list_internal+0xac>
jmp    1182 <unordered_list_internal+0x42>
jmp    1163 <unordered_list_internal+0x23>
mov    -0x8(%rbp),%rdi
lea    0xe09(%rip),%rsi
call   1050 <parser_emit_string@plt>
mov    $0x1,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<unordered_list_internal>:
push   %rbp
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %esi,%ebp
mov    %rdi,%rbx
lea    0xead(%rip),%rsi
call   1050 <parser_emit_string@plt>
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r14,%rdx
call   1040 <unordered_list_line@plt>
test   %rax,%rax
je     11a5 <unordered_list_internal+0x65>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1060 <match@plt>
test   %rax,%rax
je     1160 <unordered_list_internal+0x20>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r14,%rdx
call   1040 <unordered_list_line@plt>
test   %rax,%rax
je     1160 <unordered_list_internal+0x20>
mov    %rbx,%rdi
call   1030 <next@plt>
test   %rax,%rax
jns    1172 <unordered_list_internal+0x32>
jmp    1160 <unordered_list_internal+0x20>
lea    0xe59(%rip),%rsi
mov    %rbx,%rdi
call   1050 <parser_emit_string@plt>
mov    $0x1,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.cymkd_parser = type { i32 }
@.str = [5 x i8] c"<ul>\00"
@.str.1 = [6 x i8] c"</ul>\00"
define i32 @unordered_list_internal(%struct.cymkd_parser* %0, i32 %1, i8* %2) {
%4 = alloca %struct.cymkd_parser*
%5 = alloca i32
%6 = alloca i8*
store %struct.cymkd_parser* %0, %struct.cymkd_parser** %4
store i32 %1, i32* %5
store i8* %2, i8** %6
%7 = load %struct.cymkd_parser*, %struct.cymkd_parser** %4
%8 = call i32 @parser_emit_string(%struct.cymkd_parser* %7, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %9
9: ; preds = %33, %3
%10 = load %struct.cymkd_parser*, %struct.cymkd_parser** %4
%11 = load i32, i32* %5
%12 = load i8*, i8** %6
%13 = call i64 @unordered_list_line(%struct.cymkd_parser* %10, i32 %11, i8* %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %34
15: ; preds = %9
br label %16
16: ; preds = %32, %15
%17 = load %struct.cymkd_parser*, %struct.cymkd_parser** %4
%18 = call i64 @match(%struct.cymkd_parser* %17, i8 signext 10)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %30
20: ; preds = %16
%21 = load %struct.cymkd_parser*, %struct.cymkd_parser** %4
%22 = load i32, i32* %5
%23 = load i8*, i8** %6
%24 = call i64 @unordered_list_line(%struct.cymkd_parser* %21, i32 %22, i8* %23)
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %30
26: ; preds = %20
%27 = load %struct.cymkd_parser*, %struct.cymkd_parser** %4
%28 = call i64 @next(%struct.cymkd_parser* %27)
%29 = icmp sge i64 %28, 0
br label %30
30: ; preds = %26, %20, %16
%31 = phi i1 [ false, %20 ], [ false, %16 ], [ %29, %26 ]
br i1 %31, label %32, label %33
32: ; preds = %30
br label %16
33: ; preds = %30
br label %9
34: ; preds = %9
%35 = load %struct.cymkd_parser*, %struct.cymkd_parser** %4
%36 = call i32 @parser_emit_string(%struct.cymkd_parser* %35, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
ret i32 1
}

LLVM IR (-O2):
%struct.cymkd_parser = type { i32 }
@.str = [5 x i8] c"<ul>\00"
@.str.1 = [6 x i8] c"</ul>\00"
define i32 @unordered_list_internal(%struct.cymkd_parser* %0, i32 %1, i8* %2) {
%4 = tail call i32 @parser_emit_string(%struct.cymkd_parser* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%5 = tail call i64 @unordered_list_line(%struct.cymkd_parser* %0, i32 %1, i8* %2)
%6 = icmp eq i64 %5, 0
br i1 %6, label %20, label %7
7: ; preds = %3, %16
%8 = tail call i64 @match(%struct.cymkd_parser* %0, i8 signext 10)
%9 = icmp eq i64 %8, 0
br i1 %9, label %17, label %10
10: ; preds = %7
%11 = tail call i64 @unordered_list_line(%struct.cymkd_parser* %0, i32 %1, i8* %2)
%12 = icmp eq i64 %11, 0
br i1 %12, label %17, label %13
13: ; preds = %10
%14 = tail call i64 @next(%struct.cymkd_parser* %0)
%15 = icmp sgt i64 %14, -1
br i1 %15, label %16, label %17
16: ; preds = %13, %17
br label %7
17: ; preds = %7, %10, %13
%18 = tail call i64 @unordered_list_line(%struct.cymkd_parser* %0, i32 %1, i8* %2)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %16
20: ; preds = %17, %3
%21 = tail call i32 @parser_emit_string(%struct.cymkd_parser* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
ret i32 1
}