#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 */
scalar_t__ get_line(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
int main(int argc, char **argv) {
  char input_buffer[65536];
  char *ptr;
  while (get_line(input_buffer, stdin)) {
    for (ptr = input_buffer; *ptr; ptr++) {
      if (*ptr == '\'') {
        printf("&#039");
      } else if (*ptr == '&') {
        printf("&#038");
      } else
        printf("%c", *ptr);
    }
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10020,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x10010(%rbp),%rdi
mov    0x2ea1(%rip),%rax
mov    (%rax),%esi
call   1030 <get_line@plt>
cmp    $0x0,%rax
je     120e <main+0xee>
lea    -0x10010(%rbp),%rax
mov    %rax,-0x10018(%rbp)
mov    -0x10018(%rbp),%rax
cmpb   $0x0,(%rax)
je     11fb <main+0xdb>
mov    -0x10018(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x27,%eax
jne    119c <main+0x7c>
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11df <main+0xbf>
mov    -0x10018(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x26,%eax
jne    11c2 <main+0xa2>
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11da <main+0xba>
mov    -0x10018(%rbp),%rax
movsbl (%rax),%esi
lea    0xe39(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11df <main+0xbf>
jmp    11e4 <main+0xc4>
mov    -0x10018(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10018(%rbp)
jmp    1166 <main+0x46>
lea    0xe0d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1139 <main+0x19>
mov    -0x4(%rbp),%eax
add    $0x10020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10000,%rsp
mov    0x2ea1(%rip),%r12
mov    (%r12),%esi
mov    %rsp,%r13
mov    %r13,%rdi
call   1040 <get_line@plt>
test   %rax,%rax
je     11cb <main+0x9b>
lea    0xea4(%rip),%r14
lea    0xe97(%rip),%r15
mov    %r13,%rbx
jmp    117e <main+0x4e>
xchg   %ax,%ax
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
movsbl (%rbx),%edi
test   %edi,%edi
je     11a0 <main+0x70>
cmp    $0x26,%dil
je     1170 <main+0x40>
cmp    $0x27,%dil
jne    11c0 <main+0x90>
mov    %r15,%rdi
jmp    1173 <main+0x43>
cs nopw 0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    (%r12),%esi
mov    %r13,%rdi
call   1040 <get_line@plt>
mov    %r13,%rbx
test   %rax,%rax
jne    117e <main+0x4e>
jmp    11cb <main+0x9b>
call   1030 <putchar@plt>
add    $0x1,%rbx
jmp    117e <main+0x4e>
xor    %eax,%eax
add    $0x10000,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stdin = global i32 0
@.str = [6 x i8] c"&\00"
@.str.1 = [6 x i8] c"&\00"
@.str.2 = [3 x i8] c"%c\00"
@.str.3 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [65536 x i8]
%7 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
br label %8
8: ; preds = %43, %2
%9 = getelementptr inbounds [65536 x i8], [65536 x i8]* %6, i64 0, i64 0
%10 = load i32, i32* @stdin
%11 = call i64 @get_line(i8* %9, i32 %10)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %45
13: ; preds = %8
%14 = getelementptr inbounds [65536 x i8], [65536 x i8]* %6, i64 0, i64 0
store i8* %14, i8** %7
br label %15
15: ; preds = %40, %13
%16 = load i8*, i8** %7
%17 = load i8, i8* %16
%18 = icmp ne i8 %17, 0
br i1 %18, label %19, label %43
19: ; preds = %15
%20 = load i8*, i8** %7
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 39
br i1 %23, label %24, label %26
24: ; preds = %19
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %39
26: ; preds = %19
%27 = load i8*, i8** %7
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp eq i32 %29, 38
br i1 %30, label %31, label %33
31: ; preds = %26
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %38
33: ; preds = %26
%34 = load i8*, i8** %7
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %36)
br label %38
38: ; preds = %33, %31
br label %39
39: ; preds = %38, %24
br label %40
40: ; preds = %39
%41 = load i8*, i8** %7
%42 = getelementptr inbounds i8, i8* %41, i32 1
store i8* %42, i8** %7
br label %15
43: ; preds = %15
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %8
45: ; preds = %8
%46 = load i32, i32* %3
ret i32 %46
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [6 x i8] c"&\00"
@.str.1 = [6 x i8] c"&\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [65536 x i8]
%4 = getelementptr inbounds [65536 x i8], [65536 x i8]* %3, i64 0, i64 0
%5 = load i32, i32* @stdin
%6 = call i64 @get_line(i8* %4, i32 %5)
%7 = icmp eq i64 %6, 0
br i1 %7, label %27, label %8
8: ; preds = %2, %20
%9 = phi i8* [ %21, %20 ], [ %4, %2 ]
%10 = load i8, i8* %9
switch i8 %10, label %15 [
i8 0, label %22
i8 39, label %11
i8 38, label %13
]
11: ; preds = %8
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %18
13: ; preds = %8
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %18
15: ; preds = %8
%16 = sext i8 %10 to i32
%17 = call i32 @putchar(i32 %16)
br label %18
18: ; preds = %11, %15, %13
%19 = getelementptr inbounds i8, i8* %9, i64 1
br label %20
20: ; preds = %18, %22
%21 = phi i8* [ %19, %18 ], [ %4, %22 ]
br label %8
22: ; preds = %8
%23 = call i32 @putchar(i32 10)
%24 = load i32, i32* @stdin
%25 = call i64 @get_line(i8* %4, i32 %24)
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %20
27: ; preds = %22, %2
ret i32 0
}