#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*/ fputs(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ strcat(char *, char *);
int filtblocktag(FILE *destination, FILE *source) {
  char curchar;
  char inputbuf[2];
  char outputbuf[256];
  int buflocation = 0;
  int charcount = 0;
  int intag = 0;
  int endtag = 0;
  int copytag = 1;
  int prevtag = 0;
  memset(inputbuf, 0, 2);
  memset(outputbuf, 0, 256);
  curchar = fgetc(source);
  while (curchar != EOF) {
    inputbuf[0] = curchar;
    switch (inputbuf[0]) {
    case '<':
      intag = 1;
      prevtag = 1;
      if (buflocation != 0) {
        fputs(outputbuf, destination);
        buflocation = 0;
        memset(outputbuf, 0, 256);
      }
      strcat(outputbuf, inputbuf);
      buflocation++;
      break;
    case '>':
      strcat(outputbuf, inputbuf);
      if (copytag == 1)
        fputs(outputbuf, destination);
      memset(outputbuf, 0, 256);
      buflocation = 0;
      intag = 0;
      copytag = 1;
      endtag = 0;
      prevtag = 0;
      break;
    case '/':
      if (intag == 1 && prevtag == 1) {
        endtag = 1;
      }
      strcat(outputbuf, inputbuf);
      buflocation++;
      break;
    case 'b':
      if (prevtag == 1)
        copytag = 0;
      strcat(outputbuf, inputbuf);
      buflocation++;
      break;
    default:
      strcat(outputbuf, inputbuf);
      prevtag = 0;
      buflocation++;
      break;
    }
    curchar = fgetc(source);
    charcount++;
  }
  return charcount;
}


x86 assembly (clang, -O0):
<filtblocktag>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x124(%rbp)
movl   $0x0,-0x128(%rbp)
movl   $0x0,-0x12c(%rbp)
movl   $0x0,-0x130(%rbp)
movl   $0x1,-0x134(%rbp)
movl   $0x0,-0x138(%rbp)
lea    -0x13(%rbp),%rdi
xor    %esi,%esi
mov    $0x2,%edx
call   1040 <memset@plt>
lea    -0x120(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1040 <memset@plt>
mov    -0x10(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %al,-0x11(%rbp)
movsbl -0x11(%rbp),%eax
mov    0x2e1f(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     13e3 <filtblocktag+0x2a3>
mov    -0x11(%rbp),%al
mov    %al,-0x13(%rbp)
movsbl -0x13(%rbp),%eax
mov    %eax,-0x13c(%rbp)
sub    $0x2f,%eax
je     1317 <filtblocktag+0x1d7>
jmp    11f2 <filtblocktag+0xb2>
mov    -0x13c(%rbp),%eax
sub    $0x3c,%eax
je     122e <filtblocktag+0xee>
jmp    1206 <filtblocktag+0xc6>
mov    -0x13c(%rbp),%eax
sub    $0x3e,%eax
je     12a0 <filtblocktag+0x160>
jmp    121a <filtblocktag+0xda>
mov    -0x13c(%rbp),%eax
sub    $0x62,%eax
je     135f <filtblocktag+0x21f>
jmp    139a <filtblocktag+0x25a>
movl   $0x1,-0x12c(%rbp)
movl   $0x1,-0x138(%rbp)
cmpl   $0x0,-0x124(%rbp)
je     127c <filtblocktag+0x13c>
lea    -0x120(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <fputs@plt>
movl   $0x0,-0x124(%rbp)
lea    -0x120(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1040 <memset@plt>
lea    -0x120(%rbp),%rdi
lea    -0x13(%rbp),%rsi
call   1060 <strcat@plt>
mov    -0x124(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x124(%rbp)
jmp    13c3 <filtblocktag+0x283>
lea    -0x120(%rbp),%rdi
lea    -0x13(%rbp),%rsi
call   1060 <strcat@plt>
cmpl   $0x1,-0x134(%rbp)
jne    12cd <filtblocktag+0x18d>
lea    -0x120(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <fputs@plt>
lea    -0x120(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1040 <memset@plt>
movl   $0x0,-0x124(%rbp)
movl   $0x0,-0x12c(%rbp)
movl   $0x1,-0x134(%rbp)
movl   $0x0,-0x130(%rbp)
movl   $0x0,-0x138(%rbp)
jmp    13c3 <filtblocktag+0x283>
cmpl   $0x1,-0x12c(%rbp)
jne    133b <filtblocktag+0x1fb>
cmpl   $0x1,-0x138(%rbp)
jne    133b <filtblocktag+0x1fb>
movl   $0x1,-0x130(%rbp)
lea    -0x120(%rbp),%rdi
lea    -0x13(%rbp),%rsi
call   1060 <strcat@plt>
mov    -0x124(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x124(%rbp)
jmp    13c3 <filtblocktag+0x283>
cmpl   $0x1,-0x138(%rbp)
jne    1376 <filtblocktag+0x236>
movl   $0x0,-0x134(%rbp)
lea    -0x120(%rbp),%rdi
lea    -0x13(%rbp),%rsi
call   1060 <strcat@plt>
mov    -0x124(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x124(%rbp)
jmp    13c3 <filtblocktag+0x283>
lea    -0x120(%rbp),%rdi
lea    -0x13(%rbp),%rsi
call   1060 <strcat@plt>
movl   $0x0,-0x138(%rbp)
mov    -0x124(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x124(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %al,-0x11(%rbp)
mov    -0x128(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x128(%rbp)
jmp    11be <filtblocktag+0x7e>
mov    -0x128(%rbp),%eax
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<filtblocktag>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x118,%rsp
mov    %rsi,%rbx
mov    %rdi,0x8(%rsp)
lea    0x6(%rsp),%rdi
xor    %ebp,%ebp
xor    %esi,%esi
mov    $0x2,%edx
call   1040 <memset@plt>
lea    0x10(%rsp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1040 <memset@plt>
mov    %rbx,%rdi
call   1050 <fgetc@plt>
mov    0x2e5c(%rip),%rcx
cmp    (%rcx),%al
jne    11a4 <filtblocktag+0x64>
mov    %ebp,%eax
add    $0x118,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x1,%r14d
lea    0x10(%rsp),%r15
xor    %r13d,%r13d
xor    %ebp,%ebp
xor    %r12d,%r12d
jmp    11ea <filtblocktag+0xaa>
nopl   0x0(%rax)
mov    %r15,%rdi
lea    0x6(%rsp),%rsi
call   1060 <strcat@plt>
add    $0x1,%r12d
xor    %r13d,%r13d
mov    %rbx,%rdi
call   1050 <fgetc@plt>
add    $0x1,%ebp
mov    0x2e02(%rip),%rcx
cmp    (%rcx),%al
je     1190 <filtblocktag+0x50>
movsbl %al,%eax
mov    %al,0x6(%rsp)
cmp    $0x3d,%eax
jg     1240 <filtblocktag+0x100>
cmp    $0x2f,%eax
je     125b <filtblocktag+0x11b>
cmp    $0x3c,%eax
jne    11c0 <filtblocktag+0x80>
test   %r12d,%r12d
je     1221 <filtblocktag+0xe1>
mov    %r15,%rdi
mov    0x8(%rsp),%rsi
call   1030 <fputs@plt>
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1040 <memset@plt>
mov    %r15,%rdi
lea    0x6(%rsp),%rsi
call   1060 <strcat@plt>
mov    $0x1,%r12d
mov    $0x1,%r13d
jmp    11d4 <filtblocktag+0x94>
nopl   0x0(%rax)
cmp    $0x3e,%eax
je     1280 <filtblocktag+0x140>
cmp    $0x62,%eax
jne    11c0 <filtblocktag+0x80>
cmp    $0x1,%r13d
mov    $0x0,%eax
cmove  %eax,%r14d
mov    %r15,%rdi
lea    0x6(%rsp),%rsi
call   1060 <strcat@plt>
add    $0x1,%r12d
jmp    11d4 <filtblocktag+0x94>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
lea    0x6(%rsp),%rsi
call   1060 <strcat@plt>
cmp    $0x1,%r14d
jne    12a0 <filtblocktag+0x160>
mov    %r15,%rdi
mov    0x8(%rsp),%rsi
call   1030 <fputs@plt>
xor    %r12d,%r12d
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1040 <memset@plt>
mov    $0x1,%r14d
jmp    11d1 <filtblocktag+0x91>

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

LLVM IR (-O2):
@EOF = global i8 0
define i32 @filtblocktag(i32* nocapture %0, i32* nocapture %1) {
%3 = alloca [2 x i8]
%4 = alloca [256 x i8]
%5 = getelementptr inbounds [2 x i8], [2 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%7 = call i32 @memset(i8* %5, i32 0, i32 2)
%8 = call i32 @memset(i8* %6, i32 0, i32 256)
%9 = call signext i8 @fgetc(i32* %1)
%10 = load i8, i8* @EOF
%11 = icmp eq i8 %9, %10
br i1 %11, label %52, label %12
12: ; preds = %2, %44
%13 = phi i32 [ %47, %44 ], [ 0, %2 ]
%14 = phi i32 [ %46, %44 ], [ 1, %2 ]
%15 = phi i32 [ %49, %44 ], [ 0, %2 ]
%16 = phi i32 [ %45, %44 ], [ 0, %2 ]
%17 = phi i8 [ %48, %44 ], [ %9, %2 ]
%18 = sext i8 %17 to i32
store i8 %17, i8* %5
switch i32 %18, label %41 [
i32 60, label %19
i32 62, label %26
i32 47, label %33
i32 98, label %36
]
19: ; preds = %12
%20 = icmp eq i32 %16, 0
br i1 %20, label %24, label %21
21: ; preds = %19
%22 = call i32 @fputs(i8* %6, i32* %0)
%23 = call i32 @memset(i8* %6, i32 0, i32 256)
br label %24
24: ; preds = %21, %19
%25 = call i32 @strcat(i8* %6, i8* %5)
br label %44
26: ; preds = %12
%27 = call i32 @strcat(i8* %6, i8* %5)
%28 = icmp eq i32 %14, 1
br i1 %28, label %29, label %31
29: ; preds = %26
%30 = call i32 @fputs(i8* %6, i32* %0)
br label %31
31: ; preds = %29, %26
%32 = call i32 @memset(i8* %6, i32 0, i32 256)
br label %44
33: ; preds = %12
%34 = call i32 @strcat(i8* %6, i8* %5)
%35 = add nsw i32 %16, 1
br label %44
36: ; preds = %12
%37 = icmp eq i32 %13, 1
%38 = select i1 %37, i32 0, i32 %14
%39 = call i32 @strcat(i8* %6, i8* %5)
%40 = add nsw i32 %16, 1
br label %44
41: ; preds = %12
%42 = call i32 @strcat(i8* %6, i8* %5)
%43 = add nsw i32 %16, 1
br label %44
44: ; preds = %41, %36, %33, %31, %24
%45 = phi i32 [ %43, %41 ], [ %40, %36 ], [ %35, %33 ], [ 0, %31 ], [ 1, %24 ]
%46 = phi i32 [ %14, %41 ], [ %38, %36 ], [ %14, %33 ], [ 1, %31 ], [ %14, %24 ]
%47 = phi i32 [ 0, %41 ], [ %13, %36 ], [ %13, %33 ], [ 0, %31 ], [ 1, %24 ]
%48 = call signext i8 @fgetc(i32* %1)
%49 = add nuw nsw i32 %15, 1
%50 = load i8, i8* @EOF
%51 = icmp eq i8 %48, %50
br i1 %51, label %52, label %12
52: ; preds = %44, %2
%53 = phi i32 [ 0, %2 ], [ %49, %44 ]
ret i32 %53
}