#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 /*<<< orphan*/ time_t;

/* Variables and functions */
int difftime(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char *, int, int, int);
void formatDiff(time_t time1, time_t time2, char *buf) {
  int dif = difftime(time1, time2);
  int hh = dif / 3600;
  int mm = (dif - hh * 3600) / 60;
  int ss = dif % 60;
  sprintf(buf, "%02d:%02d:%02d", hh, mm, ss);
}


x86 assembly (clang, -O0):
<formatDiff>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1030 <difftime@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    $0xe10,%ecx
cltd
idiv   %ecx
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
imul   $0xe10,-0x18(%rbp),%ecx
sub    %ecx,%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %edx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%edx
mov    -0x1c(%rbp),%ecx
mov    -0x20(%rbp),%r8d
lea    0xe78(%rip),%rsi
call   1040 <sprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<formatDiff>:
push   %rbx
mov    %rdx,%rbx
call   1030 <difftime@plt>
movslq %eax,%r8
imul   $0xffffffff91a2b3c5,%r8,%rdx
shr    $0x20,%rdx
add    %r8d,%edx
mov    %edx,%eax
shr    $0x1f,%eax
sar    $0xb,%edx
add    %eax,%edx
imul   $0xfffff1f0,%edx,%eax
add    %r8d,%eax
movslq %eax,%rcx
imul   $0xffffffff88888889,%rcx,%rax
shr    $0x20,%rax
add    %eax,%ecx
mov    %ecx,%eax
shr    $0x1f,%eax
sar    $0x5,%ecx
add    %eax,%ecx
imul   $0xffffffff88888889,%r8,%rax
shr    $0x20,%rax
add    %r8d,%eax
mov    %eax,%esi
shr    $0x1f,%esi
sar    $0x5,%eax
add    %esi,%eax
imul   $0x3c,%eax,%eax
sub    %eax,%r8d
lea    0xe74(%rip),%rsi
mov    %rbx,%rdi
pop    %rbx
jmp    1040 <sprintf@plt>

LLVM IR (-O0):
@.str = [15 x i8] c"%02d:%02d:%02d\00"
define void @formatDiff(i32 %0, i32 %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i8* %2, i8** %6
%11 = load i32, i32* %4
%12 = load i32, i32* %5
%13 = call i32 @difftime(i32 %11, i32 %12)
store i32 %13, i32* %7
%14 = load i32, i32* %7
%15 = sdiv i32 %14, 3600
store i32 %15, i32* %8
%16 = load i32, i32* %7
%17 = load i32, i32* %8
%18 = mul nsw i32 %17, 3600
%19 = sub nsw i32 %16, %18
%20 = sdiv i32 %19, 60
store i32 %20, i32* %9
%21 = load i32, i32* %7
%22 = srem i32 %21, 60
store i32 %22, i32* %10
%23 = load i8*, i8** %6
%24 = load i32, i32* %8
%25 = load i32, i32* %9
%26 = load i32, i32* %10
%27 = call i32 @sprintf(i8* %23, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %24, i32 %25, i32 %26)
ret void
}

LLVM IR (-O2):
@.str = [15 x i8] c"%02d:%02d:%02d\00"
define void @formatDiff(i32 %0, i32 %1, i8* nocapture writeonly %2) {
%4 = tail call i32 @difftime(i32 %0, i32 %1)
%5 = sdiv i32 %4, 3600
%6 = mul nsw i32 %5, -3600
%7 = add i32 %6, %4
%8 = sdiv i32 %7, 60
%9 = srem i32 %4, 60
%10 = tail call i32 @sprintf(i8* dereferenceable(1) %2, i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %5, i32 %8, i32 %9)
ret void
}