#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 */

/* Variables and functions */
char *calloc(int, int);
int /*<<< orphan*/ sprintf(char *, char *, unsigned long long,
                           unsigned long long, unsigned long long,
                           unsigned long long);
char *_pretty_print_time_us(unsigned long long diff) {
  unsigned long long us;
  unsigned long long secs;
  unsigned long long mins;
  unsigned long long hours;
  char *buff = calloc(512, sizeof(*buff));
  if (!buff)
    return NULL;
  secs = diff / 1000000;
  us = diff - secs * 1000000;
  mins = secs / 60;
  secs -= mins * 60;
  hours = mins / 60;
  mins -= hours * 60;
  sprintf(buff, "%llu hours %llu mins %llu.%llu secs", hours, mins, secs, us);
  return buff;
}


x86 assembly (clang, -O0):
<_pretty_print_time_us>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    $0x200,%edi
mov    $0x1,%esi
call   1030 <calloc@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    1157 <_pretty_print_time_us+0x37>
movq   $0x0,-0x8(%rbp)
jmp    11e8 <_pretty_print_time_us+0xc8>
mov    -0x10(%rbp),%rax
mov    $0xf4240,%ecx
xor    %edx,%edx
div    %rcx
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
imul   $0xf4240,-0x20(%rbp),%rcx
sub    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rax
mov    $0x3c,%ecx
xor    %edx,%edx
div    %rcx
mov    %rax,-0x28(%rbp)
imul   $0x3c,-0x28(%rbp),%rcx
mov    -0x20(%rbp),%rax
sub    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x28(%rbp),%rax
mov    $0x3c,%ecx
xor    %edx,%edx
div    %rcx
mov    %rax,-0x30(%rbp)
imul   $0x3c,-0x30(%rbp),%rcx
mov    -0x28(%rbp),%rax
sub    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x20(%rbp),%r8
mov    -0x18(%rbp),%r9
lea    0xe25(%rip),%rsi
call   1040 <sprintf@plt>
mov    -0x38(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_pretty_print_time_us>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    $0x200,%edi
mov    $0x1,%esi
call   1030 <calloc@plt>
mov    %rax,%r14
test   %rax,%rax
je     11ab <_pretty_print_time_us+0x8b>
movabs $0x431bde82d7b634db,%rcx
de 1b 43
mov    %rbx,%rax
mul    %rcx
mov    %rdx,%rcx
shr    $0x12,%rcx
imul   $0xfffffffffff0bdc0,%rcx,%r9
add    %rbx,%r9
mov    %rbx,%rax
shr    $0x8,%rax
movabs $0x11e54c672874daf,%rdx
54 1e 01
mul    %rdx
mov    %rdx,%rsi
shr    $0xa,%rsi
movabs $0x98b5bf2c03e529c5,%rdx
bf b5 98
mov    %rbx,%rax
mul    %rdx
imul   $0xffffffffffffffc4,%rsi,%r8
add    %rcx,%r8
shr    $0x1f,%rdx
imul   $0xffffffffffffffc4,%rdx,%rcx
add    %rsi,%rcx
lea    0xe5d(%rip),%rsi
mov    %r14,%rdi
call   1040 <sprintf@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [36 x i8] c"%llu hours %llu mins %llu.%llu secs\00"
define i8* @_pretty_print_time_us(i64 %0) {
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = alloca i8*
store i64 %0, i64* %3
%9 = call i8* @calloc(i32 512, i32 1)
store i8* %9, i8** %8
%10 = load i8*, i8** %8
%11 = icmp ne i8* %10, null
br i1 %11, label %13, label %12
12: ; preds = %1
store i8* null, i8** %2
br label %39
13: ; preds = %1
%14 = load i64, i64* %3
%15 = udiv i64 %14, 1000000
store i64 %15, i64* %5
%16 = load i64, i64* %3
%17 = load i64, i64* %5
%18 = mul i64 %17, 1000000
%19 = sub i64 %16, %18
store i64 %19, i64* %4
%20 = load i64, i64* %5
%21 = udiv i64 %20, 60
store i64 %21, i64* %6
%22 = load i64, i64* %6
%23 = mul i64 %22, 60
%24 = load i64, i64* %5
%25 = sub i64 %24, %23
store i64 %25, i64* %5
%26 = load i64, i64* %6
%27 = udiv i64 %26, 60
store i64 %27, i64* %7
%28 = load i64, i64* %7
%29 = mul i64 %28, 60
%30 = load i64, i64* %6
%31 = sub i64 %30, %29
store i64 %31, i64* %6
%32 = load i8*, i8** %8
%33 = load i64, i64* %7
%34 = load i64, i64* %6
%35 = load i64, i64* %5
%36 = load i64, i64* %4
%37 = call i32 @sprintf(i8* %32, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i64 %33, i64 %34, i64 %35, i64 %36)
%38 = load i8*, i8** %8
store i8* %38, i8** %2
br label %39
39: ; preds = %13, %12
%40 = load i8*, i8** %2
ret i8* %40
}

LLVM IR (-O2):
@.str = [36 x i8] c"%llu hours %llu mins %llu.%llu secs\00"
define noalias i8* @_pretty_print_time_us(i64 %0) {
%2 = tail call dereferenceable_or_null(512) i8* @calloc(i32 512, i32 1)
%3 = icmp eq i8* %2, null
br i1 %3, label %15, label %4
4: ; preds = %1
%5 = udiv i64 %0, 1000000
%6 = mul i64 %5, -1000000
%7 = add i64 %6, %0
%8 = udiv i64 %0, 60000000
%9 = mul nsw i64 %8, -60
%10 = add nsw i64 %9, %5
%11 = udiv i64 %0, 3600000000
%12 = mul nsw i64 %11, -60
%13 = add nsw i64 %12, %8
%14 = tail call i32 @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i64 %11, i64 %13, i64 %10, i64 %7)
br label %15
15: ; preds = %1, %4
ret i8* %2
}