#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 */
int /*<<< orphan*/ printBuffer(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ putc(char, int /*<<< orphan*/);
int /*<<< orphan*/ stdout;
void handleListItem(int length) {
  extern char BUFFER[];
  int i, identified;
  printf("<li");
  i = 1;
  identified = BUFFER[i] == ':' ? 1 : 0;
  if (identified) {
    printf(" id=\"");
    for (i++; BUFFER[i] != ':' && BUFFER[i] != '\0'; ++i)
      putc(BUFFER[i], stdout);
    printf("\"");
    i++;
  }
  printf(">\n");
  int j;
  for (j = 0; i < length && BUFFER[i] != '\0'; ++i, ++j) {
    BUFFER[j] = BUFFER[i];
  }
  BUFFER[j] = '\0';
  printBuffer(j);
  printf("\n</li>\n");
}


x86 assembly (clang, -O0):
<handleListItem>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
lea    0xebe(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x8(%rbp)
movslq -0x8(%rbp),%rcx
mov    0x2e8f(%rip),%rax
movsbl (%rax,%rcx,1),%edx
xor    %eax,%eax
mov    $0x1,%ecx
cmp    $0x3a,%edx
cmove  %ecx,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     1213 <handleListItem+0xe3>
lea    0xe86(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
movslq -0x8(%rbp),%rcx
mov    0x2e51(%rip),%rax
movsbl (%rax,%rcx,1),%ecx
xor    %eax,%eax
cmp    $0x3a,%ecx
mov    %al,-0x11(%rbp)
je     11c1 <handleListItem+0x91>
movslq -0x8(%rbp),%rcx
mov    0x2e34(%rip),%rax
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    11d1 <handleListItem+0xa1>
jmp    11fe <handleListItem+0xce>
movslq -0x8(%rbp),%rcx
mov    0x2e0c(%rip),%rax
mov    (%rax,%rcx,1),%al
mov    0x2df2(%rip),%rcx
mov    (%rcx),%esi
movsbl %al,%edi
call   1040 <putc@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    118c <handleListItem+0x5c>
lea    0xe03(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
lea    0xdf5(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%ecx
xor    %eax,%eax
cmp    -0x4(%rbp),%ecx
mov    %al,-0x12(%rbp)
jge    124f <handleListItem+0x11f>
movslq -0x8(%rbp),%rcx
mov    0x2da6(%rip),%rax
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x12(%rbp)
mov    -0x12(%rbp),%al
test   $0x1,%al
jne    125f <handleListItem+0x12f>
jmp    1292 <handleListItem+0x162>
movslq -0x8(%rbp),%rcx
mov    0x2d7e(%rip),%rax
mov    (%rax,%rcx,1),%dl
movslq -0x10(%rbp),%rcx
mov    0x2d70(%rip),%rax
mov    %dl,(%rax,%rcx,1)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1226 <handleListItem+0xf6>
movslq -0x10(%rbp),%rcx
mov    0x2d4b(%rip),%rax
movb   $0x0,(%rax,%rcx,1)
mov    -0x10(%rbp),%edi
call   1050 <printBuffer@plt>
lea    0xd5a(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<handleListItem>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %edi,%r15d
lea    0xe9e(%rip),%rdi
call   1050 <printf@plt>
mov    0x2e7a(%rip),%r14
mov    $0x1,%ebx
cmpb   $0x3a,0x1(%r14)
jne    11cc <handleListItem+0x7c>
lea    0xe83(%rip),%rdi
call   1050 <printf@plt>
mov    $0x2,%ebx
mov    0x2e46(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movzbl (%r14,%rbx,1),%eax
test   %al,%al
je     11bf <handleListItem+0x6f>
cmp    $0x3a,%al
je     11bf <handleListItem+0x6f>
mov    (%r12),%esi
movsbl %al,%edi
call   1060 <putc@plt>
add    $0x1,%rbx
jmp    11a0 <handleListItem+0x50>
mov    $0x22,%edi
call   1030 <putchar@plt>
add    $0x1,%ebx
lea    0xe3c(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
cmp    %r15d,%ebx
jge    1208 <handleListItem+0xb8>
movslq %ebx,%rax
sub    %ebx,%r15d
add    0x2dfc(%rip),%rax
xor    %edi,%edi
xchg   %ax,%ax
movzbl (%rax,%rdi,1),%ecx
test   %cl,%cl
je     1208 <handleListItem+0xb8>
mov    %cl,(%r14,%rdi,1)
add    $0x1,%rdi
cmp    %rdi,%r15
jne    11f0 <handleListItem+0xa0>
mov    %r15d,%edi
mov    %edi,%eax
movb   $0x0,(%r14,%rax,1)
call   1070 <printBuffer@plt>
lea    0xdef(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1040 <puts@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"<li\00"
@BUFFER = external global [0 x i8]
@.str.1 = [6 x i8] c" id=\22\00"
@stdout = global i32 0
@.str.2 = [2 x i8] c"\22\00"
@.str.3 = [3 x i8] c">\0A\00"
@.str.4 = [8 x i8] c"\0A</li>\0A\00"
define void @handleListItem(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %2
%6 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
%7 = load i32, i32* %3
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds [0 x i8], [0 x i8]* @BUFFER, i64 0, i64 %8
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp eq i32 %11, 58
%13 = zext i1 %12 to i64
%14 = select i1 %12, i32 1, i32 0
store i32 %14, i32* %4
%15 = load i32, i32* %4
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %51
17: ; preds = %1
%18 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%19 = load i32, i32* %3
%20 = add nsw i32 %19, 1
store i32 %20, i32* %3
br label %21
21: ; preds = %44, %17
%22 = load i32, i32* %3
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [0 x i8], [0 x i8]* @BUFFER, i64 0, i64 %23
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp ne i32 %26, 58
br i1 %27, label %28, label %35
28: ; preds = %21
%29 = load i32, i32* %3
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [0 x i8], [0 x i8]* @BUFFER, i64 0, i64 %30
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp ne i32 %33, 0
br label %35
35: ; preds = %28, %21
%36 = phi i1 [ false, %21 ], [ %34, %28 ]
br i1 %36, label %37, label %47
37: ; preds = %35
%38 = load i32, i32* %3
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [0 x i8], [0 x i8]* @BUFFER, i64 0, i64 %39
%41 = load i8, i8* %40
%42 = load i32, i32* @stdout
%43 = call i32 @putc(i8 signext %41, i32 %42)
br label %44
44: ; preds = %37
%45 = load i32, i32* %3
%46 = add nsw i32 %45, 1
store i32 %46, i32* %3
br label %21
47: ; preds = %35
%48 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%49 = load i32, i32* %3
%50 = add nsw i32 %49, 1
store i32 %50, i32* %3
br label %51
51: ; preds = %47, %1
%52 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %5
br label %53
53: ; preds = %74, %51
%54 = load i32, i32* %3
%55 = load i32, i32* %2
%56 = icmp slt i32 %54, %55
br i1 %56, label %57, label %64
57: ; preds = %53
%58 = load i32, i32* %3
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds [0 x i8], [0 x i8]* @BUFFER, i64 0, i64 %59
%61 = load i8, i8* %60
%62 = sext i8 %61 to i32
%63 = icmp ne i32 %62, 0
br label %64
64: ; preds = %57, %53
%65 = phi i1 [ false, %53 ], [ %63, %57 ]
br i1 %65, label %66, label %79
66: ; preds = %64
%67 = load i32, i32* %3
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds [0 x i8], [0 x i8]* @BUFFER, i64 0, i64 %68
%70 = load i8, i8* %69
%71 = load i32, i32* %5
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds [0 x i8], [0 x i8]* @BUFFER, i64 0, i64 %72
store i8 %70, i8* %73
br label %74
74: ; preds = %66
%75 = load i32, i32* %3
%76 = add nsw i32 %75, 1
store i32 %76, i32* %3
%77 = load i32, i32* %5
%78 = add nsw i32 %77, 1
store i32 %78, i32* %5
br label %53
79: ; preds = %64
%80 = load i32, i32* %5
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds [0 x i8], [0 x i8]* @BUFFER, i64 0, i64 %81
store i8 0, i8* %82
%83 = load i32, i32* %5
%84 = call i32 @printBuffer(i32 %83)
%85 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"<li\00"
@BUFFER = external global [0 x i8]
@.str.1 = [6 x i8] c" id=\22\00"
@stdout = global i32 0
@str = [2 x i8] c">\00"
@str.5 = [7 x i8] c"\0A</li>\00"
define void @handleListItem(i32 %0) {
%2 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%3 = load i8, i8* getelementptr inbounds ([0 x i8], [0 x i8]* @BUFFER, i64 0, i64 1)
%4 = icmp eq i8 %3, 58
br i1 %4, label %5, label %19
5: ; preds = %1
%6 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %7
7: ; preds = %11, %5
%8 = phi i64 [ %14, %11 ], [ 2, %5 ]
%9 = getelementptr inbounds [0 x i8], [0 x i8]* @BUFFER, i64 0, i64 %8
%10 = load i8, i8* %9
switch i8 %10, label %11 [
i8 58, label %15
i8 0, label %15
]
11: ; preds = %7
%12 = load i32, i32* @stdout
%13 = tail call i32 @putc(i8 signext %10, i32 %12)
%14 = add nuw i64 %8, 1
br label %7
15: ; preds = %7, %7
%16 = trunc i64 %8 to i32
%17 = tail call i32 @putchar(i32 34)
%18 = add nuw nsw i32 %16, 1
br label %19
19: ; preds = %15, %1
%20 = phi i32 [ %18, %15 ], [ 1, %1 ]
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
%22 = icmp slt i32 %20, %0
br i1 %22, label %23, label %40
23: ; preds = %19
%24 = sext i32 %20 to i64
%25 = sub i32 %0, %20
%26 = zext i32 %25 to i64
br label %27
27: ; preds = %23, %33
%28 = phi i64 [ %24, %23 ], [ %35, %33 ]
%29 = phi i64 [ 0, %23 ], [ %36, %33 ]
%30 = getelementptr inbounds [0 x i8], [0 x i8]* @BUFFER, i64 0, i64 %28
%31 = load i8, i8* %30
%32 = icmp eq i8 %31, 0
br i1 %32, label %38, label %33
33: ; preds = %27
%34 = getelementptr inbounds [0 x i8], [0 x i8]* @BUFFER, i64 0, i64 %29
store i8 %31, i8* %34
%35 = add nsw i64 %28, 1
%36 = add nuw nsw i64 %29, 1
%37 = icmp eq i64 %36, %26
br i1 %37, label %40, label %27
38: ; preds = %27
%39 = trunc i64 %29 to i32
br label %40
40: ; preds = %33, %38, %19
%41 = phi i32 [ 0, %19 ], [ %39, %38 ], [ %25, %33 ]
%42 = zext i32 %41 to i64
%43 = getelementptr inbounds [0 x i8], [0 x i8]* @BUFFER, i64 0, i64 %42
store i8 0, i8* %43
%44 = tail call i32 @printBuffer(i32 %41)
%45 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str.5, i64 0, i64 0))
ret void
}