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


x86 assembly (clang, -O0):
<onIorB>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %al,-0x25(%rbp)
movsbl -0x25(%rbp),%eax
cmp    $0x2a,%eax
jne    1194 <onIorB+0x64>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <onBold@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
je     1188 <onIorB+0x58>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    12e3 <onIorB+0x1b3>
movl   $0xffffffff,-0x4(%rbp)
jmp    12e3 <onIorB+0x1b3>
movsbl -0x25(%rbp),%eax
cmp    $0x20,%eax
jne    11ad <onIorB+0x7d>
movl   $0x1,-0x24(%rbp)
jmp    11cb <onIorB+0x9b>
movl   $0x0,-0x24(%rbp)
mov    -0x25(%rbp),%cl
mov    -0x1c(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x1c(%rbp)
cltq
mov    %cl,-0x410(%rbp,%rax,1)
jmp    11d0 <onIorB+0xa0>
cmpl   $0x0,-0x24(%rbp)
je     1213 <onIorB+0xe3>
jmp    11df <onIorB+0xaf>
mov    -0x18(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %al,-0x25(%rbp)
movsbl %al,%eax
cmp    $0x20,%eax
jne    11fc <onIorB+0xcc>
jmp    11df <onIorB+0xaf>
mov    -0x25(%rbp),%cl
mov    -0x1c(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x1c(%rbp)
cltq
mov    %cl,-0x410(%rbp,%rax,1)
jmp    1218 <onIorB+0xe8>
mov    -0x18(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %al,-0x25(%rbp)
movsbl %al,%eax
mov    0x2dba(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1281 <onIorB+0x151>
movsbl -0x25(%rbp),%eax
cmp    $0x2a,%eax
je     1260 <onIorB+0x130>
movsbl -0x25(%rbp),%eax
cmp    $0xa,%eax
je     1260 <onIorB+0x130>
cmpl   $0x3e7,-0x1c(%rbp)
jle    1265 <onIorB+0x135>
jmp    1281 <onIorB+0x151>
mov    -0x25(%rbp),%cl
mov    -0x1c(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x1c(%rbp)
cltq
mov    %cl,-0x410(%rbp,%rax,1)
jmp    1218 <onIorB+0xe8>
movslq -0x1c(%rbp),%rax
movb   $0x0,-0x410(%rbp,%rax,1)
movsbl -0x25(%rbp),%eax
cmp    $0x2a,%eax
je     12c3 <onIorB+0x193>
mov    -0x10(%rbp),%rdi
lea    -0x410(%rbp),%rdx
movsbl -0x25(%rbp),%ecx
lea    0xd50(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0xa,-0x4(%rbp)
jmp    12e3 <onIorB+0x1b3>
mov    -0x10(%rbp),%rdi
lea    -0x410(%rbp),%rdx
lea    0xd31(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0xfffffffe,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<onIorB>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x3e8,%rsp
mov    %rsi,%r15
mov    %rdi,%r14
mov    %rsi,%rdi
call   1040 <fgetc@plt>
cmp    $0x2a,%al
je     11ed <onIorB+0xbd>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmp    $0x20,%al
jne    1170 <onIorB+0x40>
mov    %r15,%rdi
call   1040 <fgetc@plt>
cmp    $0x20,%al
je     1164 <onIorB+0x34>
mov    %al,(%rsp)
mov    %r15,%rdi
call   1040 <fgetc@plt>
mov    0x2e66(%rip),%r12
mov    $0x1,%ebx
cmp    (%r12),%al
je     11c8 <onIorB+0x98>
mov    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %eax,%ecx
and    $0xdf,%cl
cmp    $0xa,%cl
je     11c8 <onIorB+0x98>
cmp    $0x3e7,%rbx
ja     11c8 <onIorB+0x98>
mov    %al,(%rsp,%rbx,1)
add    $0x1,%rbx
mov    %r15,%rdi
call   1040 <fgetc@plt>
cmp    (%r12),%al
jne    11a0 <onIorB+0x70>
mov    %ebx,%ecx
movb   $0x0,(%rsp,%rcx,1)
cmp    $0x2a,%al
jne    1203 <onIorB+0xd3>
lea    0xe2d(%rip),%rsi
mov    %rsp,%rdx
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0xfffffffe,%eax
jmp    121f <onIorB+0xef>
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <onBold@plt>
mov    %eax,%ecx
cmp    $0x1,%eax
sbb    %eax,%eax
or     %ecx,%eax
jmp    121f <onIorB+0xef>
movsbl %al,%ecx
lea    0xdf3(%rip),%rsi
mov    %rsp,%rdx
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0xa,%eax
add    $0x3e8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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