#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 {
  int tv_sec;
};

/* Variables and functions */
int /*<<< orphan*/ snprintf(char *, int, char *, int, int, int);
void get_elapsed_time(struct timeval *t_end, struct timeval *t_start,
                      char *buf) {
  int hour, min, sec = 0;
  hour = ((t_end->tv_sec - t_start->tv_sec) / 3600);
  min = (((t_end->tv_sec - t_start->tv_sec) / 60) - (hour * 60));
  sec = ((t_end->tv_sec - t_start->tv_sec) - (hour * 3600) - (min * 60));
  snprintf(buf, 10, "%02d:%02d:%02d", hour, min, sec);
}


x86 assembly (clang, -O0):
<get_elapsed_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    -0x10(%rbp),%rcx
sub    (%rcx),%eax
mov    $0xe10,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    -0x10(%rbp),%rcx
sub    (%rcx),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
imul   $0x3c,-0x1c(%rbp),%ecx
sub    %ecx,%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    -0x10(%rbp),%rcx
sub    (%rcx),%eax
imul   $0xe10,-0x1c(%rbp),%ecx
sub    %ecx,%eax
imul   $0x3c,-0x20(%rbp),%ecx
sub    %ecx,%eax
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%ecx
mov    -0x20(%rbp),%r8d
mov    -0x24(%rbp),%r9d
mov    $0xa,%esi
lea    0xe68(%rip),%rdx
call   1030 <snprintf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_elapsed_time>:
mov    %rdx,%rax
mov    (%rdi),%ecx
sub    (%rsi),%ecx
movslq %ecx,%rdx
imul   $0xffffffff91a2b3c5,%rdx,%rcx
shr    $0x20,%rcx
add    %edx,%ecx
mov    %ecx,%esi
shr    $0x1f,%esi
sar    $0xb,%ecx
add    %esi,%ecx
imul   $0xffffffff88888889,%rdx,%rsi
shr    $0x20,%rsi
add    %edx,%esi
mov    %esi,%edi
shr    $0x1f,%edi
sar    $0x5,%esi
add    %edi,%esi
imul   $0xffffffc4,%ecx,%r8d
add    %esi,%r8d
imul   $0xfffff1f0,%ecx,%esi
add    %edx,%esi
imul   $0xffffffc4,%r8d,%r9d
add    %esi,%r9d
lea    0xe9b(%rip),%rdx
mov    %rax,%rdi
mov    $0xa,%esi
jmp    1030 <snprintf@plt>

LLVM IR (-O0):
%struct.timeval = type { i32 }
@.str = [15 x i8] c"%02d:%02d:%02d\00"
define void @get_elapsed_time(%struct.timeval* %0, %struct.timeval* %1, i8* %2) {
%4 = alloca %struct.timeval*
%5 = alloca %struct.timeval*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store %struct.timeval* %0, %struct.timeval** %4
store %struct.timeval* %1, %struct.timeval** %5
store i8* %2, i8** %6
store i32 0, i32* %9
%10 = load %struct.timeval*, %struct.timeval** %4
%11 = getelementptr inbounds %struct.timeval, %struct.timeval* %10, i32 0, i32 0
%12 = load i32, i32* %11
%13 = load %struct.timeval*, %struct.timeval** %5
%14 = getelementptr inbounds %struct.timeval, %struct.timeval* %13, i32 0, i32 0
%15 = load i32, i32* %14
%16 = sub nsw i32 %12, %15
%17 = sdiv i32 %16, 3600
store i32 %17, i32* %7
%18 = load %struct.timeval*, %struct.timeval** %4
%19 = getelementptr inbounds %struct.timeval, %struct.timeval* %18, i32 0, i32 0
%20 = load i32, i32* %19
%21 = load %struct.timeval*, %struct.timeval** %5
%22 = getelementptr inbounds %struct.timeval, %struct.timeval* %21, i32 0, i32 0
%23 = load i32, i32* %22
%24 = sub nsw i32 %20, %23
%25 = sdiv i32 %24, 60
%26 = load i32, i32* %7
%27 = mul nsw i32 %26, 60
%28 = sub nsw i32 %25, %27
store i32 %28, i32* %8
%29 = load %struct.timeval*, %struct.timeval** %4
%30 = getelementptr inbounds %struct.timeval, %struct.timeval* %29, i32 0, i32 0
%31 = load i32, i32* %30
%32 = load %struct.timeval*, %struct.timeval** %5
%33 = getelementptr inbounds %struct.timeval, %struct.timeval* %32, i32 0, i32 0
%34 = load i32, i32* %33
%35 = sub nsw i32 %31, %34
%36 = load i32, i32* %7
%37 = mul nsw i32 %36, 3600
%38 = sub nsw i32 %35, %37
%39 = load i32, i32* %8
%40 = mul nsw i32 %39, 60
%41 = sub nsw i32 %38, %40
store i32 %41, i32* %9
%42 = load i8*, i8** %6
%43 = load i32, i32* %7
%44 = load i32, i32* %8
%45 = load i32, i32* %9
%46 = call i32 @snprintf(i8* %42, i32 10, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %43, i32 %44, i32 %45)
ret void
}

LLVM IR (-O2):
%struct.timeval = type { i32 }
@.str = [15 x i8] c"%02d:%02d:%02d\00"
define void @get_elapsed_time(%struct.timeval* nocapture %0, %struct.timeval* nocapture %1, i8* %2) {
%4 = getelementptr inbounds %struct.timeval, %struct.timeval* %0, i64 0, i32 0
%5 = load i32, i32* %4
%6 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 0
%7 = load i32, i32* %6
%8 = sub nsw i32 %5, %7
%9 = sdiv i32 %8, 3600
%10 = sdiv i32 %8, 60
%11 = mul nsw i32 %9, -60
%12 = add nsw i32 %11, %10
%13 = mul nsw i32 %9, -3600
%14 = add i32 %13, %8
%15 = mul i32 %12, -60
%16 = add i32 %14, %15
%17 = tail call i32 @snprintf(i8* %2, i32 10, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %9, i32 %12, i32 %16)
ret void
}