#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 */
typedef struct TYPE_4__ TYPE_2__;
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
struct TYPE_3__ {
  int tv_sec;
  double tv_usec;
};
struct TYPE_4__ {
  int tv_sec;
  double tv_usec;
};
struct rusage {
  TYPE_1__ ru_stime;
  TYPE_2__ ru_utime;
};

/* Variables and functions */
double calculate(const struct rusage *b, const struct rusage *a) {
  if (b == NULL || a == NULL)
    return 0;
  else
    return ((((a->ru_utime.tv_sec * 1000000 + a->ru_utime.tv_usec) -
              (b->ru_utime.tv_sec * 1000000 + b->ru_utime.tv_usec)) +
             ((a->ru_stime.tv_sec * 1000000 + a->ru_stime.tv_usec) -
              (b->ru_stime.tv_sec * 1000000 + b->ru_stime.tv_usec))) /
            1000000.0);
}


x86 assembly (clang, -O0):
<calculate>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1122 <calculate+0x22>
cmpq   $0x0,-0x18(%rbp)
jne    112f <calculate+0x2f>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11aa <calculate+0xaa>
mov    -0x18(%rbp),%rax
imul   $0xf4240,0x10(%rax),%eax
cvtsi2sd %eax,%xmm0
mov    -0x18(%rbp),%rax
addsd  0x18(%rax),%xmm0
mov    -0x10(%rbp),%rax
imul   $0xf4240,0x10(%rax),%eax
cvtsi2sd %eax,%xmm1
mov    -0x10(%rbp),%rax
addsd  0x18(%rax),%xmm1
subsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
imul   $0xf4240,(%rax),%eax
cvtsi2sd %eax,%xmm1
mov    -0x18(%rbp),%rax
addsd  0x8(%rax),%xmm1
mov    -0x10(%rbp),%rax
imul   $0xf4240,(%rax),%eax
cvtsi2sd %eax,%xmm2
mov    -0x10(%rbp),%rax
addsd  0x8(%rax),%xmm2
subsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  0xe5f(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<calculate>:
xorpd  %xmm0,%xmm0
test   %rdi,%rdi
je     1166 <calculate+0x66>
test   %rsi,%rsi
je     1166 <calculate+0x66>
imul   $0xf4240,0x10(%rsi),%eax
cvtsi2sd %eax,%xmm1
addsd  0x18(%rsi),%xmm1
imul   $0xf4240,0x10(%rdi),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
addsd  0x18(%rdi),%xmm0
subsd  %xmm0,%xmm1
imul   $0xf4240,(%rsi),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
addsd  0x8(%rsi),%xmm0
imul   $0xf4240,(%rdi),%eax
cvtsi2sd %eax,%xmm2
addsd  0x8(%rdi),%xmm2
subsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
divsd  0xe9a(%rip),%xmm0
ret

LLVM IR (-O0):
%struct.rusage = type { %struct.TYPE_3__, %struct.TYPE_4__ }
%struct.TYPE_3__ = type { i32, double }
%struct.TYPE_4__ = type { i32, double }
define double @calculate(%struct.rusage* %0, %struct.rusage* %1) {
%3 = alloca double
%4 = alloca %struct.rusage*
%5 = alloca %struct.rusage*
store %struct.rusage* %0, %struct.rusage** %4
store %struct.rusage* %1, %struct.rusage** %5
%6 = load %struct.rusage*, %struct.rusage** %4
%7 = icmp eq %struct.rusage* %6, null
br i1 %7, label %11, label %8
8: ; preds = %2
%9 = load %struct.rusage*, %struct.rusage** %5
%10 = icmp eq %struct.rusage* %9, null
br i1 %10, label %11, label %12
11: ; preds = %8, %2
store double 0.000000e+00, double* %3
br label %61
12: ; preds = %8
%13 = load %struct.rusage*, %struct.rusage** %5
%14 = getelementptr inbounds %struct.rusage, %struct.rusage* %13, i32 0, i32 1
%15 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %14, i32 0, i32 0
%16 = load i32, i32* %15
%17 = mul nsw i32 %16, 1000000
%18 = sitofp i32 %17 to double
%19 = load %struct.rusage*, %struct.rusage** %5
%20 = getelementptr inbounds %struct.rusage, %struct.rusage* %19, i32 0, i32 1
%21 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %20, i32 0, i32 1
%22 = load double, double* %21
%23 = fadd double %18, %22
%24 = load %struct.rusage*, %struct.rusage** %4
%25 = getelementptr inbounds %struct.rusage, %struct.rusage* %24, i32 0, i32 1
%26 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %25, i32 0, i32 0
%27 = load i32, i32* %26
%28 = mul nsw i32 %27, 1000000
%29 = sitofp i32 %28 to double
%30 = load %struct.rusage*, %struct.rusage** %4
%31 = getelementptr inbounds %struct.rusage, %struct.rusage* %30, i32 0, i32 1
%32 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %31, i32 0, i32 1
%33 = load double, double* %32
%34 = fadd double %29, %33
%35 = fsub double %23, %34
%36 = load %struct.rusage*, %struct.rusage** %5
%37 = getelementptr inbounds %struct.rusage, %struct.rusage* %36, i32 0, i32 0
%38 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %37, i32 0, i32 0
%39 = load i32, i32* %38
%40 = mul nsw i32 %39, 1000000
%41 = sitofp i32 %40 to double
%42 = load %struct.rusage*, %struct.rusage** %5
%43 = getelementptr inbounds %struct.rusage, %struct.rusage* %42, i32 0, i32 0
%44 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %43, i32 0, i32 1
%45 = load double, double* %44
%46 = fadd double %41, %45
%47 = load %struct.rusage*, %struct.rusage** %4
%48 = getelementptr inbounds %struct.rusage, %struct.rusage* %47, i32 0, i32 0
%49 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %48, i32 0, i32 0
%50 = load i32, i32* %49
%51 = mul nsw i32 %50, 1000000
%52 = sitofp i32 %51 to double
%53 = load %struct.rusage*, %struct.rusage** %4
%54 = getelementptr inbounds %struct.rusage, %struct.rusage* %53, i32 0, i32 0
%55 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %54, i32 0, i32 1
%56 = load double, double* %55
%57 = fadd double %52, %56
%58 = fsub double %46, %57
%59 = fadd double %35, %58
%60 = fdiv double %59, 1.000000e+06
store double %60, double* %3
br label %61
61: ; preds = %12, %11
%62 = load double, double* %3
ret double %62
}

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