#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 */
int EOF;
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ clean_word(char *);
int /*<<< orphan*/ end_tag(char *);
int /*<<< orphan*/ entity_ref(int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ isalnum(int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ start_tag(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ tag_section(char *, int /*<<< orphan*/ *);
int tolower(int);
int ungetc(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ word(char *);
void parse(FILE *stream) {
  char buffer[256];
  int c = 0, index = 0;
  while (EOF != (c = tolower(getc(stream)))) {
    switch (c) {
    case '<':
      if (index) {
        buffer[index] = '\0';
        clean_word(buffer);
        word(buffer);
        index = 0;
      }
      c = getc(stream);
      switch (c) {
      case '/':
        tag_section(buffer, stream);
        end_tag(buffer);
        break;
      default:
        c = ungetc(c, stream);
        if (EOF != c) {
          tag_section(buffer, stream);
          start_tag(buffer);
        }
        break;
      }
      break;
    case '&':
      entity_ref(stream);
      break;
    default:
      if (index == 256) {
        fprintf(stderr, "Maximum word length exceeded!\n");
        exit(EXIT_FAILURE);
      }
      if (isalnum(c) || c == 39) {
        if (c != 39 || index) {
          buffer[index++] = c;
        }
      } else if (index) {
        buffer[index] = '\0';
        clean_word(buffer);
        word(buffer);
        index = 0;
      }
      break;
    }
  }
  if (!feof(stream)) {
    perror("Parsing failure");
    exit(EXIT_FAILURE);
  }
}


x86 assembly (clang, -O0):
<parse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x114(%rbp)
movl   $0x0,-0x118(%rbp)
mov    0x2dde(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x11c(%rbp)
mov    -0x8(%rbp),%rdi
call   1100 <getc@plt>
mov    %eax,%edi
call   1080 <tolower@plt>
mov    %eax,%ecx
mov    -0x11c(%rbp),%eax
mov    %ecx,-0x114(%rbp)
cmp    %ecx,%eax
je     1428 <parse+0x248>
mov    -0x114(%rbp),%eax
mov    %eax,-0x120(%rbp)
sub    $0x26,%eax
je     1338 <parse+0x158>
jmp    1252 <parse+0x72>
mov    -0x120(%rbp),%eax
sub    $0x3c,%eax
jne    1346 <parse+0x166>
jmp    1266 <parse+0x86>
cmpl   $0x0,-0x118(%rbp)
je     12a4 <parse+0xc4>
movslq -0x118(%rbp),%rax
movb   $0x0,-0x110(%rbp,%rax,1)
lea    -0x110(%rbp),%rdi
call   10b0 <clean_word@plt>
lea    -0x110(%rbp),%rdi
call   1090 <word@plt>
movl   $0x0,-0x118(%rbp)
mov    -0x8(%rbp),%rdi
call   1100 <getc@plt>
mov    %eax,-0x114(%rbp)
mov    -0x114(%rbp),%eax
sub    $0x2f,%eax
jne    12e8 <parse+0x108>
jmp    12c7 <parse+0xe7>
lea    -0x110(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   10c0 <tag_section@plt>
lea    -0x110(%rbp),%rdi
call   1050 <end_tag@plt>
jmp    1333 <parse+0x153>
mov    -0x114(%rbp),%edi
mov    -0x8(%rbp),%rsi
call   10a0 <ungetc@plt>
mov    %eax,-0x114(%rbp)
mov    0x2ce4(%rip),%rax
mov    (%rax),%eax
cmp    -0x114(%rbp),%eax
je     132e <parse+0x14e>
lea    -0x110(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   10c0 <tag_section@plt>
lea    -0x110(%rbp),%rdi
call   1030 <start_tag@plt>
jmp    1333 <parse+0x153>
jmp    1423 <parse+0x243>
mov    -0x8(%rbp),%rdi
call   10e0 <entity_ref@plt>
jmp    1423 <parse+0x243>
cmpl   $0x100,-0x118(%rbp)
jne    1379 <parse+0x199>
mov    0x2c7b(%rip),%rax
mov    (%rax),%edi
lea    0xc9a(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2c5e(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>
mov    -0x114(%rbp),%edi
call   1040 <isalnum@plt>
cmp    $0x0,%eax
jne    139a <parse+0x1ba>
cmpl   $0x27,-0x114(%rbp)
jne    13db <parse+0x1fb>
cmpl   $0x27,-0x114(%rbp)
jne    13b4 <parse+0x1d4>
cmpl   $0x0,-0x118(%rbp)
je     13d6 <parse+0x1f6>
mov    -0x114(%rbp),%eax
mov    %al,%cl
mov    -0x118(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x118(%rbp)
cltq
mov    %cl,-0x110(%rbp,%rax,1)
jmp    141e <parse+0x23e>
cmpl   $0x0,-0x118(%rbp)
je     1419 <parse+0x239>
movslq -0x118(%rbp),%rax
movb   $0x0,-0x110(%rbp,%rax,1)
lea    -0x110(%rbp),%rdi
call   10b0 <clean_word@plt>
lea    -0x110(%rbp),%rdi
call   1090 <word@plt>
movl   $0x0,-0x118(%rbp)
jmp    141e <parse+0x23e>
jmp    1423 <parse+0x243>
jmp    1203 <parse+0x23>
mov    -0x8(%rbp),%rdi
call   1070 <feof@plt>
cmp    $0x0,%eax
jne    1454 <parse+0x274>
lea    0xbde(%rip),%rdi
call   10d0 <perror@plt>
mov    0x2b83(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x108,%rsp
mov    %rdi,%r12
mov    0x2ded(%rip),%r15
mov    (%r15),%ebx
call   1100 <getc@plt>
mov    %eax,%edi
call   1080 <tolower@plt>
cmp    %eax,%ebx
jne    1230 <parse+0x50>
mov    %r12,%rdi
call   1070 <feof@plt>
test   %eax,%eax
je     1361 <parse+0x181>
add    $0x108,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %eax,%ebp
xor    %ebx,%ebx
jmp    126c <parse+0x8c>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %r12,%rsi
call   10c0 <tag_section@plt>
mov    %rbx,%rdi
call   1050 <end_tag@plt>
xor    %r13d,%r13d
nop
mov    (%r15),%r14d
mov    %r12,%rdi
call   1100 <getc@plt>
mov    %eax,%edi
call   1080 <tolower@plt>
mov    %eax,%ebp
mov    %r13d,%ebx
cmp    %eax,%r14d
je     120e <parse+0x2e>
cmp    $0x26,%ebp
je     12d0 <parse+0xf0>
cmp    $0x3c,%ebp
jne    12e0 <parse+0x100>
test   %ebx,%ebx
je     1294 <parse+0xb4>
movslq %ebx,%rax
movb   $0x0,(%rsp,%rax,1)
mov    %rsp,%rbx
mov    %rbx,%rdi
call   10b0 <clean_word@plt>
mov    %rbx,%rdi
call   1090 <word@plt>
mov    %r12,%rdi
call   1100 <getc@plt>
cmp    $0x2f,%eax
je     1236 <parse+0x56>
mov    %eax,%edi
mov    %r12,%rsi
call   10a0 <ungetc@plt>
xor    %r13d,%r13d
cmp    %eax,(%r15)
je     1250 <parse+0x70>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %r12,%rsi
call   10c0 <tag_section@plt>
mov    %rbx,%rdi
call   1030 <start_tag@plt>
jmp    1250 <parse+0x70>
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
call   10e0 <entity_ref@plt>
mov    %ebx,%r13d
jmp    1250 <parse+0x70>
cmp    $0x100,%ebx
je     133e <parse+0x15e>
mov    %ebp,%edi
call   1040 <isalnum@plt>
test   %eax,%eax
jne    1322 <parse+0x142>
cmp    $0x27,%ebp
je     1322 <parse+0x142>
xor    %r13d,%r13d
test   %ebx,%ebx
je     1250 <parse+0x70>
movslq %ebx,%rax
movb   $0x0,(%rsp,%rax,1)
mov    %rsp,%rbx
mov    %rbx,%rdi
call   10b0 <clean_word@plt>
mov    %rbx,%rdi
call   1090 <word@plt>
jmp    1250 <parse+0x70>
cmp    $0x27,%ebp
jne    1332 <parse+0x152>
xor    %r13d,%r13d
test   %ebx,%ebx
je     1250 <parse+0x70>
movslq %ebx,%rax
add    $0x1,%ebx
mov    %bpl,(%rsp,%rax,1)
jmp    12d8 <parse+0xf8>
mov    0x2c93(%rip),%rax
mov    (%rax),%edi
lea    0xcb2(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2c76(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>
lea    0xcb7(%rip),%rdi
call   10d0 <perror@plt>
jmp    1353 <parse+0x173>

LLVM IR (-O0):
@EOF = global i32 0
@stderr = global i32 0
@.str = [31 x i8] c"Maximum word length exceeded!\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [16 x i8] c"Parsing failure\00"
define void @parse(i32* %0) {
%2 = alloca i32*
%3 = alloca [256 x i8]
%4 = alloca i32
%5 = alloca i32
store i32* %0, i32** %2
store i32 0, i32* %4
store i32 0, i32* %5
br label %6
6: ; preds = %95, %1
%7 = load i32, i32* @EOF
%8 = load i32*, i32** %2
%9 = call i32 @getc(i32* %8)
%10 = call i32 @tolower(i32 %9)
store i32 %10, i32* %4
%11 = icmp ne i32 %7, %10
br i1 %11, label %12, label %96
12: ; preds = %6
%13 = load i32, i32* %4
switch i32 %13, label %53 [
i32 60, label %14
i32 38, label %50
]
14: ; preds = %12
%15 = load i32, i32* %5
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %25
17: ; preds = %14
%18 = load i32, i32* %5
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %19
store i8 0, i8* %20
%21 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%22 = call i32 @clean_word(i8* %21)
%23 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%24 = call i32 @word(i8* %23)
store i32 0, i32* %5
br label %25
25: ; preds = %17, %14
%26 = load i32*, i32** %2
%27 = call i32 @getc(i32* %26)
store i32 %27, i32* %4
%28 = load i32, i32* %4
switch i32 %28, label %35 [
i32 47, label %29
]
29: ; preds = %25
%30 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%31 = load i32*, i32** %2
%32 = call i32 @tag_section(i8* %30, i32* %31)
%33 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%34 = call i32 @end_tag(i8* %33)
br label %49
35: ; preds = %25
%36 = load i32, i32* %4
%37 = load i32*, i32** %2
%38 = call i32 @ungetc(i32 %36, i32* %37)
store i32 %38, i32* %4
%39 = load i32, i32* @EOF
%40 = load i32, i32* %4
%41 = icmp ne i32 %39, %40
br i1 %41, label %42, label %48
42: ; preds = %35
%43 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%44 = load i32*, i32** %2
%45 = call i32 @tag_section(i8* %43, i32* %44)
%46 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%47 = call i32 @start_tag(i8* %46)
br label %48
48: ; preds = %42, %35
br label %49
49: ; preds = %48, %29
br label %95
50: ; preds = %12
%51 = load i32*, i32** %2
%52 = call i32 @entity_ref(i32* %51)
br label %95
53: ; preds = %12
%54 = load i32, i32* %5
%55 = icmp eq i32 %54, 256
br i1 %55, label %56, label %61
56: ; preds = %53
%57 = load i32, i32* @stderr
%58 = call i32 @fprintf(i32 %57, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%59 = load i32, i32* @EXIT_FAILURE
%60 = call i32 @exit(i32 %59)
unreachable
61: ; preds = %53
%62 = load i32, i32* %4
%63 = call i32 @isalnum(i32 %62)
%64 = icmp ne i32 %63, 0
br i1 %64, label %68, label %65
65: ; preds = %61
%66 = load i32, i32* %4
%67 = icmp eq i32 %66, 39
br i1 %67, label %68, label %82
68: ; preds = %65, %61
%69 = load i32, i32* %4
%70 = icmp ne i32 %69, 39
br i1 %70, label %74, label %71
71: ; preds = %68
%72 = load i32, i32* %5
%73 = icmp ne i32 %72, 0
br i1 %73, label %74, label %81
74: ; preds = %71, %68
%75 = load i32, i32* %4
%76 = trunc i32 %75 to i8
%77 = load i32, i32* %5
%78 = add nsw i32 %77, 1
store i32 %78, i32* %5
%79 = sext i32 %77 to i64
%80 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %79
store i8 %76, i8* %80
br label %81
81: ; preds = %74, %71
br label %94
82: ; preds = %65
%83 = load i32, i32* %5
%84 = icmp ne i32 %83, 0
br i1 %84, label %85, label %93
85: ; preds = %82
%86 = load i32, i32* %5
%87 = sext i32 %86 to i64
%88 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %87
store i8 0, i8* %88
%89 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%90 = call i32 @clean_word(i8* %89)
%91 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%92 = call i32 @word(i8* %91)
store i32 0, i32* %5
br label %93
93: ; preds = %85, %82
br label %94
94: ; preds = %93, %81
br label %95
95: ; preds = %94, %50, %49
br label %6
96: ; preds = %6
%97 = load i32*, i32** %2
%98 = call i32 @feof(i32* %97)
%99 = icmp ne i32 %98, 0
br i1 %99, label %104, label %100
100: ; preds = %96
%101 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%102 = load i32, i32* @EXIT_FAILURE
%103 = call i32 @exit(i32 %102)
unreachable
104: ; preds = %96
ret void
}

LLVM IR (-O2):
@EOF = global i32 0
@stderr = global i32 0
@.str = [31 x i8] c"Maximum word length exceeded!\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [16 x i8] c"Parsing failure\00"
define void @parse(i32* %0) {
%2 = alloca [256 x i8]
%3 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%4 = load i32, i32* @EOF
%5 = call i32 @getc(i32* %0)
%6 = call i32 @tolower(i32 %5)
%7 = icmp eq i32 %4, %6
br i1 %7, label %67, label %8
8: ; preds = %1, %61
%9 = phi i32 [ %65, %61 ], [ %6, %1 ]
%10 = phi i32 [ %62, %61 ], [ 0, %1 ]
switch i32 %9, label %33 [
i32 60, label %11
i32 38, label %31
]
11: ; preds = %8
%12 = icmp eq i32 %10, 0
br i1 %12, label %18, label %13
13: ; preds = %11
%14 = sext i32 %10 to i64
%15 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 %14
store i8 0, i8* %15
%16 = call i32 @clean_word(i8* %3)
%17 = call i32 @word(i8* %3)
br label %18
18: ; preds = %13, %11
%19 = call i32 @getc(i32* %0)
%20 = icmp eq i32 %19, 47
br i1 %20, label %21, label %24
21: ; preds = %18
%22 = call i32 @tag_section(i8* %3, i32* %0)
%23 = call i32 @end_tag(i8* %3)
br label %61
24: ; preds = %18
%25 = call i32 @ungetc(i32 %19, i32* %0)
%26 = load i32, i32* @EOF
%27 = icmp eq i32 %26, %25
br i1 %27, label %61, label %28
28: ; preds = %24
%29 = call i32 @tag_section(i8* %3, i32* %0)
%30 = call i32 @start_tag(i8* %3)
br label %61
31: ; preds = %8
%32 = call i32 @entity_ref(i32* %0)
br label %61
33: ; preds = %8
%34 = icmp eq i32 %10, 256
br i1 %34, label %35, label %40
35: ; preds = %33
%36 = load i32, i32* @stderr
%37 = call i32 @fprintf(i32 %36, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%38 = load i32, i32* @EXIT_FAILURE
%39 = call i32 @exit(i32 %38)
unreachable
40: ; preds = %33
%41 = call i32 @isalnum(i32 %9)
%42 = icmp ne i32 %41, 0
%43 = icmp eq i32 %9, 39
%44 = select i1 %42, i1 true, i1 %43
br i1 %44, label %45, label %54
45: ; preds = %40
%46 = icmp ne i32 %9, 39
%47 = icmp ne i32 %10, 0
%48 = select i1 %46, i1 true, i1 %47
br i1 %48, label %49, label %61
49: ; preds = %45
%50 = trunc i32 %9 to i8
%51 = add nsw i32 %10, 1
%52 = sext i32 %10 to i64
%53 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 %52
store i8 %50, i8* %53
br label %61
54: ; preds = %40
%55 = icmp eq i32 %10, 0
br i1 %55, label %61, label %56
56: ; preds = %54
%57 = sext i32 %10 to i64
%58 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 %57
store i8 0, i8* %58
%59 = call i32 @clean_word(i8* %3)
%60 = call i32 @word(i8* %3)
br label %61
61: ; preds = %45, %49, %56, %54, %21, %28, %24, %31
%62 = phi i32 [ %51, %49 ], [ 0, %45 ], [ 0, %56 ], [ 0, %54 ], [ %10, %31 ], [ 0, %21 ], [ 0, %28 ], [ 0, %24 ]
%63 = load i32, i32* @EOF
%64 = call i32 @getc(i32* %0)
%65 = call i32 @tolower(i32 %64)
%66 = icmp eq i32 %63, %65
br i1 %66, label %67, label %8
67: ; preds = %61, %1
%68 = call i32 @feof(i32* %0)
%69 = icmp eq i32 %68, 0
br i1 %69, label %70, label %74
70: ; preds = %67
%71 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%72 = load i32, i32* @EXIT_FAILURE
%73 = call i32 @exit(i32 %72)
unreachable
74: ; preds = %67
ret void
}