#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 /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ puts(char *);
int cgi_html_include(char *file_name) {
  FILE *fp;
  char str[1024];
  memset(str, 0, 1024);
  fp = fopen(file_name, "r");
  if (fp == NULL)
    return -1;
  while (!feof(fp)) {
    fgets(str, 1024, fp);
    puts(str);
  }
  fclose(fp);
  return 0;
}


x86 assembly (clang, -O0):
<cgi_html_include>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %rdi,-0x10(%rbp)
lea    -0x420(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1050 <memset@plt>
mov    -0x10(%rbp),%rdi
lea    0xe73(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11ad <cgi_html_include+0x4d>
movl   $0xffffffff,-0x4(%rbp)
jmp    1206 <cgi_html_include+0xa6>
jmp    11b2 <cgi_html_include+0x52>
mov    -0x18(%rbp),%rdi
call   1070 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11d0 <cgi_html_include+0x70>
jmp    11f6 <cgi_html_include+0x96>
lea    -0x420(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x400,%esi
call   1060 <fgets@plt>
lea    -0x420(%rbp),%rdi
call   1030 <puts@plt>
jmp    11b2 <cgi_html_include+0x52>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cgi_html_include>:
push   %r14
push   %rbx
sub    $0x408,%rsp
mov    %rdi,%rbx
mov    %rsp,%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1050 <memset@plt>
lea    0xe7d(%rip),%rsi
mov    %rbx,%rdi
call   1080 <fopen@plt>
test   %rax,%rax
je     11e0 <cgi_html_include+0x80>
mov    %rax,%rbx
mov    %rax,%rdi
call   1070 <feof@plt>
test   %eax,%eax
jne    11d4 <cgi_html_include+0x74>
mov    %rsp,%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
mov    $0x400,%esi
mov    %rbx,%rdx
call   1060 <fgets@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1070 <feof@plt>
test   %eax,%eax
je     11b0 <cgi_html_include+0x50>
mov    %rbx,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
jmp    11e5 <cgi_html_include+0x85>
mov    $0xffffffff,%eax
add    $0x408,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
define i32 @cgi_html_include(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca [1024 x i8]
store i8* %0, i8** %3
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%7 = call i32 @memset(i8* %6, i32 0, i32 1024)
%8 = load i8*, i8** %3
%9 = call i32* @fopen(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %9, i32** %4
%10 = load i32*, i32** %4
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %13
12: ; preds = %1
store i32 -1, i32* %2
br label %28
13: ; preds = %1
br label %14
14: ; preds = %19, %13
%15 = load i32*, i32** %4
%16 = call i32 @feof(i32* %15)
%17 = icmp ne i32 %16, 0
%18 = xor i1 %17, true
br i1 %18, label %19, label %25
19: ; preds = %14
%20 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%21 = load i32*, i32** %4
%22 = call i32 @fgets(i8* %20, i32 1024, i32* %21)
%23 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%24 = call i32 @puts(i8* %23)
br label %14
25: ; preds = %14
%26 = load i32*, i32** %4
%27 = call i32 @fclose(i32* %26)
store i32 0, i32* %2
br label %28
28: ; preds = %25, %12
%29 = load i32, i32* %2
ret i32 %29
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
define i32 @cgi_html_include(i8* nocapture %0) {
%2 = alloca [1024 x i8]
%3 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%4 = call i32 @memset(i8* %3, i32 0, i32 1024)
%5 = call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %17, label %7
7: ; preds = %1
%8 = call i32 @feof(i32* %5)
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %15
10: ; preds = %7, %10
%11 = call i32 @fgets(i8* %3, i32 1024, i32* %5)
%12 = call i32 @puts(i8* %3)
%13 = call i32 @feof(i32* %5)
%14 = icmp eq i32 %13, 0
br i1 %14, label %10, label %15
15: ; preds = %10, %7
%16 = call i32 @fclose(i32* %5)
br label %17
17: ; preds = %1, %15
%18 = phi i32 [ 0, %15 ], [ -1, %1 ]
ret i32 %18
}