#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(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printMake(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ system(char *);
void makeMakefile(char *platform) {
  char command[255];
  char makefileName[255];
  FILE *make;
  strcpy(makefileName, "../Makefile.old");
  sprintf(command, "rm -f %s\n", makefileName);
  system(command);
  sprintf(command, "cat makestart > %s\n", makefileName);
  system(command);
  make = fopen(makefileName, "a");
  if (make == NULL) {
    printf("Can't open output '%s'.\n", makefileName);
    exit(1);
  }
  printMake(make, platform);
  fclose(make);
}


x86 assembly (clang, -O0):
<makeMakefile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x220,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x210(%rbp),%rdi
lea    0xe63(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x110(%rbp),%rdi
lea    -0x210(%rbp),%rdx
lea    0xe59(%rip),%rsi
call   1090 <sprintf@plt>
lea    -0x110(%rbp),%rdi
call   1050 <system@plt>
lea    -0x110(%rbp),%rdi
lea    -0x210(%rbp),%rdx
lea    0xe3d(%rip),%rsi
call   1090 <sprintf@plt>
lea    -0x110(%rbp),%rdi
call   1050 <system@plt>
lea    -0x210(%rbp),%rdi
lea    0xe32(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x218(%rbp)
cmpq   $0x0,-0x218(%rbp)
jne    1233 <makeMakefile+0xb3>
lea    -0x210(%rbp),%rsi
lea    0xe0c(%rip),%rdi
call   1060 <printf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    -0x218(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1080 <printMake@plt>
mov    -0x218(%rbp),%rdi
call   1040 <fclose@plt>
add    $0x220,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<makeMakefile>:
push   %r15
push   %r14
push   %rbx
sub    $0x200,%rsp
mov    %rdi,%r14
lea    0xe6a(%rip),%rsi
mov    %rsp,%r15
mov    %r15,%rdi
call   1030 <strcpy@plt>
lea    0xe68(%rip),%rsi
lea    0x100(%rsp),%rbx
mov    %rbx,%rdi
mov    %r15,%rdx
call   1090 <sprintf@plt>
mov    %rbx,%rdi
call   1050 <system@plt>
lea    0xe50(%rip),%rsi
mov    %rbx,%rdi
mov    %r15,%rdx
call   1090 <sprintf@plt>
mov    %rbx,%rdi
call   1050 <system@plt>
lea    0xe4a(%rip),%rsi
mov    %r15,%rdi
call   1070 <fopen@plt>
test   %rax,%rax
je     1214 <makeMakefile+0x94>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
call   1080 <printMake@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
add    $0x200,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xe15(%rip),%rdi
mov    %rsp,%rsi
call   1060 <printf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [16 x i8] c"../Makefile.old\00"
@.str.1 = [10 x i8] c"rm -f %s\0A\00"
@.str.2 = [20 x i8] c"cat makestart > %s\0A\00"
@.str.3 = [2 x i8] c"a\00"
@.str.4 = [25 x i8] c"Can't open output '%s'.\0A\00"
define void @makeMakefile(i8* %0) {
%2 = alloca i8*
%3 = alloca [255 x i8]
%4 = alloca [255 x i8]
%5 = alloca i32*
store i8* %0, i8** %2
%6 = getelementptr inbounds [255 x i8], [255 x i8]* %4, i64 0, i64 0
%7 = call i32 @strcpy(i8* %6, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%8 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%9 = getelementptr inbounds [255 x i8], [255 x i8]* %4, i64 0, i64 0
%10 = call i32 @sprintf(i8* %8, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%11 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%12 = call i32 @system(i8* %11)
%13 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%14 = getelementptr inbounds [255 x i8], [255 x i8]* %4, i64 0, i64 0
%15 = call i32 @sprintf(i8* %13, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %14)
%16 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%17 = call i32 @system(i8* %16)
%18 = getelementptr inbounds [255 x i8], [255 x i8]* %4, i64 0, i64 0
%19 = call i32* @fopen(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %19, i32** %5
%20 = load i32*, i32** %5
%21 = icmp eq i32* %20, null
br i1 %21, label %22, label %26
22: ; preds = %1
%23 = getelementptr inbounds [255 x i8], [255 x i8]* %4, i64 0, i64 0
%24 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i8* %23)
%25 = call i32 @exit(i32 1)
unreachable
26: ; preds = %1
%27 = load i32*, i32** %5
%28 = load i8*, i8** %2
%29 = call i32 @printMake(i32* %27, i8* %28)
%30 = load i32*, i32** %5
%31 = call i32 @fclose(i32* %30)
ret void
}

LLVM IR (-O2):
@.str = [16 x i8] c"../Makefile.old\00"
@.str.1 = [10 x i8] c"rm -f %s\0A\00"
@.str.2 = [20 x i8] c"cat makestart > %s\0A\00"
@.str.3 = [2 x i8] c"a\00"
@.str.4 = [25 x i8] c"Can't open output '%s'.\0A\00"
define void @makeMakefile(i8* %0) {
%2 = alloca [255 x i8]
%3 = alloca [255 x i8]
%4 = getelementptr inbounds [255 x i8], [255 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%6 = call i32 @strcpy(i8* %5, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%8 = call i32 @system(i8* %4)
%9 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %5)
%10 = call i32 @system(i8* %4)
%11 = call i32* @fopen(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %16
13: ; preds = %1
%14 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i8* %5)
%15 = call i32 @exit(i32 1)
unreachable
16: ; preds = %1
%17 = call i32 @printMake(i32* %11, i8* %0)
%18 = call i32 @fclose(i32* %11)
ret void
}