// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/src/deark-util.c
// Function: de_timestamp_to_string
char *de_timestamp_to_string(const struct de_timestamp *ts,
	char *buf, size_t buf_len, unsigned int flags)
{
	const char *tzlabel;
	char subsec[16];
	struct de_struct_tm tm2;

	if(!ts->is_valid) {
		de_strlcpy(buf, "[invalid timestamp]", buf_len);
		goto done;
	}

	de_gmtime(ts, &tm2);
	if(!tm2.is_valid) {
		de_snprintf(buf, buf_len, "[timestamp out of range: %"I64_FMT"]",
			de_timestamp_to_unix_time(ts));
		goto done;
	}

	if(ts->precision>DE_TSPREC_1SEC) {
		unsigned int ms;
		ms = (unsigned int)(tm2.tm_subsec/10000);
		if(ms>=1000) ms=999;
		de_snprintf(subsec, sizeof(subsec), ".%03u", ms);
	}
	else {
		subsec[0] = '\0';
	}

	tzlabel = (ts->tzcode==DE_TZCODE_UTC)?" UTC":"";
	if(ts->precision!=DE_TSPREC_UNKNOWN && ts->precision<=DE_TSPREC_1DAY) { // date only
		de_snprintf(buf, buf_len, "%04d-%02d-%02d",
			tm2.tm_fullyear, 1+tm2.tm_mon, tm2.tm_mday);
		goto done;
	}
	de_snprintf(buf, buf_len, "%04d-%02d-%02d %02d:%02d:%02d%s%s",
		tm2.tm_fullyear, 1+tm2.tm_mon, tm2.tm_mday,
		tm2.tm_hour, tm2.tm_min, tm2.tm_sec, subsec, tzlabel);
done:
	return buf;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0xa0, %rsp
movq %rdi, -0x18(%rbp)
movq %rsi, -0x20(%rbp)
movq %rdx, -0x28(%rbp)
movl %ecx, -0x2c(%rbp)
movq -0x18(%rbp), %rax
cmpb $0x0, (%rax)
jne 0x15e16f
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rdx
leaq 0x73e58(%rip), %rsi     # 0x1d1fbd
callq 0x15aa30
jmp 0x15e2bb
movq -0x18(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x15de50
cmpl $0x0, -0x70(%rbp)
jne 0x15e1bf
movq -0x20(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x18(%rbp), %rdi
callq 0x15dd00
movq -0x88(%rbp), %rdi
movq -0x80(%rbp), %rsi
movq %rax, %rcx
leaq 0x73e1e(%rip), %rdx     # 0x1d1fd1
movb $0x0, %al
callq 0x15a980
jmp 0x15e2bb
movq -0x18(%rbp), %rax
movzbl 0x2(%rax), %eax
cmpl $0x1e, %eax
jle 0x15e206
movl -0x54(%rbp), %eax
movl $0x2710, %ecx           # imm = 0x2710
cltd
idivl %ecx
movl %eax, -0x74(%rbp)
cmpl $0x3e8, -0x74(%rbp)     # imm = 0x3E8
jb 0x15e1ea
movl $0x3e7, -0x74(%rbp)     # imm = 0x3E7
leaq -0x50(%rbp), %rdi
movl -0x74(%rbp), %ecx
movl $0x10, %esi
leaq 0x73df2(%rip), %rdx     # 0x1d1fef
movb $0x0, %al
callq 0x15a980
jmp 0x15e20a
movb $0x0, -0x50(%rbp)
movq -0x18(%rbp), %rax
movzbl 0x1(%rax), %edx
leaq 0x729b7(%rip), %rax     # 0x1d0bd0
leaq 0x727b2(%rip), %rcx     # 0x1d09d2
cmpl $0x1, %edx
cmoveq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x18(%rbp), %rax
movzbl 0x2(%rax), %eax
cmpl $0x0, %eax
je 0x15e26c
movq -0x18(%rbp), %rax
movzbl 0x2(%rax), %eax
cmpl $0xa, %eax
jg 0x15e26c
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
movl -0x6c(%rbp), %ecx
movl -0x68(%rbp), %r8d
addl $0x1, %r8d
movl -0x64(%rbp), %r9d
leaq 0x73d92(%rip), %rdx     # 0x1d1ff5
movb $0x0, %al
callq 0x15a980
jmp 0x15e2bb
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
movl -0x6c(%rbp), %ecx
movl -0x68(%rbp), %r8d
addl $0x1, %r8d
movl -0x64(%rbp), %r9d
movl -0x60(%rbp), %r14d
movl -0x5c(%rbp), %ebx
movl -0x58(%rbp), %r11d
leaq -0x50(%rbp), %r10
movq -0x38(%rbp), %rax
leaq 0x73d67(%rip), %rdx     # 0x1d2004
movl %r14d, (%rsp)
movl %ebx, 0x8(%rsp)
movl %r11d, 0x10(%rsp)
movq %r10, 0x18(%rsp)
movq %rax, 0x20(%rsp)
movb $0x0, %al
callq 0x15a980
movq -0x20(%rbp), %rax
addq $0xa0, %rsp
popq %rbx
popq %r14
popq %rbp
retq
nopl (%rax,%rax)