#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 */
long qfits_date_now();
long qfits_time_now();
int /*<<< orphan*/ sprintf(char *, char *, int, int, int, int, int, int);
char *qfits_get_datetime_iso8601(void) {
  static char date_iso8601[20];
  long curdate;
  long curtime;
  curdate = qfits_date_now();
  curtime = qfits_time_now();
  sprintf(date_iso8601, "%04d-%02d-%02dT%02d:%02d:%02d",
          (int)((curdate) / 10000L), (int)(((curdate) % 10000L) / 100),
          (int)((curdate) % 100), (int)((curtime) / 1000000L),
          (int)(((curtime) % 1000000L) / 10000L),
          (int)(((curtime) % 10000L) / 100));
  return date_iso8601;
}


x86 assembly (clang, -O0):
<qfits_get_datetime_iso8601>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    $0x0,%al
call   1030 <qfits_date_now@plt>
mov    %rax,-0x8(%rbp)
mov    $0x0,%al
call   1040 <qfits_time_now@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    $0x2710,%ecx
cqto
idiv   %rcx
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    $0x2710,%ecx
cqto
idiv   %rcx
mov    %rdx,%rax
mov    $0x64,%ecx
cqto
idiv   %rcx
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    $0x64,%esi
cqto
idiv   %rsi
mov    %edx,%r8d
mov    -0x10(%rbp),%rax
mov    $0xf4240,%esi
cqto
idiv   %rsi
mov    %eax,%r9d
mov    -0x10(%rbp),%rax
mov    $0xf4240,%esi
cqto
idiv   %rsi
mov    %rdx,%rax
mov    $0x2710,%esi
cqto
idiv   %rsi
mov    %eax,%r10d
mov    -0x10(%rbp),%rax
mov    $0x2710,%esi
cqto
idiv   %rsi
mov    %rdx,%rax
mov    $0x64,%esi
cqto
idiv   %rsi
mov    -0x14(%rbp),%edx
lea    0x2e6f(%rip),%rdi
lea    0xe18(%rip),%rsi
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
call   1050 <sprintf@plt>
lea    0x2e54(%rip),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<qfits_get_datetime_iso8601>:
push   %r15
push   %r14
push   %rbx
xor    %eax,%eax
call   1030 <qfits_date_now@plt>
mov    %rax,%r14
xor    %eax,%eax
call   1040 <qfits_time_now@plt>
mov    %rax,%rsi
movabs $0x346dc5d63886594b,%rdi
c5 6d 34
mov    %r14,%rax
imul   %rdi
mov    %rdx,%r8
mov    %rdx,%rax
shr    $0x3f,%rax
shr    $0xb,%r8
add    %eax,%r8d
imul   $0x2710,%r8d,%eax
mov    %r14d,%ecx
sub    %eax,%ecx
movswl %cx,%eax
imul   $0x147b,%eax,%ecx
mov    %ecx,%ebx
shr    $0x1f,%ebx
sar    $0x13,%ecx
movabs $0xa3d70a3d70a3d70b,%rdx
0a d7 a3
mov    %r14,%rax
imul   %rdx
add    %ebx,%ecx
add    %r14,%rdx
mov    %rdx,%rax
shr    $0x3f,%rax
shr    $0x6,%rdx
add    %eax,%edx
imul   $0x64,%edx,%eax
sub    %eax,%r14d
movabs $0x431bde82d7b634db,%rdx
de 1b 43
mov    %rsi,%rax
imul   %rdx
mov    %rdx,%r9
shr    $0x3f,%r9
shr    $0x12,%rdx
add    %edx,%r9d
imul   $0xf4240,%r9d,%eax
mov    %esi,%edx
sub    %eax,%edx
movslq %edx,%rax
imul   $0x68db8bad,%rax,%rbx
mov    %rbx,%rax
shr    $0x3f,%rax
sar    $0x2c,%rbx
add    %eax,%ebx
mov    %rsi,%rax
imul   %rdi
mov    %rdx,%rax
shr    $0x3f,%rax
shr    $0xb,%edx
add    %eax,%edx
imul   $0x2710,%edx,%eax
sub    %eax,%esi
movswl %si,%eax
imul   $0x147b,%eax,%eax
mov    %eax,%edx
shr    $0x1f,%edx
sar    $0x13,%eax
add    %edx,%eax
lea    0x2e2d(%rip),%r15
lea    0xdd6(%rip),%rsi
mov    %r15,%rdi
mov    %r8d,%edx
mov    %r14d,%r8d
push   %rax
push   %rbx
call   1050 <sprintf@plt>
add    $0x10,%rsp
mov    %r15,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@qfits_get_datetime_iso8601.date_iso8601 = internal global [20 x i8] zeroinitializer
@.str = [30 x i8] c"%04d-%02d-%02dT%02d:%02d:%02d\00"
define i8* @qfits_get_datetime_iso8601() {
%1 = alloca i64
%2 = alloca i64
%3 = call i64 (...) @qfits_date_now()
store i64 %3, i64* %1
%4 = call i64 (...) @qfits_time_now()
store i64 %4, i64* %2
%5 = load i64, i64* %1
%6 = sdiv i64 %5, 10000
%7 = trunc i64 %6 to i32
%8 = load i64, i64* %1
%9 = srem i64 %8, 10000
%10 = sdiv i64 %9, 100
%11 = trunc i64 %10 to i32
%12 = load i64, i64* %1
%13 = srem i64 %12, 100
%14 = trunc i64 %13 to i32
%15 = load i64, i64* %2
%16 = sdiv i64 %15, 1000000
%17 = trunc i64 %16 to i32
%18 = load i64, i64* %2
%19 = srem i64 %18, 1000000
%20 = sdiv i64 %19, 10000
%21 = trunc i64 %20 to i32
%22 = load i64, i64* %2
%23 = srem i64 %22, 10000
%24 = sdiv i64 %23, 100
%25 = trunc i64 %24 to i32
%26 = call i32 @sprintf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @qfits_get_datetime_iso8601.date_iso8601, i64 0, i64 0), i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %7, i32 %11, i32 %14, i32 %17, i32 %21, i32 %25)
ret i8* getelementptr inbounds ([20 x i8], [20 x i8]* @qfits_get_datetime_iso8601.date_iso8601, i64 0, i64 0)
}

LLVM IR (-O2):
@qfits_get_datetime_iso8601.date_iso8601 = internal global [20 x i8] zeroinitializer
@.str = [30 x i8] c"%04d-%02d-%02dT%02d:%02d:%02d\00"
define i8* @qfits_get_datetime_iso8601() {
%1 = tail call i64 (...) @qfits_date_now()
%2 = tail call i64 (...) @qfits_time_now()
%3 = sdiv i64 %1, 10000
%4 = trunc i64 %3 to i32
%5 = srem i64 %1, 10000
%6 = trunc i64 %5 to i16
%7 = sdiv i16 %6, 100
%8 = sext i16 %7 to i32
%9 = srem i64 %1, 100
%10 = trunc i64 %9 to i32
%11 = sdiv i64 %2, 1000000
%12 = trunc i64 %11 to i32
%13 = srem i64 %2, 1000000
%14 = trunc i64 %13 to i32
%15 = sdiv i32 %14, 10000
%16 = srem i64 %2, 10000
%17 = trunc i64 %16 to i16
%18 = sdiv i16 %17, 100
%19 = sext i16 %18 to i32
%20 = tail call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @qfits_get_datetime_iso8601.date_iso8601, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %4, i32 %8, i32 %10, i32 %12, i32 %15, i32 %19)
ret i8* getelementptr inbounds ([20 x i8], [20 x i8]* @qfits_get_datetime_iso8601.date_iso8601, i64 0, i64 0)
}