#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 */
scalar_t__ fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, long *);
long GetValue(void) {
  FILE *RslFile;
  long Value;
  Value = 0;
  RslFile = fopen("benchmarkvalue.txt", "r");
  if (RslFile != NULL)
    while (((char)fgetc(RslFile)) != 'C')
      fscanf(RslFile, "%li", &Value);
  return Value;
}


x86 assembly (clang, -O0):
<GetValue>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movq   $0x0,-0x10(%rbp)
lea    0xeb9(%rip),%rdi
lea    0xec5(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     119a <GetValue+0x6a>
jmp    1167 <GetValue+0x37>
mov    -0x8(%rbp),%rdi
call   1040 <fgetc@plt>
movsbl %al,%eax
cmp    $0x43,%eax
je     1195 <GetValue+0x65>
mov    -0x8(%rbp),%rdi
lea    0xe8e(%rip),%rsi
lea    -0x10(%rbp),%rdx
call   1030 <fscanf@plt>
jmp    1167 <GetValue+0x37>
jmp    119a <GetValue+0x6a>
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetValue>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
movq   $0x0,0x8(%rsp)
lea    0xeb7(%rip),%rdi
lea    0xec3(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     1169 <GetValue+0x39>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <fgetc@plt>
cmp    $0x43,%al
jne    116d <GetValue+0x3d>
xor    %eax,%eax
jmp    119f <GetValue+0x6f>
lea    0xea1(%rip),%r14
lea    0x8(%rsp),%r15
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1030 <fscanf@plt>
mov    %rbx,%rdi
call   1040 <fgetc@plt>
cmp    $0x43,%al
jne    1180 <GetValue+0x50>
mov    0x8(%rsp),%rax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [19 x i8] c"benchmarkvalue.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [4 x i8] c"%li\00"
define i64 @GetValue() {
%1 = alloca i32*
%2 = alloca i64
store i64 0, i64* %2
%3 = call i32* @fopen(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %3, i32** %1
%4 = load i32*, i32** %1
%5 = icmp ne i32* %4, null
br i1 %5, label %6, label %17
6: ; preds = %0
br label %7
7: ; preds = %13, %6
%8 = load i32*, i32** %1
%9 = call i64 @fgetc(i32* %8)
%10 = trunc i64 %9 to i8
%11 = sext i8 %10 to i32
%12 = icmp ne i32 %11, 67
br i1 %12, label %13, label %16
13: ; preds = %7
%14 = load i32*, i32** %1
%15 = call i32 @fscanf(i32* %14, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i64* %2)
br label %7
16: ; preds = %7
br label %17
17: ; preds = %16, %0
%18 = load i64, i64* %2
ret i64 %18
}

LLVM IR (-O2):
@.str = [19 x i8] c"benchmarkvalue.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [4 x i8] c"%li\00"
define i64 @GetValue() {
%1 = alloca i64
%2 = bitcast i64* %1 to i8*
store i64 0, i64* %1
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %16, label %5
5: ; preds = %0
%6 = call i64 @fgetc(i32* %3)
%7 = and i64 %6, 255
%8 = icmp eq i64 %7, 67
br i1 %8, label %16, label %9
9: ; preds = %5, %9
%10 = call i32 @fscanf(i32* %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i64* %1)
%11 = call i64 @fgetc(i32* %3)
%12 = and i64 %11, 255
%13 = icmp eq i64 %12, 67
br i1 %13, label %14, label %9
14: ; preds = %9
%15 = load i64, i64* %1
br label %16
16: ; preds = %14, %5, %0
%17 = phi i64 [ %15, %14 ], [ 0, %5 ], [ 0, %0 ]
ret i64 %17
}