#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;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int fread(char *, int, int, int /*<<< orphan*/ *);
char *malloc(int);
int stat(char const *, struct stat *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stripHtml(char *, int, char *);
main(int argc, char **argv) {
  if (argc > 1) {
    int htmlFileSize, retcode, noOfBytesRead;
    char *htmlFileBuf;
    struct stat stbuf;
    FILE *htmlFile;
    const char *htmlFileName = argv[1];
    retcode = stat(htmlFileName, &stbuf);
    fprintf(stderr, "stat retcode: %d\n", retcode);
    htmlFileSize = stbuf.st_size;
    fprintf(stderr, "input file size: %d\n", htmlFileSize);
    htmlFileBuf = malloc(htmlFileSize + 1);
    htmlFile = fopen(htmlFileName, "r");
    noOfBytesRead = fread(htmlFileBuf, 1, htmlFileSize, htmlFile);
    fprintf(stderr, "input file bytes read: %d\n", noOfBytesRead);
    htmlFileBuf[htmlFileSize] = '\000';
    stripHtml(htmlFileBuf, htmlFileSize, "-");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    1244 <main+0xe4>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1050 <stat@plt>
mov    %eax,-0x18(%rbp)
mov    0x2e3d(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%edx
lea    0xe51(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x30(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    0x2e1f(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
lea    0xe45(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x14(%rbp),%edi
add    $0x1,%edi
call   1060 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x40(%rbp),%rdi
lea    0xe3b(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x38(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x14(%rbp),%edx
mov    -0x38(%rbp),%rcx
mov    $0x1,%esi
call   1030 <fread@plt>
mov    %eax,-0x1c(%rbp)
mov    0x2dcc(%rip),%rax
mov    (%rax),%edi
mov    -0x1c(%rbp),%edx
lea    0xe09(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x28(%rbp),%rax
movslq -0x14(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x28(%rbp),%rdi
mov    -0x14(%rbp),%esi
lea    0xe05(%rip),%rdx
call   1070 <stripHtml@plt>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
cmp    $0x2,%edi
jl     120e <main+0xae>
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    0x8(%rsi),%r14
mov    %rsp,%rsi
mov    %r14,%rdi
call   1050 <stat@plt>
mov    0x2e59(%rip),%r12
mov    (%r12),%edi
lea    0xe6e(%rip),%rsi
mov    %eax,%edx
call   1040 <fprintf@plt>
movslq (%rsp),%rbx
mov    (%r12),%edi
lea    0xe6a(%rip),%rsi
mov    %ebx,%edx
call   1040 <fprintf@plt>
lea    0x1(%rbx),%edi
call   1060 <malloc@plt>
mov    %rax,%r15
lea    0xe66(%rip),%rsi
mov    %r14,%rdi
call   1080 <fopen@plt>
mov    %r15,%rdi
mov    $0x1,%esi
mov    %ebx,%edx
mov    %rax,%rcx
call   1030 <fread@plt>
mov    (%r12),%edi
lea    0xe43(%rip),%rsi
mov    %eax,%edx
call   1040 <fprintf@plt>
movb   $0x0,(%r15,%rbx,1)
lea    0xe4b(%rip),%rdx
mov    %r15,%rdi
mov    %ebx,%esi
call   1070 <stripHtml@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
xor    %eax,%eax
ret

LLVM IR (-O0):
%struct.stat = type { i32 }
@stderr = global i32 0
@.str = [18 x i8] c"stat retcode: %d\0A\00"
@.str.1 = [21 x i8] c"input file size: %d\0A\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [27 x i8] c"input file bytes read: %d\0A\00"
@.str.4 = [2 x i8] c"-\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca %struct.stat
%11 = alloca i32*
%12 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i32, i32* %4
%14 = icmp sgt i32 %13, 1
br i1 %14, label %15, label %48
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
store i8* %18, i8** %12
%19 = load i8*, i8** %12
%20 = call i32 @stat(i8* %19, %struct.stat* %10)
store i32 %20, i32* %7
%21 = load i32, i32* @stderr
%22 = load i32, i32* %7
%23 = call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %22)
%24 = getelementptr inbounds %struct.stat, %struct.stat* %10, i32 0, i32 0
%25 = load i32, i32* %24
store i32 %25, i32* %6
%26 = load i32, i32* @stderr
%27 = load i32, i32* %6
%28 = call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %27)
%29 = load i32, i32* %6
%30 = add nsw i32 %29, 1
%31 = call i8* @malloc(i32 %30)
store i8* %31, i8** %9
%32 = load i8*, i8** %12
%33 = call i32* @fopen(i8* %32, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %33, i32** %11
%34 = load i8*, i8** %9
%35 = load i32, i32* %6
%36 = load i32*, i32** %11
%37 = call i32 @fread(i8* %34, i32 1, i32 %35, i32* %36)
store i32 %37, i32* %8
%38 = load i32, i32* @stderr
%39 = load i32, i32* %8
%40 = call i32 @fprintf(i32 %38, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i32 %39)
%41 = load i8*, i8** %9
%42 = load i32, i32* %6
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8, i8* %41, i64 %43
store i8 0, i8* %44
%45 = load i8*, i8** %9
%46 = load i32, i32* %6
%47 = call i32 @stripHtml(i8* %45, i32 %46, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %48
48: ; preds = %15, %2
%49 = load i32, i32* %3
ret i32 %49
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@stderr = global i32 0
@.str = [18 x i8] c"stat retcode: %d\0A\00"
@.str.1 = [21 x i8] c"input file size: %d\0A\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [27 x i8] c"input file bytes read: %d\0A\00"
@.str.4 = [2 x i8] c"-\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.stat
%4 = icmp sgt i32 %0, 1
br i1 %4, label %5, label %25
5: ; preds = %2
%6 = bitcast %struct.stat* %3 to i8*
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = call i32 @stat(i8* %8, %struct.stat* %3)
%10 = load i32, i32* @stderr
%11 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %9)
%12 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%13 = load i32, i32* %12
%14 = load i32, i32* @stderr
%15 = tail call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %13)
%16 = add nsw i32 %13, 1
%17 = tail call i8* @malloc(i32 %16)
%18 = tail call i32* @fopen(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%19 = tail call i32 @fread(i8* %17, i32 1, i32 %13, i32* %18)
%20 = load i32, i32* @stderr
%21 = tail call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i32 %19)
%22 = sext i32 %13 to i64
%23 = getelementptr inbounds i8, i8* %17, i64 %22
store i8 0, i8* %23
%24 = tail call i32 @stripHtml(i8* %17, i32 %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %25
25: ; preds = %5, %2
ret i32 0
}