#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 EOF;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ putchar(int);
int main(void) {
  FILE *f = fopen("./www/cgi/data.txt", "r");
  int ch;
  if (f == NULL) {
    printf("%s%c%c\n", "Content-Type:text/html;charset=iso-8859-1", 13, 10);
    printf("<TITLE>Failure</TITLE>\n");
    printf("<P><EM>Unable to open data file, sorry!</EM>");
  } else {
    printf("%s%c%c\n", "Content-Type:text/plain;charset=iso-8859-1", 13, 10);
    while ((ch = getc(f)) != EOF)
      putchar(ch);
    fclose(f);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
lea    0xea6(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11c1 <main+0x71>
lea    0xe8d(%rip),%rdi
lea    0xe8e(%rip),%rsi
mov    $0xd,%edx
mov    $0xa,%ecx
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1211 <main+0xc1>
lea    0xe4d(%rip),%rdi
lea    0xebd(%rip),%rsi
mov    $0xd,%edx
mov    $0xa,%ecx
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1070 <getc@plt>
mov    %eax,-0x14(%rbp)
mov    0x2df5(%rip),%rcx
cmp    (%rcx),%eax
je     1208 <main+0xb8>
mov    -0x14(%rbp),%edi
call   1030 <putchar@plt>
jmp    11e0 <main+0x90>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xe95(%rip),%rdi
lea    0xea1(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     11de <main+0x7e>
mov    %rax,%rbx
lea    0xe8f(%rip),%rdi
lea    0xee7(%rip),%rsi
mov    $0xd,%edx
mov    $0xa,%ecx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1080 <getc@plt>
mov    0x2e3b(%rip),%r14
cmp    (%r14),%eax
je     11d4 <main+0x74>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %eax,%edi
call   1030 <putchar@plt>
mov    %rbx,%rdi
call   1080 <getc@plt>
cmp    (%r14),%eax
jne    11c0 <main+0x60>
mov    %rbx,%rdi
call   1050 <fclose@plt>
jmp    1217 <main+0xb7>
lea    0xe30(%rip),%rdi
lea    0xe31(%rip),%rsi
mov    $0xd,%edx
mov    $0xa,%ecx
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe9b(%rip),%rdi
call   1040 <puts@plt>
lea    0xe37(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [19 x i8] c"./www/cgi/data.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [8 x i8] c"%s%c%c\0A\00"
@.str.3 = [42 x i8] c"Content-Type:text/html;charset=iso-8859-1\00"
@.str.4 = [24 x i8] c"<TITLE>Failure</TITLE>\0A\00"
@.str.5 = [45 x i8] c"<P><EM>Unable to open data file, sorry!</EM>\00"
@.str.6 = [43 x i8] c"Content-Type:text/plain;charset=iso-8859-1\00"
@EOF = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32* @fopen(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %4, i32** %2
%5 = load i32*, i32** %2
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %11
7: ; preds = %0
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0), i32 13, i32 10)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.5, i64 0, i64 0))
br label %24
11: ; preds = %0
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.6, i64 0, i64 0), i32 13, i32 10)
br label %13
13: ; preds = %18, %11
%14 = load i32*, i32** %2
%15 = call i32 @getc(i32* %14)
store i32 %15, i32* %3
%16 = load i32, i32* @EOF
%17 = icmp ne i32 %15, %16
br i1 %17, label %18, label %21
18: ; preds = %13
%19 = load i32, i32* %3
%20 = call i32 @putchar(i32 %19)
br label %13
21: ; preds = %13
%22 = load i32*, i32** %2
%23 = call i32 @fclose(i32* %22)
br label %24
24: ; preds = %21, %7
ret i32 0
}

LLVM IR (-O2):
@.str = [19 x i8] c"./www/cgi/data.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [8 x i8] c"%s%c%c\0A\00"
@.str.3 = [42 x i8] c"Content-Type:text/html;charset=iso-8859-1\00"
@.str.5 = [45 x i8] c"<P><EM>Unable to open data file, sorry!</EM>\00"
@.str.6 = [43 x i8] c"Content-Type:text/plain;charset=iso-8859-1\00"
@EOF = global i32 0
@str = [23 x i8] c"<TITLE>Failure</TITLE>\00"
define i32 @main() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%2 = icmp eq i32* %1, null
br i1 %2, label %3, label %7
3: ; preds = %0
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0), i32 13, i32 10)
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.5, i64 0, i64 0))
br label %20
7: ; preds = %0
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.6, i64 0, i64 0), i32 13, i32 10)
%9 = tail call i32 @getc(i32* %1)
%10 = load i32, i32* @EOF
%11 = icmp eq i32 %9, %10
br i1 %11, label %18, label %12
12: ; preds = %7, %12
%13 = phi i32 [ %15, %12 ], [ %9, %7 ]
%14 = tail call i32 @putchar(i32 %13)
%15 = tail call i32 @getc(i32* %1)
%16 = load i32, i32* @EOF
%17 = icmp eq i32 %15, %16
br i1 %17, label %18, label %12
18: ; preds = %12, %7
%19 = tail call i32 @fclose(i32* %1)
br label %20
20: ; preds = %18, %3
ret i32 0
}