#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 /*<<< orphan*/ fputc(char, int /*<<< orphan*/ *);
int onBold(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int onList(int /*<<< orphan*/ *, int /*<<< orphan*/ *, int const);
int onAster(FILE *out_fp, FILE *in_fp, const int sign) {
  int state, i = 0;
  char ch, content[1000];
  ch = fgetc(in_fp);
  if (ch == ' ') {
    state = onList(out_fp, in_fp, sign);
    if (state == 0) {
      return -3;
    } else {
      return state;
    }
  } else if (ch == '*') {
    fputc('\n', out_fp);
    state = onBold(out_fp, in_fp);
    if (state == 0) {
      return -1;
    } else {
      return state;
    }
  } else if (ch == '\n') {
    fprintf(out_fp, "<p>*</p>\n");
  }
  content[i++] = ch;
  while ((ch = fgetc(in_fp)) != EOF) {
    if (ch == '*' || ch == '\n' || i > 999) {
      break;
    }
    content[i++] = ch;
  }
  content[i] = '\0';
  if (ch != '*') {
    if (ch == '\n') {
      fprintf(out_fp, "<p>*%s</p>\n", content);
    } else {
      fprintf(out_fp, "<p>*%s%c", content, ch);
    }
    return 10;
  }
  fprintf(out_fp, "<p><i>%s</i>", content);
  return -2;
}


x86 assembly (clang, -O0):
<onAster>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %al,-0x25(%rbp)
movsbl -0x25(%rbp),%eax
cmp    $0x20,%eax
jne    11ba <onAster+0x6a>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1070 <onList@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jne    11af <onAster+0x5f>
movl   $0xfffffffd,-0x4(%rbp)
jmp    133c <onAster+0x1ec>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    133c <onAster+0x1ec>
movsbl -0x25(%rbp),%eax
cmp    $0x2a,%eax
jne    1206 <onAster+0xb6>
mov    -0x10(%rbp),%rsi
mov    $0xa,%edi
call   1050 <fputc@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <onBold@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jne    11fb <onAster+0xab>
movl   $0xffffffff,-0x4(%rbp)
jmp    133c <onAster+0x1ec>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    133c <onAster+0x1ec>
movsbl -0x25(%rbp),%eax
cmp    $0xa,%eax
jne    1225 <onAster+0xd5>
mov    -0x10(%rbp),%rdi
lea    0xde2(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    122a <onAster+0xda>
jmp    122f <onAster+0xdf>
mov    -0x25(%rbp),%cl
mov    -0x24(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x24(%rbp)
cltq
mov    %cl,-0x410(%rbp,%rax,1)
mov    -0x18(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %al,-0x25(%rbp)
movsbl %al,%eax
mov    0x2d8c(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     12af <onAster+0x15f>
movsbl -0x25(%rbp),%eax
cmp    $0x2a,%eax
je     128e <onAster+0x13e>
movsbl -0x25(%rbp),%eax
cmp    $0xa,%eax
je     128e <onAster+0x13e>
cmpl   $0x3e7,-0x24(%rbp)
jle    1293 <onAster+0x143>
jmp    12af <onAster+0x15f>
mov    -0x25(%rbp),%cl
mov    -0x24(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x24(%rbp)
cltq
mov    %cl,-0x410(%rbp,%rax,1)
jmp    1246 <onAster+0xf6>
movslq -0x24(%rbp),%rax
movb   $0x0,-0x410(%rbp,%rax,1)
movsbl -0x25(%rbp),%eax
cmp    $0x2a,%eax
je     131c <onAster+0x1cc>
movsbl -0x25(%rbp),%eax
cmp    $0xa,%eax
jne    12f3 <onAster+0x1a3>
mov    -0x10(%rbp),%rdi
lea    -0x410(%rbp),%rdx
lea    0xd23(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    1310 <onAster+0x1c0>
mov    -0x10(%rbp),%rdi
lea    -0x410(%rbp),%rdx
movsbl -0x25(%rbp),%ecx
lea    0xd0d(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0xa,-0x4(%rbp)
jmp    133c <onAster+0x1ec>
mov    -0x10(%rbp),%rdi
lea    -0x410(%rbp),%rdx
lea    0xcf1(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0xfffffffe,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<onAster>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x3e8,%rsp
mov    %edx,%ebp
mov    %rsi,%r15
mov    %rdi,%r14
mov    %rsi,%rdi
call   1040 <fgetc@plt>
mov    %eax,%ebx
cmp    $0xa,%al
je     11af <onAster+0x4f>
cmp    $0x2a,%bl
je     123b <onAster+0xdb>
cmp    $0x20,%bl
jne    11c8 <onAster+0x68>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
call   1070 <onList@plt>
mov    %eax,%ecx
test   %eax,%eax
mov    $0xfffffffd,%eax
cmovne %ecx,%eax
jmp    1295 <onAster+0x135>
lea    0xe4a(%rip),%rdi
mov    $0x9,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1080 <fwrite@plt>
mov    %bl,(%rsp)
mov    %r15,%rdi
call   1040 <fgetc@plt>
mov    0x2e0e(%rip),%rbp
mov    $0x1,%ebx
cmp    0x0(%rbp),%al
je     1217 <onAster+0xb7>
mov    $0x1,%ebx
nopl   0x0(%rax)
mov    %eax,%ecx
and    $0xdf,%cl
cmp    $0xa,%cl
je     1217 <onAster+0xb7>
cmp    $0x3e7,%rbx
ja     1217 <onAster+0xb7>
mov    %al,(%rsp,%rbx,1)
add    $0x1,%rbx
mov    %r15,%rdi
call   1040 <fgetc@plt>
cmp    0x0(%rbp),%al
jne    11f0 <onAster+0x90>
mov    %ebx,%ecx
movb   $0x0,(%rsp,%rcx,1)
cmp    $0x2a,%al
je     125e <onAster+0xfe>
cmp    $0xa,%al
jne    1279 <onAster+0x119>
lea    0xdde(%rip),%rsi
mov    %rsp,%rdx
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <fprintf@plt>
jmp    1290 <onAster+0x130>
mov    $0xa,%edi
mov    %r14,%rsi
call   1050 <fputc@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <onBold@plt>
mov    %eax,%ecx
cmp    $0x1,%eax
sbb    %eax,%eax
or     %ecx,%eax
jmp    1295 <onAster+0x135>
lea    0xdba(%rip),%rsi
mov    %rsp,%rdx
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0xfffffffe,%eax
jmp    1295 <onAster+0x135>
movsbl %al,%ecx
lea    0xd93(%rip),%rsi
mov    %rsp,%rdx
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0xa,%eax
add    $0x3e8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"<p>*</p>\0A\00"
@EOF = global i8 0
@.str.1 = [12 x i8] c"<p>*%s</p>\0A\00"
@.str.2 = [9 x i8] c"<p>*%s%c\00"
@.str.3 = [13 x i8] c"<p><i>%s</i>\00"
define i32 @onAster(i32* %0, i32* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8
%11 = alloca [1000 x i8]
store i32* %0, i32** %5
store i32* %1, i32** %6
store i32 %2, i32* %7
store i32 0, i32* %9
%12 = load i32*, i32** %6
%13 = call signext i8 @fgetc(i32* %12)
store i8 %13, i8* %10
%14 = load i8, i8* %10
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 32
br i1 %16, label %17, label %27
17: ; preds = %3
%18 = load i32*, i32** %5
%19 = load i32*, i32** %6
%20 = load i32, i32* %7
%21 = call i32 @onList(i32* %18, i32* %19, i32 %20)
store i32 %21, i32* %8
%22 = load i32, i32* %8
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %17
store i32 -3, i32* %4
br label %108
25: ; preds = %17
%26 = load i32, i32* %8
store i32 %26, i32* %4
br label %108
27: ; preds = %3
%28 = load i8, i8* %10
%29 = sext i8 %28 to i32
%30 = icmp eq i32 %29, 42
br i1 %30, label %31, label %42
31: ; preds = %27
%32 = load i32*, i32** %5
%33 = call i32 @fputc(i8 signext 10, i32* %32)
%34 = load i32*, i32** %5
%35 = load i32*, i32** %6
%36 = call i32 @onBold(i32* %34, i32* %35)
store i32 %36, i32* %8
%37 = load i32, i32* %8
%38 = icmp eq i32 %37, 0
br i1 %38, label %39, label %40
39: ; preds = %31
store i32 -1, i32* %4
br label %108
40: ; preds = %31
%41 = load i32, i32* %8
store i32 %41, i32* %4
br label %108
42: ; preds = %27
%43 = load i8, i8* %10
%44 = sext i8 %43 to i32
%45 = icmp eq i32 %44, 10
br i1 %45, label %46, label %49
46: ; preds = %42
%47 = load i32*, i32** %5
%48 = call i32 (i32*, i8*, ...) @fprintf(i32* %47, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
br label %49
49: ; preds = %46, %42
br label %50
50: ; preds = %49
br label %51
51: ; preds = %50
%52 = load i8, i8* %10
%53 = load i32, i32* %9
%54 = add nsw i32 %53, 1
store i32 %54, i32* %9
%55 = sext i32 %53 to i64
%56 = getelementptr inbounds [1000 x i8], [1000 x i8]* %11, i64 0, i64 %55
store i8 %52, i8* %56
br label %57
57: ; preds = %76, %51
%58 = load i32*, i32** %6
%59 = call signext i8 @fgetc(i32* %58)
store i8 %59, i8* %10
%60 = sext i8 %59 to i32
%61 = load i8, i8* @EOF
%62 = sext i8 %61 to i32
%63 = icmp ne i32 %60, %62
br i1 %63, label %64, label %82
64: ; preds = %57
%65 = load i8, i8* %10
%66 = sext i8 %65 to i32
%67 = icmp eq i32 %66, 42
br i1 %67, label %75, label %68
68: ; preds = %64
%69 = load i8, i8* %10
%70 = sext i8 %69 to i32
%71 = icmp eq i32 %70, 10
br i1 %71, label %75, label %72
72: ; preds = %68
%73 = load i32, i32* %9
%74 = icmp sgt i32 %73, 999
br i1 %74, label %75, label %76
75: ; preds = %72, %68, %64
br label %82
76: ; preds = %72
%77 = load i8, i8* %10
%78 = load i32, i32* %9
%79 = add nsw i32 %78, 1
store i32 %79, i32* %9
%80 = sext i32 %78 to i64
%81 = getelementptr inbounds [1000 x i8], [1000 x i8]* %11, i64 0, i64 %80
store i8 %77, i8* %81
br label %57
82: ; preds = %75, %57
%83 = load i32, i32* %9
%84 = sext i32 %83 to i64
%85 = getelementptr inbounds [1000 x i8], [1000 x i8]* %11, i64 0, i64 %84
store i8 0, i8* %85
%86 = load i8, i8* %10
%87 = sext i8 %86 to i32
%88 = icmp ne i32 %87, 42
br i1 %88, label %89, label %104
89: ; preds = %82
%90 = load i8, i8* %10
%91 = sext i8 %90 to i32
%92 = icmp eq i32 %91, 10
br i1 %92, label %93, label %97
93: ; preds = %89
%94 = load i32*, i32** %5
%95 = getelementptr inbounds [1000 x i8], [1000 x i8]* %11, i64 0, i64 0
%96 = call i32 (i32*, i8*, ...) @fprintf(i32* %94, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %95)
br label %103
97: ; preds = %89
%98 = load i32*, i32** %5
%99 = getelementptr inbounds [1000 x i8], [1000 x i8]* %11, i64 0, i64 0
%100 = load i8, i8* %10
%101 = sext i8 %100 to i32
%102 = call i32 (i32*, i8*, ...) @fprintf(i32* %98, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %99, i32 %101)
br label %103
103: ; preds = %97, %93
store i32 10, i32* %4
br label %108
104: ; preds = %82
%105 = load i32*, i32** %5
%106 = getelementptr inbounds [1000 x i8], [1000 x i8]* %11, i64 0, i64 0
%107 = call i32 (i32*, i8*, ...) @fprintf(i32* %105, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* %106)
store i32 -2, i32* %4
br label %108
108: ; preds = %104, %103, %40, %39, %25, %24
%109 = load i32, i32* %4
ret i32 %109
}

LLVM IR (-O2):
@.str = [10 x i8] c"<p>*</p>\0A\00"
@EOF = global i8 0
@.str.1 = [12 x i8] c"<p>*%s</p>\0A\00"
@.str.2 = [9 x i8] c"<p>*%s%c\00"
@.str.3 = [13 x i8] c"<p><i>%s</i>\00"
define i32 @onAster(i32* %0, i32* %1, i32 %2) {
%4 = alloca [1000 x i8]
%5 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%6 = tail call signext i8 @fgetc(i32* %1)
switch i8 %6, label %18 [
i8 32, label %7
i8 42, label %11
i8 10, label %16
]
7: ; preds = %3
%8 = tail call i32 @onList(i32* %0, i32* %1, i32 %2)
%9 = icmp eq i32 %8, 0
%10 = select i1 %9, i32 -3, i32 %8
br label %51
11: ; preds = %3
%12 = tail call i32 @fputc(i8 signext 10, i32* %0)
%13 = tail call i32 @onBold(i32* %0, i32* %1)
%14 = icmp eq i32 %13, 0
%15 = select i1 %14, i32 -1, i32 %13
br label %51
16: ; preds = %3
%17 = tail call i64 @fwrite(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i64 9, i64 1, i32* %0)
br label %18
18: ; preds = %3, %16
store i8 %6, i8* %5
%19 = tail call signext i8 @fgetc(i32* %1)
%20 = load i8, i8* @EOF
%21 = icmp eq i8 %19, %20
br i1 %21, label %39, label %22
22: ; preds = %18, %30
%23 = phi i64 [ %31, %30 ], [ 1, %18 ]
%24 = phi i8 [ %34, %30 ], [ %19, %18 ]
%25 = phi i32 [ %32, %30 ], [ 1, %18 ]
%26 = and i8 %24, -33
%27 = icmp eq i8 %26, 10
%28 = icmp ugt i64 %23, 999
%29 = select i1 %27, i1 true, i1 %28
br i1 %29, label %37, label %30
30: ; preds = %22
%31 = add nuw nsw i64 %23, 1
%32 = add nuw nsw i32 %25, 1
%33 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 %23
store i8 %24, i8* %33
%34 = tail call signext i8 @fgetc(i32* %1)
%35 = load i8, i8* @EOF
%36 = icmp eq i8 %34, %35
br i1 %36, label %39, label %22
37: ; preds = %22
%38 = trunc i64 %23 to i32
br label %39
39: ; preds = %30, %37, %18
%40 = phi i8 [ %19, %18 ], [ %24, %37 ], [ %34, %30 ]
%41 = phi i32 [ 1, %18 ], [ %38, %37 ], [ %32, %30 ]
%42 = zext i32 %41 to i64
%43 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 %42
store i8 0, i8* %43
switch i8 %40, label %46 [
i8 42, label %49
i8 10, label %44
]
44: ; preds = %39
%45 = call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %5)
br label %51
46: ; preds = %39
%47 = sext i8 %40 to i32
%48 = call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %5, i32 %47)
br label %51
49: ; preds = %39
%50 = call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* %5)
br label %51
51: ; preds = %44, %46, %11, %7, %49
%52 = phi i32 [ -2, %49 ], [ %10, %7 ], [ %15, %11 ], [ 10, %46 ], [ 10, %44 ]
ret i32 %52
}