#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 */

/* Variables and functions */
int /*<<< orphan*/ FileProxy_ReadFile(char *, char *, unsigned int);
int /*<<< orphan*/ strcpy(char *, char *);
int FileProxy_ReadVersionTxt(char *filename, char *verstr, char *vername) {
  char buf[(1024U)] = {0};
  int len;
  FileProxy_ReadFile(filename, buf, (1024U));
  for (len = 0; len < (1024U); len++) {
    if ((buf[len] == ' ') || (buf[len] == 0)) {
      buf[len] = 0;
      break;
    }
  }
  strcpy(verstr, buf);
  return (0);
}


x86 assembly (clang, -O0):
<FileProxy_ReadVersionTxt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    -0x420(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1040 <memset@plt>
mov    -0x8(%rbp),%rdi
lea    -0x420(%rbp),%rsi
mov    $0x400,%edx
call   1050 <FileProxy_ReadFile@plt>
movl   $0x0,-0x424(%rbp)
cmpl   $0x400,-0x424(%rbp)
jae    11e6 <FileProxy_ReadVersionTxt+0xb6>
movslq -0x424(%rbp),%rax
movsbl -0x420(%rbp,%rax,1),%eax
ff
cmp    $0x20,%eax
je     11b9 <FileProxy_ReadVersionTxt+0x89>
movslq -0x424(%rbp),%rax
movsbl -0x420(%rbp,%rax,1),%eax
ff
cmp    $0x0,%eax
jne    11cd <FileProxy_ReadVersionTxt+0x9d>
movslq -0x424(%rbp),%rax
movb   $0x0,-0x420(%rbp,%rax,1)
jmp    11e6 <FileProxy_ReadVersionTxt+0xb6>
jmp    11d2 <FileProxy_ReadVersionTxt+0xa2>
mov    -0x424(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x424(%rbp)
jmp    1179 <FileProxy_ReadVersionTxt+0x49>
mov    -0x10(%rbp),%rdi
lea    -0x420(%rbp),%rsi
call   1030 <strcpy@plt>
xor    %eax,%eax
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<FileProxy_ReadVersionTxt>:
push   %r15
push   %r14
push   %rbx
sub    $0x400,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %rsp,%r15
mov    $0x400,%edx
mov    %r15,%rdi
xor    %esi,%esi
call   1040 <memset@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    $0x400,%edx
call   1050 <FileProxy_ReadFile@plt>
mov    $0x7,%eax
testb  $0xdf,-0x7(%rsp,%rax,1)
je     11ae <FileProxy_ReadVersionTxt+0x7e>
testb  $0xdf,-0x6(%rsp,%rax,1)
je     11b4 <FileProxy_ReadVersionTxt+0x84>
testb  $0xdf,-0x5(%rsp,%rax,1)
je     11ba <FileProxy_ReadVersionTxt+0x8a>
testb  $0xdf,-0x4(%rsp,%rax,1)
je     11c0 <FileProxy_ReadVersionTxt+0x90>
testb  $0xdf,-0x3(%rsp,%rax,1)
je     11c6 <FileProxy_ReadVersionTxt+0x96>
testb  $0xdf,-0x2(%rsp,%rax,1)
je     11cc <FileProxy_ReadVersionTxt+0x9c>
testb  $0xdf,-0x1(%rsp,%rax,1)
je     11d2 <FileProxy_ReadVersionTxt+0xa2>
testb  $0xdf,(%rsp,%rax,1)
je     11d6 <FileProxy_ReadVersionTxt+0xa6>
add    $0x8,%rax
cmp    $0x407,%rax
jne    1169 <FileProxy_ReadVersionTxt+0x39>
jmp    11dc <FileProxy_ReadVersionTxt+0xac>
add    $0xfffffffffffffff9,%rax
jmp    11d6 <FileProxy_ReadVersionTxt+0xa6>
add    $0xfffffffffffffffa,%rax
jmp    11d6 <FileProxy_ReadVersionTxt+0xa6>
add    $0xfffffffffffffffb,%rax
jmp    11d6 <FileProxy_ReadVersionTxt+0xa6>
add    $0xfffffffffffffffc,%rax
jmp    11d6 <FileProxy_ReadVersionTxt+0xa6>
add    $0xfffffffffffffffd,%rax
jmp    11d6 <FileProxy_ReadVersionTxt+0xa6>
add    $0xfffffffffffffffe,%rax
jmp    11d6 <FileProxy_ReadVersionTxt+0xa6>
add    $0xffffffffffffffff,%rax
mov    %eax,%eax
movb   $0x0,(%rsp,%rax,1)
mov    %rsp,%rsi
mov    %r14,%rdi
call   1030 <strcpy@plt>
xor    %eax,%eax
add    $0x400,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @FileProxy_ReadVersionTxt(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca [1024 x i8]
%8 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%9 = bitcast [1024 x i8]* %7 to i8*
%10 = load i8*, i8** %4
%11 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%12 = call i32 @FileProxy_ReadFile(i8* %10, i8* %11, i32 1024)
store i32 0, i32* %8
br label %13
13: ; preds = %35, %3
%14 = load i32, i32* %8
%15 = icmp ult i32 %14, 1024
br i1 %15, label %16, label %38
16: ; preds = %13
%17 = load i32, i32* %8
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 %18
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 32
br i1 %22, label %30, label %23
23: ; preds = %16
%24 = load i32, i32* %8
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 %25
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %34
30: ; preds = %23, %16
%31 = load i32, i32* %8
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 %32
store i8 0, i8* %33
br label %38
34: ; preds = %23
br label %35
35: ; preds = %34
%36 = load i32, i32* %8
%37 = add nsw i32 %36, 1
store i32 %37, i32* %8
br label %13
38: ; preds = %30, %13
%39 = load i8*, i8** %5
%40 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%41 = call i32 @strcpy(i8* %39, i8* %40)
ret i32 0
}

LLVM IR (-O2):
define i32 @FileProxy_ReadVersionTxt(i8* %0, i8* %1, i8* nocapture readnone %2) {
%4 = alloca [1024 x i8]
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%6 = call i32 @FileProxy_ReadFile(i8* %0, i8* %5, i32 1024)
br label %7
7: ; preds = %43, %3
%8 = phi i64 [ 0, %3 ], [ %44, %43 ]
%9 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 %8
%10 = load i8, i8* %9
switch i8 %10, label %15 [
i8 32, label %11
i8 0, label %11
]
11: ; preds = %39, %39, %35, %35, %31, %31, %27, %27, %23, %23, %19, %19, %15, %15, %7, %7
%12 = phi i64 [ %8, %7 ], [ %8, %7 ], [ %16, %15 ], [ %16, %15 ], [ %20, %19 ], [ %20, %19 ], [ %24, %23 ], [ %24, %23 ], [ %28, %27 ], [ %28, %27 ], [ %32, %31 ], [ %32, %31 ], [ %36, %35 ], [ %36, %35 ], [ %40, %39 ], [ %40, %39 ]
%13 = and i64 %12, 4294967295
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 %13
store i8 0, i8* %14
br label %46
15: ; preds = %7
%16 = or i64 %8, 1
%17 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 %16
%18 = load i8, i8* %17
switch i8 %18, label %19 [
i8 32, label %11
i8 0, label %11
]
19: ; preds = %15
%20 = or i64 %8, 2
%21 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 %20
%22 = load i8, i8* %21
switch i8 %22, label %23 [
i8 32, label %11
i8 0, label %11
]
23: ; preds = %19
%24 = or i64 %8, 3
%25 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 %24
%26 = load i8, i8* %25
switch i8 %26, label %27 [
i8 32, label %11
i8 0, label %11
]
27: ; preds = %23
%28 = or i64 %8, 4
%29 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 %28
%30 = load i8, i8* %29
switch i8 %30, label %31 [
i8 32, label %11
i8 0, label %11
]
31: ; preds = %27
%32 = or i64 %8, 5
%33 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 %32
%34 = load i8, i8* %33
switch i8 %34, label %35 [
i8 32, label %11
i8 0, label %11
]
35: ; preds = %31
%36 = or i64 %8, 6
%37 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 %36
%38 = load i8, i8* %37
switch i8 %38, label %39 [
i8 32, label %11
i8 0, label %11
]
39: ; preds = %35
%40 = or i64 %8, 7
%41 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 %40
%42 = load i8, i8* %41
switch i8 %42, label %43 [
i8 32, label %11
i8 0, label %11
]
43: ; preds = %39
%44 = add nuw nsw i64 %8, 8
%45 = icmp eq i64 %44, 1024
br i1 %45, label %46, label %7
46: ; preds = %43, %11
%47 = call i32 @strcpy(i8* %1, i8* %5)
ret i32 0
}