void Print_Duration(from, to) long from;
long to;
{
  long delta, days, hours, minutes;
  delta = ((to - from > 0) ? to - from : 0);
  days = delta / (24L * 60L * 60L);
  delta = delta % (24L * 60L * 60L);
  hours = delta / (60L * 60L);
  delta = delta % (60L * 60L);
  minutes = delta / 60L;
  if (days > 0)
    printf("(%ld+", days);
  else
    printf(" (");
  printf("%02ld:%02ld)\n", hours, minutes);
}


x86 assembly (clang, -O0):
<Print_Duration>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
sub    -0x8(%rbp),%rax
cmp    $0x0,%rax
jle    1143 <Print_Duration+0x33>
mov    -0x10(%rbp),%rax
sub    -0x8(%rbp),%rax
mov    %rax,-0x38(%rbp)
jmp    114e <Print_Duration+0x3e>
xor    %eax,%eax
mov    %rax,-0x38(%rbp)
jmp    114e <Print_Duration+0x3e>
mov    -0x38(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    $0x15180,%ecx
cqto
idiv   %rcx
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    $0x15180,%ecx
cqto
idiv   %rcx
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    $0xe10,%ecx
cqto
idiv   %rcx
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    $0xe10,%ecx
cqto
idiv   %rcx
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    $0x3c,%ecx
cqto
idiv   %rcx
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x20(%rbp)
jle    11d2 <Print_Duration+0xc2>
mov    -0x20(%rbp),%rsi
lea    0xe3a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11e0 <Print_Duration+0xd0>
lea    0xe2d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdx
lea    0xe1a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Print_Duration>:
push   %r14
push   %rbx
push   %rax
xor    %ebx,%ebx
sub    %rdi,%rsi
cmovns %rsi,%rbx
movabs $0xc22e450672894ab7,%r14
45 2e c2
cmp    $0x15180,%rbx
jae    1140 <Print_Duration+0x30>
lea    0xecf(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    115b <Print_Duration+0x4b>
mov    %rbx,%rax
mul    %r14
shr    $0x10,%rdx
lea    0xeaf(%rip),%rdi
mov    %rdx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rax
mul    %r14
shr    $0x10,%rdx
imul   $0x15180,%rdx,%rax
sub    %rax,%rbx
mov    $0x91a2b3c5,%esi
imul   %rbx,%rsi
shr    $0x2b,%rsi
imul   $0xe10,%esi,%eax
sub    %eax,%ebx
movzwl %bx,%eax
imul   $0x8889,%eax,%edx
shr    $0x15,%edx
lea    0xe72(%rip),%rdi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"(%ld+\00"
@.str.1 = [3 x i8] c" (\00"
@.str.2 = [14 x i8] c"%02ld:%02ld)\0A\00"
define void @Print_Duration(i64 %0, i64 %1) {
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
store i64 %0, i64* %3
store i64 %1, i64* %4
%9 = load i64, i64* %4
%10 = load i64, i64* %3
%11 = sub nsw i64 %9, %10
%12 = icmp sgt i64 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %2
%14 = load i64, i64* %4
%15 = load i64, i64* %3
%16 = sub nsw i64 %14, %15
br label %18
17: ; preds = %2
br label %18
18: ; preds = %17, %13
%19 = phi i64 [ %16, %13 ], [ 0, %17 ]
store i64 %19, i64* %5
%20 = load i64, i64* %5
%21 = sdiv i64 %20, 86400
store i64 %21, i64* %6
%22 = load i64, i64* %5
%23 = srem i64 %22, 86400
store i64 %23, i64* %5
%24 = load i64, i64* %5
%25 = sdiv i64 %24, 3600
store i64 %25, i64* %7
%26 = load i64, i64* %5
%27 = srem i64 %26, 3600
store i64 %27, i64* %5
%28 = load i64, i64* %5
%29 = sdiv i64 %28, 60
store i64 %29, i64* %8
%30 = load i64, i64* %6
%31 = icmp sgt i64 %30, 0
br i1 %31, label %32, label %35
32: ; preds = %18
%33 = load i64, i64* %6
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i64 %33)
br label %37
35: ; preds = %18
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %37
37: ; preds = %35, %32
%38 = load i64, i64* %7
%39 = load i64, i64* %8
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i64 %38, i64 %39)
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"(%ld+\00"
@.str.1 = [3 x i8] c" (\00"
@.str.2 = [14 x i8] c"%02ld:%02ld)\0A\00"
define void @Print_Duration(i64 %0, i64 %1) {
%3 = sub nsw i64 %1, %0
%4 = icmp sgt i64 %3, 0
%5 = select i1 %4, i64 %3, i64 0
%6 = icmp ult i64 %5, 86400
br i1 %6, label %10, label %7
7: ; preds = %2
%8 = udiv i64 %5, 86400
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i64 %8)
br label %12
10: ; preds = %2
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %12
12: ; preds = %10, %7
%13 = urem i64 %5, 86400
%14 = trunc i64 %13 to i32
%15 = urem i32 %14, 3600
%16 = trunc i32 %15 to i16
%17 = udiv i16 %16, 60
%18 = zext i16 %17 to i64
%19 = udiv i32 %14, 3600
%20 = zext i32 %19 to i64
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i64 %20, i64 %18)
ret void
}