#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 */
int /*<<< orphan*/ sprintf(char *, char *, int, int, int, int);
char *fixed_duration(int duration) {
  static char dbuffer[20];
  int days = 0, hours = 0, mins = 0;
  days = (int)(duration / (24 * 60 * 60));
  duration %= (24 * 60 * 60);
  hours = (int)(duration / (60 * 60));
  duration %= (60 * 60);
  mins = (int)(duration / 60);
  duration %= 60;
  sprintf(dbuffer, "%01d days, %02d:%02d:%02d", days, hours, mins, duration);
  return dbuffer;
}


x86 assembly (clang, -O0):
<fixed_duration>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x15180,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x15180,%ecx
cltd
idiv   %ecx
mov    %edx,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    $0xe10,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%eax
mov    $0xe10,%ecx
cltd
idiv   %ecx
mov    %edx,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %edx,-0x4(%rbp)
mov    -0x8(%rbp),%edx
mov    -0xc(%rbp),%ecx
mov    -0x10(%rbp),%r8d
mov    -0x4(%rbp),%r9d
lea    0x2ea7(%rip),%rdi
lea    0xe60(%rip),%rsi
call   1030 <sprintf@plt>
lea    0x2e94(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fixed_duration>:
push   %rbx
movslq %edi,%rax
imul   $0xffffffffc22e4507,%rax,%rdx
shr    $0x20,%rdx
add    %eax,%edx
mov    %edx,%ecx
shr    $0x1f,%ecx
sar    $0x10,%edx
add    %ecx,%edx
imul   $0x15180,%edx,%ecx
sub    %ecx,%eax
cltq
imul   $0xffffffff91a2b3c5,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%esi
shr    $0x1f,%esi
sar    $0xb,%ecx
add    %esi,%ecx
imul   $0xe10,%ecx,%esi
sub    %esi,%eax
movswl %ax,%esi
imul   $0xffff8889,%esi,%esi
shr    $0x10,%esi
add    %eax,%esi
movzwl %si,%esi
movswl %si,%edi
shr    $0xf,%esi
sar    $0x5,%edi
add    %esi,%edi
movswl %di,%r8d
imul   $0x3c,%edi,%esi
sub    %esi,%eax
movswl %ax,%r9d
lea    0x2ebc(%rip),%rbx
lea    0xe75(%rip),%rsi
mov    %rbx,%rdi
call   1030 <sprintf@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@fixed_duration.dbuffer = internal global [20 x i8] zeroinitializer
@.str = [26 x i8] c"%01d days, %02d:%02d:%02d\00"
define i8* @fixed_duration(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
%6 = load i32, i32* %2
%7 = sdiv i32 %6, 86400
store i32 %7, i32* %3
%8 = load i32, i32* %2
%9 = srem i32 %8, 86400
store i32 %9, i32* %2
%10 = load i32, i32* %2
%11 = sdiv i32 %10, 3600
store i32 %11, i32* %4
%12 = load i32, i32* %2
%13 = srem i32 %12, 3600
store i32 %13, i32* %2
%14 = load i32, i32* %2
%15 = sdiv i32 %14, 60
store i32 %15, i32* %5
%16 = load i32, i32* %2
%17 = srem i32 %16, 60
store i32 %17, i32* %2
%18 = load i32, i32* %3
%19 = load i32, i32* %4
%20 = load i32, i32* %5
%21 = load i32, i32* %2
%22 = call i32 @sprintf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @fixed_duration.dbuffer, i64 0, i64 0), i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %18, i32 %19, i32 %20, i32 %21)
ret i8* getelementptr inbounds ([20 x i8], [20 x i8]* @fixed_duration.dbuffer, i64 0, i64 0)
}

LLVM IR (-O2):
@fixed_duration.dbuffer = internal global [20 x i8] zeroinitializer
@.str = [26 x i8] c"%01d days, %02d:%02d:%02d\00"
define i8* @fixed_duration(i32 %0) {
%2 = sdiv i32 %0, 86400
%3 = srem i32 %0, 86400
%4 = sdiv i32 %3, 3600
%5 = srem i32 %3, 3600
%6 = trunc i32 %5 to i16
%7 = sdiv i16 %6, 60
%8 = sext i16 %7 to i32
%9 = srem i16 %6, 60
%10 = sext i16 %9 to i32
%11 = tail call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @fixed_duration.dbuffer, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %2, i32 %4, i32 %8, i32 %10)
ret i8* getelementptr inbounds ([20 x i8], [20 x i8]* @fixed_duration.dbuffer, i64 0, i64 0)
}