#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 */
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
struct TYPE_3__ {
  int quot;
  int rem;
};
typedef TYPE_1__ ldiv_t;

/* Variables and functions */
double floor(double);
TYPE_1__ ldiv(int, int);
void timename(int days, int secs, int nanosecs, char *str) {
  double ntime;
  ldiv_t d;
  int i;
  ntime = (double)secs * 1E9 + (double)nanosecs;
  ntime = (ntime * (36.0 * 36.0 * 36.0 * 36.0 * 36.0 * 36.0 * 36.0 * 36.0)) /
          86400E9;
  ntime = floor(ntime + 0.5);
  for (i = 11; i >= 4; i--) {
    double _d = floor(ntime / 36.0);
    int rem = (int)(floor(ntime - (_d * 36.0)));
    str[i] = rem < 10 ? '0' + rem : 'a' + rem - 10;
    ntime = _d;
  }
  d.quot = days + (25 * 365 + 6) + (31 * 36 * 36 * 36);
  for (i = 4; i--;) {
    d = ldiv(d.quot, 36);
    str[i] = d.rem < 10 ? '0' + (char)d.rem : 'a' + (char)d.rem - 10;
  }
}


x86 assembly (clang, -O0):
<timename>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %rcx,-0x18(%rbp)
cvtsi2sdl -0x8(%rbp),%xmm0
cvtsi2sdl -0xc(%rbp),%xmm1
movsd  0xed1(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xeb4(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  0xe9f(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe86(%rip),%xmm0
addsd  -0x20(%rbp),%xmm0
call   1040 <floor@plt>
movsd  %xmm0,-0x20(%rbp)
movl   $0xb,-0x2c(%rbp)
cmpl   $0x4,-0x2c(%rbp)
jl     123e <timename+0x11e>
movsd  -0x20(%rbp),%xmm0
movsd  0xe79(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1040 <floor@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x20(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xe42(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1040 <floor@plt>
cvttsd2si %xmm0,%eax
mov    %eax,-0x3c(%rbp)
cmpl   $0xa,-0x3c(%rbp)
jge    120a <timename+0xea>
mov    -0x3c(%rbp),%eax
add    $0x30,%eax
mov    %eax,-0x4c(%rbp)
jmp    1216 <timename+0xf6>
mov    -0x3c(%rbp),%eax
add    $0x61,%eax
sub    $0xa,%eax
mov    %eax,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
mov    %al,%dl
mov    -0x18(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x2c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x2c(%rbp)
jmp    1190 <timename+0x70>
mov    -0x4(%rbp),%eax
add    $0x23ab,%eax
add    $0x1611c0,%eax
mov    %eax,-0x28(%rbp)
movl   $0x4,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x2c(%rbp)
cmp    $0x0,%eax
je     12c1 <timename+0x1a1>
mov    -0x28(%rbp),%edi
mov    $0x24,%esi
call   1030 <ldiv@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpl   $0xa,-0x24(%rbp)
jge    129d <timename+0x17d>
mov    -0x24(%rbp),%eax
movsbl %al,%eax
add    $0x30,%eax
mov    %eax,-0x50(%rbp)
jmp    12ac <timename+0x18c>
mov    -0x24(%rbp),%eax
movsbl %al,%eax
add    $0x61,%eax
sub    $0xa,%eax
mov    %eax,-0x50(%rbp)
mov    -0x50(%rbp),%eax
mov    %al,%dl
mov    -0x18(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
jmp    1255 <timename+0x135>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<timename>:
push   %rbp
push   %rbx
sub    $0x58,%rsp
cvtsi2sd %esi,%xmm0
cvtsi2sd %edx,%xmm1
mulsd  0xeca(%rip),%xmm0
mov    %rcx,%rbx
mov    %edi,%ebp
addsd  %xmm1,%xmm0
mulsd  0xec1(%rip),%xmm0
divsd  0xec1(%rip),%xmm0
addsd  0xec1(%rip),%xmm0
call   1040 <floor@plt>
movapd %xmm0,0x10(%rsp)
divsd  0xeb6(%rip),%xmm0
call   1040 <floor@plt>
movapd %xmm0,0x20(%rsp)
divsd  0xea3(%rip),%xmm0
call   1040 <floor@plt>
movapd %xmm0,0x40(%rsp)
divsd  0xe90(%rip),%xmm0
call   1040 <floor@plt>
movapd %xmm0,(%rsp)
divsd  0xe7e(%rip),%xmm0
call   1040 <floor@plt>
movapd %xmm0,0x30(%rsp)
movapd %xmm0,%xmm1
movapd (%rsp),%xmm0
unpcklpd %xmm0,%xmm1
movapd 0x40(%rsp),%xmm3
unpcklpd %xmm3,%xmm0
movapd %xmm0,%xmm4
movapd 0x20(%rsp),%xmm2
unpcklpd %xmm2,%xmm3
unpcklpd 0x10(%rsp),%xmm2
movapd 0xe50(%rip),%xmm0
mulpd  %xmm0,%xmm3
subpd  %xmm3,%xmm2
movapd %xmm2,0x20(%rsp)
mulpd  %xmm0,%xmm1
movapd %xmm4,%xmm0
subpd  %xmm1,%xmm0
movapd %xmm0,(%rsp)
call   1040 <floor@plt>
movapd %xmm0,0x10(%rsp)
movaps (%rsp),%xmm0
movhlps %xmm0,%xmm0
call   1040 <floor@plt>
movaps 0x10(%rsp),%xmm1
movlhps %xmm0,%xmm1
movaps %xmm1,0x10(%rsp)
movaps 0x20(%rsp),%xmm0
call   1040 <floor@plt>
movaps %xmm0,(%rsp)
movapd 0x20(%rsp),%xmm0
unpckhpd %xmm0,%xmm0
call   1040 <floor@plt>
movapd (%rsp),%xmm1
unpcklpd %xmm0,%xmm1
cvttpd2dq %xmm1,%xmm0
cvttpd2dq 0x10(%rsp),%xmm1
unpcklpd %xmm0,%xmm1
movdqa 0xde1(%rip),%xmm0
pcmpgtd %xmm1,%xmm0
movdqa %xmm0,%xmm2
pandn  0xde1(%rip),%xmm2
pand   0xde9(%rip),%xmm0
por    %xmm2,%xmm0
paddd  %xmm1,%xmm0
pand   0xde9(%rip),%xmm0
packuswb %xmm0,%xmm0
packuswb %xmm0,%xmm0
movd   %xmm0,0x8(%rbx)
movapd 0x30(%rsp),%xmm0
divsd  0xd7e(%rip),%xmm0
call   1040 <floor@plt>
movapd %xmm0,0x20(%rsp)
divsd  0xd6b(%rip),%xmm0
call   1040 <floor@plt>
movapd %xmm0,0x10(%rsp)
divsd  0xd58(%rip),%xmm0
call   1040 <floor@plt>
movapd %xmm0,(%rsp)
divsd  0xd46(%rip),%xmm0
call   1040 <floor@plt>
movapd (%rsp),%xmm3
unpcklpd %xmm3,%xmm0
movapd 0x10(%rsp),%xmm4
unpcklpd %xmm4,%xmm3
movapd 0x20(%rsp),%xmm2
unpcklpd %xmm2,%xmm4
unpcklpd 0x30(%rsp),%xmm2
movapd 0xd26(%rip),%xmm1
mulpd  %xmm1,%xmm4
subpd  %xmm4,%xmm2
movapd %xmm2,0x20(%rsp)
mulpd  %xmm1,%xmm0
subpd  %xmm0,%xmm3
movapd %xmm3,(%rsp)
movapd %xmm3,%xmm0
call   1040 <floor@plt>
movapd %xmm0,0x10(%rsp)
movaps (%rsp),%xmm0
movhlps %xmm0,%xmm0
call   1040 <floor@plt>
movaps 0x10(%rsp),%xmm1
movlhps %xmm0,%xmm1
movaps %xmm1,0x10(%rsp)
movaps 0x20(%rsp),%xmm0
call   1040 <floor@plt>
movaps %xmm0,(%rsp)
movapd 0x20(%rsp),%xmm0
unpckhpd %xmm0,%xmm0
call   1040 <floor@plt>
movapd (%rsp),%xmm1
unpcklpd %xmm0,%xmm1
cvttpd2dq %xmm1,%xmm0
cvttpd2dq 0x10(%rsp),%xmm1
unpcklpd %xmm0,%xmm1
movdqa 0xcb7(%rip),%xmm2
pcmpgtd %xmm1,%xmm2
movdqa %xmm2,%xmm0
pandn  0xcb7(%rip),%xmm0
pand   0xcbf(%rip),%xmm2
por    %xmm0,%xmm2
paddd  %xmm1,%xmm2
pand   0xcbf(%rip),%xmm2
packuswb %xmm2,%xmm2
packuswb %xmm2,%xmm2
movd   %xmm2,0x4(%rbx)
add    $0x16356b,%ebp
mov    %ebp,%edi
mov    $0x24,%esi
call   1030 <ldiv@plt>
mov    %rax,%rcx
shr    $0x20,%rcx
lea    0x57(%rcx),%edx
lea    0x30(%rcx),%esi
cmp    $0xa,%ecx
cmovge %edx,%esi
mov    %sil,0x3(%rbx)
mov    %eax,%edi
mov    $0x24,%esi
call   1030 <ldiv@plt>
mov    %rax,%rcx
shr    $0x20,%rcx
lea    0x57(%rcx),%edx
lea    0x30(%rcx),%esi
cmp    $0xa,%ecx
cmovge %edx,%esi
mov    %sil,0x2(%rbx)
mov    %eax,%edi
mov    $0x24,%esi
call   1030 <ldiv@plt>
mov    %rax,%rcx
shr    $0x20,%rcx
lea    0x57(%rcx),%edx
lea    0x30(%rcx),%esi
cmp    $0xa,%ecx
cmovge %edx,%esi
mov    %sil,0x1(%rbx)
mov    %eax,%edi
mov    $0x24,%esi
call   1030 <ldiv@plt>
shr    $0x20,%rax
lea    0x57(%rax),%ecx
lea    0x30(%rax),%edx
cmp    $0xa,%eax
cmovge %ecx,%edx
mov    %dl,(%rbx)
add    $0x58,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { i32, i32 }
define void @timename(i32 %0, i32 %1, i32 %2, i8* %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca double
%10 = alloca %struct.TYPE_3__
%11 = alloca i32
%12 = alloca double
%13 = alloca i32
%14 = alloca %struct.TYPE_3__
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i8* %3, i8** %8
%15 = load i32, i32* %6
%16 = sitofp i32 %15 to double
%17 = load i32, i32* %7
%18 = sitofp i32 %17 to double
%19 = call double @llvm.fmuladd.f64(double %16, double 1.000000e+09, double %18)
store double %19, double* %9
%20 = load double, double* %9
%21 = fmul double %20, 0x428486BA08000000
%22 = fdiv double %21, 8.640000e+13
store double %22, double* %9
%23 = load double, double* %9
%24 = fadd double %23, 5.000000e-01
%25 = call double @llvm.floor.f64(double %24)
store double %25, double* %9
store i32 11, i32* %11
br label %26
26: ; preds = %56, %4
%27 = load i32, i32* %11
%28 = icmp sge i32 %27, 4
br i1 %28, label %29, label %59
29: ; preds = %26
%30 = load double, double* %9
%31 = fdiv double %30, 3.600000e+01
%32 = call double @llvm.floor.f64(double %31)
store double %32, double* %12
%33 = load double, double* %9
%34 = load double, double* %12
%35 = fneg double %34
%36 = call double @llvm.fmuladd.f64(double %35, double 3.600000e+01, double %33)
%37 = call double @llvm.floor.f64(double %36)
%38 = fptosi double %37 to i32
store i32 %38, i32* %13
%39 = load i32, i32* %13
%40 = icmp slt i32 %39, 10
br i1 %40, label %41, label %44
41: ; preds = %29
%42 = load i32, i32* %13
%43 = add nsw i32 48, %42
br label %48
44: ; preds = %29
%45 = load i32, i32* %13
%46 = add nsw i32 97, %45
%47 = sub nsw i32 %46, 10
br label %48
48: ; preds = %44, %41
%49 = phi i32 [ %43, %41 ], [ %47, %44 ]
%50 = trunc i32 %49 to i8
%51 = load i8*, i8** %8
%52 = load i32, i32* %11
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i8, i8* %51, i64 %53
store i8 %50, i8* %54
%55 = load double, double* %12
store double %55, double* %9
br label %56
56: ; preds = %48
%57 = load i32, i32* %11
%58 = add nsw i32 %57, -1
store i32 %58, i32* %11
br label %26
59: ; preds = %26
%60 = load i32, i32* %5
%61 = add nsw i32 %60, 9131
%62 = add nsw i32 %61, 1446336
%63 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %10, i32 0, i32 0
store i32 %62, i32* %63
store i32 4, i32* %11
br label %64
64: ; preds = %91, %59
%65 = load i32, i32* %11
%66 = add nsw i32 %65, -1
store i32 %66, i32* %11
%67 = icmp ne i32 %65, 0
br i1 %67, label %68, label %98
68: ; preds = %64
%69 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %10, i32 0, i32 0
%70 = load i32, i32* %69
%71 = call i64 @ldiv(i32 %70, i32 36)
%72 = bitcast %struct.TYPE_3__* %14 to i64*
store i64 %71, i64* %72
%73 = bitcast %struct.TYPE_3__* %10 to i8*
%74 = bitcast %struct.TYPE_3__* %14 to i8*
%75 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %10, i32 0, i32 1
%76 = load i32, i32* %75
%77 = icmp slt i32 %76, 10
br i1 %77, label %78, label %84
78: ; preds = %68
%79 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %10, i32 0, i32 1
%80 = load i32, i32* %79
%81 = trunc i32 %80 to i8
%82 = sext i8 %81 to i32
%83 = add nsw i32 48, %82
br label %91
84: ; preds = %68
%85 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %10, i32 0, i32 1
%86 = load i32, i32* %85
%87 = trunc i32 %86 to i8
%88 = sext i8 %87 to i32
%89 = add nsw i32 97, %88
%90 = sub nsw i32 %89, 10
br label %91
91: ; preds = %84, %78
%92 = phi i32 [ %83, %78 ], [ %90, %84 ]
%93 = trunc i32 %92 to i8
%94 = load i8*, i8** %8
%95 = load i32, i32* %11
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds i8, i8* %94, i64 %96
store i8 %93, i8* %97
br label %64
98: ; preds = %64
ret void
}

LLVM IR (-O2):
define void @timename(i32 %0, i32 %1, i32 %2, i8* nocapture writeonly %3) {
%5 = sitofp i32 %1 to double
%6 = sitofp i32 %2 to double
%7 = tail call double @llvm.fmuladd.f64(double %5, double 1.000000e+09, double %6)
%8 = fmul double %7, 0x428486BA08000000
%9 = fdiv double %8, 8.640000e+13
%10 = fadd double %9, 5.000000e-01
%11 = tail call double @llvm.floor.f64(double %10)
%12 = fdiv double %11, 3.600000e+01
%13 = tail call double @llvm.floor.f64(double %12)
%14 = fdiv double %13, 3.600000e+01
%15 = tail call double @llvm.floor.f64(double %14)
%16 = fdiv double %15, 3.600000e+01
%17 = tail call double @llvm.floor.f64(double %16)
%18 = fdiv double %17, 3.600000e+01
%19 = tail call double @llvm.floor.f64(double %18)
%20 = insertelement <4 x double> poison, double %19, i64 0
%21 = insertelement <4 x double> %20, double %17, i64 1
%22 = insertelement <4 x double> %21, double %15, i64 2
%23 = insertelement <4 x double> %22, double %13, i64 3
%24 = fneg <4 x double> %23
%25 = insertelement <4 x double> poison, double %17, i64 0
%26 = insertelement <4 x double> %25, double %15, i64 1
%27 = insertelement <4 x double> %26, double %13, i64 2
%28 = insertelement <4 x double> %27, double %11, i64 3
%29 = call <4 x double> @llvm.fmuladd.v4f64(<4 x double> %24, <4 x double> <double 3.600000e+01, double 3.600000e+01, double 3.600000e+01, double 3.600000e+01>, <4 x double> %28)
%30 = call <4 x double> @llvm.floor.v4f64(<4 x double> %29)
%31 = fptosi <4 x double> %30 to <4 x i32>
%32 = icmp slt <4 x i32> %31, <i32 10, i32 10, i32 10, i32 10>
%33 = select <4 x i1> %32, <4 x i32> <i32 48, i32 48, i32 48, i32 48>, <4 x i32> <i32 87, i32 87, i32 87, i32 87>
%34 = add nsw <4 x i32> %33, %31
%35 = trunc <4 x i32> %34 to <4 x i8>
%36 = getelementptr inbounds i8, i8* %3, i64 8
%37 = bitcast i8* %36 to <4 x i8>*
store <4 x i8> %35, <4 x i8>* %37
%38 = fdiv double %19, 3.600000e+01
%39 = tail call double @llvm.floor.f64(double %38)
%40 = fdiv double %39, 3.600000e+01
%41 = tail call double @llvm.floor.f64(double %40)
%42 = fdiv double %41, 3.600000e+01
%43 = tail call double @llvm.floor.f64(double %42)
%44 = fdiv double %43, 3.600000e+01
%45 = tail call double @llvm.floor.f64(double %44)
%46 = insertelement <4 x double> poison, double %45, i64 0
%47 = insertelement <4 x double> %46, double %43, i64 1
%48 = insertelement <4 x double> %47, double %41, i64 2
%49 = insertelement <4 x double> %48, double %39, i64 3
%50 = fneg <4 x double> %49
%51 = insertelement <4 x double> poison, double %43, i64 0
%52 = insertelement <4 x double> %51, double %41, i64 1
%53 = insertelement <4 x double> %52, double %39, i64 2
%54 = insertelement <4 x double> %53, double %19, i64 3
%55 = call <4 x double> @llvm.fmuladd.v4f64(<4 x double> %50, <4 x double> <double 3.600000e+01, double 3.600000e+01, double 3.600000e+01, double 3.600000e+01>, <4 x double> %54)
%56 = call <4 x double> @llvm.floor.v4f64(<4 x double> %55)
%57 = fptosi <4 x double> %56 to <4 x i32>
%58 = icmp slt <4 x i32> %57, <i32 10, i32 10, i32 10, i32 10>
%59 = select <4 x i1> %58, <4 x i32> <i32 48, i32 48, i32 48, i32 48>, <4 x i32> <i32 87, i32 87, i32 87, i32 87>
%60 = add nsw <4 x i32> %59, %57
%61 = trunc <4 x i32> %60 to <4 x i8>
%62 = getelementptr inbounds i8, i8* %3, i64 4
%63 = bitcast i8* %62 to <4 x i8>*
store <4 x i8> %61, <4 x i8>* %63
%64 = add nsw i32 %0, 1455467
%65 = tail call i64 @ldiv(i32 %64, i32 36)
%66 = trunc i64 %65 to i32
%67 = lshr i64 %65, 32
%68 = trunc i64 %67 to i32
%69 = icmp slt i32 %68, 10
%70 = select i1 %69, i32 48, i32 87
%71 = add i32 %70, %68
%72 = trunc i32 %71 to i8
%73 = getelementptr inbounds i8, i8* %3, i64 3
store i8 %72, i8* %73
%74 = tail call i64 @ldiv(i32 %66, i32 36)
%75 = trunc i64 %74 to i32
%76 = lshr i64 %74, 32
%77 = trunc i64 %76 to i32
%78 = icmp slt i32 %77, 10
%79 = select i1 %78, i32 48, i32 87
%80 = add i32 %79, %77
%81 = trunc i32 %80 to i8
%82 = getelementptr inbounds i8, i8* %3, i64 2
store i8 %81, i8* %82
%83 = tail call i64 @ldiv(i32 %75, i32 36)
%84 = trunc i64 %83 to i32
%85 = lshr i64 %83, 32
%86 = trunc i64 %85 to i32
%87 = icmp slt i32 %86, 10
%88 = select i1 %87, i32 48, i32 87
%89 = add i32 %88, %86
%90 = trunc i32 %89 to i8
%91 = getelementptr inbounds i8, i8* %3, i64 1
store i8 %90, i8* %91
%92 = tail call i64 @ldiv(i32 %84, i32 36)
%93 = lshr i64 %92, 32
%94 = trunc i64 %93 to i32
%95 = icmp slt i32 %94, 10
%96 = select i1 %95, i32 48, i32 87
%97 = add i32 %96, %94
%98 = trunc i32 %97 to i8
store i8 %98, i8* %3
ret void
}