#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_usec;
  scalar_t__ tv_sec;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *, scalar_t__);
void printTimeDiff(FILE *out, const struct timeval *start,
                   const struct timeval *end) {
  struct timeval diff = {.tv_sec = end->tv_sec - start->tv_sec,
                         .tv_usec = end->tv_usec - start->tv_usec};
  fprintf(out, "%s:%ld\n", "wall_time_sec", diff.tv_sec);
  fprintf(out, "%s:%ld\n", "wall_time_usec", diff.tv_usec);
}


x86 assembly (clang, -O0):
<printTimeDiff>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    -0x10(%rbp),%rcx
sub    (%rcx),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rax
mov    -0x10(%rbp),%rcx
sub    0x8(%rcx),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rcx
lea    0xea7(%rip),%rsi
lea    0xea8(%rip),%rdx
call   1030 <fprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rcx
lea    0xe8c(%rip),%rsi
lea    0xe9b(%rip),%rdx
call   1030 <fprintf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printTimeDiff>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
mov    (%rdx),%rbx
mov    0x8(%rdx),%rcx
sub    (%rsi),%rbx
sub    0x8(%rsi),%rcx
lea    0xed3(%rip),%r15
lea    0xed4(%rip),%rdx
mov    %r15,%rsi
call   1030 <fprintf@plt>
lea    0xed3(%rip),%rdx
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rcx
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <fprintf@plt>

LLVM IR (-O0):
%struct.timeval = type { i64, i64 }
@.str = [8 x i8] c"%s:%ld\0A\00"
@.str.1 = [14 x i8] c"wall_time_sec\00"
@.str.2 = [15 x i8] c"wall_time_usec\00"
define void @printTimeDiff(i32* %0, %struct.timeval* %1, %struct.timeval* %2) {
%4 = alloca i32*
%5 = alloca %struct.timeval*
%6 = alloca %struct.timeval*
%7 = alloca %struct.timeval
store i32* %0, i32** %4
store %struct.timeval* %1, %struct.timeval** %5
store %struct.timeval* %2, %struct.timeval** %6
%8 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 0
%9 = load %struct.timeval*, %struct.timeval** %6
%10 = getelementptr inbounds %struct.timeval, %struct.timeval* %9, i32 0, i32 0
%11 = load i64, i64* %10
%12 = load %struct.timeval*, %struct.timeval** %5
%13 = getelementptr inbounds %struct.timeval, %struct.timeval* %12, i32 0, i32 0
%14 = load i64, i64* %13
%15 = sub nsw i64 %11, %14
store i64 %15, i64* %8
%16 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 1
%17 = load %struct.timeval*, %struct.timeval** %6
%18 = getelementptr inbounds %struct.timeval, %struct.timeval* %17, i32 0, i32 1
%19 = load i64, i64* %18
%20 = load %struct.timeval*, %struct.timeval** %5
%21 = getelementptr inbounds %struct.timeval, %struct.timeval* %20, i32 0, i32 1
%22 = load i64, i64* %21
%23 = sub nsw i64 %19, %22
store i64 %23, i64* %16
%24 = load i32*, i32** %4
%25 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 1
%26 = load i64, i64* %25
%27 = call i32 @fprintf(i32* %24, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i64 %26)
%28 = load i32*, i32** %4
%29 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 0
%30 = load i64, i64* %29
%31 = call i32 @fprintf(i32* %28, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i64 %30)
ret void
}

LLVM IR (-O2):
%struct.timeval = type { i64, i64 }
@.str = [8 x i8] c"%s:%ld\0A\00"
@.str.1 = [14 x i8] c"wall_time_sec\00"
@.str.2 = [15 x i8] c"wall_time_usec\00"
define void @printTimeDiff(i32* nocapture %0, %struct.timeval* nocapture %1, %struct.timeval* nocapture %2) {
%4 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 0, i32 0
%5 = load i64, i64* %4
%6 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 0
%7 = load i64, i64* %6
%8 = sub nsw i64 %5, %7
%9 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 0, i32 1
%10 = load i64, i64* %9
%11 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 1
%12 = load i64, i64* %11
%13 = sub nsw i64 %10, %12
%14 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i64 %13)
%15 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i64 %8)
ret void
}