#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;
scalar_t__ ferror(int /*<<< orphan*/ *);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ fputc(int, int /*<<< orphan*/ *);
int htmlenc(FILE *in, FILE *out) {
  int c;
  while ((c = fgetc(in)) != EOF) {
    if (ferror(in) || ferror(out))
      return 1;
    switch (c) {
    case '&':
      fprintf(out, "&amp;");
      break;
    case '\"':
      fprintf(out, "&quot;");
      break;
    case '\'':
      fprintf(out, "&apos;");
      break;
    case '<':
      fprintf(out, "&lt;");
      break;
    case '>':
      fprintf(out, "&gt;");
      break;
    case '\\':
      fprintf(out, "\\\\");
      break;
    default:
      fputc(c, out);
      break;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<htmlenc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %eax,-0x1c(%rbp)
mov    0x2e85(%rip),%rcx
cmp    (%rcx),%eax
je     1255 <htmlenc+0x115>
mov    -0x10(%rbp),%rdi
call   1030 <ferror@plt>
cmp    $0x0,%rax
jne    1191 <htmlenc+0x51>
mov    -0x18(%rbp),%rdi
call   1030 <ferror@plt>
cmp    $0x0,%rax
je     119d <htmlenc+0x5d>
movl   $0x1,-0x4(%rbp)
jmp    125c <htmlenc+0x11c>
mov    -0x1c(%rbp),%eax
add    $0xffffffde,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x3a,%eax
ja     1244 <htmlenc+0x104>
mov    -0x28(%rbp),%rax
lea    0xe43(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x18(%rbp),%rdi
lea    0xf1b(%rip),%rsi
call   1060 <fprintf@plt>
jmp    1250 <htmlenc+0x110>
mov    -0x18(%rbp),%rdi
lea    0xf0c(%rip),%rsi
call   1060 <fprintf@plt>
jmp    1250 <htmlenc+0x110>
mov    -0x18(%rbp),%rdi
lea    0xefe(%rip),%rsi
call   1060 <fprintf@plt>
jmp    1250 <htmlenc+0x110>
mov    -0x18(%rbp),%rdi
lea    0xef0(%rip),%rsi
call   1060 <fprintf@plt>
jmp    1250 <htmlenc+0x110>
mov    -0x18(%rbp),%rdi
lea    0xee0(%rip),%rsi
call   1060 <fprintf@plt>
jmp    1250 <htmlenc+0x110>
mov    -0x18(%rbp),%rdi
lea    0xed0(%rip),%rsi
call   1060 <fprintf@plt>
jmp    1250 <htmlenc+0x110>
mov    -0x1c(%rbp),%edi
mov    -0x18(%rbp),%rsi
call   1050 <fputc@plt>
jmp    1150 <htmlenc+0x10>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<htmlenc>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
call   1040 <fgetc@plt>
mov    0x2e8b(%rip),%r15
cmp    (%r15),%eax
je     125c <htmlenc+0x11c>
mov    %eax,%r13d
lea    0xe90(%rip),%r12
mov    $0x1,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
call   1030 <ferror@plt>
test   %rax,%rax
jne    125e <htmlenc+0x11e>
mov    %r14,%rdi
call   1030 <ferror@plt>
test   %rax,%rax
jne    125e <htmlenc+0x11e>
lea    -0x22(%r13),%eax
cmp    $0x3a,%eax
ja     11c7 <htmlenc+0x87>
movslq (%r12,%rax,4),%rax
add    %r12,%rax
jmp    *%rax
mov    $0x6,%esi
mov    $0x1,%edx
lea    0xf2d(%rip),%rdi
jmp    1240 <htmlenc+0x100>
mov    %r13d,%edi
mov    %r14,%rsi
call   1050 <fputc@plt>
jmp    1248 <htmlenc+0x108>
mov    $0x5,%esi
mov    $0x1,%edx
lea    0xf07(%rip),%rdi
jmp    1240 <htmlenc+0x100>
mov    $0x6,%esi
mov    $0x1,%edx
lea    0xf01(%rip),%rdi
jmp    1240 <htmlenc+0x100>
mov    $0x4,%esi
mov    $0x1,%edx
lea    0xef5(%rip),%rdi
jmp    1240 <htmlenc+0x100>
mov    $0x4,%esi
mov    $0x1,%edx
lea    0xee7(%rip),%rdi
jmp    1240 <htmlenc+0x100>
mov    $0x2,%esi
mov    $0x1,%edx
lea    0xed9(%rip),%rdi
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14,%rcx
call   1060 <fwrite@plt>
mov    %rbx,%rdi
call   1040 <fgetc@plt>
mov    %eax,%r13d
cmp    (%r15),%eax
jne    1180 <htmlenc+0x40>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global i32 0
@.str = [6 x i8] c"&amp;\00"
@.str.1 = [7 x i8] c"&quot;\00"
@.str.2 = [7 x i8] c"&apos;\00"
@.str.3 = [5 x i8] c"&lt;\00"
@.str.4 = [5 x i8] c"&gt;\00"
@.str.5 = [3 x i8] c"\\\\\00"
define i32 @htmlenc(i32* %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32
store i32* %0, i32** %4
store i32* %1, i32** %5
br label %7
7: ; preds = %45, %2
%8 = load i32*, i32** %4
%9 = call i32 @fgetc(i32* %8)
store i32 %9, i32* %6
%10 = load i32, i32* @EOF
%11 = icmp ne i32 %9, %10
br i1 %11, label %12, label %46
12: ; preds = %7
%13 = load i32*, i32** %4
%14 = call i64 @ferror(i32* %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %20, label %16
16: ; preds = %12
%17 = load i32*, i32** %5
%18 = call i64 @ferror(i32* %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %16, %12
store i32 1, i32* %3
br label %47
21: ; preds = %16
%22 = load i32, i32* %6
switch i32 %22, label %41 [
i32 38, label %23
i32 34, label %26
i32 39, label %29
i32 60, label %32
i32 62, label %35
i32 92, label %38
]
23: ; preds = %21
%24 = load i32*, i32** %5
%25 = call i32 @fprintf(i32* %24, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %45
26: ; preds = %21
%27 = load i32*, i32** %5
%28 = call i32 @fprintf(i32* %27, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %45
29: ; preds = %21
%30 = load i32*, i32** %5
%31 = call i32 @fprintf(i32* %30, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
br label %45
32: ; preds = %21
%33 = load i32*, i32** %5
%34 = call i32 @fprintf(i32* %33, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
br label %45
35: ; preds = %21
%36 = load i32*, i32** %5
%37 = call i32 @fprintf(i32* %36, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
br label %45
38: ; preds = %21
%39 = load i32*, i32** %5
%40 = call i32 @fprintf(i32* %39, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
br label %45
41: ; preds = %21
%42 = load i32, i32* %6
%43 = load i32*, i32** %5
%44 = call i32 @fputc(i32 %42, i32* %43)
br label %45
45: ; preds = %41, %38, %35, %32, %29, %26, %23
br label %7
46: ; preds = %7
store i32 0, i32* %3
br label %47
47: ; preds = %46, %20
%48 = load i32, i32* %3
ret i32 %48
}

LLVM IR (-O2):
@EOF = global i32 0
@.str = [6 x i8] c"&amp;\00"
@.str.1 = [7 x i8] c"&quot;\00"
@.str.2 = [7 x i8] c"&apos;\00"
@.str.3 = [5 x i8] c"&lt;\00"
@.str.4 = [5 x i8] c"&gt;\00"
@.str.5 = [3 x i8] c"\\\\\00"
define i32 @htmlenc(i32* nocapture %0, i32* nocapture %1) {
%3 = tail call i32 @fgetc(i32* %0)
%4 = load i32, i32* @EOF
%5 = icmp eq i32 %3, %4
br i1 %5, label %32, label %6
6: ; preds = %2, %28
%7 = phi i32 [ %29, %28 ], [ %3, %2 ]
%8 = tail call i64 @ferror(i32* %0)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %32
10: ; preds = %6
%11 = tail call i64 @ferror(i32* %1)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %32
13: ; preds = %10
switch i32 %7, label %26 [
i32 38, label %14
i32 34, label %16
i32 39, label %18
i32 60, label %20
i32 62, label %22
i32 92, label %24
]
14: ; preds = %13
%15 = tail call i64 @fwrite(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i64 5, i64 1, i32* %1)
br label %28
16: ; preds = %13
%17 = tail call i64 @fwrite(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i64 6, i64 1, i32* %1)
br label %28
18: ; preds = %13
%19 = tail call i64 @fwrite(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i64 6, i64 1, i32* %1)
br label %28
20: ; preds = %13
%21 = tail call i64 @fwrite(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i64 4, i64 1, i32* %1)
br label %28
22: ; preds = %13
%23 = tail call i64 @fwrite(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i64 4, i64 1, i32* %1)
br label %28
24: ; preds = %13
%25 = tail call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i64 2, i64 1, i32* %1)
br label %28
26: ; preds = %13
%27 = tail call i32 @fputc(i32 %7, i32* %1)
br label %28
28: ; preds = %26, %24, %22, %20, %18, %16, %14
%29 = tail call i32 @fgetc(i32* %0)
%30 = load i32, i32* @EOF
%31 = icmp eq i32 %29, %30
br i1 %31, label %32, label %6
32: ; preds = %10, %6, %28, %2
%33 = phi i32 [ 0, %2 ], [ 0, %28 ], [ 1, %6 ], [ 1, %10 ]
ret i32 %33
}