#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 /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
char *strrchr(char *, char);
char *strstr(char *, char *);
int litCpuMes(double *dTps, double *dCycle) {
  FILE *fFile;
  char ligne[300 + 1], ligne2[300 + 1];
  char *pos, *pos2;
  int ok = 0;
  fFile = fopen("/tmp/wrekames.tmp", "r");
  if (!fFile) {
    return 0;
  }
  while (!feof(fFile)) {
    fgets(ligne, sizeof(ligne), fFile);
    strcpy(ligne2, ligne);
    pos = strstr(ligne2, "temps ");
    if (!pos)
      break;
    pos2 = strrchr(pos, ' ');
    if (!pos2)
      break;
    pos2[0] = '\0';
    strcpy(ligne2, pos + strlen("temps "));
    *dTps = atof(ligne2);
    pos = strstr(ligne, "clock ");
    if (!pos)
      break;
    strcpy(ligne2, pos + strlen("clock "));
    *dCycle = atof(ligne2);
    ok = 1;
    break;
  }
  fclose(fFile);
  return ok;
}


x86 assembly (clang, -O0):
<litCpuMes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2c0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x294(%rbp)
lea    0xe4c(%rip),%rdi
lea    0xe57(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11db <litCpuMes+0x4b>
movl   $0x0,-0x4(%rbp)
jmp    1379 <litCpuMes+0x1e9>
jmp    11e0 <litCpuMes+0x50>
mov    -0x20(%rbp),%rdi
call   1090 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11fe <litCpuMes+0x6e>
jmp    1367 <litCpuMes+0x1d7>
lea    -0x150(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    $0x12d,%esi
call   1080 <fgets@plt>
lea    -0x280(%rbp),%rdi
lea    -0x150(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x280(%rbp),%rdi
lea    0xde0(%rip),%rsi
call   10b0 <strstr@plt>
mov    %rax,-0x288(%rbp)
cmpq   $0x0,-0x288(%rbp)
jne    1253 <litCpuMes+0xc3>
jmp    1367 <litCpuMes+0x1d7>
mov    -0x288(%rbp),%rdi
mov    $0x20,%esi
call   1070 <strrchr@plt>
mov    %rax,-0x290(%rbp)
cmpq   $0x0,-0x290(%rbp)
jne    127e <litCpuMes+0xee>
jmp    1367 <litCpuMes+0x1d7>
mov    -0x290(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x280(%rbp),%rax
mov    %rax,-0x2a0(%rbp)
mov    -0x288(%rbp),%rax
mov    %rax,-0x2a8(%rbp)
lea    0xd69(%rip),%rdi
call   1060 <strlen@plt>
mov    -0x2a8(%rbp),%rsi
mov    -0x2a0(%rbp),%rdi
cltq
add    %rax,%rsi
call   1030 <strcpy@plt>
lea    -0x280(%rbp),%rdi
call   1040 <atof@plt>
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
lea    -0x150(%rbp),%rdi
lea    0xd31(%rip),%rsi
call   10b0 <strstr@plt>
mov    %rax,-0x288(%rbp)
cmpq   $0x0,-0x288(%rbp)
jne    1309 <litCpuMes+0x179>
jmp    1367 <litCpuMes+0x1d7>
lea    -0x280(%rbp),%rax
mov    %rax,-0x2b0(%rbp)
mov    -0x288(%rbp),%rax
mov    %rax,-0x2b8(%rbp)
lea    0xcef(%rip),%rdi
call   1060 <strlen@plt>
mov    -0x2b8(%rbp),%rsi
mov    -0x2b0(%rbp),%rdi
cltq
add    %rax,%rsi
call   1030 <strcpy@plt>
lea    -0x280(%rbp),%rdi
call   1040 <atof@plt>
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
movl   $0x1,-0x294(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x294(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x2c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<litCpuMes>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x268,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
lea    0xe52(%rip),%rdi
lea    0xe5d(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     11da <litCpuMes+0x4a>
mov    %rax,%rbx
mov    %rax,%rdi
call   1090 <feof@plt>
xor    %ebp,%ebp
test   %eax,%eax
je     11f0 <litCpuMes+0x60>
mov    %rbx,%rdi
call   1050 <fclose@plt>
jmp    11dc <litCpuMes+0x4c>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x268,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x130(%rsp),%r12
mov    %r12,%rdi
mov    $0x12d,%esi
mov    %rbx,%rdx
call   1080 <fgets@plt>
mov    %rsp,%r13
mov    %r13,%rdi
mov    %r12,%rsi
call   1030 <strcpy@plt>
lea    0xdf7(%rip),%rsi
mov    %r13,%rdi
call   10b0 <strstr@plt>
test   %rax,%rax
je     11d0 <litCpuMes+0x40>
mov    %rax,%r12
mov    %rax,%rdi
mov    $0x20,%esi
call   1070 <strrchr@plt>
test   %rax,%rax
je     11d0 <litCpuMes+0x40>
movb   $0x0,(%rax)
lea    0xdcb(%rip),%rdi
call   1060 <strlen@plt>
cltq
add    %rax,%r12
mov    %rsp,%r13
mov    %r13,%rdi
mov    %r12,%rsi
call   1030 <strcpy@plt>
mov    %r13,%rdi
call   1040 <atof@plt>
movsd  %xmm0,(%r15)
lea    0xda6(%rip),%rsi
lea    0x130(%rsp),%rdi
call   10b0 <strstr@plt>
test   %rax,%rax
je     11d0 <litCpuMes+0x40>
mov    %rax,%r15
lea    0xd86(%rip),%rdi
call   1060 <strlen@plt>
cltq
add    %rax,%r15
mov    %rsp,%rbp
mov    %rbp,%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
mov    %rbp,%rdi
call   1040 <atof@plt>
movsd  %xmm0,(%r14)
mov    $0x1,%ebp
jmp    11d0 <litCpuMes+0x40>

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

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