#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(int argc, char *argv[]) {
  int c;
  printf("<html>\n"
         "<head>\n"
         "  <title>%s</title>\n"
         "  <link rel=\"icon\" type=\"image/png\" "
         "href=\"images/free42-icon.png\">\n"
         "</head>\n"
         "<body>\n"
         "<h3>%s</h3>\n"
         "<pre>",
         argv[1], argv[1]);
  while ((c = getchar()) != EOF) {
    switch (c) {
    case '<':
      printf("&lt;");
      break;
    case '>':
      printf("&gt;");
      break;
    case '&':
      printf("&amp;");
      break;
    default:
      putchar(c);
    }
  }
  printf("</pre>\n"
         "<p>\n"
         "<a href=\".\">Go to Free42 home page</a>\n"
         "</body>\n"
         "</html>\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,-0x14(%rbp)
mov    0x2e73(%rip),%rcx
cmp    (%rcx),%eax
je     11f9 <main+0xc9>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
sub    $0x26,%eax
je     11d9 <main+0xa9>
jmp    1191 <main+0x61>
mov    -0x18(%rbp),%eax
sub    $0x3c,%eax
je     11b3 <main+0x83>
jmp    11a2 <main+0x72>
mov    -0x18(%rbp),%eax
sub    $0x3e,%eax
je     11c6 <main+0x96>
jmp    11ec <main+0xbc>
lea    0xecc(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11f4 <main+0xc4>
lea    0xebe(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11f4 <main+0xc4>
lea    0xeb0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11f4 <main+0xc4>
mov    -0x14(%rbp),%edi
call   1030 <putchar@plt>
jmp    1164 <main+0x34>
lea    0xe96(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    0x8(%rsi),%rdx
lea    0xead(%rip),%rdi
mov    %rdx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
mov    0x2e7d(%rip),%rbx
cmp    (%rbx),%eax
jne    1189 <main+0x49>
lea    0xf20(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
lea    0xf00(%rip),%r14
lea    0xef4(%rip),%r12
lea    0xee8(%rip),%r15
jmp    11b5 <main+0x75>
mov    %r12,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
cmp    (%rbx),%eax
je     116f <main+0x2f>
cmp    $0x26,%eax
je     11d0 <main+0x90>
cmp    $0x3e,%eax
je     11a0 <main+0x60>
cmp    $0x3c,%eax
jne    11e0 <main+0xa0>
mov    %r15,%rdi
jmp    11a3 <main+0x63>
nopl   0x0(%rax)
mov    %r14,%rdi
jmp    11a3 <main+0x63>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %eax,%edi
call   1030 <putchar@plt>
jmp    11aa <main+0x6a>

LLVM IR (-O0):
@.str = [134 x i8] c"<html>\0A<head>\0A <title>%s</title>\0A <link rel=\22icon\22 type=\22image/png\22 href=\22images/free42-icon.png\22>\0A</head>\0A<body>\0A<h3>%s</h3>\0A<pre>\00"
@EOF = global i32 0
@.str.1 = [5 x i8] c"&lt;\00"
@.str.2 = [5 x i8] c"&gt;\00"
@.str.3 = [6 x i8] c"&amp;\00"
@.str.4 = [67 x i8] c"</pre>\0A<p>\0A<a href=\22.\22>Go to Free42 home page</a>\0A</body>\0A</html>\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i8**, i8*** %5
%8 = getelementptr inbounds i8*, i8** %7, i64 1
%9 = load i8*, i8** %8
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([134 x i8], [134 x i8]* @.str, i64 0, i64 0), i8* %9, i8* %12)
br label %14
14: ; preds = %29, %2
%15 = call i32 (...) @getchar()
store i32 %15, i32* %6
%16 = load i32, i32* @EOF
%17 = icmp ne i32 %15, %16
br i1 %17, label %18, label %30
18: ; preds = %14
%19 = load i32, i32* %6
switch i32 %19, label %26 [
i32 60, label %20
i32 62, label %22
i32 38, label %24
]
20: ; preds = %18
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %29
22: ; preds = %18
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %29
24: ; preds = %18
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %29
26: ; preds = %18
%27 = load i32, i32* %6
%28 = call i32 @putchar(i32 %27)
br label %29
29: ; preds = %26, %24, %22, %20
br label %14
30: ; preds = %14
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.4, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [134 x i8] c"<html>\0A<head>\0A <title>%s</title>\0A <link rel=\22icon\22 type=\22image/png\22 href=\22images/free42-icon.png\22>\0A</head>\0A<body>\0A<h3>%s</h3>\0A<pre>\00"
@EOF = global i32 0
@.str.1 = [5 x i8] c"&lt;\00"
@.str.2 = [5 x i8] c"&gt;\00"
@.str.3 = [6 x i8] c"&amp;\00"
@str = [66 x i8] c"</pre>\0A<p>\0A<a href=\22.\22>Go to Free42 home page</a>\0A</body>\0A</html>\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([134 x i8], [134 x i8]* @.str, i64 0, i64 0), i8* %4, i8* %4)
%6 = tail call i32 (...) @getchar()
%7 = load i32, i32* @EOF
%8 = icmp eq i32 %6, %7
br i1 %8, label %23, label %9
9: ; preds = %2, %19
%10 = phi i32 [ %20, %19 ], [ %6, %2 ]
switch i32 %10, label %17 [
i32 60, label %11
i32 62, label %13
i32 38, label %15
]
11: ; preds = %9
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %19
13: ; preds = %9
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %19
15: ; preds = %9
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %19
17: ; preds = %9
%18 = tail call i32 @putchar(i32 %10)
br label %19
19: ; preds = %17, %15, %13, %11
%20 = tail call i32 (...) @getchar()
%21 = load i32, i32* @EOF
%22 = icmp eq i32 %20, %21
br i1 %22, label %23, label %9
23: ; preds = %19, %2
%24 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([66 x i8], [66 x i8]* @str, i64 0, i64 0))
ret i32 0
}