#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 */
struct timeval {
  scalar_t__ tv_sec;
  scalar_t__ tv_usec;
};

/* Variables and functions */
double DiffTime(struct timeval *heure_depart, struct timeval *heure_fin) {
  double val;
  if (heure_fin->tv_sec != heure_depart->tv_sec) {
    if (heure_fin->tv_usec > heure_depart->tv_usec) {
      val = (double)(heure_fin->tv_sec - heure_depart->tv_sec) +
            ((double)(heure_fin->tv_usec - heure_depart->tv_usec) / 1000000.0);
    } else {
      val = (double)(heure_fin->tv_sec - heure_depart->tv_sec) - 1.0 +
            (double)((double)((1000000.0 - (double)(heure_depart->tv_usec) +
                               (double)(heure_fin->tv_usec)) /
                              1000000.0));
    }
  } else {
    val = (double)(heure_fin->tv_sec - heure_depart->tv_sec) +
          (double)((double)(heure_fin->tv_usec - heure_depart->tv_usec) /
                   1000000.0);
  }
  return (val);
}


x86 assembly (clang, -O0):
<DiffTime>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    -0x8(%rbp),%rcx
cmp    (%rcx),%rax
je     11d5 <DiffTime+0xd5>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    -0x8(%rbp),%rcx
cmp    0x8(%rcx),%rax
jle    1178 <DiffTime+0x78>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    -0x8(%rbp),%rcx
sub    (%rcx),%rax
cvtsi2sd %rax,%xmm0
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    -0x8(%rbp),%rcx
sub    0x8(%rcx),%rax
cvtsi2sd %rax,%xmm1
movsd  0xe9a(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    11d0 <DiffTime+0xd0>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    -0x8(%rbp),%rcx
sub    (%rcx),%rax
cvtsi2sd %rax,%xmm0
movsd  0xe75(%rip),%xmm1
subsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
cvtsi2sdq 0x8(%rax),%xmm2
movsd  0xe57(%rip),%xmm1
subsd  %xmm2,%xmm1
mov    -0x10(%rbp),%rax
cvtsi2sdq 0x8(%rax),%xmm2
addsd  %xmm2,%xmm1
movsd  0xe3d(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    1212 <DiffTime+0x112>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    -0x8(%rbp),%rcx
sub    (%rcx),%rax
cvtsi2sd %rax,%xmm0
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    -0x8(%rbp),%rcx
sub    0x8(%rcx),%rax
cvtsi2sd %rax,%xmm1
movsd  0xdfb(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<DiffTime>:
mov    (%rsi),%rdx
mov    0x8(%rsi),%rax
mov    0x8(%rdi),%rcx
sub    (%rdi),%rdx
jne    1129 <DiffTime+0x29>
sub    %rcx,%rax
cvtsi2sd %rax,%xmm1
divsd  0xee8(%rip),%xmm1
xorpd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
ret
mov    %rax,%rsi
cvtsi2sd %rdx,%xmm0
sub    %rcx,%rsi
jle    1148 <DiffTime+0x48>
cvtsi2sd %rsi,%xmm1
divsd  0xec5(%rip),%xmm1
addsd  %xmm1,%xmm0
ret
movapd %xmm0,%xmm1
addsd  0xeac(%rip),%xmm1
xorps  %xmm0,%xmm0
cvtsi2sd %rcx,%xmm0
movsd  0xea4(%rip),%xmm2
movapd %xmm2,%xmm3
subsd  %xmm0,%xmm3
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  %xmm3,%xmm0
divsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
ret

LLVM IR (-O0):
%struct.timeval = type { i64, i64 }
define double @DiffTime(%struct.timeval* %0, %struct.timeval* %1) {
%3 = alloca %struct.timeval*
%4 = alloca %struct.timeval*
%5 = alloca double
store %struct.timeval* %0, %struct.timeval** %3
store %struct.timeval* %1, %struct.timeval** %4
%6 = load %struct.timeval*, %struct.timeval** %4
%7 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 0
%8 = load i64, i64* %7
%9 = load %struct.timeval*, %struct.timeval** %3
%10 = getelementptr inbounds %struct.timeval, %struct.timeval* %9, i32 0, i32 0
%11 = load i64, i64* %10
%12 = icmp ne i64 %8, %11
br i1 %12, label %13, label %63
13: ; preds = %2
%14 = load %struct.timeval*, %struct.timeval** %4
%15 = getelementptr inbounds %struct.timeval, %struct.timeval* %14, i32 0, i32 1
%16 = load i64, i64* %15
%17 = load %struct.timeval*, %struct.timeval** %3
%18 = getelementptr inbounds %struct.timeval, %struct.timeval* %17, i32 0, i32 1
%19 = load i64, i64* %18
%20 = icmp sgt i64 %16, %19
br i1 %20, label %21, label %40
21: ; preds = %13
%22 = load %struct.timeval*, %struct.timeval** %4
%23 = getelementptr inbounds %struct.timeval, %struct.timeval* %22, i32 0, i32 0
%24 = load i64, i64* %23
%25 = load %struct.timeval*, %struct.timeval** %3
%26 = getelementptr inbounds %struct.timeval, %struct.timeval* %25, i32 0, i32 0
%27 = load i64, i64* %26
%28 = sub nsw i64 %24, %27
%29 = sitofp i64 %28 to double
%30 = load %struct.timeval*, %struct.timeval** %4
%31 = getelementptr inbounds %struct.timeval, %struct.timeval* %30, i32 0, i32 1
%32 = load i64, i64* %31
%33 = load %struct.timeval*, %struct.timeval** %3
%34 = getelementptr inbounds %struct.timeval, %struct.timeval* %33, i32 0, i32 1
%35 = load i64, i64* %34
%36 = sub nsw i64 %32, %35
%37 = sitofp i64 %36 to double
%38 = fdiv double %37, 1.000000e+06
%39 = fadd double %29, %38
store double %39, double* %5
br label %62
40: ; preds = %13
%41 = load %struct.timeval*, %struct.timeval** %4
%42 = getelementptr inbounds %struct.timeval, %struct.timeval* %41, i32 0, i32 0
%43 = load i64, i64* %42
%44 = load %struct.timeval*, %struct.timeval** %3
%45 = getelementptr inbounds %struct.timeval, %struct.timeval* %44, i32 0, i32 0
%46 = load i64, i64* %45
%47 = sub nsw i64 %43, %46
%48 = sitofp i64 %47 to double
%49 = fsub double %48, 1.000000e+00
%50 = load %struct.timeval*, %struct.timeval** %3
%51 = getelementptr inbounds %struct.timeval, %struct.timeval* %50, i32 0, i32 1
%52 = load i64, i64* %51
%53 = sitofp i64 %52 to double
%54 = fsub double 1.000000e+06, %53
%55 = load %struct.timeval*, %struct.timeval** %4
%56 = getelementptr inbounds %struct.timeval, %struct.timeval* %55, i32 0, i32 1
%57 = load i64, i64* %56
%58 = sitofp i64 %57 to double
%59 = fadd double %54, %58
%60 = fdiv double %59, 1.000000e+06
%61 = fadd double %49, %60
store double %61, double* %5
br label %62
62: ; preds = %40, %21
br label %82
63: ; preds = %2
%64 = load %struct.timeval*, %struct.timeval** %4
%65 = getelementptr inbounds %struct.timeval, %struct.timeval* %64, i32 0, i32 0
%66 = load i64, i64* %65
%67 = load %struct.timeval*, %struct.timeval** %3
%68 = getelementptr inbounds %struct.timeval, %struct.timeval* %67, i32 0, i32 0
%69 = load i64, i64* %68
%70 = sub nsw i64 %66, %69
%71 = sitofp i64 %70 to double
%72 = load %struct.timeval*, %struct.timeval** %4
%73 = getelementptr inbounds %struct.timeval, %struct.timeval* %72, i32 0, i32 1
%74 = load i64, i64* %73
%75 = load %struct.timeval*, %struct.timeval** %3
%76 = getelementptr inbounds %struct.timeval, %struct.timeval* %75, i32 0, i32 1
%77 = load i64, i64* %76
%78 = sub nsw i64 %74, %77
%79 = sitofp i64 %78 to double
%80 = fdiv double %79, 1.000000e+06
%81 = fadd double %71, %80
store double %81, double* %5
br label %82
82: ; preds = %63, %62
%83 = load double, double* %5
ret double %83
}

LLVM IR (-O2):
%struct.timeval = type { i64, i64 }
define double @DiffTime(%struct.timeval* nocapture %0, %struct.timeval* nocapture %1) {
%3 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 0
%4 = load i64, i64* %3
%5 = getelementptr inbounds %struct.timeval, %struct.timeval* %0, i64 0, i32 0
%6 = load i64, i64* %5
%7 = icmp eq i64 %4, %6
%8 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 1
%9 = load i64, i64* %8
%10 = getelementptr inbounds %struct.timeval, %struct.timeval* %0, i64 0, i32 1
%11 = load i64, i64* %10
br i1 %7, label %27, label %12
12: ; preds = %2
%13 = icmp sgt i64 %9, %11
%14 = sub nsw i64 %4, %6
%15 = sitofp i64 %14 to double
br i1 %13, label %16, label %20
16: ; preds = %12
%17 = sub nsw i64 %9, %11
%18 = sitofp i64 %17 to double
%19 = fdiv double %18, 1.000000e+06
br label %31
20: ; preds = %12
%21 = fadd double %15, -1.000000e+00
%22 = sitofp i64 %11 to double
%23 = fsub double 1.000000e+06, %22
%24 = sitofp i64 %9 to double
%25 = fadd double %23, %24
%26 = fdiv double %25, 1.000000e+06
br label %31
27: ; preds = %2
%28 = sub nsw i64 %9, %11
%29 = sitofp i64 %28 to double
%30 = fdiv double %29, 1.000000e+06
br label %31
31: ; preds = %16, %20, %27
%32 = phi double [ %15, %16 ], [ %26, %20 ], [ 0.000000e+00, %27 ]
%33 = phi double [ %19, %16 ], [ %21, %20 ], [ %30, %27 ]
%34 = fadd double %33, %32
ret double %34
}