#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(FILE *out_fp, FILE *in_fp) {
  int i = 0;
  char ch, content[1000];
  while ((ch = fgetc(in_fp)) == ' ') {
  }
  if (ch == '*') {
    ch = fgetc(in_fp);
    if (ch == '*') {
      fprintf(out_fp, "<strong></strong>");
      return 1;
    } else {
      fprintf(out_fp, "<i>*</i>");
      return 2;
    }
  } else if (ch == '\n') {
    fputc(ch, out_fp);
    return 3;
  }
  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 4;
  }
  ch = fgetc(in_fp);
  if (ch != '*') {
    fprintf(out_fp, "<i>*%s</i>%c", content, ch);
    return 5;
  }
  fprintf(out_fp, "<strong>%s</strong>", content);
  return 0;
}


x86 assembly (clang, -O0):
<onBold>:
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   1030 <fgetc@plt>
mov    %al,-0x1d(%rbp)
movsbl %al,%eax
cmp    $0x20,%eax
jne    1167 <onBold+0x37>
jmp    114a <onBold+0x1a>
movsbl -0x1d(%rbp),%eax
cmp    $0x2a,%eax
jne    11c9 <onBold+0x99>
mov    -0x18(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %al,-0x1d(%rbp)
movsbl -0x1d(%rbp),%eax
cmp    $0x2a,%eax
jne    11ab <onBold+0x7b>
mov    -0x10(%rbp),%rdi
lea    0xe68(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    131a <onBold+0x1ea>
mov    -0x10(%rbp),%rdi
lea    0xe5c(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x2,-0x4(%rbp)
jmp    131a <onBold+0x1ea>
movsbl -0x1d(%rbp),%eax
cmp    $0xa,%eax
jne    11f1 <onBold+0xc1>
mov    -0x1d(%rbp),%al
mov    -0x10(%rbp),%rsi
movsbl %al,%edi
call   1040 <fputc@plt>
movl   $0x3,-0x4(%rbp)
jmp    131a <onBold+0x1ea>
jmp    11f6 <onBold+0xc6>
mov    -0x1d(%rbp),%cl
mov    -0x1c(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x1c(%rbp)
cltq
mov    %cl,-0x410(%rbp,%rax,1)
mov    -0x18(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %al,-0x1d(%rbp)
movsbl %al,%eax
mov    0x2dc5(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1276 <onBold+0x146>
movsbl -0x1d(%rbp),%eax
cmp    $0x2a,%eax
je     1255 <onBold+0x125>
movsbl -0x1d(%rbp),%eax
cmp    $0xa,%eax
je     1255 <onBold+0x125>
cmpl   $0x3e7,-0x1c(%rbp)
jle    125a <onBold+0x12a>
jmp    1276 <onBold+0x146>
mov    -0x1d(%rbp),%cl
mov    -0x1c(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x1c(%rbp)
cltq
mov    %cl,-0x410(%rbp,%rax,1)
jmp    120d <onBold+0xdd>
movslq -0x1c(%rbp),%rax
movb   $0x0,-0x410(%rbp,%rax,1)
movsbl -0x1d(%rbp),%eax
cmp    $0x2a,%eax
je     12b8 <onBold+0x188>
mov    -0x10(%rbp),%rdi
lea    -0x410(%rbp),%rdx
movsbl -0x1d(%rbp),%ecx
lea    0xd76(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x4,-0x4(%rbp)
jmp    131a <onBold+0x1ea>
mov    -0x18(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %al,-0x1d(%rbp)
movsbl -0x1d(%rbp),%eax
cmp    $0x2a,%eax
je     12fa <onBold+0x1ca>
mov    -0x10(%rbp),%rdi
lea    -0x410(%rbp),%rdx
movsbl -0x1d(%rbp),%ecx
lea    0xd39(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x5,-0x4(%rbp)
jmp    131a <onBold+0x1ea>
mov    -0x10(%rbp),%rdi
lea    -0x410(%rbp),%rdx
lea    0xd21(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<onBold>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x3e8,%rsp
mov    %rsi,%r15
mov    %rdi,%r14
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r15,%rdi
call   1030 <fgetc@plt>
cmp    $0x20,%al
je     1160 <onBold+0x20>
cmp    $0xa,%al
je     11a7 <onBold+0x67>
cmp    $0x2a,%al
jne    11be <onBold+0x7e>
mov    %r15,%rdi
call   1030 <fgetc@plt>
cmp    $0x2a,%al
jne    1236 <onBold+0xf6>
lea    0xe75(%rip),%rdi
mov    $0x11,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1060 <fwrite@plt>
mov    $0x1,%ebx
jmp    1290 <onBold+0x150>
mov    $0xa,%edi
mov    %r14,%rsi
call   1040 <fputc@plt>
mov    $0x3,%ebx
jmp    1290 <onBold+0x150>
mov    %al,(%rsp)
mov    %r15,%rdi
call   1030 <fgetc@plt>
mov    0x2e18(%rip),%r12
mov    $0x1,%ebx
cmp    (%r12),%al
je     1208 <onBold+0xc8>
mov    $0x1,%ebx
mov    %eax,%ecx
and    $0xdf,%cl
cmp    $0xa,%cl
je     1208 <onBold+0xc8>
cmp    $0x3e7,%rbx
ja     1208 <onBold+0xc8>
mov    %al,(%rsp,%rbx,1)
add    $0x1,%rbx
mov    %r15,%rdi
call   1030 <fgetc@plt>
cmp    (%r12),%al
jne    11e0 <onBold+0xa0>
mov    %ebx,%ecx
movb   $0x0,(%rsp,%rcx,1)
cmp    $0x2a,%al
jne    1256 <onBold+0x116>
mov    %r15,%rdi
call   1030 <fgetc@plt>
cmp    $0x2a,%al
jne    1274 <onBold+0x134>
lea    0xe08(%rip),%rsi
xor    %ebx,%ebx
mov    %rsp,%rdx
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <fprintf@plt>
jmp    1290 <onBold+0x150>
lea    0xdd5(%rip),%rdi
mov    $0x8,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1060 <fwrite@plt>
mov    $0x2,%ebx
jmp    1290 <onBold+0x150>
movsbl %al,%ecx
lea    0xdbb(%rip),%rsi
mov    %rsp,%rdx
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x4,%ebx
jmp    1290 <onBold+0x150>
movsbl %al,%ecx
lea    0xda2(%rip),%rsi
mov    %rsp,%rdx
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x5,%ebx
mov    %ebx,%eax
add    $0x3e8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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