#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*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *);
FILE *openFMFile(char *outputName, char *source, char *formatterVersion) {
  FILE *FMfile;
  FMfile = fopen(outputName, "w");
  if (FMfile == NULL) {
    printf("ERROR: cannot opening FrameMaker file: %s\n", outputName);
    perror("       system error");
    exit(1);
  }
  fprintf(FMfile, "<MIFFile 5.0> # This is a FRAMEMAKER 5.0 MIF File\n");
  fprintf(FMfile, "# -----------------------------------------------\n");
  fprintf(FMfile, "# This file has been automatically produced.");
  fprintf(FMfile, " DO NOT EDIT THIS FILE!!!!!!\n");
  fprintf(FMfile, "# Input file:  %s\n", source);
  fprintf(FMfile, "# Formatter :  %s\n", formatterVersion);
  fprintf(FMfile, "# -----------------------------------------------\n");
  return FMfile;
}


x86 assembly (clang, -O0):
<openFMFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe91(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11a9 <openFMFile+0x59>
mov    -0x8(%rbp),%rsi
lea    0xe74(%rip),%rdi
call   1030 <printf@plt>
lea    0xe93(%rip),%rdi
call   1060 <perror@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x20(%rbp),%rdi
lea    0xe8d(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x20(%rbp),%rdi
lea    0xeae(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x20(%rbp),%rdi
lea    0xecf(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x20(%rbp),%rdi
lea    0xeea(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xef2(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xeef(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x20(%rbp),%rdi
lea    0xe4c(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<openFMFile>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r12
lea    0xe88(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     123c <openFMFile+0xdc>
mov    %rax,%rbx
lea    0xeb1(%rip),%rdi
mov    $0x32,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   1080 <fwrite@plt>
lea    0xecb(%rip),%r12
mov    $0x32,%esi
mov    $0x1,%edx
mov    %r12,%rdi
mov    %rbx,%rcx
call   1080 <fwrite@plt>
lea    0xee2(%rip),%rdi
mov    $0x2c,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1080 <fwrite@plt>
lea    0xef6(%rip),%rdi
mov    $0x1d,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1080 <fwrite@plt>
lea    0xefb(%rip),%rsi
mov    %rbx,%rdi
mov    %r15,%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
lea    0xefa(%rip),%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0x32,%esi
mov    $0x1,%edx
mov    %r12,%rdi
mov    %rbx,%rcx
call   1080 <fwrite@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
lea    0xdbf(%rip),%rdi
mov    %r12,%rsi
call   1030 <printf@plt>
lea    0xddb(%rip),%rdi
call   1060 <perror@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"w\00"
@.str.1 = [43 x i8] c"ERROR: cannot opening FrameMaker file: %s\0A\00"
@.str.2 = [20 x i8] c" system error\00"
@.str.3 = [51 x i8] c"<MIFFile 5.0> # This is a FRAMEMAKER 5.0 MIF File\0A\00"
@.str.4 = [51 x i8] c"# -----------------------------------------------\0A\00"
@.str.5 = [45 x i8] c"# This file has been automatically produced.\00"
@.str.6 = [30 x i8] c" DO NOT EDIT THIS FILE!!!!!!\0A\00"
@.str.7 = [19 x i8] c"# Input file: %s\0A\00"
@.str.8 = [19 x i8] c"# Formatter : %s\0A\00"
define i32* @openFMFile(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%8 = load i8*, i8** %4
%9 = call i32* @fopen(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %9, i32** %7
%10 = load i32*, i32** %7
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %17
12: ; preds = %3
%13 = load i8*, i8** %4
%14 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), i8* %13)
%15 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%16 = call i32 @exit(i32 1)
unreachable
17: ; preds = %3
%18 = load i32*, i32** %7
%19 = call i32 (i32*, i8*, ...) @fprintf(i32* %18, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.3, i64 0, i64 0))
%20 = load i32*, i32** %7
%21 = call i32 (i32*, i8*, ...) @fprintf(i32* %20, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.4, i64 0, i64 0))
%22 = load i32*, i32** %7
%23 = call i32 (i32*, i8*, ...) @fprintf(i32* %22, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.5, i64 0, i64 0))
%24 = load i32*, i32** %7
%25 = call i32 (i32*, i8*, ...) @fprintf(i32* %24, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0))
%26 = load i32*, i32** %7
%27 = load i8*, i8** %5
%28 = call i32 (i32*, i8*, ...) @fprintf(i32* %26, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0), i8* %27)
%29 = load i32*, i32** %7
%30 = load i8*, i8** %6
%31 = call i32 (i32*, i8*, ...) @fprintf(i32* %29, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0), i8* %30)
%32 = load i32*, i32** %7
%33 = call i32 (i32*, i8*, ...) @fprintf(i32* %32, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.4, i64 0, i64 0))
%34 = load i32*, i32** %7
ret i32* %34
}

LLVM IR (-O2):
@.str = [2 x i8] c"w\00"
@.str.1 = [43 x i8] c"ERROR: cannot opening FrameMaker file: %s\0A\00"
@.str.2 = [20 x i8] c" system error\00"
@.str.3 = [51 x i8] c"<MIFFile 5.0> # This is a FRAMEMAKER 5.0 MIF File\0A\00"
@.str.4 = [51 x i8] c"# -----------------------------------------------\0A\00"
@.str.5 = [45 x i8] c"# This file has been automatically produced.\00"
@.str.6 = [30 x i8] c" DO NOT EDIT THIS FILE!!!!!!\0A\00"
@.str.7 = [19 x i8] c"# Input file: %s\0A\00"
@.str.8 = [19 x i8] c"# Formatter : %s\0A\00"
define noalias i32* @openFMFile(i8* %0, i8* %1, i8* %2) {
%4 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %6, label %10
6: ; preds = %3
%7 = tail call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%8 = tail call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%9 = tail call i32 @exit(i32 1)
unreachable
10: ; preds = %3
%11 = tail call i64 @fwrite(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.3, i64 0, i64 0), i64 50, i64 1, i32* %4)
%12 = tail call i64 @fwrite(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.4, i64 0, i64 0), i64 50, i64 1, i32* %4)
%13 = tail call i64 @fwrite(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.5, i64 0, i64 0), i64 44, i64 1, i32* %4)
%14 = tail call i64 @fwrite(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0), i64 29, i64 1, i32* %4)
%15 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %4, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0), i8* %1)
%16 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %4, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0), i8* %2)
%17 = tail call i64 @fwrite(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.4, i64 0, i64 0), i64 50, i64 1, i32* %4)
ret i32* %4
}