#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 */
char EOF;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/ *);
int /*<<< orphan*/ ignorableCharacter(char);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
void reverseConvertFile(char *fileName) {
  char ch;
  char fullFileName[64];
  strcpy(fullFileName, "reversed_");
  strcat(fullFileName, fileName);
  FILE *inputFile;
  FILE *outputFile;
  if (!(outputFile = fopen(fullFileName, "w"))) {
    printf("Error converting file: output file could not be opened.\n");
  } else if (!(inputFile = fopen(fileName, "r+"))) {
    printf("Error converting file: input file could not be opened.\n");
  } else {
    do {
      ch = fgetc(inputFile);
      if (ch == '\n') {
        fputc(' ', outputFile);
      } else if (!ignorableCharacter(ch)) {
        fputc(ch, outputFile);
      }
    } while (ch != EOF);
  }
  fclose(inputFile);
  fclose(outputFile);
}


x86 assembly (clang, -O0):
<reverseConvertFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x50(%rbp),%rdi
lea    0xe69(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x50(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   10a0 <strcat@plt>
lea    -0x50(%rbp),%rdi
lea    0xe56(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x60(%rbp)
cmp    $0x0,%rax
jne    11d8 <reverseConvertFile+0x58>
lea    0xe3e(%rip),%rdi
call   1060 <printf@plt>
jmp    1283 <reverseConvertFile+0x103>
mov    -0x8(%rbp),%rdi
lea    0xe62(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x58(%rbp)
cmp    $0x0,%rax
jne    1207 <reverseConvertFile+0x87>
lea    0xe4b(%rip),%rdi
call   1060 <printf@plt>
jmp    127e <reverseConvertFile+0xfe>
jmp    120c <reverseConvertFile+0x8c>
mov    -0x58(%rbp),%rdi
call   1070 <fgetc@plt>
mov    %al,-0x9(%rbp)
movsbl -0x9(%rbp),%eax
cmp    $0xa,%eax
jne    1238 <reverseConvertFile+0xb8>
mov    -0x60(%rbp),%rsi
mov    $0x20,%edi
call   1080 <fputc@plt>
jmp    125e <reverseConvertFile+0xde>
movsbl -0x9(%rbp),%edi
call   1040 <ignorableCharacter@plt>
cmp    $0x0,%eax
jne    1259 <reverseConvertFile+0xd9>
mov    -0x9(%rbp),%al
mov    -0x60(%rbp),%rsi
movsbl %al,%edi
call   1080 <fputc@plt>
jmp    125e <reverseConvertFile+0xde>
jmp    1263 <reverseConvertFile+0xe3>
movsbl -0x9(%rbp),%eax
mov    0x2d7a(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
jne    120c <reverseConvertFile+0x8c>
jmp    127e <reverseConvertFile+0xfe>
jmp    1283 <reverseConvertFile+0x103>
mov    -0x58(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x60(%rbp),%rdi
call   1050 <fclose@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<reverseConvertFile>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %rdi,%rbx
lea    0xe6b(%rip),%rsi
mov    %rsp,%r14
mov    %r14,%rdi
call   1030 <strcpy@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   10a0 <strcat@plt>
lea    0xe58(%rip),%rsi
mov    %r14,%rdi
call   1090 <fopen@plt>
test   %rax,%rax
je     1249 <reverseConvertFile+0xc9>
mov    %rax,%r14
lea    0xe3f(%rip),%rsi
mov    %rbx,%rdi
call   1090 <fopen@plt>
mov    %rax,%r15
test   %rax,%rax
je     1221 <reverseConvertFile+0xa1>
mov    0x2e04(%rip),%r12
jmp    1201 <reverseConvertFile+0x81>
cs nopw 0x0(%rax,%rax,1)
movsbl %cl,%edi
mov    %r14,%rsi
call   1080 <fputc@plt>
cmp    (%r12),%bl
je     122d <reverseConvertFile+0xad>
mov    %r15,%rdi
call   1070 <fgetc@plt>
mov    %eax,%ebx
mov    $0x20,%cl
cmp    $0xa,%al
je     11f0 <reverseConvertFile+0x70>
movsbl %bl,%edi
call   1050 <ignorableCharacter@plt>
mov    %ebx,%ecx
test   %eax,%eax
jne    11fb <reverseConvertFile+0x7b>
jmp    11f0 <reverseConvertFile+0x70>
lea    0xe1f(%rip),%rdi
call   1040 <puts@plt>
mov    %r15,%rdi
call   1060 <fclose@plt>
mov    %r14,%rdi
call   1060 <fclose@plt>
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
lea    0xdbf(%rip),%rdi
call   1040 <puts@plt>

LLVM IR (-O0):
@.str = [10 x i8] c"reversed_\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [57 x i8] c"Error converting file: output file could not be opened.\0A\00"
@.str.3 = [3 x i8] c"r+\00"
@.str.4 = [56 x i8] c"Error converting file: input file could not be opened.\0A\00"
@EOF = global i8 0
define void @reverseConvertFile(i8* %0) {
%2 = alloca i8*
%3 = alloca i8
%4 = alloca [64 x i8]
%5 = alloca i32*
%6 = alloca i32*
store i8* %0, i8** %2
%7 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 0
%8 = call i32 @strcpy(i8* %7, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%9 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 0
%10 = load i8*, i8** %2
%11 = call i32 @strcat(i8* %9, i8* %10)
%12 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 0
%13 = call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %13, i32** %6
%14 = icmp ne i32* %13, null
br i1 %14, label %17, label %15
15: ; preds = %1
%16 = call i32 @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.2, i64 0, i64 0))
br label %51
17: ; preds = %1
%18 = load i8*, i8** %2
%19 = call i32* @fopen(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
store i32* %19, i32** %5
%20 = icmp ne i32* %19, null
br i1 %20, label %23, label %21
21: ; preds = %17
%22 = call i32 @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.4, i64 0, i64 0))
br label %50
23: ; preds = %17
br label %24
24: ; preds = %43, %23
%25 = load i32*, i32** %5
%26 = call signext i8 @fgetc(i32* %25)
store i8 %26, i8* %3
%27 = load i8, i8* %3
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %28, 10
br i1 %29, label %30, label %33
30: ; preds = %24
%31 = load i32*, i32** %6
%32 = call i32 @fputc(i8 signext 32, i32* %31)
br label %42
33: ; preds = %24
%34 = load i8, i8* %3
%35 = call i32 @ignorableCharacter(i8 signext %34)
%36 = icmp ne i32 %35, 0
br i1 %36, label %41, label %37
37: ; preds = %33
%38 = load i8, i8* %3
%39 = load i32*, i32** %6
%40 = call i32 @fputc(i8 signext %38, i32* %39)
br label %41
41: ; preds = %37, %33
br label %42
42: ; preds = %41, %30
br label %43
43: ; preds = %42
%44 = load i8, i8* %3
%45 = sext i8 %44 to i32
%46 = load i8, i8* @EOF
%47 = sext i8 %46 to i32
%48 = icmp ne i32 %45, %47
br i1 %48, label %24, label %49
49: ; preds = %43
br label %50
50: ; preds = %49, %21
br label %51
51: ; preds = %50, %15
%52 = load i32*, i32** %5
%53 = call i32 @fclose(i32* %52)
%54 = load i32*, i32** %6
%55 = call i32 @fclose(i32* %54)
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"reversed_\00"
@.str.1 = [2 x i8] c"w\00"
@.str.3 = [3 x i8] c"r+\00"
@EOF = global i8 0
@str = [56 x i8] c"Error converting file: output file could not be opened.\00"
@str.5 = [55 x i8] c"Error converting file: input file could not be opened.\00"
define void @reverseConvertFile(i8* %0) {
%2 = alloca [64 x i8]
%3 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%4 = call i32 @strcpy(i8* %3, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @strcat(i8* %3, i8* %0)
%6 = call i32* @fopen(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %10
8: ; preds = %1
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @str, i64 0, i64 0))
unreachable
10: ; preds = %1
%11 = call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @str.5, i64 0, i64 0))
br label %27
15: ; preds = %10, %24
%16 = call signext i8 @fgetc(i32* %11)
%17 = icmp eq i8 %16, 10
br i1 %17, label %21, label %18
18: ; preds = %15
%19 = call i32 @ignorableCharacter(i8 signext %16)
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %18, %15
%22 = phi i8 [ 32, %15 ], [ %16, %18 ]
%23 = call i32 @fputc(i8 signext %22, i32* %6)
br label %24
24: ; preds = %21, %18
%25 = load i8, i8* @EOF
%26 = icmp eq i8 %16, %25
br i1 %26, label %27, label %15
27: ; preds = %24, %13
%28 = call i32 @fclose(i32* %11)
%29 = call i32 @fclose(i32* %6)
ret void
}