#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 */
scalar_t__ access(char *, int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int myFile(int /*<<< orphan*/ *, int, char **);
int /*<<< orphan*/ myFileComments(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ rename(char *, char *);
int myMakefile(int arg, char *argv[]) {
  int Eret = 0;
  char fname[] = "makefile";
  FILE *tfile = NULL;
  if (access(fname, 0) == 0) {
    rename(fname, "makefile.bak");
  }
  tfile = fopen(fname, "a+");
  if (tfile == NULL) {
    Eret = -1;
    printf("func myMakefile() error: if (tfile == NULL)  line: %d", 152 - 3);
    return Eret;
  }
  myFileComments(tfile);
  Eret = myFile(tfile, arg, argv);
  fclose(tfile);
  return Eret;
}


x86 assembly (clang, -O0):
<myMakefile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    0xe73(%rip),%rax
mov    %rax,-0x1d(%rbp)
mov    0xe71(%rip),%al
mov    %al,-0x15(%rbp)
movq   $0x0,-0x28(%rbp)
lea    -0x1d(%rbp),%rdi
xor    %esi,%esi
call   1060 <access@plt>
cmp    $0x0,%rax
jne    11c7 <myMakefile+0x57>
lea    -0x1d(%rbp),%rdi
lea    0xe47(%rip),%rsi
call   1090 <rename@plt>
lea    -0x1d(%rbp),%rdi
lea    0xe44(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1209 <myMakefile+0x99>
movl   $0xffffffff,-0x14(%rbp)
lea    0xe25(%rip),%rdi
mov    $0x95,%esi
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1234 <myMakefile+0xc4>
mov    -0x28(%rbp),%rdi
call   1080 <myFileComments@plt>
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%rdx
call   1050 <myFile@plt>
mov    %eax,-0x14(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<myMakefile>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
mov    %edi,%ebp
movabs $0x656c6966656b616d,%rax
69 6c 65
mov    %rax,(%rsp)
movb   $0x0,0x8(%rsp)
mov    %rsp,%rdi
xor    %esi,%esi
call   1060 <access@plt>
test   %rax,%rax
jne    11ae <myMakefile+0x3e>
lea    0xe63(%rip),%rsi
mov    %rsp,%rdi
call   1090 <rename@plt>
lea    0xe61(%rip),%rsi
mov    %rsp,%rdi
call   1070 <fopen@plt>
test   %rax,%rax
je     11e8 <myMakefile+0x78>
mov    %rax,%rbx
mov    %rax,%rdi
call   1080 <myFileComments@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r14,%rdx
call   1050 <myFile@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <fclose@plt>
mov    %ebp,%eax
jmp    11fe <myMakefile+0x8e>
lea    0xe2a(%rip),%rdi
mov    $0x95,%esi
call   1040 <printf@plt>
mov    $0xffffffff,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@__const.myMakefile.fname = [9 x i8] c"makefile\00"
@.str = [13 x i8] c"makefile.bak\00"
@.str.1 = [3 x i8] c"a+\00"
@.str.2 = [54 x i8] c"func myMakefile() error: if (tfile == NULL) line: %d\00"
define i32 @myMakefile(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [9 x i8]
%8 = alloca i32*
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%9 = bitcast [9 x i8]* %7 to i8*
store i32* null, i32** %8
%10 = getelementptr inbounds [9 x i8], [9 x i8]* %7, i64 0, i64 0
%11 = call i64 @access(i8* %10, i32 0)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %2
%14 = getelementptr inbounds [9 x i8], [9 x i8]* %7, i64 0, i64 0
%15 = call i32 @rename(i8* %14, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
br label %16
16: ; preds = %13, %2
%17 = getelementptr inbounds [9 x i8], [9 x i8]* %7, i64 0, i64 0
%18 = call i32* @fopen(i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %18, i32** %8
%19 = load i32*, i32** %8
%20 = icmp eq i32* %19, null
br i1 %20, label %21, label %24
21: ; preds = %16
store i32 -1, i32* %6
%22 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.2, i64 0, i64 0), i32 149)
%23 = load i32, i32* %6
store i32 %23, i32* %3
br label %34
24: ; preds = %16
%25 = load i32*, i32** %8
%26 = call i32 @myFileComments(i32* %25)
%27 = load i32*, i32** %8
%28 = load i32, i32* %4
%29 = load i8**, i8*** %5
%30 = call i32 @myFile(i32* %27, i32 %28, i8** %29)
store i32 %30, i32* %6
%31 = load i32*, i32** %8
%32 = call i32 @fclose(i32* %31)
%33 = load i32, i32* %6
store i32 %33, i32* %3
br label %34
34: ; preds = %24, %21
%35 = load i32, i32* %3
ret i32 %35
}

LLVM IR (-O2):
@__const.myMakefile.fname = [9 x i8] c"makefile\00"
@.str = [13 x i8] c"makefile.bak\00"
@.str.1 = [3 x i8] c"a+\00"
@.str.2 = [54 x i8] c"func myMakefile() error: if (tfile == NULL) line: %d\00"
define i32 @myMakefile(i32 %0, i8** %1) {
%3 = alloca [9 x i8]
%4 = getelementptr inbounds [9 x i8], [9 x i8]* %3, i64 0, i64 0
%5 = call i64 @access(i8* %4, i32 0)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %2
%8 = call i32 @rename(i8* %4, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
br label %9
9: ; preds = %7, %2
%10 = call i32* @fopen(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = tail call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.2, i64 0, i64 0), i32 149)
br label %18
14: ; preds = %9
%15 = tail call i32 @myFileComments(i32* %10)
%16 = tail call i32 @myFile(i32* %10, i32 %0, i8** %1)
%17 = tail call i32 @fclose(i32* %10)
br label %18
18: ; preds = %14, %12
%19 = phi i32 [ -1, %12 ], [ %16, %14 ]
ret i32 %19
}