#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 BUFSIZ;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
char getchar();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int main(void) {
  char c, f_name[10000], input[10000];
  int i;
  FILE *ofp;
  printf("\nPlease Input File Name:\n");
  scanf("%s", f_name);
  ofp = fopen(f_name, "a");
  printf("File \"%s\" opened or created\n", f_name);
  printf("\nPlease Input Text To Convert\n");
  scanf("%s", input);
  fprintf(ofp, "<pre>\n");
  for (i = 0; (c = getchar()) != '\n'; i++) {
    if (c == '&') {
      input[i] = '&';
      input[i + 1] = 'a';
      input[i + 2] = 'm';
      input[i + 3] = 'p';
      i = i + 3;
    } else if (c == '>') {
      input[i] = '&';
      input[i + 1] = 'g';
      input[i + 2] = 't';
      i = i + 2;
    } else if (c == '<') {
      input[i] = '&';
      input[i + 1] = 'l';
      input[i + 2] = 't';
      i = i + 2;
    } else {
      input[i] = c;
    }
  }
  fprintf(ofp, "%s", input);
  fprintf(ofp, "\n<pre\\n>\n");
  fclose(ofp);
  printf("BUFSIZ = %d MAX_SIZE = %d\n", BUFSIZ, 10000);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4e40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x2720(%rbp),%rsi
lea    0xe8c(%rip),%rdi
call   1070 <scanf@plt>
lea    -0x2720(%rbp),%rdi
lea    0xe7c(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x4e40(%rbp)
lea    -0x2720(%rbp),%rsi
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x4e30(%rbp),%rsi
lea    0xe3c(%rip),%rdi
call   1070 <scanf@plt>
mov    -0x4e40(%rbp),%rdi
lea    0xe6a(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x0,-0x4e34(%rbp)
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %al,-0x5(%rbp)
movsbl %al,%eax
cmp    $0xa,%eax
je     1361 <main+0x201>
movsbl -0x5(%rbp),%eax
cmp    $0x26,%eax
jne    1281 <main+0x121>
movslq -0x4e34(%rbp),%rax
movb   $0x26,-0x4e30(%rbp,%rax,1)
26
mov    -0x4e34(%rbp),%eax
add    $0x1,%eax
cltq
movb   $0x61,-0x4e30(%rbp,%rax,1)
61
mov    -0x4e34(%rbp),%eax
add    $0x2,%eax
cltq
movb   $0x6d,-0x4e30(%rbp,%rax,1)
6d
mov    -0x4e34(%rbp),%eax
add    $0x3,%eax
cltq
movb   $0x70,-0x4e30(%rbp,%rax,1)
70
mov    -0x4e34(%rbp),%eax
add    $0x3,%eax
mov    %eax,-0x4e34(%rbp)
jmp    1348 <main+0x1e8>
movsbl -0x5(%rbp),%eax
cmp    $0x3e,%eax
jne    12d7 <main+0x177>
movslq -0x4e34(%rbp),%rax
movb   $0x26,-0x4e30(%rbp,%rax,1)
26
mov    -0x4e34(%rbp),%eax
add    $0x1,%eax
cltq
movb   $0x67,-0x4e30(%rbp,%rax,1)
67
mov    -0x4e34(%rbp),%eax
add    $0x2,%eax
cltq
movb   $0x74,-0x4e30(%rbp,%rax,1)
74
mov    -0x4e34(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x4e34(%rbp)
jmp    1343 <main+0x1e3>
movsbl -0x5(%rbp),%eax
cmp    $0x3c,%eax
jne    132d <main+0x1cd>
movslq -0x4e34(%rbp),%rax
movb   $0x26,-0x4e30(%rbp,%rax,1)
26
mov    -0x4e34(%rbp),%eax
add    $0x1,%eax
cltq
movb   $0x6c,-0x4e30(%rbp,%rax,1)
6c
mov    -0x4e34(%rbp),%eax
add    $0x2,%eax
cltq
movb   $0x74,-0x4e30(%rbp,%rax,1)
74
mov    -0x4e34(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x4e34(%rbp)
jmp    133e <main+0x1de>
mov    -0x5(%rbp),%cl
movslq -0x4e34(%rbp),%rax
mov    %cl,-0x4e30(%rbp,%rax,1)
jmp    1343 <main+0x1e3>
jmp    1348 <main+0x1e8>
jmp    134d <main+0x1ed>
mov    -0x4e34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4e34(%rbp)
jmp    1202 <main+0xa2>
mov    -0x4e40(%rbp),%rdi
lea    -0x4e30(%rbp),%rdx
lea    0xca4(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x4e40(%rbp),%rdi
lea    0xcd7(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x4e40(%rbp),%rdi
call   1030 <fclose@plt>
mov    0x2c3b(%rip),%rax
mov    (%rax),%esi
lea    0xcbe(%rip),%rdi
mov    $0x2710,%edx
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x4e40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x4e20,%rsp
lea    0xebb(%rip),%rdi
call   1030 <puts@plt>
lea    0xe61(%rip),%r14
lea    0x2710(%rsp),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1080 <scanf@plt>
lea    0xe4a(%rip),%rsi
mov    %rbx,%rdi
call   1090 <fopen@plt>
mov    %rax,%r15
lea    0xe3a(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe8b(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%rsi
mov    %r14,%rdi
call   1080 <scanf@plt>
lea    0xe2f(%rip),%rdi
mov    $0x6,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   10a0 <fwrite@plt>
xor    %ebx,%ebx
jmp    1231 <main+0xb1>
nopl   0x0(%rax)
mov    $0x6c,%dl
mov    %ebx,%edi
movslq %edi,%rax
mov    %cl,(%rsp,%rax,1)
add    %ebx,%esi
movslq %esi,%rax
mov    %dl,(%rsp,%rax,1)
add    %r9d,%ebx
mov    %r8d,%eax
movslq %ebx,%rbx
mov    %al,(%rsp,%rbx,1)
add    $0x1,%ebx
xor    %eax,%eax
call   1070 <getchar@plt>
cmp    $0x3b,%al
jle    1260 <main+0xe0>
mov    $0x74,%r8b
mov    $0x2,%r9d
mov    $0x1,%esi
mov    $0x26,%cl
cmp    $0x3c,%al
je     1210 <main+0x90>
mov    $0x67,%dl
mov    %ebx,%edi
cmp    $0x3e,%al
je     1214 <main+0x94>
jmp    1228 <main+0xa8>
nopw   0x0(%rax,%rax,1)
cmp    $0x26,%al
jne    1282 <main+0x102>
movslq %ebx,%rdi
movb   $0x26,(%rsp,%rdi,1)
add    $0x1,%edi
mov    $0x70,%r8b
mov    $0x3,%r9d
mov    $0x6d,%dl
mov    $0x2,%esi
mov    $0x61,%cl
jmp    1214 <main+0x94>
cmp    $0xa,%al
jne    1228 <main+0xa8>
mov    %rsp,%rdi
mov    %r15,%rsi
call   1060 <fputs@plt>
lea    0xd91(%rip),%rdi
mov    $0x9,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   10a0 <fwrite@plt>
mov    %r15,%rdi
call   1040 <fclose@plt>
mov    0x2d27(%rip),%rax
mov    (%rax),%esi
lea    0xd71(%rip),%rdi
mov    $0x2710,%edx
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x4e20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [26 x i8] c"\0APlease Input File Name:\0A\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [2 x i8] c"a\00"
@.str.3 = [29 x i8] c"File \22%s\22 opened or created\0A\00"
@.str.4 = [31 x i8] c"\0APlease Input Text To Convert\0A\00"
@.str.5 = [7 x i8] c"<pre>\0A\00"
@.str.6 = [10 x i8] c"\0A<pre\\n>\0A\00"
@.str.7 = [27 x i8] c"BUFSIZ = %d MAX_SIZE = %d\0A\00"
@BUFSIZ = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca [10000 x i8]
%4 = alloca [10000 x i8]
%5 = alloca i32
%6 = alloca i32*
store i32 0, i32* %1
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%8 = getelementptr inbounds [10000 x i8], [10000 x i8]* %3, i64 0, i64 0
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%10 = getelementptr inbounds [10000 x i8], [10000 x i8]* %3, i64 0, i64 0
%11 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %11, i32** %6
%12 = getelementptr inbounds [10000 x i8], [10000 x i8]* %3, i64 0, i64 0
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i8* %12)
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0))
%15 = getelementptr inbounds [10000 x i8], [10000 x i8]* %4, i64 0, i64 0
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %15)
%17 = load i32*, i32** %6
%18 = call i32 (i32*, i8*, ...) @fprintf(i32* %17, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %5
br label %19
19: ; preds = %89, %0
%20 = call signext i8 (...) @getchar()
store i8 %20, i8* %2
%21 = sext i8 %20 to i32
%22 = icmp ne i32 %21, 10
br i1 %22, label %23, label %92
23: ; preds = %19
%24 = load i8, i8* %2
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 38
br i1 %26, label %27, label %45
27: ; preds = %23
%28 = load i32, i32* %5
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [10000 x i8], [10000 x i8]* %4, i64 0, i64 %29
store i8 38, i8* %30
%31 = load i32, i32* %5
%32 = add nsw i32 %31, 1
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [10000 x i8], [10000 x i8]* %4, i64 0, i64 %33
store i8 97, i8* %34
%35 = load i32, i32* %5
%36 = add nsw i32 %35, 2
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [10000 x i8], [10000 x i8]* %4, i64 0, i64 %37
store i8 109, i8* %38
%39 = load i32, i32* %5
%40 = add nsw i32 %39, 3
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [10000 x i8], [10000 x i8]* %4, i64 0, i64 %41
store i8 112, i8* %42
%43 = load i32, i32* %5
%44 = add nsw i32 %43, 3
store i32 %44, i32* %5
br label %88
45: ; preds = %23
%46 = load i8, i8* %2
%47 = sext i8 %46 to i32
%48 = icmp eq i32 %47, 62
br i1 %48, label %49, label %63
49: ; preds = %45
%50 = load i32, i32* %5
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [10000 x i8], [10000 x i8]* %4, i64 0, i64 %51
store i8 38, i8* %52
%53 = load i32, i32* %5
%54 = add nsw i32 %53, 1
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds [10000 x i8], [10000 x i8]* %4, i64 0, i64 %55
store i8 103, i8* %56
%57 = load i32, i32* %5
%58 = add nsw i32 %57, 2
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds [10000 x i8], [10000 x i8]* %4, i64 0, i64 %59
store i8 116, i8* %60
%61 = load i32, i32* %5
%62 = add nsw i32 %61, 2
store i32 %62, i32* %5
br label %87
63: ; preds = %45
%64 = load i8, i8* %2
%65 = sext i8 %64 to i32
%66 = icmp eq i32 %65, 60
br i1 %66, label %67, label %81
67: ; preds = %63
%68 = load i32, i32* %5
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds [10000 x i8], [10000 x i8]* %4, i64 0, i64 %69
store i8 38, i8* %70
%71 = load i32, i32* %5
%72 = add nsw i32 %71, 1
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds [10000 x i8], [10000 x i8]* %4, i64 0, i64 %73
store i8 108, i8* %74
%75 = load i32, i32* %5
%76 = add nsw i32 %75, 2
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds [10000 x i8], [10000 x i8]* %4, i64 0, i64 %77
store i8 116, i8* %78
%79 = load i32, i32* %5
%80 = add nsw i32 %79, 2
store i32 %80, i32* %5
br label %86
81: ; preds = %63
%82 = load i8, i8* %2
%83 = load i32, i32* %5
%84 = sext i32 %83 to i64
%85 = getelementptr inbounds [10000 x i8], [10000 x i8]* %4, i64 0, i64 %84
store i8 %82, i8* %85
br label %86
86: ; preds = %81, %67
br label %87
87: ; preds = %86, %49
br label %88
88: ; preds = %87, %27
br label %89
89: ; preds = %88
%90 = load i32, i32* %5
%91 = add nsw i32 %90, 1
store i32 %91, i32* %5
br label %19
92: ; preds = %19
%93 = load i32*, i32** %6
%94 = getelementptr inbounds [10000 x i8], [10000 x i8]* %4, i64 0, i64 0
%95 = call i32 (i32*, i8*, ...) @fprintf(i32* %93, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %94)
%96 = load i32*, i32** %6
%97 = call i32 (i32*, i8*, ...) @fprintf(i32* %96, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0))
%98 = load i32*, i32** %6
%99 = call i32 @fclose(i32* %98)
%100 = load i32, i32* @BUFSIZ
%101 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0), i32 %100, i32 10000)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [2 x i8] c"a\00"
@.str.3 = [29 x i8] c"File \22%s\22 opened or created\0A\00"
@.str.5 = [7 x i8] c"<pre>\0A\00"
@.str.6 = [10 x i8] c"\0A<pre\\n>\0A\00"
@.str.7 = [27 x i8] c"BUFSIZ = %d MAX_SIZE = %d\0A\00"
@BUFSIZ = global i32 0
@str = [25 x i8] c"\0APlease Input File Name:\00"
@str.8 = [30 x i8] c"\0APlease Input Text To Convert\00"
define i32 @main() {
%1 = alloca [10000 x i8]
%2 = alloca [10000 x i8]
%3 = getelementptr inbounds [10000 x i8], [10000 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [10000 x i8], [10000 x i8]* %2, i64 0, i64 0
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%7 = call i32* @fopen(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i8* %3)
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.8, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%11 = call i64 @fwrite(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i64 6, i64 1, i32* %7)
br label %12
12: ; preds = %33, %0
%13 = phi i32 [ 0, %0 ], [ %38, %33 ]
%14 = call signext i8 (...) @getchar()
switch i8 %14, label %33 [
i8 10, label %39
i8 38, label %15
i8 62, label %20
i8 60, label %19
]
15: ; preds = %12
%16 = sext i32 %13 to i64
%17 = getelementptr inbounds [10000 x i8], [10000 x i8]* %2, i64 0, i64 %16
store i8 38, i8* %17
%18 = add nsw i32 %13, 1
br label %20
19: ; preds = %12
br label %20
20: ; preds = %12, %19, %15
%21 = phi i32 [ %18, %15 ], [ %13, %19 ], [ %13, %12 ]
%22 = phi i8 [ 97, %15 ], [ 38, %19 ], [ 38, %12 ]
%23 = phi i32 [ 2, %15 ], [ 1, %19 ], [ 1, %12 ]
%24 = phi i8 [ 109, %15 ], [ 108, %19 ], [ 103, %12 ]
%25 = phi i32 [ 3, %15 ], [ 2, %19 ], [ 2, %12 ]
%26 = phi i8 [ 112, %15 ], [ 116, %19 ], [ 116, %12 ]
%27 = sext i32 %21 to i64
%28 = getelementptr inbounds [10000 x i8], [10000 x i8]* %2, i64 0, i64 %27
store i8 %22, i8* %28
%29 = add nsw i32 %13, %23
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [10000 x i8], [10000 x i8]* %2, i64 0, i64 %30
store i8 %24, i8* %31
%32 = add nsw i32 %13, %25
br label %33
33: ; preds = %20, %12
%34 = phi i32 [ %13, %12 ], [ %32, %20 ]
%35 = phi i8 [ %14, %12 ], [ %26, %20 ]
%36 = sext i32 %34 to i64
%37 = getelementptr inbounds [10000 x i8], [10000 x i8]* %2, i64 0, i64 %36
store i8 %35, i8* %37
%38 = add nsw i32 %34, 1
br label %12
39: ; preds = %12
%40 = call i32 @fputs(i8* %4, i32* %7)
%41 = call i64 @fwrite(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i64 9, i64 1, i32* %7)
%42 = call i32 @fclose(i32* %7)
%43 = load i32, i32* @BUFSIZ
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0), i32 %43, i32 10000)
ret i32 0
}