#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 time_t;

/* Variables and functions */
void util_get_time_diff(time_t time1, time_t time2, time_t *total_seconds,
                        int *days, int *hours, int *minutes, int *seconds) {
  time_t diff;
  diff = time2 - time1;
  if (total_seconds)
    *total_seconds = diff;
  if (days)
    *days = diff / (60 * 60 * 24);
  if (hours)
    *hours = (diff % (60 * 60 * 24)) / (60 * 60);
  if (minutes)
    *minutes = ((diff % (60 * 60 * 24)) % (60 * 60)) / 60;
  if (seconds)
    *seconds = ((diff % (60 * 60 * 24)) % (60 * 60)) % 60;
}


x86 assembly (clang, -O0):
<util_get_time_diff>:
push   %rbp
mov    %rsp,%rbp
mov    0x10(%rbp),%rax
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    %r9,-0x28(%rbp)
mov    -0x8(%rbp),%eax
sub    -0x4(%rbp),%eax
mov    %eax,-0x2c(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     113b <util_get_time_diff+0x3b>
mov    -0x2c(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
cmpq   $0x0,-0x18(%rbp)
je     1159 <util_get_time_diff+0x59>
mov    -0x2c(%rbp),%eax
mov    $0x15180,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
cmpq   $0x0,-0x20(%rbp)
je     1181 <util_get_time_diff+0x81>
mov    -0x2c(%rbp),%eax
mov    $0x15180,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    $0xe10,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
cmpq   $0x0,-0x28(%rbp)
je     11b3 <util_get_time_diff+0xb3>
mov    -0x2c(%rbp),%eax
mov    $0x15180,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    $0xe10,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
cmpq   $0x0,0x10(%rbp)
je     11e3 <util_get_time_diff+0xe3>
mov    -0x2c(%rbp),%eax
mov    $0x15180,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    $0xe10,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    0x10(%rbp),%rax
mov    %edx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<util_get_time_diff>:
sub    %edi,%esi
test   %rdx,%rdx
je     1109 <util_get_time_diff+0x9>
mov    %esi,(%rdx)
movslq %esi,%rdx
test   %rcx,%rcx
je     112a <util_get_time_diff+0x2a>
imul   $0xffffffffc22e4507,%rdx,%rax
shr    $0x20,%rax
add    %esi,%eax
mov    %eax,%edi
shr    $0x1f,%edi
sar    $0x10,%eax
add    %edi,%eax
mov    %eax,(%rcx)
test   %r8,%r8
je     116d <util_get_time_diff+0x6d>
imul   $0xffffffffc22e4507,%rdx,%rax
shr    $0x20,%rax
add    %esi,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
sar    $0x10,%eax
add    %ecx,%eax
imul   $0x15180,%eax,%eax
mov    %esi,%ecx
sub    %eax,%ecx
movslq %ecx,%rax
imul   $0xffffffff91a2b3c5,%rax,%rcx
shr    $0x20,%rcx
add    %ecx,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
sar    $0xb,%eax
add    %ecx,%eax
mov    %eax,(%r8)
mov    0x8(%rsp),%r8
test   %r9,%r9
je     11dc <util_get_time_diff+0xdc>
imul   $0xffffffffc22e4507,%rdx,%rcx
shr    $0x20,%rcx
add    %esi,%ecx
mov    %ecx,%edi
shr    $0x1f,%edi
sar    $0x10,%ecx
add    %edi,%ecx
imul   $0x15180,%ecx,%ecx
mov    %esi,%edi
sub    %ecx,%edi
movslq %edi,%rcx
imul   $0xffffffff91a2b3c5,%rcx,%rdi
shr    $0x20,%rdi
add    %ecx,%edi
mov    %edi,%eax
shr    $0x1f,%eax
sar    $0xb,%edi
add    %eax,%edi
imul   $0xe10,%edi,%eax
sub    %eax,%ecx
movswl %cx,%eax
imul   $0xffff8889,%eax,%eax
shr    $0x10,%eax
add    %ecx,%eax
movzwl %ax,%eax
movswl %ax,%ecx
shr    $0xf,%eax
sar    $0x5,%ecx
add    %eax,%ecx
movswl %cx,%eax
mov    %eax,(%r9)
test   %r8,%r8
je     1249 <util_get_time_diff+0x149>
imul   $0xffffffffc22e4507,%rdx,%rax
shr    $0x20,%rax
add    %esi,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
sar    $0x10,%eax
add    %ecx,%eax
imul   $0x15180,%eax,%eax
sub    %eax,%esi
movslq %esi,%rcx
imul   $0xffffffff91a2b3c5,%rcx,%rax
shr    $0x20,%rax
add    %ecx,%eax
mov    %eax,%edx
shr    $0x1f,%edx
sar    $0xb,%eax
add    %edx,%eax
imul   $0xe10,%eax,%eax
sub    %eax,%ecx
movswl %cx,%eax
imul   $0xffff8889,%eax,%eax
shr    $0x10,%eax
add    %ecx,%eax
movzwl %ax,%eax
movswl %ax,%edx
shr    $0xf,%eax
sar    $0x5,%edx
add    %eax,%edx
imul   $0x3c,%edx,%eax
sub    %eax,%ecx
movswl %cx,%eax
mov    %eax,(%r8)
ret

LLVM IR (-O0):
define void @util_get_time_diff(i32 %0, i32 %1, i32* %2, i32* %3, i32* %4, i32* %5, i32* %6) {
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32*
%11 = alloca i32*
%12 = alloca i32*
%13 = alloca i32*
%14 = alloca i32*
%15 = alloca i32
store i32 %0, i32* %8
store i32 %1, i32* %9
store i32* %2, i32** %10
store i32* %3, i32** %11
store i32* %4, i32** %12
store i32* %5, i32** %13
store i32* %6, i32** %14
%16 = load i32, i32* %9
%17 = load i32, i32* %8
%18 = sub nsw i32 %16, %17
store i32 %18, i32* %15
%19 = load i32*, i32** %10
%20 = icmp ne i32* %19, null
br i1 %20, label %21, label %24
21: ; preds = %7
%22 = load i32, i32* %15
%23 = load i32*, i32** %10
store i32 %22, i32* %23
br label %24
24: ; preds = %21, %7
%25 = load i32*, i32** %11
%26 = icmp ne i32* %25, null
br i1 %26, label %27, label %31
27: ; preds = %24
%28 = load i32, i32* %15
%29 = sdiv i32 %28, 86400
%30 = load i32*, i32** %11
store i32 %29, i32* %30
br label %31
31: ; preds = %27, %24
%32 = load i32*, i32** %12
%33 = icmp ne i32* %32, null
br i1 %33, label %34, label %39
34: ; preds = %31
%35 = load i32, i32* %15
%36 = srem i32 %35, 86400
%37 = sdiv i32 %36, 3600
%38 = load i32*, i32** %12
store i32 %37, i32* %38
br label %39
39: ; preds = %34, %31
%40 = load i32*, i32** %13
%41 = icmp ne i32* %40, null
br i1 %41, label %42, label %48
42: ; preds = %39
%43 = load i32, i32* %15
%44 = srem i32 %43, 86400
%45 = srem i32 %44, 3600
%46 = sdiv i32 %45, 60
%47 = load i32*, i32** %13
store i32 %46, i32* %47
br label %48
48: ; preds = %42, %39
%49 = load i32*, i32** %14
%50 = icmp ne i32* %49, null
br i1 %50, label %51, label %57
51: ; preds = %48
%52 = load i32, i32* %15
%53 = srem i32 %52, 86400
%54 = srem i32 %53, 3600
%55 = srem i32 %54, 60
%56 = load i32*, i32** %14
store i32 %55, i32* %56
br label %57
57: ; preds = %51, %48
ret void
}

LLVM IR (-O2):
define void @util_get_time_diff(i32 %0, i32 %1, i32* writeonly %2, i32* writeonly %3, i32* writeonly %4, i32* writeonly %5, i32* writeonly %6) {
%8 = sub nsw i32 %1, %0
%9 = icmp eq i32* %2, null
br i1 %9, label %11, label %10
10: ; preds = %7
store i32 %8, i32* %2
br label %11
11: ; preds = %10, %7
%12 = icmp eq i32* %3, null
br i1 %12, label %15, label %13
13: ; preds = %11
%14 = sdiv i32 %8, 86400
store i32 %14, i32* %3
br label %15
15: ; preds = %13, %11
%16 = icmp eq i32* %4, null
br i1 %16, label %20, label %17
17: ; preds = %15
%18 = srem i32 %8, 86400
%19 = sdiv i32 %18, 3600
store i32 %19, i32* %4
br label %20
20: ; preds = %17, %15
%21 = icmp eq i32* %5, null
br i1 %21, label %28, label %22
22: ; preds = %20
%23 = srem i32 %8, 86400
%24 = srem i32 %23, 3600
%25 = trunc i32 %24 to i16
%26 = sdiv i16 %25, 60
%27 = sext i16 %26 to i32
store i32 %27, i32* %5
br label %28
28: ; preds = %22, %20
%29 = icmp eq i32* %6, null
br i1 %29, label %36, label %30
30: ; preds = %28
%31 = srem i32 %8, 86400
%32 = srem i32 %31, 3600
%33 = trunc i32 %32 to i16
%34 = srem i16 %33, 60
%35 = sext i16 %34 to i32
store i32 %35, i32* %6
br label %36
36: ; preds = %30, %28
ret void
}