#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 *, long, long, long, long);
void convert_date(long P_sec, char *L_buf) {
  long L_sec, L_min, L_hour, L_day;
  long L_tmp;
  L_day = P_sec / 86400;
  L_tmp = P_sec % 86400;
  L_hour = L_tmp / 3600;
  L_tmp = L_tmp % 3600;
  L_min = L_tmp / 60;
  L_sec = L_tmp % 60;
  sprintf(L_buf, "%ld %02ld:%02ld:%02ld", L_day + 1, L_hour, L_min, L_sec);
}


x86 assembly (clang, -O0):
<convert_date>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    $0x15180,%ecx
cqto
idiv   %rcx
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
mov    $0x15180,%ecx
cqto
idiv   %rcx
mov    %rdx,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    $0xe10,%ecx
cqto
idiv   %rcx
mov    %rax,-0x28(%rbp)
mov    -0x38(%rbp),%rax
mov    $0xe10,%ecx
cqto
idiv   %rcx
mov    %rdx,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    $0x3c,%ecx
cqto
idiv   %rcx
mov    %rax,-0x20(%rbp)
mov    -0x38(%rbp),%rax
mov    $0x3c,%ecx
cqto
idiv   %rcx
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x30(%rbp),%rdx
add    $0x1,%rdx
mov    -0x28(%rbp),%rcx
mov    -0x20(%rbp),%r8
mov    -0x18(%rbp),%r9
lea    0xe55(%rip),%rsi
call   1030 <sprintf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<convert_date>:
mov    %rsi,%r10
movabs $0x1845c8a0ce512957,%rcx
c8 45 18
mov    %rdi,%rax
imul   %rcx
mov    %rdx,%r11
shr    $0x3f,%r11
sar    $0xd,%rdx
lea    (%rdx,%r11,1),%rcx
imul   $0x15180,%rcx,%rcx
sub    %rcx,%rdi
movslq %edi,%rsi
imul   $0xffffffff91a2b3c5,%rsi,%rcx
shr    $0x20,%rcx
add    %esi,%ecx
mov    %ecx,%edi
shr    $0x1f,%edi
sar    $0xb,%ecx
add    %edi,%ecx
movslq %ecx,%rcx
imul   $0xe10,%ecx,%edi
sub    %edi,%esi
movswl %si,%edi
imul   $0xffff8889,%edi,%edi
shr    $0x10,%edi
add    %esi,%edi
movzwl %di,%edi
movswl %di,%eax
shr    $0xf,%edi
sar    $0x5,%eax
add    %edi,%eax
movswq %ax,%r8
imul   $0x3c,%eax,%eax
sub    %eax,%esi
movswq %si,%r9
add    %r11,%rdx
add    $0x1,%rdx
lea    0xe68(%rip),%rsi
mov    %r10,%rdi
jmp    1030 <sprintf@plt>

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

LLVM IR (-O2):
@.str = [22 x i8] c"%ld %02ld:%02ld:%02ld\00"
define void @convert_date(i64 %0, i8* nocapture writeonly %1) {
%3 = sdiv i64 %0, 86400
%4 = srem i64 %0, 86400
%5 = trunc i64 %4 to i32
%6 = sdiv i32 %5, 3600
%7 = sext i32 %6 to i64
%8 = srem i32 %5, 3600
%9 = trunc i32 %8 to i16
%10 = sdiv i16 %9, 60
%11 = sext i16 %10 to i64
%12 = srem i16 %9, 60
%13 = sext i16 %12 to i64
%14 = add nsw i64 %3, 1
%15 = tail call i32 @sprintf(i8* dereferenceable(1) %1, i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i64 %14, i64 %7, i64 %11, i64 %13)
ret void
}