#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*/ feof(int /*<<< orphan*/ *);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ isspace(char);
int /*<<< orphan*/ printf(char *, char *);
void txtToArray(char *file, char *array) {
  FILE *f = fopen(file, "r");
  if (!f) {
    printf("Error opening %s!\n", file);
    exit(1);
  }
  int i = 0;
  while (!feof(f)) {
    char c = fgetc(f);
    if (!isspace(c)) {
      array[i] = c;
      i++;
    }
  }
  fclose(f);
}


x86 assembly (clang, -O0):
<txtToArray>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe75(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11b9 <txtToArray+0x49>
mov    -0x8(%rbp),%rsi
lea    0xe58(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
call   1070 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11de <txtToArray+0x6e>
jmp    1218 <txtToArray+0xa8>
mov    -0x18(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %al,-0x1d(%rbp)
movsbl -0x1d(%rbp),%edi
call   1060 <isspace@plt>
cmp    $0x0,%eax
jne    1213 <txtToArray+0xa3>
mov    -0x1d(%rbp),%dl
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11c0 <txtToArray+0x50>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<txtToArray>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
lea    0xe7b(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     11ef <txtToArray+0x7f>
mov    %rax,%r12
mov    %rax,%rdi
call   1070 <feof@plt>
test   %eax,%eax
je     11b1 <txtToArray+0x41>
mov    %r12,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <fclose@plt>
xor    %r15d,%r15d
jmp    11cc <txtToArray+0x5c>
cs nopw 0x0(%rax,%rax,1)
mov    %r12,%rdi
call   1070 <feof@plt>
test   %eax,%eax
jne    119e <txtToArray+0x2e>
mov    %r12,%rdi
call   1050 <fgetc@plt>
mov    %eax,%ebx
movsbl %al,%edi
call   1060 <isspace@plt>
test   %eax,%eax
jne    11c0 <txtToArray+0x50>
movslq %r15d,%r15
mov    %bl,(%r14,%r15,1)
add    $0x1,%r15d
jmp    11c0 <txtToArray+0x50>
lea    0xe0c(%rip),%rdi
mov    %r15,%rsi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [19 x i8] c"Error opening %s!\0A\00"
define void @txtToArray(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i8
store i8* %0, i8** %3
store i8* %1, i8** %4
%8 = load i8*, i8** %3
%9 = call i32* @fopen(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %9, i32** %5
%10 = load i32*, i32** %5
%11 = icmp ne i32* %10, null
br i1 %11, label %16, label %12
12: ; preds = %2
%13 = load i8*, i8** %3
%14 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %13)
%15 = call i32 @exit(i32 1)
unreachable
16: ; preds = %2
store i32 0, i32* %6
br label %17
17: ; preds = %36, %16
%18 = load i32*, i32** %5
%19 = call i32 @feof(i32* %18)
%20 = icmp ne i32 %19, 0
%21 = xor i1 %20, true
br i1 %21, label %22, label %37
22: ; preds = %17
%23 = load i32*, i32** %5
%24 = call signext i8 @fgetc(i32* %23)
store i8 %24, i8* %7
%25 = load i8, i8* %7
%26 = call i32 @isspace(i8 signext %25)
%27 = icmp ne i32 %26, 0
br i1 %27, label %36, label %28
28: ; preds = %22
%29 = load i8, i8* %7
%30 = load i8*, i8** %4
%31 = load i32, i32* %6
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %30, i64 %32
store i8 %29, i8* %33
%34 = load i32, i32* %6
%35 = add nsw i32 %34, 1
store i32 %35, i32* %6
br label %36
36: ; preds = %28, %22
br label %17
37: ; preds = %17
%38 = load i32*, i32** %5
%39 = call i32 @fclose(i32* %38)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [19 x i8] c"Error opening %s!\0A\00"
define void @txtToArray(i8* %0, i8* nocapture writeonly %1) {
%3 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %8, label %5
5: ; preds = %2
%6 = tail call i32 @feof(i32* %3)
%7 = icmp eq i32 %6, 0
br i1 %7, label %11, label %24
8: ; preds = %2
%9 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%10 = tail call i32 @exit(i32 1)
unreachable
11: ; preds = %5, %20
%12 = phi i32 [ %21, %20 ], [ 0, %5 ]
%13 = tail call signext i8 @fgetc(i32* %3)
%14 = tail call i32 @isspace(i8 signext %13)
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %20
16: ; preds = %11
%17 = sext i32 %12 to i64
%18 = getelementptr inbounds i8, i8* %1, i64 %17
store i8 %13, i8* %18
%19 = add nsw i32 %12, 1
br label %20
20: ; preds = %16, %11
%21 = phi i32 [ %12, %11 ], [ %19, %16 ]
%22 = tail call i32 @feof(i32* %3)
%23 = icmp eq i32 %22, 0
br i1 %23, label %11, label %24
24: ; preds = %20, %5
%25 = tail call i32 @fclose(i32* %3)
ret void
}