#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
char EOF;
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int onUrl(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int onList(FILE *out_fp, FILE *in_fp, const int sign) {
  int onUrlstate;
  char ch;
  if (sign == 1) {
    fprintf(out_fp, "<ul>\n");
  }
  if (sign == 1 || sign == 2) {
    fprintf(out_fp, "<li>");
    ch = fgetc(in_fp);
    while (ch != '\n' && ch != EOF) {
      if (ch == '[') {
        onUrlstate = onUrl(out_fp, in_fp);
        if (onUrlstate == 2 || onUrlstate == 4) {
          break;
        }
      } else {
        fprintf(out_fp, "%c", ch);
      }
      ch = fgetc(in_fp);
    }
    fprintf(out_fp, "</li>\n");
  }
  if (sign == 3) {
    fprintf(out_fp, "</ul>\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<onList>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
cmpl   $0x1,-0x14(%rbp)
jne    115f <onList+0x2f>
mov    -0x8(%rbp),%rdi
lea    0xea8(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
cmpl   $0x1,-0x14(%rbp)
je     1173 <onList+0x43>
cmpl   $0x2,-0x14(%rbp)
jne    123d <onList+0x10d>
mov    -0x8(%rbp),%rdi
lea    0xe88(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %al,-0x19(%rbp)
movsbl -0x19(%rbp),%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0x1a(%rbp)
je     11b9 <onList+0x89>
movsbl -0x19(%rbp),%eax
mov    0x2e3a(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
setne  %al
mov    %al,-0x1a(%rbp)
mov    -0x1a(%rbp),%al
test   $0x1,%al
jne    11c9 <onList+0x99>
jmp    122b <onList+0xfb>
movsbl -0x19(%rbp),%eax
cmp    $0x5b,%eax
jne    1204 <onList+0xd4>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <onUrl@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x2,-0x18(%rbp)
je     11fa <onList+0xca>
cmpl   $0x4,-0x18(%rbp)
jne    11ff <onList+0xcf>
jmp    122b <onList+0xfb>
jmp    121a <onList+0xea>
mov    -0x8(%rbp),%rdi
movsbl -0x19(%rbp),%edx
lea    0xdf8(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %al,-0x19(%rbp)
jmp    1191 <onList+0x61>
mov    -0x8(%rbp),%rdi
lea    0xdd8(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
cmpl   $0x3,-0x14(%rbp)
jne    1259 <onList+0x129>
mov    -0x8(%rbp),%rdi
lea    0xdc3(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<onList>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %rsi,%rbx
mov    %rdi,%r15
cmp    $0x1,%edx
jne    1171 <onList+0x31>
lea    0xea3(%rip),%rdi
mov    $0x5,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   1060 <fwrite@plt>
jmp    117e <onList+0x3e>
lea    -0x1(%r14),%eax
cmp    $0x1,%eax
ja     11ff <onList+0xbf>
lea    0xe81(%rip),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   1060 <fwrite@plt>
mov    %rbx,%rdi
call   1030 <fgetc@plt>
cmp    $0xa,%al
je     11e6 <onList+0xa6>
mov    0x2e3e(%rip),%r12
jmp    11c7 <onList+0x87>
nopl   0x0(%rax)
movsbl %al,%edi
mov    %r15,%rsi
call   1040 <fputc@plt>
mov    %rbx,%rdi
call   1030 <fgetc@plt>
cmp    $0xa,%al
je     11e6 <onList+0xa6>
cmp    (%r12),%al
je     11e6 <onList+0xa6>
cmp    $0x5b,%al
jne    11b0 <onList+0x70>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <onUrl@plt>
cmp    $0x2,%eax
je     11e6 <onList+0xa6>
cmp    $0x4,%eax
jne    11bb <onList+0x7b>
lea    0xe1e(%rip),%rdi
mov    $0x6,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   1060 <fwrite@plt>
cmp    $0x3,%r14d
jne    121e <onList+0xde>
lea    0xe06(%rip),%rdi
mov    $0x6,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   1060 <fwrite@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [6 x i8] c"<ul>\0A\00"
@.str.1 = [5 x i8] c"<li>\00"
@EOF = global i8 0
@.str.3 = [7 x i8] c"</li>\0A\00"
@.str.4 = [7 x i8] c"</ul>\0A\00"
define i32 @onList(i32* %0, i32* %1, i32 %2) {
%4 = icmp eq i32 %2, 1
br i1 %4, label %5, label %7
5: ; preds = %3
%6 = tail call i64 @fwrite(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i64 5, i64 1, i32* %0)
br label %10
7: ; preds = %3
%8 = add i32 %2, -1
%9 = icmp ult i32 %8, 2
br i1 %9, label %10, label %33
10: ; preds = %5, %7
%11 = tail call i64 @fwrite(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 4, i64 1, i32* %0)
%12 = tail call signext i8 @fgetc(i32* %1)
%13 = icmp ne i8 %12, 10
%14 = load i8, i8* @EOF
%15 = icmp ne i8 %12, %14
%16 = select i1 %13, i1 %15, i1 false
br i1 %16, label %17, label %31
17: ; preds = %10, %25
%18 = phi i8 [ %26, %25 ], [ %12, %10 ]
%19 = icmp eq i8 %18, 91
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = tail call i32 @onUrl(i32* %0, i32* %1)
switch i32 %21, label %25 [
i32 4, label %31
i32 2, label %31
]
22: ; preds = %17
%23 = sext i8 %18 to i32
%24 = tail call i32 @fputc(i32 %23, i32* %0)
br label %25
25: ; preds = %20, %22
%26 = tail call signext i8 @fgetc(i32* %1)
%27 = icmp ne i8 %26, 10
%28 = load i8, i8* @EOF
%29 = icmp ne i8 %26, %28
%30 = select i1 %27, i1 %29, i1 false
br i1 %30, label %17, label %31
31: ; preds = %25, %20, %20, %10
%32 = tail call i64 @fwrite(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i64 6, i64 1, i32* %0)
br label %33
33: ; preds = %7, %31
%34 = icmp eq i32 %2, 3
br i1 %34, label %35, label %37
35: ; preds = %33
%36 = tail call i64 @fwrite(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i64 6, i64 1, i32* %0)
br label %37
37: ; preds = %35, %33
ret i32 0
}