#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*/ DBL_MANT_DIG;
int /*<<< orphan*/ decompose(double, double, int, double *, double *);
scalar_t__ floor(double);
scalar_t__ getJuldayOrigin();
int /*<<< orphan*/ julianDayToGregorianDate(scalar_t__, int *, int *, int *);
double ldexp(double, int /*<<< orphan*/);
void ut_decode_time(double value, int *year, int *month, int *day, int *hour,
                    int *minute, double *second, double *resolution) {
  int days;
  int hours;
  int minutes;
  double seconds;
  double uncer;
  typedef union {
    double vec[7];
    struct {
      double days;
      double hours12;
      double hours;
      double minutes10;
      double minutes;
      double seconds10;
      double seconds;
    } ind;
  } Basis;
  Basis counts;
  static const Basis basis = {86400, 43200, 3600, 600, 60, 10, 1};
  uncer = ldexp(value < 0 ? -value : value, -DBL_MANT_DIG);
  days = (int)floor(value / basis.ind.days);
  value -= days * basis.ind.days;
  decompose(value, uncer, (int)(sizeof(basis.vec) / sizeof(basis.vec[0])),
            basis.vec, counts.vec);
  days += counts.ind.days;
  hours = (int)counts.ind.hours12 * 12 + (int)counts.ind.hours;
  minutes = (int)counts.ind.minutes10 * 10 + (int)counts.ind.minutes;
  seconds = (int)counts.ind.seconds10 * 10 + counts.ind.seconds;
  if (seconds >= 60) {
    seconds -= 60;
    if (++minutes >= 60) {
      minutes -= 60;
      if (++hours >= 24) {
        hours -= 24;
        days++;
      }
    }
  }
  *second = seconds;
  *minute = minutes;
  *hour = hours;
  *resolution = uncer;
  julianDayToGregorianDate(getJuldayOrigin() + days, year, month, day);
}


x86 assembly (clang, -O0):
<ut_decode_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    0x10(%rbp),%rax
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9,-0x38(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    11b3 <ut_decode_time+0x63>
movsd  -0x8(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
jmp    11c0 <ut_decode_time+0x70>
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
movsd  -0x98(%rbp),%xmm0
ff
xor    %edi,%edi
mov    0x2e17(%rip),%rax
sub    (%rax),%edi
call   1030 <ldexp@plt>
movsd  %xmm0,-0x58(%rbp)
movsd  -0x8(%rbp),%xmm0
divsd  0xe1e(%rip),%xmm0
call   1070 <floor@plt>
mov    %eax,-0x3c(%rbp)
cvtsi2sdl -0x3c(%rbp),%xmm0
movsd  0xe09(%rip),%xmm2
movsd  -0x8(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm1
lea    -0x90(%rbp),%rdx
mov    $0x7,%edi
lea    0xdc3(%rip),%rsi
call   1060 <decompose@plt>
movsd  -0x90(%rbp),%xmm1
ff
cvtsi2sdl -0x3c(%rbp),%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x3c(%rbp)
cvttsd2si -0x88(%rbp),%eax
ff
imul   $0xc,%eax,%eax
cvttsd2si -0x80(%rbp),%ecx
add    %ecx,%eax
mov    %eax,-0x40(%rbp)
cvttsd2si -0x78(%rbp),%eax
imul   $0xa,%eax,%eax
cvttsd2si -0x70(%rbp),%ecx
add    %ecx,%eax
mov    %eax,-0x44(%rbp)
cvttsd2si -0x68(%rbp),%eax
imul   $0xa,%eax,%eax
cvtsi2sd %eax,%xmm0
addsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  0xd54(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     1315 <ut_decode_time+0x1c5>
movsd  -0x50(%rbp),%xmm0
movsd  0xd3d(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
cmp    $0x3c,%eax
jl     1310 <ut_decode_time+0x1c0>
mov    -0x44(%rbp),%eax
sub    $0x3c,%eax
mov    %eax,-0x44(%rbp)
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
cmp    $0x18,%eax
jl     130b <ut_decode_time+0x1bb>
mov    -0x40(%rbp),%eax
sub    $0x18,%eax
mov    %eax,-0x40(%rbp)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1310 <ut_decode_time+0x1c0>
jmp    1315 <ut_decode_time+0x1c5>
movsd  -0x50(%rbp),%xmm0
mov    -0x38(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x44(%rbp),%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x40(%rbp),%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
movsd  -0x58(%rbp),%xmm0
mov    0x10(%rbp),%rax
movsd  %xmm0,(%rax)
mov    $0x0,%al
call   1040 <getJuldayOrigin@plt>
mov    %rax,%rdi
movslq -0x3c(%rbp),%rax
add    %rax,%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
call   1050 <julianDayToGregorianDate@plt>
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ut_decode_time>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %r9,%rbp
mov    %r8,%r13
mov    %rcx,%rbx
mov    %rdx,0x18(%rsp)
mov    %rsi,%r15
mov    %rdi,%r12
movapd %xmm0,%xmm3
movapd %xmm0,0x20(%rsp)
movapd 0xe7c(%rip),%xmm1
xorpd  %xmm0,%xmm1
xorpd  %xmm2,%xmm2
cmpltsd %xmm2,%xmm0
andpd  %xmm0,%xmm1
andnpd %xmm3,%xmm0
orpd   %xmm1,%xmm0
mov    0x2e44(%rip),%rax
xor    %edi,%edi
sub    (%rax),%edi
call   1030 <ldexp@plt>
movsd  %xmm0,0x8(%rsp)
movapd 0x20(%rsp),%xmm0
divsd  0xe4f(%rip),%xmm0
call   1070 <floor@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0xe35(%rip),%xmm1
mulsd  %xmm0,%xmm1
movapd 0x20(%rsp),%xmm0
subsd  %xmm1,%xmm0
lea    0xe38(%rip),%rsi
lea    0x30(%rsp),%rdx
movsd  0x8(%rsp),%xmm1
mov    $0x7,%edi
call   1060 <decompose@plt>
movsd  0x10(%rsp),%xmm0
addsd  0x30(%rsp),%xmm0
cvttsd2si %xmm0,%r14d
cvttsd2si 0x38(%rsp),%eax
cvttsd2si 0x40(%rsp),%ecx
cvttsd2si 0x48(%rsp),%edx
cvttsd2si 0x58(%rsp),%esi
add    %esi,%esi
lea    (%rsi,%rsi,4),%esi
xorps  %xmm0,%xmm0
cvtsi2sd %esi,%xmm0
lea    (%rax,%rax,2),%eax
cvttsd2si 0x50(%rsp),%esi
lea    (%rcx,%rax,4),%eax
lea    (%rdx,%rdx,4),%ecx
addsd  0x60(%rsp),%xmm0
lea    (%rsi,%rcx,2),%ecx
ucomisd 0xdbe(%rip),%xmm0
jb     128b <ut_decode_time+0x13b>
addsd  0xdbc(%rip),%xmm0
cmp    $0x3b,%ecx
jl     1288 <ut_decode_time+0x138>
add    $0xffffffc5,%ecx
cmp    $0x17,%eax
mov    0xa0(%rsp),%rdx
movsd  0x8(%rsp),%xmm1
jl     12d4 <ut_decode_time+0x184>
add    $0xffffffe9,%eax
add    $0x1,%r14d
jmp    1299 <ut_decode_time+0x149>
add    $0x1,%ecx
mov    0xa0(%rsp),%rdx
movsd  0x8(%rsp),%xmm1
movsd  %xmm0,0x0(%rbp)
mov    %ecx,0x0(%r13)
mov    %eax,(%rbx)
movsd  %xmm1,(%rdx)
xor    %eax,%eax
call   1040 <getJuldayOrigin@plt>
movslq %r14d,%rdi
add    %rax,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
mov    0x18(%rsp),%rcx
call   1050 <julianDayToGregorianDate@plt>
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
add    $0x1,%eax
jmp    1299 <ut_decode_time+0x149>

LLVM IR (-O0):
%union.Basis = type { [7 x double] }
%struct.anon = type { double, double, double, double, double, double, double }
@ut_decode_time.basis = internal constant %union.Basis { [7 x double] [double 8.640000e+04, double 4.320000e+04, double 3.600000e+03, double 6.000000e+02, double 6.000000e+01, double 1.000000e+01, double 1.000000e+00] }
@DBL_MANT_DIG = global i32 0
define void @ut_decode_time(double %0, i32* %1, i32* %2, i32* %3, i32* %4, i32* %5, double* %6, double* %7) {
%9 = alloca double
%10 = alloca i32*
%11 = alloca i32*
%12 = alloca i32*
%13 = alloca i32*
%14 = alloca i32*
%15 = alloca double*
%16 = alloca double*
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca double
%21 = alloca double
%22 = alloca %union.Basis
store double %0, double* %9
store i32* %1, i32** %10
store i32* %2, i32** %11
store i32* %3, i32** %12
store i32* %4, i32** %13
store i32* %5, i32** %14
store double* %6, double** %15
store double* %7, double** %16
%23 = load double, double* %9
%24 = fcmp olt double %23, 0.000000e+00
br i1 %24, label %25, label %28
25: ; preds = %8
%26 = load double, double* %9
%27 = fneg double %26
br label %30
28: ; preds = %8
%29 = load double, double* %9
br label %30
30: ; preds = %28, %25
%31 = phi double [ %27, %25 ], [ %29, %28 ]
%32 = load i32, i32* @DBL_MANT_DIG
%33 = sub nsw i32 0, %32
%34 = call double @ldexp(double %31, i32 %33)
store double %34, double* %21
%35 = load double, double* %9
%36 = load double, double* getelementptr inbounds (%struct.anon, %struct.anon* bitcast (%union.Basis* @ut_decode_time.basis to %struct.anon*), i32 0, i32 0)
%37 = fdiv double %35, %36
%38 = call i64 @floor(double %37)
%39 = trunc i64 %38 to i32
store i32 %39, i32* %17
%40 = load i32, i32* %17
%41 = sitofp i32 %40 to double
%42 = load double, double* getelementptr inbounds (%struct.anon, %struct.anon* bitcast (%union.Basis* @ut_decode_time.basis to %struct.anon*), i32 0, i32 0)
%43 = load double, double* %9
%44 = fneg double %41
%45 = call double @llvm.fmuladd.f64(double %44, double %42, double %43)
store double %45, double* %9
%46 = load double, double* %9
%47 = load double, double* %21
%48 = bitcast %union.Basis* %22 to [7 x double]*
%49 = getelementptr inbounds [7 x double], [7 x double]* %48, i64 0, i64 0
%50 = call i32 @decompose(double %46, double %47, i32 7, double* getelementptr inbounds (%union.Basis, %union.Basis* @ut_decode_time.basis, i32 0, i32 0, i64 0), double* %49)
%51 = bitcast %union.Basis* %22 to %struct.anon*
%52 = getelementptr inbounds %struct.anon, %struct.anon* %51, i32 0, i32 0
%53 = load double, double* %52
%54 = load i32, i32* %17
%55 = sitofp i32 %54 to double
%56 = fadd double %55, %53
%57 = fptosi double %56 to i32
store i32 %57, i32* %17
%58 = bitcast %union.Basis* %22 to %struct.anon*
%59 = getelementptr inbounds %struct.anon, %struct.anon* %58, i32 0, i32 1
%60 = load double, double* %59
%61 = fptosi double %60 to i32
%62 = mul nsw i32 %61, 12
%63 = bitcast %union.Basis* %22 to %struct.anon*
%64 = getelementptr inbounds %struct.anon, %struct.anon* %63, i32 0, i32 2
%65 = load double, double* %64
%66 = fptosi double %65 to i32
%67 = add nsw i32 %62, %66
store i32 %67, i32* %18
%68 = bitcast %union.Basis* %22 to %struct.anon*
%69 = getelementptr inbounds %struct.anon, %struct.anon* %68, i32 0, i32 3
%70 = load double, double* %69
%71 = fptosi double %70 to i32
%72 = mul nsw i32 %71, 10
%73 = bitcast %union.Basis* %22 to %struct.anon*
%74 = getelementptr inbounds %struct.anon, %struct.anon* %73, i32 0, i32 4
%75 = load double, double* %74
%76 = fptosi double %75 to i32
%77 = add nsw i32 %72, %76
store i32 %77, i32* %19
%78 = bitcast %union.Basis* %22 to %struct.anon*
%79 = getelementptr inbounds %struct.anon, %struct.anon* %78, i32 0, i32 5
%80 = load double, double* %79
%81 = fptosi double %80 to i32
%82 = mul nsw i32 %81, 10
%83 = sitofp i32 %82 to double
%84 = bitcast %union.Basis* %22 to %struct.anon*
%85 = getelementptr inbounds %struct.anon, %struct.anon* %84, i32 0, i32 6
%86 = load double, double* %85
%87 = fadd double %83, %86
store double %87, double* %20
%88 = load double, double* %20
%89 = fcmp oge double %88, 6.000000e+01
br i1 %89, label %90, label %109
90: ; preds = %30
%91 = load double, double* %20
%92 = fsub double %91, 6.000000e+01
store double %92, double* %20
%93 = load i32, i32* %19
%94 = add nsw i32 %93, 1
store i32 %94, i32* %19
%95 = icmp sge i32 %94, 60
br i1 %95, label %96, label %108
96: ; preds = %90
%97 = load i32, i32* %19
%98 = sub nsw i32 %97, 60
store i32 %98, i32* %19
%99 = load i32, i32* %18
%100 = add nsw i32 %99, 1
store i32 %100, i32* %18
%101 = icmp sge i32 %100, 24
br i1 %101, label %102, label %107
102: ; preds = %96
%103 = load i32, i32* %18
%104 = sub nsw i32 %103, 24
store i32 %104, i32* %18
%105 = load i32, i32* %17
%106 = add nsw i32 %105, 1
store i32 %106, i32* %17
br label %107
107: ; preds = %102, %96
br label %108
108: ; preds = %107, %90
br label %109
109: ; preds = %108, %30
%110 = load double, double* %20
%111 = load double*, double** %15
store double %110, double* %111
%112 = load i32, i32* %19
%113 = load i32*, i32** %14
store i32 %112, i32* %113
%114 = load i32, i32* %18
%115 = load i32*, i32** %13
store i32 %114, i32* %115
%116 = load double, double* %21
%117 = load double*, double** %16
store double %116, double* %117
%118 = call i64 (...) @getJuldayOrigin()
%119 = load i32, i32* %17
%120 = sext i32 %119 to i64
%121 = add nsw i64 %118, %120
%122 = load i32*, i32** %10
%123 = load i32*, i32** %11
%124 = load i32*, i32** %12
%125 = call i32 @julianDayToGregorianDate(i64 %121, i32* %122, i32* %123, i32* %124)
ret void
}

LLVM IR (-O2):
%union.Basis = type { [7 x double] }
@ut_decode_time.basis = internal constant %union.Basis { [7 x double] [double 8.640000e+04, double 4.320000e+04, double 3.600000e+03, double 6.000000e+02, double 6.000000e+01, double 1.000000e+01, double 1.000000e+00] }
@DBL_MANT_DIG = global i32 0
define void @ut_decode_time(double %0, i32* %1, i32* %2, i32* %3, i32* nocapture writeonly %4, i32* nocapture writeonly %5, double* nocapture writeonly %6, double* nocapture writeonly %7) {
%9 = alloca %union.Basis
%10 = bitcast %union.Basis* %9 to i8*
%11 = fcmp olt double %0, 0.000000e+00
%12 = fneg double %0
%13 = select i1 %11, double %12, double %0
%14 = load i32, i32* @DBL_MANT_DIG
%15 = sub nsw i32 0, %14
%16 = tail call double @ldexp(double %13, i32 %15)
%17 = fdiv double %0, 8.640000e+04
%18 = tail call i64 @floor(double %17)
%19 = trunc i64 %18 to i32
%20 = sitofp i32 %19 to double
%21 = fneg double %20
%22 = tail call double @llvm.fmuladd.f64(double %21, double 8.640000e+04, double %0)
%23 = getelementptr inbounds %union.Basis, %union.Basis* %9, i64 0, i32 0, i64 0
%24 = call i32 @decompose(double %22, double %16, i32 7, double* getelementptr inbounds (%union.Basis, %union.Basis* @ut_decode_time.basis, i64 0, i32 0, i64 0), double* %23)
%25 = load double, double* %23
%26 = fadd double %25, %20
%27 = fptosi double %26 to i32
%28 = getelementptr inbounds %union.Basis, %union.Basis* %9, i64 0, i32 0, i64 1
%29 = load double, double* %28
%30 = fptosi double %29 to i32
%31 = mul nsw i32 %30, 12
%32 = getelementptr inbounds %union.Basis, %union.Basis* %9, i64 0, i32 0, i64 2
%33 = load double, double* %32
%34 = fptosi double %33 to i32
%35 = add nsw i32 %31, %34
%36 = getelementptr inbounds %union.Basis, %union.Basis* %9, i64 0, i32 0, i64 3
%37 = load double, double* %36
%38 = fptosi double %37 to i32
%39 = mul nsw i32 %38, 10
%40 = getelementptr inbounds %union.Basis, %union.Basis* %9, i64 0, i32 0, i64 4
%41 = load double, double* %40
%42 = fptosi double %41 to i32
%43 = add nsw i32 %39, %42
%44 = getelementptr inbounds %union.Basis, %union.Basis* %9, i64 0, i32 0, i64 5
%45 = load double, double* %44
%46 = fptosi double %45 to i32
%47 = mul nsw i32 %46, 10
%48 = sitofp i32 %47 to double
%49 = getelementptr inbounds %union.Basis, %union.Basis* %9, i64 0, i32 0, i64 6
%50 = load double, double* %49
%51 = fadd double %50, %48
%52 = fcmp ult double %51, 6.000000e+01
br i1 %52, label %64, label %53
53: ; preds = %8
%54 = fadd double %51, -6.000000e+01
%55 = add nsw i32 %43, 1
%56 = icmp sgt i32 %43, 58
br i1 %56, label %57, label %64
57: ; preds = %53
%58 = add nsw i32 %43, -59
%59 = add nsw i32 %35, 1
%60 = icmp sgt i32 %35, 22
br i1 %60, label %61, label %64
61: ; preds = %57
%62 = add nsw i32 %35, -23
%63 = add nsw i32 %27, 1
br label %64
64: ; preds = %53, %61, %57, %8
%65 = phi i32 [ %62, %61 ], [ %59, %57 ], [ %35, %53 ], [ %35, %8 ]
%66 = phi i32 [ %58, %61 ], [ %58, %57 ], [ %55, %53 ], [ %43, %8 ]
%67 = phi double [ %54, %61 ], [ %54, %57 ], [ %54, %53 ], [ %51, %8 ]
%68 = phi i32 [ %63, %61 ], [ %27, %57 ], [ %27, %53 ], [ %27, %8 ]
store double %67, double* %6
store i32 %66, i32* %5
store i32 %65, i32* %4
store double %16, double* %7
%69 = call i64 (...) @getJuldayOrigin()
%70 = sext i32 %68 to i64
%71 = add nsw i64 %69, %70
%72 = call i32 @julianDayToGregorianDate(i64 %71, i32* %1, i32* %2, i32* %3)
ret void
}