#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 */

/* Variables and functions */
int EOF;
int getchar();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ putchar(int);
int main(void) {
  int c;
  printf("<pre>\n");
  while ((c = getchar()) != EOF) {
    if (c == '&') {
      putchar('&');
      putchar('a');
      putchar('m');
      putchar('p');
      putchar(';');
    } else if (c == '>') {
      putchar('&');
      putchar('g');
      putchar('t');
      putchar(';');
    } else if (c == '<') {
      putchar('&');
      putchar('l');
      putchar('t');
      putchar(';');
    } else
      putchar(c);
  }
  printf("</pre>\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e8c(%rip),%rcx
cmp    (%rcx),%eax
je     122a <main+0xfa>
cmpl   $0x26,-0x8(%rbp)
jne    11a5 <main+0x75>
mov    $0x26,%edi
call   1030 <putchar@plt>
mov    $0x61,%edi
call   1030 <putchar@plt>
mov    $0x6d,%edi
call   1030 <putchar@plt>
mov    $0x70,%edi
call   1030 <putchar@plt>
mov    $0x3b,%edi
call   1030 <putchar@plt>
jmp    1225 <main+0xf5>
cmpl   $0x3e,-0x8(%rbp)
jne    11dc <main+0xac>
mov    $0x26,%edi
call   1030 <putchar@plt>
mov    $0x67,%edi
call   1030 <putchar@plt>
mov    $0x74,%edi
call   1030 <putchar@plt>
mov    $0x3b,%edi
call   1030 <putchar@plt>
jmp    1220 <main+0xf0>
cmpl   $0x3c,-0x8(%rbp)
jne    1213 <main+0xe3>
mov    $0x26,%edi
call   1030 <putchar@plt>
mov    $0x6c,%edi
call   1030 <putchar@plt>
mov    $0x74,%edi
call   1030 <putchar@plt>
mov    $0x3b,%edi
call   1030 <putchar@plt>
jmp    121b <main+0xeb>
mov    -0x8(%rbp),%edi
call   1030 <putchar@plt>
jmp    1220 <main+0xf0>
jmp    1225 <main+0xf5>
jmp    114b <main+0x1b>
lea    0xdd6(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
lea    0xec5(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    0x2e9a(%rip),%r14
jmp    1180 <main+0x50>
mov    $0x6c,%ebp
mov    $0x26,%edi
call   1030 <putchar@plt>
mov    %ebp,%edi
call   1030 <putchar@plt>
mov    %ebx,%edi
call   1030 <putchar@plt>
mov    $0x3b,%eax
mov    %eax,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    (%r14),%eax
je     11c7 <main+0x97>
mov    $0x74,%ebx
cmp    $0x3e,%eax
je     11c0 <main+0x90>
cmp    $0x3c,%eax
je     1150 <main+0x20>
cmp    $0x26,%eax
jne    1172 <main+0x42>
mov    $0x26,%edi
call   1030 <putchar@plt>
mov    $0x70,%ebx
mov    $0x6d,%ebp
mov    $0x61,%edi
jmp    115a <main+0x2a>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0x67,%ebp
jmp    1155 <main+0x25>
lea    0xe38(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"<pre>\0A\00"
@EOF = global i32 0
@.str.1 = [8 x i8] c"</pre>\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %4
4: ; preds = %38, %0
%5 = call i32 (...) @getchar()
store i32 %5, i32* %2
%6 = load i32, i32* @EOF
%7 = icmp ne i32 %5, %6
br i1 %7, label %8, label %39
8: ; preds = %4
%9 = load i32, i32* %2
%10 = icmp eq i32 %9, 38
br i1 %10, label %11, label %17
11: ; preds = %8
%12 = call i32 @putchar(i32 38)
%13 = call i32 @putchar(i32 97)
%14 = call i32 @putchar(i32 109)
%15 = call i32 @putchar(i32 112)
%16 = call i32 @putchar(i32 59)
br label %38
17: ; preds = %8
%18 = load i32, i32* %2
%19 = icmp eq i32 %18, 62
br i1 %19, label %20, label %25
20: ; preds = %17
%21 = call i32 @putchar(i32 38)
%22 = call i32 @putchar(i32 103)
%23 = call i32 @putchar(i32 116)
%24 = call i32 @putchar(i32 59)
br label %37
25: ; preds = %17
%26 = load i32, i32* %2
%27 = icmp eq i32 %26, 60
br i1 %27, label %28, label %33
28: ; preds = %25
%29 = call i32 @putchar(i32 38)
%30 = call i32 @putchar(i32 108)
%31 = call i32 @putchar(i32 116)
%32 = call i32 @putchar(i32 59)
br label %36
33: ; preds = %25
%34 = load i32, i32* %2
%35 = call i32 @putchar(i32 %34)
br label %36
36: ; preds = %33, %28
br label %37
37: ; preds = %36, %20
br label %38
38: ; preds = %37, %11
br label %4
39: ; preds = %4
%40 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@EOF = global i32 0
@str = [6 x i8] c"<pre>\00"
@str.2 = [7 x i8] c"</pre>\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 (...) @getchar()
%3 = load i32, i32* @EOF
%4 = icmp eq i32 %2, %3
br i1 %4, label %23, label %5
5: ; preds = %0, %17
%6 = phi i32 [ %20, %17 ], [ %2, %0 ]
switch i32 %6, label %17 [
i32 38, label %7
i32 62, label %10
i32 60, label %9
]
7: ; preds = %5
%8 = tail call i32 @putchar(i32 38)
br label %10
9: ; preds = %5
br label %10
10: ; preds = %5, %7, %9
%11 = phi i32 [ 38, %9 ], [ 97, %7 ], [ 38, %5 ]
%12 = phi i32 [ 108, %9 ], [ 109, %7 ], [ 103, %5 ]
%13 = phi i32 [ 116, %9 ], [ 112, %7 ], [ 116, %5 ]
%14 = tail call i32 @putchar(i32 %11)
%15 = tail call i32 @putchar(i32 %12)
%16 = tail call i32 @putchar(i32 %13)
br label %17
17: ; preds = %10, %5
%18 = phi i32 [ %6, %5 ], [ 59, %10 ]
%19 = tail call i32 @putchar(i32 %18)
%20 = tail call i32 (...) @getchar()
%21 = load i32, i32* @EOF
%22 = icmp eq i32 %20, %21
br i1 %22, label %23, label %5
23: ; preds = %17, %0
%24 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str.2, i64 0, i64 0))
ret i32 0
}