#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*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ file_exists(char *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ stderr;
void create_index_page() {
  char file_name[] = "index.html";
  if (file_exists(file_name)) {
    return;
  }
  FILE *fp = fopen(file_name, "w");
  if (fp == NULL) {
    fprintf(stderr, "ERROR: could not open for writing: %s", file_name);
    exit(EXIT_FAILURE);
  }
  fprintf(fp, "---\nlayout: default\n---\n\n");
  fprintf(fp, "<h2>Posts</h2>\n\n");
  fprintf(fp, "<ul>\n");
  fprintf(fp, "{{#posts}}\n");
  fprintf(fp, "%s<li>", "    ");
  fprintf(fp, "<a href=\"{{url}}\">{{title}} ({{date}})</a>");
  fprintf(fp, "</li>\n");
  fprintf(fp, "{{/posts}}\n");
  fprintf(fp, "</ul>\n");
  fclose(fp);
}


x86 assembly (clang, -O0):
<create_index_page>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0xea1(%rip),%rax
mov    %rax,-0xb(%rbp)
mov    0xe9e(%rip),%ax
mov    %ax,-0x3(%rbp)
mov    0xe96(%rip),%al
mov    %al,-0x1(%rbp)
lea    -0xb(%rbp),%rdi
call   1030 <file_exists@plt>
cmp    $0x0,%rax
je     118f <create_index_page+0x3f>
jmp    128a <create_index_page+0x13a>
lea    -0xb(%rbp),%rdi
lea    0xe71(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11d8 <create_index_page+0x88>
mov    0x2e2b(%rip),%rax
movslq (%rax),%rdi
lea    -0xb(%rbp),%rdx
lea    0xe4a(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2e07(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    -0x18(%rbp),%rdi
lea    0xe50(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    0xe58(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    0xe57(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    0xe4b(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    0xe45(%rip),%rsi
lea    0xe45(%rip),%rdx
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    0xe38(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    0xe51(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    0xe46(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    0xe40(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_index_page>:
push   %rbx
sub    $0x10,%rsp
movabs $0x74682e7865646e69,%rax
2e 68 74
mov    %rax,(%rsp)
movl   $0x6c6d74,0x7(%rsp)
mov    %rsp,%rdi
call   1030 <file_exists@plt>
test   %rax,%rax
jne    128f <create_index_page+0x12f>
lea    0xe78(%rip),%rsi
mov    %rsp,%rdi
call   1060 <fopen@plt>
test   %rax,%rax
je     1295 <create_index_page+0x135>
mov    %rax,%rbx
lea    0xe85(%rip),%rdi
mov    $0x19,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   1080 <fwrite@plt>
lea    0xe86(%rip),%rdi
mov    $0x10,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1080 <fwrite@plt>
lea    0xe7e(%rip),%rdi
mov    $0x5,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1080 <fwrite@plt>
lea    0xe6b(%rip),%rdi
mov    $0xb,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1080 <fwrite@plt>
lea    0xe5e(%rip),%rsi
lea    0xe5e(%rip),%rdx
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <fprintf@plt>
lea    0xe52(%rip),%rdi
mov    $0x2a,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1080 <fwrite@plt>
lea    0xe64(%rip),%rdi
mov    $0x6,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1080 <fwrite@plt>
lea    0xe52(%rip),%rdi
mov    $0xb,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1080 <fwrite@plt>
lea    0xe45(%rip),%rdi
mov    $0x6,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1080 <fwrite@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
add    $0x10,%rsp
pop    %rbx
ret
mov    0x2d44(%rip),%rax
movslq (%rax),%rdi
lea    0xd67(%rip),%rsi
mov    %rsp,%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    0x2d21(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@__const.create_index_page.file_name = [11 x i8] c"index.html\00"
@.str = [2 x i8] c"w\00"
@stderr = global i32 0
@.str.1 = [38 x i8] c"ERROR: could not open for writing: %s\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [26 x i8] c"---\0Alayout: default\0A---\0A\0A\00"
@.str.3 = [17 x i8] c"<h2>Posts</h2>\0A\0A\00"
@.str.4 = [6 x i8] c"<ul>\0A\00"
@.str.5 = [12 x i8] c"{{#posts}}\0A\00"
@.str.6 = [7 x i8] c"%s<li>\00"
@.str.7 = [5 x i8] c" \00"
@.str.8 = [43 x i8] c"<a href=\22{{url}}\22>{{title}} ({{date}})</a>\00"
@.str.9 = [7 x i8] c"</li>\0A\00"
@.str.10 = [12 x i8] c"{{/posts}}\0A\00"
@.str.11 = [7 x i8] c"</ul>\0A\00"
define void @create_index_page() {
%1 = alloca [11 x i8]
%2 = alloca i32*
%3 = bitcast [11 x i8]* %1 to i8*
%4 = getelementptr inbounds [11 x i8], [11 x i8]* %1, i64 0, i64 0
%5 = call i64 @file_exists(i8* %4)
%6 = icmp ne i64 %5, 0
br i1 %6, label %7, label %8
7: ; preds = %0
br label %42
8: ; preds = %0
%9 = getelementptr inbounds [11 x i8], [11 x i8]* %1, i64 0, i64 0
%10 = call i32* @fopen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %10, i32** %2
%11 = load i32*, i32** %2
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %21
13: ; preds = %8
%14 = load i32, i32* @stderr
%15 = sext i32 %14 to i64
%16 = inttoptr i64 %15 to i32*
%17 = getelementptr inbounds [11 x i8], [11 x i8]* %1, i64 0, i64 0
%18 = call i32 (i32*, i8*, ...) @fprintf(i32* %16, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i8* %17)
%19 = load i32, i32* @EXIT_FAILURE
%20 = call i32 @exit(i32 %19)
unreachable
21: ; preds = %8
%22 = load i32*, i32** %2
%23 = call i32 (i32*, i8*, ...) @fprintf(i32* %22, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%24 = load i32*, i32** %2
%25 = call i32 (i32*, i8*, ...) @fprintf(i32* %24, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%26 = load i32*, i32** %2
%27 = call i32 (i32*, i8*, ...) @fprintf(i32* %26, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%28 = load i32*, i32** %2
%29 = call i32 (i32*, i8*, ...) @fprintf(i32* %28, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
%30 = load i32*, i32** %2
%31 = call i32 (i32*, i8*, ...) @fprintf(i32* %30, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%32 = load i32*, i32** %2
%33 = call i32 (i32*, i8*, ...) @fprintf(i32* %32, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.8, i64 0, i64 0))
%34 = load i32*, i32** %2
%35 = call i32 (i32*, i8*, ...) @fprintf(i32* %34, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0))
%36 = load i32*, i32** %2
%37 = call i32 (i32*, i8*, ...) @fprintf(i32* %36, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0))
%38 = load i32*, i32** %2
%39 = call i32 (i32*, i8*, ...) @fprintf(i32* %38, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0))
%40 = load i32*, i32** %2
%41 = call i32 @fclose(i32* %40)
br label %42
42: ; preds = %21, %7
ret void
}

LLVM IR (-O2):
@__const.create_index_page.file_name = [11 x i8] c"index.html\00"
@.str = [2 x i8] c"w\00"
@stderr = global i32 0
@.str.1 = [38 x i8] c"ERROR: could not open for writing: %s\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [26 x i8] c"---\0Alayout: default\0A---\0A\0A\00"
@.str.3 = [17 x i8] c"<h2>Posts</h2>\0A\0A\00"
@.str.4 = [6 x i8] c"<ul>\0A\00"
@.str.5 = [12 x i8] c"{{#posts}}\0A\00"
@.str.6 = [7 x i8] c"%s<li>\00"
@.str.7 = [5 x i8] c" \00"
@.str.8 = [43 x i8] c"<a href=\22{{url}}\22>{{title}} ({{date}})</a>\00"
@.str.9 = [7 x i8] c"</li>\0A\00"
@.str.10 = [12 x i8] c"{{/posts}}\0A\00"
@.str.11 = [7 x i8] c"</ul>\0A\00"
define void @create_index_page() {
%1 = alloca [11 x i8]
%2 = getelementptr inbounds [11 x i8], [11 x i8]* %1, i64 0, i64 0
%3 = call i64 @file_exists(i8* %2)
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %26
5: ; preds = %0
%6 = call i32* @fopen(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %15
8: ; preds = %5
%9 = load i32, i32* @stderr
%10 = sext i32 %9 to i64
%11 = inttoptr i64 %10 to i32*
%12 = call i32 (i32*, i8*, ...) @fprintf(i32* %11, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%13 = load i32, i32* @EXIT_FAILURE
%14 = call i32 @exit(i32 %13)
unreachable
15: ; preds = %5
%16 = call i64 @fwrite(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i64 25, i64 1, i32* %6)
%17 = call i64 @fwrite(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i64 16, i64 1, i32* %6)
%18 = call i64 @fwrite(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i64 5, i64 1, i32* %6)
%19 = call i64 @fwrite(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i64 11, i64 1, i32* %6)
%20 = call i32 (i32*, i8*, ...) @fprintf(i32* %6, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%21 = call i64 @fwrite(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.8, i64 0, i64 0), i64 42, i64 1, i32* %6)
%22 = call i64 @fwrite(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0), i64 6, i64 1, i32* %6)
%23 = call i64 @fwrite(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0), i64 11, i64 1, i32* %6)
%24 = call i64 @fwrite(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0), i64 6, i64 1, i32* %6)
%25 = call i32 @fclose(i32* %6)
br label %26
26: ; preds = %0, %15
ret void
}