#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 */
int atol(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 litBandwidthMes(int *iBandwidth) {
  FILE *fFile;
  char ligne[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);
    pos = strstr(ligne, "MBytes ");
    if (!pos)
      break;
    pos2 = strrchr(pos, ' ');
    if (!pos2)
      break;
    pos2[0] = '\0';
    strcpy(ligne, pos + strlen("Mbits "));
    *iBandwidth = atol(ligne);
    ok = 1;
    break;
  }
  fclose(fFile);
  return ok;
}


x86 assembly (clang, -O0):
<litBandwidthMes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x180,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x164(%rbp)
lea    0xe50(%rip),%rdi
lea    0xe5b(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11d7 <litBandwidthMes+0x47>
movl   $0x0,-0x4(%rbp)
jmp    12e1 <litBandwidthMes+0x151>
jmp    11dc <litBandwidthMes+0x4c>
mov    -0x18(%rbp),%rdi
call   1080 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11fa <litBandwidthMes+0x6a>
jmp    12cf <litBandwidthMes+0x13f>
lea    -0x150(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x12d,%esi
call   1070 <fgets@plt>
lea    -0x150(%rbp),%rdi
lea    0xdf7(%rip),%rsi
call   10b0 <strstr@plt>
mov    %rax,-0x158(%rbp)
cmpq   $0x0,-0x158(%rbp)
jne    123c <litBandwidthMes+0xac>
jmp    12cf <litBandwidthMes+0x13f>
mov    -0x158(%rbp),%rdi
mov    $0x20,%esi
call   1060 <strrchr@plt>
mov    %rax,-0x160(%rbp)
cmpq   $0x0,-0x160(%rbp)
jne    1267 <litBandwidthMes+0xd7>
jmp    12cf <litBandwidthMes+0x13f>
mov    -0x160(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x150(%rbp),%rax
mov    %rax,-0x170(%rbp)
mov    -0x158(%rbp),%rax
mov    %rax,-0x178(%rbp)
lea    0xd88(%rip),%rdi
call   1050 <strlen@plt>
mov    -0x178(%rbp),%rsi
mov    -0x170(%rbp),%rdi
cltq
add    %rax,%rsi
call   1030 <strcpy@plt>
lea    -0x150(%rbp),%rdi
call   1090 <atol@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x1,-0x164(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x164(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x180,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<litBandwidthMes>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x138,%rsp
mov    %rdi,%r14
lea    0xe59(%rip),%rdi
lea    0xe64(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     1245 <litBandwidthMes+0xb5>
mov    %rax,%rbx
mov    %rax,%rdi
call   1080 <feof@plt>
xor    %ebp,%ebp
test   %eax,%eax
jne    123b <litBandwidthMes+0xab>
mov    %rsp,%r15
mov    %r15,%rdi
mov    $0x12d,%esi
mov    %rbx,%rdx
call   1070 <fgets@plt>
lea    0xe2d(%rip),%rsi
mov    %r15,%rdi
call   10b0 <strstr@plt>
test   %rax,%rax
je     123b <litBandwidthMes+0xab>
mov    %rax,%r15
mov    %rax,%rdi
mov    $0x20,%esi
call   1060 <strrchr@plt>
test   %rax,%rax
je     123b <litBandwidthMes+0xab>
movb   $0x0,(%rax)
lea    0xe09(%rip),%rdi
call   1050 <strlen@plt>
cltq
add    %rax,%r15
mov    %rsp,%rbp
mov    %rbp,%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
mov    %rbp,%rdi
call   1090 <atol@plt>
mov    %eax,(%r14)
mov    $0x1,%ebp
mov    %rbx,%rdi
call   1040 <fclose@plt>
jmp    1247 <litBandwidthMes+0xb7>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x138,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [18 x i8] c"/tmp/wrekames.tmp\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [8 x i8] c"MBytes \00"
@.str.3 = [7 x i8] c"Mbits \00"
define i32 @litBandwidthMes(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca [301 x i8]
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
store i32* %0, i32** %3
store i32 0, i32* %8
%9 = 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* %9, i32** %4
%10 = load i32*, i32** %4
%11 = icmp ne i32* %10, null
br i1 %11, label %13, label %12
12: ; preds = %1
store i32 0, i32* %2
br label %50
13: ; preds = %1
br label %14
14: ; preds = %13
%15 = load i32*, i32** %4
%16 = call i32 @feof(i32* %15)
%17 = icmp ne i32 %16, 0
%18 = xor i1 %17, true
br i1 %18, label %19, label %46
19: ; preds = %14
%20 = getelementptr inbounds [301 x i8], [301 x i8]* %5, i64 0, i64 0
%21 = load i32*, i32** %4
%22 = call i32 @fgets(i8* %20, i32 301, i32* %21)
%23 = getelementptr inbounds [301 x i8], [301 x i8]* %5, i64 0, i64 0
%24 = call i8* @strstr(i8* %23, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
store i8* %24, i8** %6
%25 = load i8*, i8** %6
%26 = icmp ne i8* %25, null
br i1 %26, label %28, label %27
27: ; preds = %19
br label %46
28: ; preds = %19
%29 = load i8*, i8** %6
%30 = call i8* @strrchr(i8* %29, i8 signext 32)
store i8* %30, i8** %7
%31 = load i8*, i8** %7
%32 = icmp ne i8* %31, null
br i1 %32, label %34, label %33
33: ; preds = %28
br label %46
34: ; preds = %28
%35 = load i8*, i8** %7
%36 = getelementptr inbounds i8, i8* %35, i64 0
store i8 0, i8* %36
%37 = getelementptr inbounds [301 x i8], [301 x i8]* %5, i64 0, i64 0
%38 = load i8*, i8** %6
%39 = call i32 @strlen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8, i8* %38, i64 %40
%42 = call i32 @strcpy(i8* %37, i8* %41)
%43 = getelementptr inbounds [301 x i8], [301 x i8]* %5, i64 0, i64 0
%44 = call i32 @atol(i8* %43)
%45 = load i32*, i32** %3
store i32 %44, i32* %45
store i32 1, i32* %8
br label %46
46: ; preds = %34, %33, %27, %14
%47 = load i32*, i32** %4
%48 = call i32 @fclose(i32* %47)
%49 = load i32, i32* %8
store i32 %49, i32* %2
br label %50
50: ; preds = %46, %12
%51 = load i32, i32* %2
ret i32 %51
}

LLVM IR (-O2):
@.str = [18 x i8] c"/tmp/wrekames.tmp\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [8 x i8] c"MBytes \00"
@.str.3 = [7 x i8] c"Mbits \00"
define i32 @litBandwidthMes(i32* 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 ([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))
%5 = icmp eq i32* %4, null
br i1 %5, label %25, label %6
6: ; preds = %1
%7 = tail call i32 @feof(i32* %4)
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %22
9: ; preds = %6
%10 = call i32 @fgets(i8* %3, i32 301, i32* %4)
%11 = call i8* @strstr(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%12 = icmp eq i8* %11, null
br i1 %12, label %22, label %13
13: ; preds = %9
%14 = call i8* @strrchr(i8* %11, i8 signext 32)
%15 = icmp eq i8* %14, null
br i1 %15, label %22, label %16
16: ; preds = %13
store i8 0, i8* %14
%17 = call i32 @strlen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %11, i64 %18
%20 = call i32 @strcpy(i8* %3, i8* %19)
%21 = call i32 @atol(i8* %3)
store i32 %21, i32* %0
br label %22
22: ; preds = %13, %9, %16, %6
%23 = phi i32 [ 1, %16 ], [ 0, %13 ], [ 0, %9 ], [ 0, %6 ]
%24 = call i32 @fclose(i32* %4)
br label %25
25: ; preds = %1, %22
%26 = phi i32 [ %23, %22 ], [ 0, %1 ]
ret i32 %26
}