#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*/ scalar_to_ymd(int, unsigned int *, unsigned int *,
                                 unsigned int *);
int snprintf(char *, int, char *, unsigned int, unsigned int, unsigned int,
             unsigned int, unsigned int, unsigned int, unsigned int);
int wg_strf_iso_datetime(void *db, int date, int time, char *buf) {
  unsigned yr, mo, day, hr, min, sec, spart;
  int t = time;
  int c;
  hr = t / (60 * 60 * 100);
  t = t - (hr * (60 * 60 * 100));
  min = t / (60 * 100);
  t = t - (min * (60 * 100));
  sec = t / 100;
  t = t - (sec * (100));
  spart = t;
  scalar_to_ymd(date, &yr, &mo, &day);
  c = snprintf(buf, 24, "%04d-%02d-%02dT%02d:%02d:%02d.%02d", yr, mo, day, hr,
               min, sec, spart);
  return (c);
}


x86 assembly (clang, -O0):
<wg_strf_iso_datetime>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
sub    $0x68,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x40(%rbp)
mov    -0x40(%rbp),%eax
mov    $0x57e40,%ecx
cltd
idiv   %ecx
mov    %eax,-0x30(%rbp)
mov    -0x40(%rbp),%eax
imul   $0x57e40,-0x30(%rbp),%ecx
sub    %ecx,%eax
mov    %eax,-0x40(%rbp)
mov    -0x40(%rbp),%eax
mov    $0x1770,%ecx
cltd
idiv   %ecx
mov    %eax,-0x34(%rbp)
mov    -0x40(%rbp),%eax
imul   $0x1770,-0x34(%rbp),%ecx
sub    %ecx,%eax
mov    %eax,-0x40(%rbp)
mov    -0x40(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %eax,-0x38(%rbp)
mov    -0x40(%rbp),%eax
imul   $0x64,-0x38(%rbp),%ecx
sub    %ecx,%eax
mov    %eax,-0x40(%rbp)
mov    -0x40(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x24(%rbp),%rsi
lea    -0x28(%rbp),%rdx
lea    -0x2c(%rbp),%rcx
call   1030 <scalar_to_ymd@plt>
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%ecx
mov    -0x28(%rbp),%r8d
mov    -0x2c(%rbp),%r9d
mov    -0x30(%rbp),%ebx
mov    -0x34(%rbp),%r11d
mov    -0x38(%rbp),%r10d
mov    -0x3c(%rbp),%eax
mov    $0x18,%esi
lea    0xe2c(%rip),%rdx
mov    %ebx,(%rsp)
mov    %r11d,0x8(%rsp)
mov    %r10d,0x10(%rsp)
mov    %eax,0x18(%rsp)
call   1040 <snprintf@plt>
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%eax
add    $0x68,%rsp
pop    %rbx
pop    %rbp
ret

x86 assembly (clang, -O2):
<wg_strf_iso_datetime>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rcx,%r14
mov    %esi,%edi
movslq %edx,%rax
imul   $0x5d34edef,%rax,%r15
mov    %r15,%rcx
shr    $0x3f,%rcx
sar    $0x31,%r15
add    %ecx,%r15d
imul   $0xfffa81c0,%r15d,%ecx
add    %ecx,%eax
cltq
imul   $0x57619f1,%rax,%r12
mov    %r12,%rcx
shr    $0x3f,%rcx
sar    $0x27,%r12
add    %ecx,%r12d
imul   $0xffffe890,%r12d,%ecx
add    %ecx,%eax
movslq %eax,%r13
imul   $0x51eb851f,%r13,%rbx
mov    %rbx,%rax
shr    $0x3f,%rax
sar    $0x25,%rbx
add    %eax,%ebx
imul   $0xffffff9c,%ebx,%eax
add    %eax,%r13d
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
lea    0x4(%rsp),%rcx
call   1030 <scalar_to_ymd@plt>
mov    0xc(%rsp),%ecx
mov    0x8(%rsp),%r8d
mov    0x4(%rsp),%r9d
lea    0xe47(%rip),%rdx
mov    %r14,%rdi
mov    $0x18,%esi
push   %r13
push   %rbx
push   %r12
push   %r15
call   1040 <snprintf@plt>
add    $0x30,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [35 x i8] c"%04d-%02d-%02dT%02d:%02d:%02d.%02d\00"
define i32 @wg_strf_iso_datetime(i8* %0, i32 %1, i32 %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i8* %3, i8** %8
%18 = load i32, i32* %7
store i32 %18, i32* %16
%19 = load i32, i32* %16
%20 = sdiv i32 %19, 360000
store i32 %20, i32* %12
%21 = load i32, i32* %16
%22 = load i32, i32* %12
%23 = mul i32 %22, 360000
%24 = sub i32 %21, %23
store i32 %24, i32* %16
%25 = load i32, i32* %16
%26 = sdiv i32 %25, 6000
store i32 %26, i32* %13
%27 = load i32, i32* %16
%28 = load i32, i32* %13
%29 = mul i32 %28, 6000
%30 = sub i32 %27, %29
store i32 %30, i32* %16
%31 = load i32, i32* %16
%32 = sdiv i32 %31, 100
store i32 %32, i32* %14
%33 = load i32, i32* %16
%34 = load i32, i32* %14
%35 = mul i32 %34, 100
%36 = sub i32 %33, %35
store i32 %36, i32* %16
%37 = load i32, i32* %16
store i32 %37, i32* %15
%38 = load i32, i32* %6
%39 = call i32 @scalar_to_ymd(i32 %38, i32* %9, i32* %10, i32* %11)
%40 = load i8*, i8** %8
%41 = load i32, i32* %9
%42 = load i32, i32* %10
%43 = load i32, i32* %11
%44 = load i32, i32* %12
%45 = load i32, i32* %13
%46 = load i32, i32* %14
%47 = load i32, i32* %15
%48 = call i32 @snprintf(i8* %40, i32 24, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 %41, i32 %42, i32 %43, i32 %44, i32 %45, i32 %46, i32 %47)
store i32 %48, i32* %17
%49 = load i32, i32* %17
ret i32 %49
}

LLVM IR (-O2):
@.str = [35 x i8] c"%04d-%02d-%02dT%02d:%02d:%02d.%02d\00"
define i32 @wg_strf_iso_datetime(i8* nocapture readnone %0, i32 %1, i32 %2, i8* %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = bitcast i32* %5 to i8*
%9 = bitcast i32* %6 to i8*
%10 = bitcast i32* %7 to i8*
%11 = sdiv i32 %2, 360000
%12 = mul nsw i32 %11, -360000
%13 = add i32 %12, %2
%14 = sdiv i32 %13, 6000
%15 = mul nsw i32 %14, -6000
%16 = add i32 %15, %13
%17 = sdiv i32 %16, 100
%18 = mul nsw i32 %17, -100
%19 = add i32 %18, %16
%20 = call i32 @scalar_to_ymd(i32 %1, i32* %5, i32* %6, i32* %7)
%21 = load i32, i32* %5
%22 = load i32, i32* %6
%23 = load i32, i32* %7
%24 = call i32 @snprintf(i8* %3, i32 24, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 %21, i32 %22, i32 %23, i32 %11, i32 %14, i32 %17, i32 %19)
ret i32 %24
}