#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 */
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
void evolution(double *Arrivee, double *Depart, double D) {
  int a = 0, d = 0;
  int currentClientNumber = 0;
  unsigned int currentTime = 0;
  FILE *evolFile = fopen("output/evolValue.m", "w");
  fprintf(evolFile, "function [x] = evolValue()\nx = [");
  while ((Arrivee[a] != 0.0 || Depart[d] != 0.0) && currentTime >= D) {
    if (Arrivee[a] > Depart[d]) {
      currentClientNumber--;
      currentTime = Depart[d];
      fprintf(evolFile, " %f %d;", currentTime, currentClientNumber);
      d++;
    } else {
      currentClientNumber++;
      currentTime = Arrivee[a];
      fprintf(evolFile, " %f %d;", currentTime, currentClientNumber);
      a++;
    }
  }
  fprintf(evolFile, "]\nend");
}


x86 assembly (clang, -O0):
<evolution>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
lea    0xea8(%rip),%rdi
lea    0xeb4(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
lea    0xea2(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11c4 <evolution+0xa4>
jp     11c4 <evolution+0xa4>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
xor    %eax,%eax
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
mov    %al,-0x31(%rbp)
jne    11c4 <evolution+0xa4>
jp     11c4 <evolution+0xa4>
jmp    11d7 <evolution+0xb7>
mov    -0x28(%rbp),%eax
cvtsi2sd %rax,%xmm0
ucomisd -0x18(%rbp),%xmm0
setae  %al
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%al
test   $0x1,%al
jne    11e7 <evolution+0xc7>
jmp    1287 <evolution+0x167>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
ucomisd (%rax,%rcx,8),%xmm0
jbe    1247 <evolution+0x127>
mov    -0x24(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
cvttsd2si (%rax,%rcx,8),%rax
mov    %eax,-0x28(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%edx
mov    -0x24(%rbp),%ecx
lea    0xe04(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1282 <evolution+0x162>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
cvttsd2si (%rax,%rcx,8),%rax
mov    %eax,-0x28(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%edx
mov    -0x24(%rbp),%ecx
lea    0xdc4(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    117a <evolution+0x5a>
mov    -0x30(%rbp),%rdi
lea    0xdac(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<evolution>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movsd  %xmm0,0x10(%rsp)
mov    %rsi,0x8(%rsp)
mov    %rdi,%r15
lea    0xeb5(%rip),%rdi
lea    0xec1(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,%r13
lea    0xeb4(%rip),%rdi
mov    $0x20,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   1050 <fwrite@plt>
xor    %eax,%eax
xor    %ebx,%ebx
xor    %ebp,%ebp
xor    %r12d,%r12d
mov    %eax,%r14d
add    $0xffffffff,%ebx
movslq %r12d,%r12
nopl   (%rax)
movsd  (%r15,%r12,8),%xmm0
ucomisd 0xe62(%rip),%xmm0
mov    %ebp,%eax
xorps  %xmm1,%xmm1
cvtsi2sd %rax,%xmm1
jne    11ac <evolution+0x7c>
jnp    11d0 <evolution+0xa0>
ucomisd 0x10(%rsp),%xmm1
jb     1243 <evolution+0x113>
mov    0x8(%rsp),%rax
movsd  (%rax,%r14,8),%xmm1
jmp    11ef <evolution+0xbf>
cs nopw 0x0(%rax,%rax,1)
nop
ucomisd 0x10(%rsp),%xmm1
jb     1243 <evolution+0x113>
mov    0x8(%rsp),%rax
movsd  (%rax,%r14,8),%xmm1
ucomisd 0xe15(%rip),%xmm1
jne    11ef <evolution+0xbf>
jnp    1243 <evolution+0x113>
ucomisd %xmm1,%xmm0
ja     1220 <evolution+0xf0>
lea    0x2(%rbx),%ecx
cvttsd2si %xmm0,%rbp
mov    %r13,%rdi
lea    0xe37(%rip),%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1030 <fprintf@plt>
add    $0x1,%ebx
add    $0x1,%r12
jmp    1190 <evolution+0x60>
nopl   0x0(%rax)
cvttsd2si %xmm1,%rbp
mov    %r13,%rdi
lea    0xe0f(%rip),%rsi
mov    %ebp,%edx
mov    %ebx,%ecx
xor    %eax,%eax
call   1030 <fprintf@plt>
lea    0x1(%r14),%eax
jmp    1184 <evolution+0x54>
lea    0xdfc(%rip),%rdi
mov    $0x5,%esi
mov    $0x1,%edx
mov    %r13,%rcx
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <fwrite@plt>

LLVM IR (-O0):
@.str = [19 x i8] c"output/evolValue.m\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [33 x i8] c"function [x] = evolValue()\0Ax = [\00"
@.str.3 = [8 x i8] c" %f %d;\00"
@.str.4 = [6 x i8] c"]\0Aend\00"
define void @evolution(double* %0, double* %1, double %2) {
%4 = alloca double*
%5 = alloca double*
%6 = alloca double
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32*
store double* %0, double** %4
store double* %1, double** %5
store double %2, double* %6
store i32 0, i32* %7
store i32 0, i32* %8
store i32 0, i32* %9
store i32 0, i32* %10
%12 = 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* %12, i32** %11
%13 = load i32*, i32** %11
%14 = call i32 (i32*, i8*, ...) @fprintf(i32* %13, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
br label %15
15: ; preds = %78, %3
%16 = load double*, double** %4
%17 = load i32, i32* %7
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds double, double* %16, i64 %18
%20 = load double, double* %19
%21 = fcmp une double %20, 0.000000e+00
br i1 %21, label %29, label %22
22: ; preds = %15
%23 = load double*, double** %5
%24 = load i32, i32* %8
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds double, double* %23, i64 %25
%27 = load double, double* %26
%28 = fcmp une double %27, 0.000000e+00
br i1 %28, label %29, label %34
29: ; preds = %22, %15
%30 = load i32, i32* %10
%31 = uitofp i32 %30 to double
%32 = load double, double* %6
%33 = fcmp oge double %31, %32
br label %34
34: ; preds = %29, %22
%35 = phi i1 [ false, %22 ], [ %33, %29 ]
br i1 %35, label %36, label %79
36: ; preds = %34
%37 = load double*, double** %4
%38 = load i32, i32* %7
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds double, double* %37, i64 %39
%41 = load double, double* %40
%42 = load double*, double** %5
%43 = load i32, i32* %8
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds double, double* %42, i64 %44
%46 = load double, double* %45
%47 = fcmp ogt double %41, %46
br i1 %47, label %48, label %63
48: ; preds = %36
%49 = load i32, i32* %9
%50 = add nsw i32 %49, -1
store i32 %50, i32* %9
%51 = load double*, double** %5
%52 = load i32, i32* %8
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds double, double* %51, i64 %53
%55 = load double, double* %54
%56 = fptoui double %55 to i32
store i32 %56, i32* %10
%57 = load i32*, i32** %11
%58 = load i32, i32* %10
%59 = load i32, i32* %9
%60 = call i32 (i32*, i8*, ...) @fprintf(i32* %57, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %58, i32 %59)
%61 = load i32, i32* %8
%62 = add nsw i32 %61, 1
store i32 %62, i32* %8
br label %78
63: ; preds = %36
%64 = load i32, i32* %9
%65 = add nsw i32 %64, 1
store i32 %65, i32* %9
%66 = load double*, double** %4
%67 = load i32, i32* %7
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds double, double* %66, i64 %68
%70 = load double, double* %69
%71 = fptoui double %70 to i32
store i32 %71, i32* %10
%72 = load i32*, i32** %11
%73 = load i32, i32* %10
%74 = load i32, i32* %9
%75 = call i32 (i32*, i8*, ...) @fprintf(i32* %72, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %73, i32 %74)
%76 = load i32, i32* %7
%77 = add nsw i32 %76, 1
store i32 %77, i32* %7
br label %78
78: ; preds = %63, %48
br label %15
79: ; preds = %34
%80 = load i32*, i32** %11
%81 = call i32 (i32*, i8*, ...) @fprintf(i32* %80, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [19 x i8] c"output/evolValue.m\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [33 x i8] c"function [x] = evolValue()\0Ax = [\00"
@.str.3 = [8 x i8] c" %f %d;\00"
@.str.4 = [6 x i8] c"]\0Aend\00"
define void @evolution(double* nocapture %0, double* nocapture %1, double %2) {
%4 = 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))
%5 = tail call i64 @fwrite(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i64 32, i64 1, i32* %4)
br label %6
6: ; preds = %37, %3
%7 = phi i32 [ %41, %37 ], [ 0, %3 ]
%8 = phi i32 [ %38, %37 ], [ 0, %3 ]
%9 = phi i32 [ %39, %37 ], [ 0, %3 ]
%10 = phi i32 [ %18, %37 ], [ 0, %3 ]
%11 = zext i32 %7 to i64
%12 = getelementptr inbounds double, double* %1, i64 %11
%13 = zext i32 %7 to i64
%14 = getelementptr inbounds double, double* %1, i64 %13
br label %15
15: ; preds = %6, %42
%16 = phi i32 [ %43, %42 ], [ %8, %6 ]
%17 = phi i32 [ %44, %42 ], [ %9, %6 ]
%18 = phi i32 [ %46, %42 ], [ %10, %6 ]
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds double, double* %0, i64 %19
%21 = load double, double* %20
%22 = fcmp une double %21, 0.000000e+00
br i1 %22, label %29, label %23
23: ; preds = %15
%24 = load double, double* %12
%25 = fcmp oeq double %24, 0.000000e+00
%26 = uitofp i32 %17 to double
%27 = fcmp ult double %26, %2
%28 = or i1 %27, %25
br i1 %28, label %47, label %34
29: ; preds = %15
%30 = uitofp i32 %17 to double
%31 = fcmp ult double %30, %2
br i1 %31, label %47, label %32
32: ; preds = %29
%33 = load double, double* %14
br label %34
34: ; preds = %32, %23
%35 = phi double [ %33, %32 ], [ %24, %23 ]
%36 = fcmp ogt double %21, %35
br i1 %36, label %37, label %42
37: ; preds = %34
%38 = add nsw i32 %16, -1
%39 = fptoui double %35 to i32
%40 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %4, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %39, i32 %38)
%41 = add nuw nsw i32 %7, 1
br label %6
42: ; preds = %34
%43 = add nsw i32 %16, 1
%44 = fptoui double %21 to i32
%45 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %4, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %44, i32 %43)
%46 = add nsw i32 %18, 1
br label %15
47: ; preds = %23, %29
%48 = tail call i64 @fwrite(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i64 5, i64 1, i32* %4)
ret void
}