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

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int S_IFREG;
int /*<<< orphan*/ die(int /*<<< orphan*/, char *);
scalar_t__ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ fclose(int /*<<< orphan*/ *);
char fgetc(int /*<<< orphan*/);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, char *, ...);
int /*<<< orphan*/ free(char *);
size_t fwrite(char const *, int, size_t, int /*<<< orphan*/ *);
char *get_current_dir_name();
char *malloc(int);
int /*<<< orphan*/ perror(char *);
scalar_t__ stat(char *, struct stat *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strcat(char *, char const *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char const *);
int main(void) {
  const char *comment_text = "/************************************************"
                             "***************************\n"
                             " * Created by mkcmain                            "
                             "                          *\n"
                             " ************************************************"
                             "**************************/\n\n";
  size_t comment_text_size;
  const char *cmain_text = "int main(int argc, char *argv[])\n"
                           "{\n\n"
                           "\treturn 0;\n"
                           "}\n";
  size_t cmain_text_size;
  const char *filename = "main.c";
  char *cw_dir;
  char *filepath;
  FILE *file;
  struct stat sb;
  errno = 0;
  cw_dir = get_current_dir_name();
  if (NULL == cw_dir) {
    perror("get_current_dir_name");
    die(EXIT_FAILURE, "could not get current directory name");
  }
  if (NULL == (filepath = malloc((strlen(cw_dir) + 1 + strlen(filename) + 1) *
                                 sizeof(char)))) {
    die(EXIT_FAILURE, "could not allocate memory for file path name");
  }
  strcpy(filepath, cw_dir);
  strcat(filepath, "/");
  strcat(filepath, filename);
  free(cw_dir);
  if (0 == stat(filepath, &sb)) {
    bool abort = false;
    if (!(sb.st_mode & S_IFREG)) {
      abort = true;
      fprintf(stderr, "%s: %s is not a regular file\n", "mkcmain", filepath);
    } else {
      char response;
      fprintf(stdout, "%s: %jd byte file %s exists. Replace file? [y/N?] ",
              "mkcmain", (intmax_t)sb.st_size, filepath);
      response = fgetc(stdin);
      if (response != 'y' && response != 'Y') {
        abort = true;
      }
    }
    if (abort) {
      free(filepath);
      die(EXIT_FAILURE, "no file written");
    }
  }
  errno = 0;
  if (NULL == (file = fopen(filepath, "w"))) {
    perror("fopen");
    fprintf(stderr, "%s: could not open %s for writing\n", "mkcmain", filepath);
    free(filepath);
    die(EXIT_FAILURE, NULL);
  }
  comment_text_size = strlen(comment_text);
  if (fwrite(comment_text, sizeof(char), comment_text_size, file) !=
      comment_text_size * sizeof(char)) {
    fprintf(stderr, "%s: could not write to open file %s\n", "mkcmain",
            filepath);
    free(filepath);
    die(EXIT_FAILURE, NULL);
  }
  cmain_text_size = strlen(cmain_text);
  if (fwrite(cmain_text, sizeof(char), cmain_text_size, file) !=
      cmain_text_size * sizeof(char)) {
    fprintf(stderr, "%s: could not write to open file %s\n", "mkcmain",
            filepath);
    free(filepath);
    die(EXIT_FAILURE, NULL);
  }
  errno = 0;
  if (fclose(file)) {
    perror("fclose");
    free(filepath);
    die(EXIT_FAILURE, "encountered error during attempt to close file");
  }
  fprintf(stdout, "%s: successfully created %s\n", "mkcmain", filepath);
  free(filepath);
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xdfa(%rip),%rax
mov    %rax,-0x10(%rbp)
lea    0xed8(%rip),%rax
mov    %rax,-0x20(%rbp)
lea    0xeff(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0x2da1(%rip),%rax
movq   $0x0,(%rax)
mov    $0x0,%al
call   10a0 <get_current_dir_name@plt>
mov    %rax,-0x38(%rbp)
xor    %eax,%eax
cmp    -0x38(%rbp),%rax
jne    1266 <main+0x76>
lea    0xed6(%rip),%rdi
call   10e0 <perror@plt>
mov    0x2d68(%rip),%rax
mov    (%rax),%edi
lea    0xed6(%rip),%rsi
call   10d0 <die@plt>
mov    -0x38(%rbp),%rdi
call   1060 <strlen@plt>
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
mov    -0x30(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0x64(%rbp),%eax
add    %ecx,%eax
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   10b0 <malloc@plt>
mov    %rax,%rcx
mov    %rcx,-0x40(%rbp)
xor    %eax,%eax
cmp    %rcx,%rax
jne    12bc <main+0xcc>
mov    0x2d12(%rip),%rax
mov    (%rax),%edi
lea    0xea5(%rip),%rsi
call   10d0 <die@plt>
mov    -0x40(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x40(%rbp),%rdi
lea    0xeb5(%rip),%rsi
call   10f0 <strcat@plt>
mov    -0x40(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   10f0 <strcat@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x40(%rbp),%rdi
lea    -0x58(%rbp),%rsi
call   1090 <stat@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    13e1 <main+0x1f1>
movl   $0x0,-0x5c(%rbp)
mov    -0x58(%rbp),%eax
mov    0x2cc5(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
jne    1354 <main+0x164>
movl   $0x1,-0x5c(%rbp)
mov    0x2c9c(%rip),%rax
mov    (%rax),%edi
mov    -0x40(%rbp),%rcx
lea    0xe4a(%rip),%rsi
lea    0xe61(%rip),%rdx
mov    $0x0,%al
call   1080 <fprintf@plt>
jmp    13b4 <main+0x1c4>
mov    0x2c5d(%rip),%rax
mov    (%rax),%edi
mov    -0x50(%rbp),%rax
movslq %eax,%rcx
mov    -0x40(%rbp),%r8
lea    0xe42(%rip),%rsi
lea    0xe33(%rip),%rdx
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2c64(%rip),%rax
mov    (%rax),%edi
call   1070 <fgetc@plt>
mov    %al,-0x5d(%rbp)
movsbl -0x5d(%rbp),%eax
cmp    $0x79,%eax
je     13af <main+0x1bf>
movsbl -0x5d(%rbp),%eax
cmp    $0x59,%eax
je     13af <main+0x1bf>
movl   $0x1,-0x5c(%rbp)
jmp    13b4 <main+0x1c4>
cmpl   $0x0,-0x5c(%rbp)
je     13dc <main+0x1ec>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
mov    0x2bf2(%rip),%rax
mov    (%rax),%edi
lea    0xe0d(%rip),%rsi
call   10d0 <die@plt>
jmp    13e1 <main+0x1f1>
mov    0x2be0(%rip),%rax
movq   $0x0,(%rax)
mov    -0x40(%rbp),%rdi
lea    0xdfa(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,%rcx
mov    %rcx,-0x48(%rbp)
xor    %eax,%eax
cmp    %rcx,%rax
jne    145a <main+0x26a>
lea    0xdde(%rip),%rdi
call   10e0 <perror@plt>
mov    0x2bac(%rip),%rax
mov    (%rax),%edi
mov    -0x40(%rbp),%rcx
lea    0xdcb(%rip),%rsi
lea    0xd71(%rip),%rdx
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
mov    0x2b71(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
mov    %eax,%esi
call   10d0 <die@plt>
mov    -0x10(%rbp),%rdi
call   1060 <strlen@plt>
cltq
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x48(%rbp),%rcx
mov    $0x1,%esi
call   1110 <fwrite@plt>
mov    -0x18(%rbp),%rcx
shl    $0x0,%rcx
cmp    %rcx,%rax
je     14cd <main+0x2dd>
mov    0x2b39(%rip),%rax
mov    (%rax),%edi
mov    -0x40(%rbp),%rcx
lea    0xd7b(%rip),%rsi
lea    0xcfe(%rip),%rdx
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
mov    0x2afe(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
mov    %eax,%esi
call   10d0 <die@plt>
mov    -0x20(%rbp),%rdi
call   1060 <strlen@plt>
cltq
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    -0x48(%rbp),%rcx
mov    $0x1,%esi
call   1110 <fwrite@plt>
mov    -0x28(%rbp),%rcx
shl    $0x0,%rcx
cmp    %rcx,%rax
je     1540 <main+0x350>
mov    0x2ac6(%rip),%rax
mov    (%rax),%edi
mov    -0x40(%rbp),%rcx
lea    0xd08(%rip),%rsi
lea    0xc8b(%rip),%rdx
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
mov    0x2a8b(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
mov    %eax,%esi
call   10d0 <die@plt>
mov    0x2a81(%rip),%rax
movq   $0x0,(%rax)
mov    -0x48(%rbp),%rdi
call   1050 <fclose@plt>
cmp    $0x0,%rax
je     158b <main+0x39b>
lea    0xcdc(%rip),%rdi
call   10e0 <perror@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
mov    0x2a43(%rip),%rax
mov    (%rax),%edi
lea    0xcc5(%rip),%rsi
call   10d0 <die@plt>
mov    0x2a26(%rip),%rax
mov    (%rax),%edi
mov    -0x40(%rbp),%rcx
lea    0xcdb(%rip),%rsi
lea    0xc03(%rip),%rdx
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
mov    0x29f3(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    0x2dc4(%rip),%r13
movq   $0x0,0x0(%r13)
xor    %eax,%eax
call   10a0 <get_current_dir_name@plt>
mov    %rax,%r14
test   %rax,%rax
jne    123c <main+0x4c>
lea    0xf00(%rip),%rdi
call   10e0 <perror@plt>
mov    0x2d92(%rip),%rax
mov    (%rax),%edi
lea    0xf00(%rip),%rsi
call   10d0 <die@plt>
mov    %r14,%rdi
call   1060 <strlen@plt>
mov    %eax,%ebx
lea    0xece(%rip),%rdi
call   1060 <strlen@plt>
lea    (%rbx,%rax,1),%edi
add    $0x2,%edi
call   10b0 <malloc@plt>
mov    %rax,%r15
test   %rax,%rax
jne    127a <main+0x8a>
mov    0x2d54(%rip),%rax
mov    (%rax),%edi
lea    0xee7(%rip),%rsi
call   10d0 <die@plt>
mov    %r15,%rdi
mov    %r14,%rsi
call   1040 <strcpy@plt>
lea    0xefd(%rip),%rsi
mov    %r15,%rdi
call   10f0 <strcat@plt>
lea    0xe80(%rip),%rsi
mov    %r15,%rdi
call   10f0 <strcat@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %rsp,%rsi
mov    %r15,%rdi
call   1090 <stat@plt>
test   %rax,%rax
jne    1347 <main+0x157>
mov    0x2d1a(%rip),%rax
mov    (%rax),%eax
test   %eax,(%rsp)
jne    12f0 <main+0x100>
mov    0x2cfc(%rip),%rax
mov    (%rax),%edi
lea    0xeae(%rip),%rsi
lea    0xec5(%rip),%rdx
mov    %r15,%rcx
xor    %eax,%eax
call   1080 <fprintf@plt>
jmp    132a <main+0x13a>
mov    0x2cc1(%rip),%rax
mov    (%rax),%edi
movslq 0x8(%rsp),%rcx
lea    0xeac(%rip),%rsi
lea    0xe9d(%rip),%rdx
mov    %r15,%r8
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    0x2ccb(%rip),%rax
mov    (%rax),%edi
call   1070 <fgetc@plt>
and    $0xdf,%al
cmp    $0x59,%al
je     1347 <main+0x157>
mov    %r15,%rdi
call   1030 <free@plt>
mov    0x2c87(%rip),%rax
mov    (%rax),%edi
lea    0xea2(%rip),%rsi
call   10d0 <die@plt>
movq   $0x0,0x0(%r13)
lea    0xe9e(%rip),%rsi
mov    %r15,%rdi
call   10c0 <fopen@plt>
mov    %rax,%r14
test   %rax,%rax
jne    13ab <main+0x1bb>
lea    0xe89(%rip),%rdi
call   10e0 <perror@plt>
mov    0x2c57(%rip),%rax
mov    (%rax),%edi
lea    0xe7a(%rip),%rsi
lea    0xe20(%rip),%rdx
mov    %r15,%rcx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    0x2c1e(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
call   10d0 <die@plt>
lea    0xc4e(%rip),%r12
mov    %r12,%rdi
call   1060 <strlen@plt>
movslq %eax,%rbx
mov    %r12,%rdi
mov    $0x1,%esi
mov    %rbx,%rdx
mov    %r14,%rcx
call   1110 <fwrite@plt>
cmp    %rbx,%rax
je     140e <main+0x21e>
mov    0x2bf4(%rip),%rax
mov    (%rax),%edi
lea    0xe3a(%rip),%rsi
lea    0xdbd(%rip),%rdx
mov    %r15,%rcx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    0x2bbb(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
call   10d0 <die@plt>
lea    0xcd4(%rip),%r12
mov    %r12,%rdi
call   1060 <strlen@plt>
movslq %eax,%rbx
mov    %r12,%rdi
mov    $0x1,%esi
mov    %rbx,%rdx
mov    %r14,%rcx
call   1110 <fwrite@plt>
cmp    %rbx,%rax
je     1471 <main+0x281>
mov    0x2b91(%rip),%rax
mov    (%rax),%edi
lea    0xdd7(%rip),%rsi
lea    0xd5a(%rip),%rdx
mov    %r15,%rcx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    0x2b58(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
call   10d0 <die@plt>
movq   $0x0,0x0(%r13)
mov    %r14,%rdi
call   1050 <fclose@plt>
test   %rax,%rax
je     14af <main+0x2bf>
lea    0xdb7(%rip),%rdi
call   10e0 <perror@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    0x2b1f(%rip),%rax
mov    (%rax),%edi
lea    0xda1(%rip),%rsi
call   10d0 <die@plt>
mov    0x2b02(%rip),%rax
mov    (%rax),%edi
lea    0xdbb(%rip),%rsi
lea    0xce3(%rip),%rdx
mov    %r15,%rcx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    0x2ad1(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>

LLVM IR (-O0):
%struct.stat = type { i32, i64 }
@.str = [233 x i8] c"/***************************************************************************\0A * Created by mkcmain *\0A **************************************************************************/\0A\0A\00"
@.str.1 = [50 x i8] c"int main(int argc, char *argv[])\0A{\0A\0A\09return 0;\0A}\0A\00"
@.str.2 = [7 x i8] c"main.c\00"
@errno = global i64 0
@.str.3 = [21 x i8] c"get_current_dir_name\00"
@EXIT_FAILURE = global i32 0
@.str.4 = [37 x i8] c"could not get current directory name\00"
@.str.5 = [45 x i8] c"could not allocate memory for file path name\00"
@.str.6 = [2 x i8] c"/\00"
@S_IFREG = global i32 0
@stderr = global i32 0
@.str.7 = [30 x i8] c"%s: %s is not a regular file\0A\00"
@.str.8 = [8 x i8] c"mkcmain\00"
@stdout = global i32 0
@.str.9 = [51 x i8] c"%s: %jd byte file %s exists. Replace file? [y/N?] \00"
@stdin = global i32 0
@.str.10 = [16 x i8] c"no file written\00"
@.str.11 = [2 x i8] c"w\00"
@.str.12 = [6 x i8] c"fopen\00"
@.str.13 = [35 x i8] c"%s: could not open %s for writing\0A\00"
@.str.14 = [37 x i8] c"%s: could not write to open file %s\0A\00"
@.str.15 = [7 x i8] c"fclose\00"
@.str.16 = [47 x i8] c"encountered error during attempt to close file\00"
@.str.17 = [29 x i8] c"%s: successfully created %s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32*
%10 = alloca %struct.stat
%11 = alloca i32
%12 = alloca i8
store i32 0, i32* %1
store i8* getelementptr inbounds ([233 x i8], [233 x i8]* @.str, i64 0, i64 0), i8** %2
store i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0), i8** %4
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8** %6
store i64 0, i64* @errno
%13 = call i8* (...) @get_current_dir_name()
store i8* %13, i8** %7
%14 = load i8*, i8** %7
%15 = icmp eq i8* null, %14
br i1 %15, label %16, label %20
16: ; preds = %0
%17 = call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
%18 = load i32, i32* @EXIT_FAILURE
%19 = call i32 @die(i32 %18, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0))
br label %20
20: ; preds = %16, %0
%21 = load i8*, i8** %7
%22 = call i32 @strlen(i8* %21)
%23 = add nsw i32 %22, 1
%24 = load i8*, i8** %6
%25 = call i32 @strlen(i8* %24)
%26 = add nsw i32 %23, %25
%27 = add nsw i32 %26, 1
%28 = sext i32 %27 to i64
%29 = mul i64 %28, 1
%30 = trunc i64 %29 to i32
%31 = call i8* @malloc(i32 %30)
store i8* %31, i8** %8
%32 = icmp eq i8* null, %31
br i1 %32, label %33, label %36
33: ; preds = %20
%34 = load i32, i32* @EXIT_FAILURE
%35 = call i32 @die(i32 %34, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.5, i64 0, i64 0))
br label %36
36: ; preds = %33, %20
%37 = load i8*, i8** %8
%38 = load i8*, i8** %7
%39 = call i32 @strcpy(i8* %37, i8* %38)
%40 = load i8*, i8** %8
%41 = call i32 @strcat(i8* %40, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%42 = load i8*, i8** %8
%43 = load i8*, i8** %6
%44 = call i32 @strcat(i8* %42, i8* %43)
%45 = load i8*, i8** %7
%46 = call i32 @free(i8* %45)
%47 = load i8*, i8** %8
%48 = call i64 @stat(i8* %47, %struct.stat* %10)
%49 = icmp eq i64 0, %48
br i1 %49, label %50, label %89
50: ; preds = %36
store i32 0, i32* %11
%51 = getelementptr inbounds %struct.stat, %struct.stat* %10, i32 0, i32 0
%52 = load i32, i32* %51
%53 = load i32, i32* @S_IFREG
%54 = and i32 %52, %53
%55 = icmp ne i32 %54, 0
br i1 %55, label %60, label %56
56: ; preds = %50
store i32 1, i32* %11
%57 = load i32, i32* @stderr
%58 = load i8*, i8** %8
%59 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %57, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i8* %58)
br label %80
60: ; preds = %50
%61 = load i32, i32* @stdout
%62 = getelementptr inbounds %struct.stat, %struct.stat* %10, i32 0, i32 1
%63 = load i64, i64* %62
%64 = trunc i64 %63 to i32
%65 = sext i32 %64 to i64
%66 = inttoptr i64 %65 to i8*
%67 = load i8*, i8** %8
%68 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %61, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i8* %66, i8* %67)
%69 = load i32, i32* @stdin
%70 = call signext i8 @fgetc(i32 %69)
store i8 %70, i8* %12
%71 = load i8, i8* %12
%72 = sext i8 %71 to i32
%73 = icmp ne i32 %72, 121
br i1 %73, label %74, label %79
74: ; preds = %60
%75 = load i8, i8* %12
%76 = sext i8 %75 to i32
%77 = icmp ne i32 %76, 89
br i1 %77, label %78, label %79
78: ; preds = %74
store i32 1, i32* %11
br label %79
79: ; preds = %78, %74, %60
br label %80
80: ; preds = %79, %56
%81 = load i32, i32* %11
%82 = icmp ne i32 %81, 0
br i1 %82, label %83, label %88
83: ; preds = %80
%84 = load i8*, i8** %8
%85 = call i32 @free(i8* %84)
%86 = load i32, i32* @EXIT_FAILURE
%87 = call i32 @die(i32 %86, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0))
br label %88
88: ; preds = %83, %80
br label %89
89: ; preds = %88, %36
store i64 0, i64* @errno
%90 = load i8*, i8** %8
%91 = call i32* @fopen(i8* %90, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0))
store i32* %91, i32** %9
%92 = icmp eq i32* null, %91
br i1 %92, label %93, label %102
93: ; preds = %89
%94 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0))
%95 = load i32, i32* @stderr
%96 = load i8*, i8** %8
%97 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %95, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i8* %96)
%98 = load i8*, i8** %8
%99 = call i32 @free(i8* %98)
%100 = load i32, i32* @EXIT_FAILURE
%101 = call i32 @die(i32 %100, i8* null)
br label %102
102: ; preds = %93, %89
%103 = load i8*, i8** %2
%104 = call i32 @strlen(i8* %103)
%105 = sext i32 %104 to i64
store i64 %105, i64* %3
%106 = load i8*, i8** %2
%107 = load i64, i64* %3
%108 = load i32*, i32** %9
%109 = call i64 @fwrite(i8* %106, i32 1, i64 %107, i32* %108)
%110 = load i64, i64* %3
%111 = mul i64 %110, 1
%112 = icmp ne i64 %109, %111
br i1 %112, label %113, label %121
113: ; preds = %102
%114 = load i32, i32* @stderr
%115 = load i8*, i8** %8
%116 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %114, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.14, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i8* %115)
%117 = load i8*, i8** %8
%118 = call i32 @free(i8* %117)
%119 = load i32, i32* @EXIT_FAILURE
%120 = call i32 @die(i32 %119, i8* null)
br label %121
121: ; preds = %113, %102
%122 = load i8*, i8** %4
%123 = call i32 @strlen(i8* %122)
%124 = sext i32 %123 to i64
store i64 %124, i64* %5
%125 = load i8*, i8** %4
%126 = load i64, i64* %5
%127 = load i32*, i32** %9
%128 = call i64 @fwrite(i8* %125, i32 1, i64 %126, i32* %127)
%129 = load i64, i64* %5
%130 = mul i64 %129, 1
%131 = icmp ne i64 %128, %130
br i1 %131, label %132, label %140
132: ; preds = %121
%133 = load i32, i32* @stderr
%134 = load i8*, i8** %8
%135 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %133, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.14, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i8* %134)
%136 = load i8*, i8** %8
%137 = call i32 @free(i8* %136)
%138 = load i32, i32* @EXIT_FAILURE
%139 = call i32 @die(i32 %138, i8* null)
br label %140
140: ; preds = %132, %121
store i64 0, i64* @errno
%141 = load i32*, i32** %9
%142 = call i64 @fclose(i32* %141)
%143 = icmp ne i64 %142, 0
br i1 %143, label %144, label %150
144: ; preds = %140
%145 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.15, i64 0, i64 0))
%146 = load i8*, i8** %8
%147 = call i32 @free(i8* %146)
%148 = load i32, i32* @EXIT_FAILURE
%149 = call i32 @die(i32 %148, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.16, i64 0, i64 0))
br label %150
150: ; preds = %144, %140
%151 = load i32, i32* @stdout
%152 = load i8*, i8** %8
%153 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %151, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.17, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i8* %152)
%154 = load i8*, i8** %8
%155 = call i32 @free(i8* %154)
%156 = load i32, i32* @EXIT_SUCCESS
%157 = call i32 @exit(i32 %156)
unreachable
}

LLVM IR (-O2):
%struct.stat = type { i32, i64 }
@.str = [233 x i8] c"/***************************************************************************\0A * Created by mkcmain *\0A **************************************************************************/\0A\0A\00"
@.str.1 = [50 x i8] c"int main(int argc, char *argv[])\0A{\0A\0A\09return 0;\0A}\0A\00"
@.str.2 = [7 x i8] c"main.c\00"
@errno = global i64 0
@.str.3 = [21 x i8] c"get_current_dir_name\00"
@EXIT_FAILURE = global i32 0
@.str.4 = [37 x i8] c"could not get current directory name\00"
@.str.5 = [45 x i8] c"could not allocate memory for file path name\00"
@.str.6 = [2 x i8] c"/\00"
@S_IFREG = global i32 0
@stderr = global i32 0
@.str.7 = [30 x i8] c"%s: %s is not a regular file\0A\00"
@.str.8 = [8 x i8] c"mkcmain\00"
@stdout = global i32 0
@.str.9 = [51 x i8] c"%s: %jd byte file %s exists. Replace file? [y/N?] \00"
@stdin = global i32 0
@.str.10 = [16 x i8] c"no file written\00"
@.str.11 = [2 x i8] c"w\00"
@.str.12 = [6 x i8] c"fopen\00"
@.str.13 = [35 x i8] c"%s: could not open %s for writing\0A\00"
@.str.14 = [37 x i8] c"%s: could not write to open file %s\0A\00"
@.str.15 = [7 x i8] c"fclose\00"
@.str.16 = [47 x i8] c"encountered error during attempt to close file\00"
@.str.17 = [29 x i8] c"%s: successfully created %s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca %struct.stat
%2 = bitcast %struct.stat* %1 to i8*
store i64 0, i64* @errno
%3 = tail call i8* (...) @get_current_dir_name()
%4 = icmp eq i8* %3, null
br i1 %4, label %5, label %9
5: ; preds = %0
%6 = tail call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
%7 = load i32, i32* @EXIT_FAILURE
%8 = tail call i32 @die(i32 %7, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0))
br label %9
9: ; preds = %5, %0
%10 = tail call i32 @strlen(i8* %3)
%11 = tail call i32 @strlen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%12 = add i32 %10, 2
%13 = add i32 %12, %11
%14 = tail call i8* @malloc(i32 %13)
%15 = icmp eq i8* %14, null
br i1 %15, label %16, label %19
16: ; preds = %9
%17 = load i32, i32* @EXIT_FAILURE
%18 = tail call i32 @die(i32 %17, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.5, i64 0, i64 0))
br label %19
19: ; preds = %16, %9
%20 = tail call i32 @strcpy(i8* %14, i8* %3)
%21 = tail call i32 @strcat(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%22 = tail call i32 @strcat(i8* %14, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%23 = tail call i32 @free(i8* %3)
%24 = call i64 @stat(i8* %14, %struct.stat* %1)
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %51
26: ; preds = %19
%27 = getelementptr inbounds %struct.stat, %struct.stat* %1, i64 0, i32 0
%28 = load i32, i32* %27
%29 = load i32, i32* @S_IFREG
%30 = and i32 %29, %28
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %35
32: ; preds = %26
%33 = load i32, i32* @stderr
%34 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %33, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i8* %14)
br label %47
35: ; preds = %26
%36 = load i32, i32* @stdout
%37 = getelementptr inbounds %struct.stat, %struct.stat* %1, i64 0, i32 1
%38 = load i64, i64* %37
%39 = shl i64 %38, 32
%40 = ashr exact i64 %39, 32
%41 = inttoptr i64 %40 to i8*
%42 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %36, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i8* %41, i8* %14)
%43 = load i32, i32* @stdin
%44 = call signext i8 @fgetc(i32 %43)
%45 = and i8 %44, -33
%46 = icmp eq i8 %45, 89
br i1 %46, label %51, label %47
47: ; preds = %35, %32
%48 = call i32 @free(i8* %14)
%49 = load i32, i32* @EXIT_FAILURE
%50 = call i32 @die(i32 %49, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0))
br label %51
51: ; preds = %35, %47, %19
store i64 0, i64* @errno
%52 = call i32* @fopen(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0))
%53 = icmp eq i32* %52, null
br i1 %53, label %54, label %61
54: ; preds = %51
%55 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0))
%56 = load i32, i32* @stderr
%57 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %56, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i8* %14)
%58 = call i32 @free(i8* %14)
%59 = load i32, i32* @EXIT_FAILURE
%60 = call i32 @die(i32 %59, i8* null)
br label %61
61: ; preds = %54, %51
%62 = call i32 @strlen(i8* getelementptr inbounds ([233 x i8], [233 x i8]* @.str, i64 0, i64 0))
%63 = sext i32 %62 to i64
%64 = call i64 @fwrite(i8* getelementptr inbounds ([233 x i8], [233 x i8]* @.str, i64 0, i64 0), i32 1, i64 %63, i32* %52)
%65 = icmp eq i64 %64, %63
br i1 %65, label %72, label %66
66: ; preds = %61
%67 = load i32, i32* @stderr
%68 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %67, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.14, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i8* %14)
%69 = call i32 @free(i8* %14)
%70 = load i32, i32* @EXIT_FAILURE
%71 = call i32 @die(i32 %70, i8* null)
br label %72
72: ; preds = %66, %61
%73 = call i32 @strlen(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0))
%74 = sext i32 %73 to i64
%75 = call i64 @fwrite(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0), i32 1, i64 %74, i32* %52)
%76 = icmp eq i64 %75, %74
br i1 %76, label %83, label %77
77: ; preds = %72
%78 = load i32, i32* @stderr
%79 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %78, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.14, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i8* %14)
%80 = call i32 @free(i8* %14)
%81 = load i32, i32* @EXIT_FAILURE
%82 = call i32 @die(i32 %81, i8* null)
br label %83
83: ; preds = %77, %72
store i64 0, i64* @errno
%84 = call i64 @fclose(i32* %52)
%85 = icmp eq i64 %84, 0
br i1 %85, label %91, label %86
86: ; preds = %83
%87 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.15, i64 0, i64 0))
%88 = call i32 @free(i8* %14)
%89 = load i32, i32* @EXIT_FAILURE
%90 = call i32 @die(i32 %89, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.16, i64 0, i64 0))
br label %91
91: ; preds = %86, %83
%92 = load i32, i32* @stdout
%93 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %92, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.17, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i8* %14)
%94 = call i32 @free(i8* %14)
%95 = load i32, i32* @EXIT_SUCCESS
%96 = call i32 @exit(i32 %95)
unreachable
}