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

/* Variables and functions */
int /*<<< orphan*/ snprintf(char *, int, char *, unsigned long, unsigned long,
                            unsigned long);
void get_elapsed_time_str(char *buf, int bufsize, uint64_t secs) {
  long unsigned int minutes = (secs % 3600) / 60;
  long unsigned int hours = (secs / 3600) % 24;
  long unsigned int days = (secs / 3600) / 24;
  snprintf(buf, bufsize, "%lud %luh %lum", days, hours, minutes);
}


x86 assembly (clang, -O0):
<get_elapsed_time_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    $0xe10,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
cltq
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%eax
mov    $0xe10,%ecx
cltd
idiv   %ecx
mov    $0x18,%ecx
cltd
idiv   %ecx
movslq %edx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%eax
mov    $0xe10,%ecx
cltd
idiv   %ecx
mov    $0x18,%ecx
cltd
idiv   %ecx
cltq
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x28(%rbp),%rcx
mov    -0x20(%rbp),%r8
mov    -0x18(%rbp),%r9
lea    0xe76(%rip),%rdx
call   1030 <snprintf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_elapsed_time_str>:
movslq %edx,%rcx
imul   $0xffffffff91a2b3c5,%rcx,%r10
shr    $0x20,%r10
add    %ecx,%r10d
mov    %r10d,%edx
shr    $0x1f,%edx
sar    $0xb,%r10d
add    %edx,%r10d
imul   $0xe10,%r10d,%r8d
imul   $0xffffffffc22e4507,%rcx,%rdx
shr    $0x20,%rdx
add    %ecx,%edx
sub    %r8d,%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
movswq %cx,%r9
movslq %r10d,%rax
imul   $0x2aaaaaab,%rax,%rcx
mov    %rcx,%r8
shr    $0x3f,%r8
shr    $0x22,%rcx
add    %r8d,%ecx
shl    $0x3,%ecx
lea    (%rcx,%rcx,2),%ecx
sub    %ecx,%eax
movslq %eax,%r8
mov    %edx,%eax
shr    $0x1f,%eax
sar    $0x10,%edx
add    %eax,%edx
movslq %edx,%rcx
lea    0xe64(%rip),%rdx
jmp    1030 <snprintf@plt>

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

LLVM IR (-O2):
@.str = [15 x i8] c"%lud %luh %lum\00"
define void @get_elapsed_time_str(i8* %0, i32 %1, i32 %2) {
%4 = srem i32 %2, 3600
%5 = trunc i32 %4 to i16
%6 = sdiv i16 %5, 60
%7 = sext i16 %6 to i64
%8 = sdiv i32 %2, 3600
%9 = srem i32 %8, 24
%10 = sext i32 %9 to i64
%11 = sdiv i32 %2, 86400
%12 = sext i32 %11 to i64
%13 = tail call i32 @snprintf(i8* %0, i32 %1, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i64 %12, i64 %10, i64 %7)
ret void
}