#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);
void UTL_ConvertLongtoDate(long ld, char *date) {
  int year, month, day;
  year = ld / 10000;
  ld -= (year * 10000);
  month = ld / 100;
  ld -= (month * 100);
  day = ld;
  sprintf(date, "%04d%02d%02d", year, month, day);
  return;
}


x86 assembly (clang, -O0):
<UTL_ConvertLongtoDate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    $0x2710,%ecx
cqto
idiv   %rcx
mov    %eax,-0x14(%rbp)
imul   $0x2710,-0x14(%rbp),%eax
movslq %eax,%rcx
mov    -0x8(%rbp),%rax
sub    %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    $0x64,%ecx
cqto
idiv   %rcx
mov    %eax,-0x18(%rbp)
imul   $0x64,-0x18(%rbp),%eax
movslq %eax,%rcx
mov    -0x8(%rbp),%rax
sub    %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
lea    0xe7b(%rip),%rsi
call   1030 <sprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<UTL_ConvertLongtoDate>:
mov    %rdi,%r8
movabs $0x346dc5d63886594b,%rcx
c5 6d 34
mov    %rdi,%rax
imul   %rcx
mov    %rdx,%r9
mov    %rsi,%rdi
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0xb,%r9
add    %rax,%r9
movabs $0x271000000000,%rax
imul   %r9,%rax
sar    $0x20,%rax
sub    %rax,%r8
movabs $0xa3d70a3d70a3d70b,%rcx
0a d7 a3
mov    %r8,%rax
imul   %rcx
mov    %rdx,%rcx
add    %r8,%rcx
mov    %rcx,%rax
shr    $0x3f,%rax
sar    $0x6,%rcx
add    %rax,%rcx
movabs $0x6400000000,%rax
imul   %rcx,%rax
shr    $0x20,%rax
sub    %eax,%r8d
lea    0xe74(%rip),%rsi
mov    %r9d,%edx
jmp    1030 <sprintf@plt>

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

LLVM IR (-O2):
@.str = [13 x i8] c"%04d%02d%02d\00"
define void @UTL_ConvertLongtoDate(i64 %0, i8* nocapture writeonly %1) {
%3 = sdiv i64 %0, 10000
%4 = trunc i64 %3 to i32
%5 = mul i64 %3, 42949672960000
%6 = ashr exact i64 %5, 32
%7 = sub nsw i64 %0, %6
%8 = sdiv i64 %7, 100
%9 = trunc i64 %8 to i32
%10 = mul i64 %8, 429496729600
%11 = lshr exact i64 %10, 32
%12 = sub i64 %7, %11
%13 = trunc i64 %12 to i32
%14 = tail call i32 @sprintf(i8* dereferenceable(1) %1, i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %4, i32 %9, i32 %13)
ret void
}