#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strcpy(char *, char *);
void ReadFile(char *E) {
  char path[50];
  int i = 0;
  for (i = 5; E[i] != '#'; i++) {
    if (E[i] == '\n')
      continue;
    path[i - 5] = E[i];
  }
  path[i - 5] = '\0';
  FILE *fp = fopen(path, "r");
  if (!fp) {
    printf("File Path Error!\n");
    strcpy(E, "error");
    return;
  }
  fscanf(fp, "%s", E);
  printf("Expression:   %s\n", E);
  fclose(fp);
}


x86 assembly (clang, -O0):
<ReadFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x44(%rbp)
movl   $0x5,-0x44(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x23,%eax
je     11be <ReadFile+0x6e>
mov    -0x8(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
jne    1199 <ReadFile+0x49>
jmp    11b0 <ReadFile+0x60>
mov    -0x8(%rbp),%rax
movslq -0x44(%rbp),%rcx
mov    (%rax,%rcx,1),%cl
mov    -0x44(%rbp),%eax
sub    $0x5,%eax
cltq
mov    %cl,-0x40(%rbp,%rax,1)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    116a <ReadFile+0x1a>
mov    -0x44(%rbp),%eax
sub    $0x5,%eax
cltq
movb   $0x0,-0x40(%rbp,%rax,1)
lea    -0x40(%rbp),%rdi
lea    0xe40(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
jne    120d <ReadFile+0xbd>
lea    0xe0f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x8(%rbp),%rdi
lea    0xe0f(%rip),%rsi
call   1030 <strcpy@plt>
jmp    123c <ReadFile+0xec>
mov    -0x50(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xdfc(%rip),%rsi
call   1060 <fscanf@plt>
mov    -0x8(%rbp),%rsi
lea    0xdef(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x50(%rbp),%rdi
call   1040 <fclose@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ReadFile>:
push   %r14
push   %rbx
sub    $0x38,%rsp
mov    %rdi,%rbx
xor    %eax,%eax
movabs $0x100000000,%rsi
xor    %ecx,%ecx
jmp    118a <ReadFile+0x2a>
nopw   0x0(%rax,%rax,1)
mov    %dl,(%rsp,%rax,1)
add    %rsi,%rcx
add    $0x1,%rax
movzbl 0x5(%rbx,%rax,1),%edx
cmp    $0xa,%dl
je     1183 <ReadFile+0x23>
cmp    $0x23,%dl
jne    1180 <ReadFile+0x20>
sar    $0x20,%rcx
movb   $0x0,(%rsp,%rcx,1)
lea    0xe5c(%rip),%rsi
mov    %rsp,%rdi
call   1080 <fopen@plt>
test   %rax,%rax
je     11ea <ReadFile+0x8a>
mov    %rax,%r14
lea    0xe47(%rip),%rsi
mov    %rax,%rdi
mov    %rbx,%rdx
call   1070 <fscanf@plt>
lea    0xe38(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r14,%rdi
add    $0x38,%rsp
pop    %rbx
pop    %r14
jmp    1050 <fclose@plt>
lea    0xe2a(%rip),%rdi
call   1040 <puts@plt>
lea    0xe03(%rip),%rsi
mov    %rbx,%rdi
add    $0x38,%rsp
pop    %rbx
pop    %r14
jmp    1030 <strcpy@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [18 x i8] c"File Path Error!\0A\00"
@.str.2 = [6 x i8] c"error\00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [18 x i8] c"Expression: %s\0A\00"
define void @ReadFile(i8* %0) {
%2 = alloca i8*
%3 = alloca [50 x i8]
%4 = alloca i32
%5 = alloca i32*
store i8* %0, i8** %2
store i32 0, i32* %4
store i32 5, i32* %4
br label %6
6: ; preds = %33, %1
%7 = load i8*, i8** %2
%8 = load i32, i32* %4
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds i8, i8* %7, i64 %9
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %12, 35
br i1 %13, label %14, label %36
14: ; preds = %6
%15 = load i8*, i8** %2
%16 = load i32, i32* %4
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %15, i64 %17
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 10
br i1 %21, label %22, label %23
22: ; preds = %14
br label %33
23: ; preds = %14
%24 = load i8*, i8** %2
%25 = load i32, i32* %4
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %24, i64 %26
%28 = load i8, i8* %27
%29 = load i32, i32* %4
%30 = sub nsw i32 %29, 5
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 %31
store i8 %28, i8* %32
br label %33
33: ; preds = %23, %22
%34 = load i32, i32* %4
%35 = add nsw i32 %34, 1
store i32 %35, i32* %4
br label %6
36: ; preds = %6
%37 = load i32, i32* %4
%38 = sub nsw i32 %37, 5
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 %39
store i8 0, i8* %40
%41 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%42 = call i32* @fopen(i8* %41, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %42, i32** %5
%43 = load i32*, i32** %5
%44 = icmp ne i32* %43, null
br i1 %44, label %49, label %45
45: ; preds = %36
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%47 = load i8*, i8** %2
%48 = call i32 @strcpy(i8* %47, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
br label %57
49: ; preds = %36
%50 = load i32*, i32** %5
%51 = load i8*, i8** %2
%52 = call i32 @fscanf(i32* %50, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %51)
%53 = load i8*, i8** %2
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i8* %53)
%55 = load i32*, i32** %5
%56 = call i32 @fclose(i32* %55)
br label %57
57: ; preds = %49, %45
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.2 = [6 x i8] c"error\00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [18 x i8] c"Expression: %s\0A\00"
@str = [17 x i8] c"File Path Error!\00"
define void @ReadFile(i8* %0) {
%2 = alloca [50 x i8]
%3 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
br label %4
4: ; preds = %11, %1
%5 = phi i64 [ %12, %11 ], [ 5, %1 ]
%6 = getelementptr inbounds i8, i8* %0, i64 %5
%7 = load i8, i8* %6
switch i8 %7, label %8 [
i8 35, label %13
i8 10, label %11
]
8: ; preds = %4
%9 = add nsw i64 %5, -5
%10 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 %9
store i8 %7, i8* %10
br label %11
11: ; preds = %4, %8
%12 = add nuw i64 %5, 1
br label %4
13: ; preds = %4
%14 = shl i64 %5, 32
%15 = add i64 %14, -21474836480
%16 = ashr exact i64 %15, 32
%17 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 %16
store i8 0, i8* %17
%18 = call i32* @fopen(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%19 = icmp eq i32* %18, null
br i1 %19, label %20, label %23
20: ; preds = %13
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
%22 = tail call i32 @strcpy(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
br label %27
23: ; preds = %13
%24 = tail call i32 @fscanf(i32* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %0)
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i8* %0)
%26 = tail call i32 @fclose(i32* %18)
br label %27
27: ; preds = %23, %20
ret void
}