#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*/ ligne;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
double atof(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int strlen(char const *);
int /*<<< orphan*/ strncmp(char *, char const *, int);
int /*<<< orphan*/ strncpy(char *, char *, int);
char *strrchr(char *, char);
int litFrequenceCpu(double *fFrequency) {
  const char *prefixe = "cycle frequency";
  FILE *fFile;
  char ligne[300 + 1];
  char *pos;
  int ok = 0;
  fFile = fopen("/tmp/wrekavalid.tmp", "r");
  if (!fFile)
    return 0;
  while (!feof(fFile)) {
    fgets(ligne, sizeof(ligne), fFile);
    if (!strncmp(ligne, prefixe, strlen(prefixe))) {
      pos = strrchr(ligne, ':') + 2;
      if (!pos)
        break;
      if (pos[strlen(pos) - 1] == '\n')
        pos[strlen(pos) - 1] = '\0';
      strncpy(ligne, pos, strlen(pos) - 5);
      *fFrequency = atof(ligne);
      ok = 1;
      break;
    }
  }
  fclose(fFile);
  return ok;
}


x86 assembly (clang, -O0):
<litFrequenceCpu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x190,%rsp
mov    %rdi,-0x10(%rbp)
lea    0xe5a(%rip),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x15c(%rbp)
lea    0xe55(%rip),%rdi
lea    0xe62(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11e2 <litFrequenceCpu+0x52>
movl   $0x0,-0x4(%rbp)
jmp    1366 <litFrequenceCpu+0x1d6>
jmp    11e7 <litFrequenceCpu+0x57>
mov    -0x20(%rbp),%rdi
call   10a0 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1205 <litFrequenceCpu+0x75>
jmp    1354 <litFrequenceCpu+0x1c4>
lea    -0x150(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    $0x12d,%esi
call   1090 <fgets@plt>
lea    -0x150(%rbp),%rax
mov    %rax,-0x170(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x168(%rbp)
mov    -0x18(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0x170(%rbp),%rdi
mov    -0x168(%rbp),%rsi
mov    %eax,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%eax
jne    134f <litFrequenceCpu+0x1bf>
lea    -0x150(%rbp),%rdi
mov    $0x3a,%esi
call   1080 <strrchr@plt>
add    $0x2,%rax
mov    %rax,-0x158(%rbp)
cmpq   $0x0,-0x158(%rbp)
jne    1289 <litFrequenceCpu+0xf9>
jmp    1354 <litFrequenceCpu+0x1c4>
mov    -0x158(%rbp),%rax
mov    %rax,-0x178(%rbp)
mov    -0x158(%rbp),%rdi
call   1070 <strlen@plt>
mov    %eax,%ecx
mov    -0x178(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
jne    12ec <litFrequenceCpu+0x15c>
mov    -0x158(%rbp),%rax
mov    %rax,-0x180(%rbp)
mov    -0x158(%rbp),%rdi
call   1070 <strlen@plt>
mov    %eax,%ecx
mov    -0x180(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
lea    -0x150(%rbp),%rax
mov    %rax,-0x190(%rbp)
mov    -0x158(%rbp),%rax
mov    %rax,-0x188(%rbp)
mov    -0x158(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0x190(%rbp),%rdi
mov    -0x188(%rbp),%rsi
mov    %eax,%edx
sub    $0x5,%edx
call   1030 <strncpy@plt>
lea    -0x150(%rbp),%rdi
call   1050 <atof@plt>
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
movl   $0x1,-0x15c(%rbp)
jmp    1354 <litFrequenceCpu+0x1c4>
jmp    11e7 <litFrequenceCpu+0x57>
mov    -0x20(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x15c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x190,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<litFrequenceCpu>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x130,%rsp
mov    %rdi,%r14
lea    0xe67(%rip),%rdi
lea    0xe74(%rip),%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
je     126b <litFrequenceCpu+0xdb>
mov    %rax,%rbx
mov    %rsp,%r15
lea    0xe35(%rip),%r12
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   10a0 <feof@plt>
test   %eax,%eax
jne    126f <litFrequenceCpu+0xdf>
mov    %r15,%rdi
mov    $0x12d,%esi
mov    %rbx,%rdx
call   1090 <fgets@plt>
mov    %r12,%rdi
call   1070 <strlen@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %eax,%edx
call   1040 <strncmp@plt>
test   %eax,%eax
jne    11d0 <litFrequenceCpu+0x40>
mov    %rsp,%rdi
mov    $0x3a,%esi
call   1080 <strrchr@plt>
mov    %rax,%rbp
lea    0x2(%rax),%r15
mov    %r15,%rdi
call   1070 <strlen@plt>
cltq
cmpb   $0xa,0x1(%rax,%rbp,1)
jne    123e <litFrequenceCpu+0xae>
mov    %r15,%rdi
call   1070 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%r15,1)
mov    %r15,%rdi
call   1070 <strlen@plt>
lea    -0x5(%rax),%edx
mov    %rsp,%rbp
mov    %rbp,%rdi
mov    %r15,%rsi
call   1030 <strncpy@plt>
mov    %rbp,%rdi
call   1050 <atof@plt>
movsd  %xmm0,(%r14)
mov    $0x1,%ebp
jmp    1271 <litFrequenceCpu+0xe1>
xor    %ebp,%ebp
jmp    1279 <litFrequenceCpu+0xe9>
xor    %ebp,%ebp
mov    %rbx,%rdi
call   1060 <fclose@plt>
mov    %ebp,%eax
add    $0x130,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [16 x i8] c"cycle frequency\00"
@.str.1 = [20 x i8] c"/tmp/wrekavalid.tmp\00"
@.str.2 = [2 x i8] c"r\00"
define i32 @litFrequenceCpu(double* %0) {
%2 = alloca i32
%3 = alloca double*
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca [301 x i8]
%7 = alloca i8*
%8 = alloca i32
store double* %0, double** %3
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8** %4
store i32 0, i32* %8
%9 = call i32* @fopen(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %9, i32** %5
%10 = load i32*, i32** %5
%11 = icmp ne i32* %10, null
br i1 %11, label %13, label %12
12: ; preds = %1
store i32 0, i32* %2
br label %68
13: ; preds = %1
br label %14
14: ; preds = %63, %13
%15 = load i32*, i32** %5
%16 = call i32 @feof(i32* %15)
%17 = icmp ne i32 %16, 0
%18 = xor i1 %17, true
br i1 %18, label %19, label %64
19: ; preds = %14
%20 = getelementptr inbounds [301 x i8], [301 x i8]* %6, i64 0, i64 0
%21 = load i32*, i32** %5
%22 = call i32 @fgets(i8* %20, i32 301, i32* %21)
%23 = getelementptr inbounds [301 x i8], [301 x i8]* %6, i64 0, i64 0
%24 = load i8*, i8** %4
%25 = load i8*, i8** %4
%26 = call i32 @strlen(i8* %25)
%27 = call i32 @strncmp(i8* %23, i8* %24, i32 %26)
%28 = icmp ne i32 %27, 0
br i1 %28, label %63, label %29
29: ; preds = %19
%30 = getelementptr inbounds [301 x i8], [301 x i8]* %6, i64 0, i64 0
%31 = call i8* @strrchr(i8* %30, i8 signext 58)
%32 = getelementptr inbounds i8, i8* %31, i64 2
store i8* %32, i8** %7
%33 = load i8*, i8** %7
%34 = icmp ne i8* %33, null
br i1 %34, label %36, label %35
35: ; preds = %29
br label %64
36: ; preds = %29
%37 = load i8*, i8** %7
%38 = load i8*, i8** %7
%39 = call i32 @strlen(i8* %38)
%40 = sub nsw i32 %39, 1
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8, i8* %37, i64 %41
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = icmp eq i32 %44, 10
br i1 %45, label %46, label %53
46: ; preds = %36
%47 = load i8*, i8** %7
%48 = load i8*, i8** %7
%49 = call i32 @strlen(i8* %48)
%50 = sub nsw i32 %49, 1
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i8, i8* %47, i64 %51
store i8 0, i8* %52
br label %53
53: ; preds = %46, %36
%54 = getelementptr inbounds [301 x i8], [301 x i8]* %6, i64 0, i64 0
%55 = load i8*, i8** %7
%56 = load i8*, i8** %7
%57 = call i32 @strlen(i8* %56)
%58 = sub nsw i32 %57, 5
%59 = call i32 @strncpy(i8* %54, i8* %55, i32 %58)
%60 = getelementptr inbounds [301 x i8], [301 x i8]* %6, i64 0, i64 0
%61 = call double @atof(i8* %60)
%62 = load double*, double** %3
store double %61, double* %62
store i32 1, i32* %8
br label %64
63: ; preds = %19
br label %14
64: ; preds = %53, %35, %14
%65 = load i32*, i32** %5
%66 = call i32 @fclose(i32* %65)
%67 = load i32, i32* %8
store i32 %67, i32* %2
br label %68
68: ; preds = %64, %12
%69 = load i32, i32* %2
ret i32 %69
}

LLVM IR (-O2):
@.str = [16 x i8] c"cycle frequency\00"
@.str.1 = [20 x i8] c"/tmp/wrekavalid.tmp\00"
@.str.2 = [2 x i8] c"r\00"
define i32 @litFrequenceCpu(double* nocapture writeonly %0) {
%2 = alloca [301 x i8]
%3 = getelementptr inbounds [301 x i8], [301 x i8]* %2, i64 0, i64 0
%4 = tail call i32* @fopen(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %36, label %6
6: ; preds = %1, %9
%7 = call i32 @feof(i32* %4)
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %33
9: ; preds = %6
%10 = call i32 @fgets(i8* %3, i32 301, i32* %4)
%11 = call i32 @strlen(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @strncmp(i8* %3, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %6
14: ; preds = %9
%15 = call i8* @strrchr(i8* %3, i8 signext 58)
%16 = getelementptr inbounds i8, i8* %15, i64 2
%17 = call i32 @strlen(i8* %16)
%18 = add nsw i32 %17, -1
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %16, i64 %19
%21 = load i8, i8* %20
%22 = icmp eq i8 %21, 10
br i1 %22, label %23, label %28
23: ; preds = %14
%24 = call i32 @strlen(i8* %16)
%25 = add nsw i32 %24, -1
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %16, i64 %26
store i8 0, i8* %27
br label %28
28: ; preds = %23, %14
%29 = call i32 @strlen(i8* %16)
%30 = add nsw i32 %29, -5
%31 = call i32 @strncpy(i8* %3, i8* %16, i32 %30)
%32 = call double @atof(i8* %3)
store double %32, double* %0
br label %33
33: ; preds = %6, %28
%34 = phi i32 [ 1, %28 ], [ 0, %6 ]
%35 = call i32 @fclose(i32* %4)
br label %36
36: ; preds = %1, %33
%37 = phi i32 [ %34, %33 ], [ 0, %1 ]
ret i32 %37
}