#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*/ time_t;
struct tm {
  int dummy;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ asprintf(char **, char *, char *, char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ localtime_r(int /*<<< orphan*/ *, struct tm *);
scalar_t__ mkdir(char *, int);
int /*<<< orphan*/ *stderr;
int /*<<< orphan*/ strftime(char *, int, char *, struct tm *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void create_posts_directory() {
  if (mkdir("_posts", 0770) != 0) {
    fprintf(stderr, "ERROR: Could not create _posts directory\n");
    exit(EXIT_FAILURE);
  }
  time_t now;
  time(&now);
  struct tm tm;
  localtime_r(&now, &tm);
  char today[11];
  strftime(today, 11, "%Y-%m-%d", &tm);
  char *file_path;
  asprintf(&file_path, "%s/%s-example-post.md", "_posts", today);
  FILE *fp = fopen(file_path, "w");
  if (fp == NULL) {
    char err_fmt[] = "ERROR: Could not open file for writing: %s\n";
    fprintf(stderr, err_fmt, file_path);
    exit(EXIT_FAILURE);
  }
  fprintf(fp, "---\n");
  fprintf(fp, "layout: default\n");
  fprintf(fp, "title: Example Post\n");
  fprintf(fp, "---\n\n");
  fprintf(fp, "This is an *example* post.");
  fclose(fp);
  free(file_path);
}


x86 assembly (clang, -O0):
<create_posts_directory>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
lea    0xe41(%rip),%rdi
mov    $0x1f8,%esi
call   1050 <mkdir@plt>
cmp    $0x0,%rax
je     11f9 <create_posts_directory+0x49>
mov    0x2e06(%rip),%rax
mov    (%rax),%rdi
lea    0xe23(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2de6(%rip),%rax
mov    (%rax),%edi
call   10d0 <exit@plt>
lea    -0x4(%rbp),%rdi
call   1090 <time@plt>
lea    -0x4(%rbp),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <localtime_r@plt>
lea    -0x13(%rbp),%rdi
mov    $0xb,%esi
lea    0xe12(%rip),%rdx
lea    -0x8(%rbp),%rcx
call   10b0 <strftime@plt>
lea    -0x13(%rbp),%rcx
lea    -0x20(%rbp),%rdi
lea    0xe03(%rip),%rsi
lea    0xdc2(%rip),%rdx
call   10a0 <asprintf@plt>
mov    -0x20(%rbp),%rdi
lea    0xe02(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    129e <create_posts_directory+0xee>
lea    -0x60(%rbp),%rdi
lea    0xe33(%rip),%rsi
mov    $0x2c,%edx
call   1080 <memcpy@plt>
mov    0x2d62(%rip),%rax
mov    (%rax),%rdi
lea    -0x60(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2d41(%rip),%rax
mov    (%rax),%edi
call   10d0 <exit@plt>
mov    -0x28(%rbp),%rdi
lea    0xda9(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x28(%rbp),%rdi
lea    0xd9c(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x28(%rbp),%rdi
lea    0xd9b(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x28(%rbp),%rdi
lea    0xd9e(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x28(%rbp),%rdi
lea    0xd92(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x28(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_posts_directory>:
push   %r14
push   %rbx
sub    $0x48,%rsp
lea    0xe42(%rip),%rdi
mov    $0x1f8,%esi
call   1050 <mkdir@plt>
test   %rax,%rax
jne    12d5 <create_posts_directory+0x125>
lea    0xc(%rsp),%rbx
mov    %rbx,%rdi
call   1080 <time@plt>
lea    0x8(%rsp),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <localtime_r@plt>
lea    0xe3c(%rip),%rdx
lea    0x3d(%rsp),%rbx
mov    %rbx,%rdi
mov    $0xb,%esi
mov    %r14,%rcx
call   10a0 <strftime@plt>
lea    0xe29(%rip),%rsi
lea    0xde8(%rip),%rdx
mov    %rsp,%rdi
mov    %rbx,%rcx
call   1090 <asprintf@plt>
mov    (%rsp),%rdi
lea    0xe22(%rip),%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
je     12f7 <create_posts_directory+0x147>
mov    %rax,%rbx
lea    0xe0c(%rip),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   10d0 <fwrite@plt>
lea    0xdf8(%rip),%rdi
mov    $0x10,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10d0 <fwrite@plt>
lea    0xdf0(%rip),%rdi
mov    $0x14,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10d0 <fwrite@plt>
lea    0xdec(%rip),%rdi
mov    $0x5,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10d0 <fwrite@plt>
lea    0xdd9(%rip),%rdi
mov    $0x1a,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10d0 <fwrite@plt>
mov    %rbx,%rdi
call   1060 <fclose@plt>
mov    (%rsp),%rdi
call   1030 <free@plt>
add    $0x48,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2d04(%rip),%rax
mov    (%rax),%rcx
lea    0xd21(%rip),%rdi
mov    $0x29,%esi
mov    $0x1,%edx
call   10d0 <fwrite@plt>
jmp    1335 <create_posts_directory+0x185>
movups 0xdbe(%rip),%xmm0
movups %xmm0,0x2c(%rsp)
movaps 0xda6(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xd8a(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
mov    0x2cbe(%rip),%rax
mov    (%rax),%rdi
mov    (%rsp),%rdx
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    0x2c9c(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
%struct.tm = type { i32 }
@.str = [7 x i8] c"_posts\00"
@stderr = global i32* null
@.str.1 = [42 x i8] c"ERROR: Could not create _posts directory\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [9 x i8] c"%Y-%m-%d\00"
@.str.3 = [22 x i8] c"%s/%s-example-post.md\00"
@.str.4 = [2 x i8] c"w\00"
@__const.create_posts_directory.err_fmt = [44 x i8] c"ERROR: Could not open file for writing: %s\0A\00"
@.str.5 = [5 x i8] c"---\0A\00"
@.str.6 = [17 x i8] c"layout: default\0A\00"
@.str.7 = [21 x i8] c"title: Example Post\0A\00"
@.str.8 = [6 x i8] c"---\0A\0A\00"
@.str.9 = [27 x i8] c"This is an *example* post.\00"
define void @create_posts_directory() {
%1 = alloca i32
%2 = alloca %struct.tm
%3 = alloca [11 x i8]
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca [44 x i8]
%7 = call i64 @mkdir(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 504)
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %14
9: ; preds = %0
%10 = load i32*, i32** @stderr
%11 = call i32 (i32*, i8*, ...) @fprintf(i32* %10, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0))
%12 = load i32, i32* @EXIT_FAILURE
%13 = call i32 @exit(i32 %12)
unreachable
14: ; preds = %0
%15 = call i32 @time(i32* %1)
%16 = call i32 @localtime_r(i32* %1, %struct.tm* %2)
%17 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 0
%18 = call i32 @strftime(i8* %17, i32 11, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), %struct.tm* %2)
%19 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 0
%20 = call i32 @asprintf(i8** %4, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %19)
%21 = load i8*, i8** %4
%22 = call i32* @fopen(i8* %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %22, i32** %5
%23 = load i32*, i32** %5
%24 = icmp eq i32* %23, null
br i1 %24, label %25, label %33
25: ; preds = %14
%26 = bitcast [44 x i8]* %6 to i8*
%27 = load i32*, i32** @stderr
%28 = getelementptr inbounds [44 x i8], [44 x i8]* %6, i64 0, i64 0
%29 = load i8*, i8** %4
%30 = call i32 (i32*, i8*, ...) @fprintf(i32* %27, i8* %28, i8* %29)
%31 = load i32, i32* @EXIT_FAILURE
%32 = call i32 @exit(i32 %31)
unreachable
33: ; preds = %14
%34 = load i32*, i32** %5
%35 = call i32 (i32*, i8*, ...) @fprintf(i32* %34, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%36 = load i32*, i32** %5
%37 = call i32 (i32*, i8*, ...) @fprintf(i32* %36, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0))
%38 = load i32*, i32** %5
%39 = call i32 (i32*, i8*, ...) @fprintf(i32* %38, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0))
%40 = load i32*, i32** %5
%41 = call i32 (i32*, i8*, ...) @fprintf(i32* %40, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
%42 = load i32*, i32** %5
%43 = call i32 (i32*, i8*, ...) @fprintf(i32* %42, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.9, i64 0, i64 0))
%44 = load i32*, i32** %5
%45 = call i32 @fclose(i32* %44)
%46 = load i8*, i8** %4
%47 = call i32 @free(i8* %46)
ret void
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@.str = [7 x i8] c"_posts\00"
@stderr = global i32* null
@.str.1 = [42 x i8] c"ERROR: Could not create _posts directory\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [9 x i8] c"%Y-%m-%d\00"
@.str.3 = [22 x i8] c"%s/%s-example-post.md\00"
@.str.4 = [2 x i8] c"w\00"
@__const.create_posts_directory.err_fmt = [44 x i8] c"ERROR: Could not open file for writing: %s\0A\00"
@.str.5 = [5 x i8] c"---\0A\00"
@.str.6 = [17 x i8] c"layout: default\0A\00"
@.str.7 = [21 x i8] c"title: Example Post\0A\00"
@.str.8 = [6 x i8] c"---\0A\0A\00"
@.str.9 = [27 x i8] c"This is an *example* post.\00"
define void @create_posts_directory() {
%1 = alloca i32
%2 = alloca %struct.tm
%3 = alloca [11 x i8]
%4 = alloca i8*
%5 = alloca [44 x i8]
%6 = tail call i64 @mkdir(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 504)
%7 = icmp eq i64 %6, 0
br i1 %7, label %13, label %8
8: ; preds = %0
%9 = load i32*, i32** @stderr
%10 = tail call i64 @fwrite(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), i64 41, i64 1, i32* %9)
%11 = load i32, i32* @EXIT_FAILURE
%12 = tail call i32 @exit(i32 %11)
unreachable
13: ; preds = %0
%14 = bitcast i32* %1 to i8*
%15 = call i32 @time(i32* %1)
%16 = bitcast %struct.tm* %2 to i8*
%17 = call i32 @localtime_r(i32* %1, %struct.tm* %2)
%18 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 0
%19 = call i32 @strftime(i8* %18, i32 11, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), %struct.tm* %2)
%20 = bitcast i8** %4 to i8*
%21 = call i32 @asprintf(i8** %4, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %18)
%22 = load i8*, i8** %4
%23 = call i32* @fopen(i8* %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%24 = icmp eq i32* %23, null
br i1 %24, label %25, label %32
25: ; preds = %13
%26 = getelementptr inbounds [44 x i8], [44 x i8]* %5, i64 0, i64 0
%27 = load i32*, i32** @stderr
%28 = load i8*, i8** %4
%29 = call i32 (i32*, i8*, ...) @fprintf(i32* %27, i8* %26, i8* %28)
%30 = load i32, i32* @EXIT_FAILURE
%31 = call i32 @exit(i32 %30)
unreachable
32: ; preds = %13
%33 = call i64 @fwrite(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i64 4, i64 1, i32* %23)
%34 = call i64 @fwrite(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), i64 16, i64 1, i32* %23)
%35 = call i64 @fwrite(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), i64 20, i64 1, i32* %23)
%36 = call i64 @fwrite(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), i64 5, i64 1, i32* %23)
%37 = call i64 @fwrite(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.9, i64 0, i64 0), i64 26, i64 1, i32* %23)
%38 = call i32 @fclose(i32* %23)
%39 = load i8*, i8** %4
%40 = call i32 @free(i8* %39)
ret void
}