#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 */
struct stat {
  int st_size;
};

/* Variables and functions */
int O_CREAT;
int /*<<< orphan*/ O_RDONLY;
int O_TRUNC;
int O_WRONLY;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ get_full_file(int, char *, int);
int /*<<< orphan*/ get_input(char *);
char *malloc(int);
int /*<<< orphan*/ memset(char *, char, int);
int open(char *, int, ...);
int /*<<< orphan*/ parse_file(char *, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stat(char *, struct stat *);
scalar_t__ strcmp(char *, char *);
int main(int argc, char *argv[]) {
  char *input;
  int input_file = -1;
  int output_file = -1;
  int cl_bit = 0;
  int bytes = 0;
  struct stat input_file_stat;
  struct stat output_file_stat;
  char *file_string;
  char *write_string;
  if (argc > 3) {
    printf("usage: h2p [html_file] [output_file]\n");
    printf("use the -help flag for more information \n");
    exit(1);
  }
  if (argc > 1) {
    cl_bit = 1;
  }
  if (cl_bit == 1) {
    if (strcmp(argv[1], "-help") == 0) {
      printf("Title: HTML_TO_PHPecho / h2p. \nAuthor: Glenn Upthagrove \nDate: "
             "02/07/2017\nUsage: h2p [html_file] [output_file]\nCan also be "
             "run as ./h2p and user will be prompted for file names.\nTakes "
             "HTML from a file and stores into an output file as a proper PHP "
             "echo statement. If the output file does not exist it will be "
             "made. \nReport issues and find out more at the github page: "
             "https://github.com/upthagrg/HTML_to_PHPecho.\n");
      return 0;
    } else if ((strcmp(argv[0], "-help") != 0) && (argc == 2)) {
      printf("usage: h2p [html_file] [output_file]\n");
      printf("use the -help flag for more information \n");
      exit(1);
    } else {
      input_file = open(argv[1], O_RDONLY);
      stat(argv[1], &input_file_stat);
      output_file = open(argv[2], O_WRONLY | O_CREAT | O_TRUNC, 0644);
      stat(argv[2], &output_file_stat);
    }
  } else {
    input = malloc(sizeof(char) * 128);
    while (input_file < 0) {
      memset(input, '\0', 128);
      printf("Enter the file you would like to read from> ");
      get_input(input);
      input_file = open(input, O_RDONLY);
      if (input_file < 0) {
        printf("ERROR OPENING FILE\n");
      }
    }
    stat(input, &input_file_stat);
    while (output_file < 0) {
      memset(input, '\0', 128);
      printf("Enter the file you would like to write to> ");
      get_input(input);
      output_file = open(input, O_WRONLY | O_CREAT | O_TRUNC, 0644);
      if (input_file < 0) {
        printf("ERROR OPENING FILE\n");
      }
    }
    stat(input, &output_file_stat);
  }
  file_string = malloc(sizeof(char) * input_file_stat.st_size);
  memset(file_string, '\0', sizeof(char) * input_file_stat.st_size);
  get_full_file(input_file, file_string, input_file_stat.st_size);
  parse_file(file_string, output_file);
  if (cl_bit == 0) {
    free(input);
  }
  free(file_string);
  close(input_file);
  close(output_file);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0xffffffff,-0x1c(%rbp)
movl   $0xffffffff,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
cmpl   $0x3,-0x8(%rbp)
jle    121e <main+0x5e>
lea    0xdfd(%rip),%rdi
call   1040 <printf@plt>
lea    0xe17(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
cmpl   $0x1,-0x8(%rbp)
jle    122f <main+0x6f>
movl   $0x1,-0x24(%rbp)
cmpl   $0x1,-0x24(%rbp)
jne    1331 <main+0x171>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe08(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    126f <main+0xaf>
lea    0xdf8(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    14a8 <main+0x2e8>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xdd3(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
je     12b8 <main+0xf8>
cmpl   $0x2,-0x8(%rbp)
jne    12b8 <main+0xf8>
lea    0xd63(%rip),%rdi
call   1040 <printf@plt>
lea    0xd7d(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2d11(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   10b0 <open@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x30(%rbp),%rsi
call   1080 <stat@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    0x2ccd(%rip),%rax
mov    (%rax),%esi
mov    0x2cfc(%rip),%rax
or     (%rax),%esi
mov    0x2ceb(%rip),%rax
or     (%rax),%esi
mov    $0x1a4,%edx
mov    $0x0,%al
call   10b0 <open@plt>
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    -0x38(%rbp),%rsi
call   1080 <stat@plt>
jmp    132c <main+0x16c>
jmp    1432 <main+0x272>
mov    $0x80,%edi
call   1090 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    13a0 <main+0x1e0>
mov    -0x18(%rbp),%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1050 <memset@plt>
lea    0xe94(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   10e0 <get_input@plt>
mov    -0x18(%rbp),%rdi
mov    0x2c5f(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   10b0 <open@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    139b <main+0x1db>
lea    0xe8b(%rip),%rdi
call   1040 <printf@plt>
jmp    133f <main+0x17f>
mov    -0x18(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1080 <stat@plt>
cmpl   $0x0,-0x20(%rbp)
jge    1425 <main+0x265>
mov    -0x18(%rbp),%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1050 <memset@plt>
lea    0xe67(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   10e0 <get_input@plt>
mov    -0x18(%rbp),%rdi
mov    0x2bd9(%rip),%rax
mov    (%rax),%esi
mov    0x2c08(%rip),%rax
or     (%rax),%esi
mov    0x2bf7(%rip),%rax
or     (%rax),%esi
mov    $0x1a4,%edx
mov    $0x0,%al
call   10b0 <open@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    1420 <main+0x260>
lea    0xe06(%rip),%rdi
call   1040 <printf@plt>
jmp    13ad <main+0x1ed>
mov    -0x18(%rbp),%rdi
lea    -0x38(%rbp),%rsi
call   1080 <stat@plt>
movslq -0x30(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1090 <malloc@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
movslq -0x30(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edx
xor    %esi,%esi
call   1050 <memset@plt>
mov    -0x1c(%rbp),%edi
mov    -0x40(%rbp),%rsi
mov    -0x30(%rbp),%edx
call   10a0 <get_full_file@plt>
mov    -0x40(%rbp),%rdi
mov    -0x20(%rbp),%esi
call   10c0 <parse_file@plt>
cmpl   $0x0,-0x24(%rbp)
jne    1488 <main+0x2c8>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
mov    -0x1c(%rbp),%edi
call   1060 <close@plt>
mov    -0x20(%rbp),%edi
call   1060 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
cmp    $0x4,%edi
jge    142e <main+0x25e>
mov    %edi,%r14d
cmp    $0x2,%edi
jl     1288 <main+0xb8>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xdff(%rip),%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     1420 <main+0x250>
mov    (%rbx),%rdi
lea    0xde7(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x2,%r14d
jne    122d <main+0x5d>
test   %rax,%rax
jne    142e <main+0x25e>
mov    0x8(%rbx),%rdi
mov    0x2da0(%rip),%rax
mov    (%rax),%esi
xor    %eax,%eax
call   10c0 <open@plt>
mov    %eax,%r15d
mov    0x8(%rbx),%rdi
lea    0x8(%rsp),%rsi
call   1090 <stat@plt>
mov    0x2d67(%rip),%rax
mov    0x2d98(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x10(%rbx),%rdi
mov    0x2d81(%rip),%rax
or     (%rax),%esi
mov    $0x1a4,%edx
xor    %eax,%eax
call   10c0 <open@plt>
mov    %eax,%ebp
mov    0x10(%rbx),%rbx
jmp    13a8 <main+0x1d8>
mov    $0x80,%edi
call   10a0 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1060 <memset@plt>
lea    0xd5b(%rip),%rdi
call   1050 <printf@plt>
mov    %rbx,%rdi
call   10f0 <get_input@plt>
mov    0x2d19(%rip),%r13
mov    0x0(%r13),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   10c0 <open@plt>
mov    %eax,%r15d
test   %eax,%eax
jns    132c <main+0x15c>
lea    0xd84(%rip),%r12
lea    0xd24(%rip),%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r12,%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1060 <memset@plt>
mov    %rbp,%rdi
call   1050 <printf@plt>
mov    %rbx,%rdi
call   10f0 <get_input@plt>
mov    0x0(%r13),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   10c0 <open@plt>
test   %eax,%eax
js     12f0 <main+0x120>
mov    %eax,%r15d
mov    %r14d,0xc(%rsp)
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1090 <stat@plt>
mov    0x2c7b(%rip),%r13
mov    0x2cac(%rip),%r14
mov    0x2c9d(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1060 <memset@plt>
lea    0xcbd(%rip),%rdi
call   1050 <printf@plt>
mov    %rbx,%rdi
call   10f0 <get_input@plt>
mov    (%r14),%esi
or     0x0(%r13),%esi
or     (%r12),%esi
mov    %rbx,%rdi
mov    $0x1a4,%edx
xor    %eax,%eax
call   10c0 <open@plt>
test   %eax,%eax
js     1360 <main+0x190>
mov    %eax,%ebp
mov    0xc(%rsp),%r14d
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   1090 <stat@plt>
mov    0x8(%rsp),%r13d
mov    %r13d,%edi
call   10a0 <malloc@plt>
mov    %rax,%r12
mov    %rax,%rdi
xor    %esi,%esi
mov    %r13d,%edx
call   1060 <memset@plt>
mov    %r15d,%edi
mov    %r12,%rsi
mov    %r13d,%edx
call   10b0 <get_full_file@plt>
mov    %r12,%rdi
mov    %ebp,%esi
call   10d0 <parse_file@plt>
cmp    $0x1,%r14d
jg     13f8 <main+0x228>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r12,%rdi
call   1030 <free@plt>
mov    %r15d,%edi
call   1070 <close@plt>
mov    %ebp,%edi
call   1070 <close@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc4b(%rip),%rdi
call   1040 <puts@plt>
jmp    140f <main+0x23f>
lea    0xdda(%rip),%rdi
call   1040 <puts@plt>
lea    0xdf3(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>

LLVM IR (-O0):
%struct.stat = type { i32 }
@.str = [38 x i8] c"usage: h2p [html_file] [output_file]\0A\00"
@.str.1 = [42 x i8] c"use the -help flag for more information \0A\00"
@.str.2 = [6 x i8] c"-help\00"
@.str.3 = [414 x i8] c"Title: HTML_TO_PHPecho / h2p. \0AAuthor: Glenn Upthagrove \0ADate: 02/07/2017\0AUsage: h2p [html_file] [output_file]\0ACan also be run as ./h2p and user will be prompted for file names.\0ATakes HTML from a file and stores into an output file as a proper PHP echo statement. If the output file does not exist it will be made. \0AReport issues and find out more at the github page: https://github.com/upthagrg/HTML_to_PHPecho.\0A\00"
@O_RDONLY = global i32 0
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@.str.4 = [45 x i8] c"Enter the file you would like to read from> \00"
@.str.5 = [20 x i8] c"ERROR OPENING FILE\0A\00"
@.str.6 = [44 x i8] c"Enter the file you would like to write to> \00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca %struct.stat
%12 = alloca %struct.stat
%13 = alloca i8*
%14 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 -1, i32* %7
store i32 -1, i32* %8
store i32 0, i32* %9
store i32 0, i32* %10
%15 = load i32, i32* %4
%16 = icmp sgt i32 %15, 3
br i1 %16, label %17, label %21
17: ; preds = %2
%18 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%19 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0))
%20 = call i32 @exit(i32 1)
unreachable
21: ; preds = %2
%22 = load i32, i32* %4
%23 = icmp sgt i32 %22, 1
br i1 %23, label %24, label %25
24: ; preds = %21
store i32 1, i32* %9
br label %25
25: ; preds = %24, %21
%26 = load i32, i32* %9
%27 = icmp eq i32 %26, 1
br i1 %27, label %28, label %74
28: ; preds = %25
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 1
%31 = load i8*, i8** %30
%32 = call i64 @strcmp(i8* %31, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %36
34: ; preds = %28
%35 = call i32 @printf(i8* getelementptr inbounds ([414 x i8], [414 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %3
br label %154
36: ; preds = %28
%37 = load i8**, i8*** %5
%38 = getelementptr inbounds i8*, i8** %37, i64 0
%39 = load i8*, i8** %38
%40 = call i64 @strcmp(i8* %39, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%41 = icmp ne i64 %40, 0
br i1 %41, label %42, label %49
42: ; preds = %36
%43 = load i32, i32* %4
%44 = icmp eq i32 %43, 2
br i1 %44, label %45, label %49
45: ; preds = %42
%46 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%47 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0))
%48 = call i32 @exit(i32 1)
unreachable
49: ; preds = %42, %36
%50 = load i8**, i8*** %5
%51 = getelementptr inbounds i8*, i8** %50, i64 1
%52 = load i8*, i8** %51
%53 = load i32, i32* @O_RDONLY
%54 = call i32 (i8*, i32, ...) @open(i8* %52, i32 %53)
store i32 %54, i32* %7
%55 = load i8**, i8*** %5
%56 = getelementptr inbounds i8*, i8** %55, i64 1
%57 = load i8*, i8** %56
%58 = call i32 @stat(i8* %57, %struct.stat* %11)
%59 = load i8**, i8*** %5
%60 = getelementptr inbounds i8*, i8** %59, i64 2
%61 = load i8*, i8** %60
%62 = load i32, i32* @O_WRONLY
%63 = load i32, i32* @O_CREAT
%64 = or i32 %62, %63
%65 = load i32, i32* @O_TRUNC
%66 = or i32 %64, %65
%67 = call i32 (i8*, i32, ...) @open(i8* %61, i32 %66, i32 420)
store i32 %67, i32* %8
%68 = load i8**, i8*** %5
%69 = getelementptr inbounds i8*, i8** %68, i64 2
%70 = load i8*, i8** %69
%71 = call i32 @stat(i8* %70, %struct.stat* %12)
br label %72
72: ; preds = %49
br label %73
73: ; preds = %72
br label %120
74: ; preds = %25
%75 = call i8* @malloc(i32 128)
store i8* %75, i8** %6
br label %76
76: ; preds = %92, %74
%77 = load i32, i32* %7
%78 = icmp slt i32 %77, 0
br i1 %78, label %79, label %93
79: ; preds = %76
%80 = load i8*, i8** %6
%81 = call i32 @memset(i8* %80, i8 signext 0, i32 128)
%82 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.4, i64 0, i64 0))
%83 = load i8*, i8** %6
%84 = call i32 @get_input(i8* %83)
%85 = load i8*, i8** %6
%86 = load i32, i32* @O_RDONLY
%87 = call i32 (i8*, i32, ...) @open(i8* %85, i32 %86)
store i32 %87, i32* %7
%88 = load i32, i32* %7
%89 = icmp slt i32 %88, 0
br i1 %89, label %90, label %92
90: ; preds = %79
%91 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0))
br label %92
92: ; preds = %90, %79
br label %76
93: ; preds = %76
%94 = load i8*, i8** %6
%95 = call i32 @stat(i8* %94, %struct.stat* %11)
br label %96
96: ; preds = %116, %93
%97 = load i32, i32* %8
%98 = icmp slt i32 %97, 0
br i1 %98, label %99, label %117
99: ; preds = %96
%100 = load i8*, i8** %6
%101 = call i32 @memset(i8* %100, i8 signext 0, i32 128)
%102 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.6, i64 0, i64 0))
%103 = load i8*, i8** %6
%104 = call i32 @get_input(i8* %103)
%105 = load i8*, i8** %6
%106 = load i32, i32* @O_WRONLY
%107 = load i32, i32* @O_CREAT
%108 = or i32 %106, %107
%109 = load i32, i32* @O_TRUNC
%110 = or i32 %108, %109
%111 = call i32 (i8*, i32, ...) @open(i8* %105, i32 %110, i32 420)
store i32 %111, i32* %8
%112 = load i32, i32* %7
%113 = icmp slt i32 %112, 0
br i1 %113, label %114, label %116
114: ; preds = %99
%115 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0))
br label %116
116: ; preds = %114, %99
br label %96
117: ; preds = %96
%118 = load i8*, i8** %6
%119 = call i32 @stat(i8* %118, %struct.stat* %12)
br label %120
120: ; preds = %117, %73
%121 = getelementptr inbounds %struct.stat, %struct.stat* %11, i32 0, i32 0
%122 = load i32, i32* %121
%123 = sext i32 %122 to i64
%124 = mul i64 1, %123
%125 = trunc i64 %124 to i32
%126 = call i8* @malloc(i32 %125)
store i8* %126, i8** %13
%127 = load i8*, i8** %13
%128 = getelementptr inbounds %struct.stat, %struct.stat* %11, i32 0, i32 0
%129 = load i32, i32* %128
%130 = sext i32 %129 to i64
%131 = mul i64 1, %130
%132 = trunc i64 %131 to i32
%133 = call i32 @memset(i8* %127, i8 signext 0, i32 %132)
%134 = load i32, i32* %7
%135 = load i8*, i8** %13
%136 = getelementptr inbounds %struct.stat, %struct.stat* %11, i32 0, i32 0
%137 = load i32, i32* %136
%138 = call i32 @get_full_file(i32 %134, i8* %135, i32 %137)
%139 = load i8*, i8** %13
%140 = load i32, i32* %8
%141 = call i32 @parse_file(i8* %139, i32 %140)
%142 = load i32, i32* %9
%143 = icmp eq i32 %142, 0
br i1 %143, label %144, label %147
144: ; preds = %120
%145 = load i8*, i8** %6
%146 = call i32 @free(i8* %145)
br label %147
147: ; preds = %144, %120
%148 = load i8*, i8** %13
%149 = call i32 @free(i8* %148)
%150 = load i32, i32* %7
%151 = call i32 @close(i32 %150)
%152 = load i32, i32* %8
%153 = call i32 @close(i32 %152)
store i32 0, i32* %3
br label %154
154: ; preds = %147, %34
%155 = load i32, i32* %3
ret i32 %155
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@.str.2 = [6 x i8] c"-help\00"
@O_RDONLY = global i32 0
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@.str.4 = [45 x i8] c"Enter the file you would like to read from> \00"
@.str.6 = [44 x i8] c"Enter the file you would like to write to> \00"
@str = [19 x i8] c"ERROR OPENING FILE\00"
@str.9 = [413 x i8] c"Title: HTML_TO_PHPecho / h2p. \0AAuthor: Glenn Upthagrove \0ADate: 02/07/2017\0AUsage: h2p [html_file] [output_file]\0ACan also be run as ./h2p and user will be prompted for file names.\0ATakes HTML from a file and stores into an output file as a proper PHP echo statement. If the output file does not exist it will be made. \0AReport issues and find out more at the github page: https://github.com/upthagrg/HTML_to_PHPecho.\00"
@str.10 = [37 x i8] c"usage: h2p [html_file] [output_file]\00"
@str.11 = [41 x i8] c"use the -help flag for more information \00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.stat
%4 = alloca %struct.stat
%5 = bitcast %struct.stat* %3 to i8*
%6 = bitcast %struct.stat* %4 to i8*
%7 = icmp sgt i32 %0, 3
br i1 %7, label %8, label %12
8: ; preds = %2
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.10, i64 0, i64 0))
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.11, i64 0, i64 0))
%11 = tail call i32 @exit(i32 1)
unreachable
12: ; preds = %2
%13 = icmp sgt i32 %0, 1
br i1 %13, label %14, label %46
14: ; preds = %12
%15 = getelementptr inbounds i8*, i8** %1, i64 1
%16 = load i8*, i8** %15
%17 = tail call i64 @strcmp(i8* %16, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %14
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([413 x i8], [413 x i8]* @str.9, i64 0, i64 0))
br label %94
21: ; preds = %14
%22 = load i8*, i8** %1
%23 = tail call i64 @strcmp(i8* %22, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%24 = icmp ne i64 %23, 0
%25 = icmp eq i32 %0, 2
%26 = and i1 %25, %24
br i1 %26, label %27, label %31
27: ; preds = %21
%28 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.10, i64 0, i64 0))
%29 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.11, i64 0, i64 0))
%30 = tail call i32 @exit(i32 1)
unreachable
31: ; preds = %21
%32 = load i8*, i8** %15
%33 = load i32, i32* @O_RDONLY
%34 = tail call i32 (i8*, i32, ...) @open(i8* %32, i32 %33)
%35 = load i8*, i8** %15
%36 = call i32 @stat(i8* %35, %struct.stat* %3)
%37 = getelementptr inbounds i8*, i8** %1, i64 2
%38 = load i8*, i8** %37
%39 = load i32, i32* @O_WRONLY
%40 = load i32, i32* @O_CREAT
%41 = or i32 %40, %39
%42 = load i32, i32* @O_TRUNC
%43 = or i32 %41, %42
%44 = tail call i32 (i8*, i32, ...) @open(i8* %38, i32 %43, i32 420)
%45 = load i8*, i8** %37
br label %76
46: ; preds = %12
%47 = tail call dereferenceable_or_null(128) i8* @malloc(i32 128)
%48 = tail call i32 @memset(i8* %47, i8 signext 0, i32 128)
%49 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.4, i64 0, i64 0))
%50 = tail call i32 @get_input(i8* %47)
%51 = load i32, i32* @O_RDONLY
%52 = tail call i32 (i8*, i32, ...) @open(i8* %47, i32 %51)
%53 = icmp slt i32 %52, 0
br i1 %53, label %54, label %62
54: ; preds = %46, %54
%55 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
%56 = tail call i32 @memset(i8* %47, i8 signext 0, i32 128)
%57 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.4, i64 0, i64 0))
%58 = tail call i32 @get_input(i8* %47)
%59 = load i32, i32* @O_RDONLY
%60 = tail call i32 (i8*, i32, ...) @open(i8* %47, i32 %59)
%61 = icmp slt i32 %60, 0
br i1 %61, label %54, label %62
62: ; preds = %54, %46
%63 = phi i32 [ %52, %46 ], [ %60, %54 ]
%64 = call i32 @stat(i8* %47, %struct.stat* %3)
br label %65
65: ; preds = %62, %65
%66 = tail call i32 @memset(i8* %47, i8 signext 0, i32 128)
%67 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.6, i64 0, i64 0))
%68 = tail call i32 @get_input(i8* %47)
%69 = load i32, i32* @O_WRONLY
%70 = load i32, i32* @O_CREAT
%71 = or i32 %70, %69
%72 = load i32, i32* @O_TRUNC
%73 = or i32 %71, %72
%74 = tail call i32 (i8*, i32, ...) @open(i8* %47, i32 %73, i32 420)
%75 = icmp slt i32 %74, 0
br i1 %75, label %65, label %76
76: ; preds = %65, %31
%77 = phi i8* [ %45, %31 ], [ %47, %65 ]
%78 = phi i32 [ %44, %31 ], [ %74, %65 ]
%79 = phi i32 [ %34, %31 ], [ %63, %65 ]
%80 = phi i8* [ undef, %31 ], [ %47, %65 ]
%81 = call i32 @stat(i8* %77, %struct.stat* %4)
%82 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%83 = load i32, i32* %82
%84 = tail call i8* @malloc(i32 %83)
%85 = tail call i32 @memset(i8* %84, i8 signext 0, i32 %83)
%86 = tail call i32 @get_full_file(i32 %79, i8* %84, i32 %83)
%87 = tail call i32 @parse_file(i8* %84, i32 %78)
br i1 %13, label %90, label %88
88: ; preds = %76
%89 = tail call i32 @free(i8* %80)
br label %90
90: ; preds = %88, %76
%91 = tail call i32 @free(i8* %84)
%92 = tail call i32 @close(i32 %79)
%93 = tail call i32 @close(i32 %78)
br label %94
94: ; preds = %90, %19
ret i32 0
}