// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/src/fmtutil-arch.c
// Function: de_arch_read_field_dttm_p
void de_arch_read_field_dttm_p(de_arch_lctx *d,
	struct de_timestamp *ts, const char *name,
	enum de_arch_tstype_enum tstype, i64 *ppos)
{
	i64 n1, n2;
	char timestamp_buf[64];
	int is_set = 0;

	ts->is_valid = 0;
	if(tstype==DE_ARCH_TSTYPE_UNIX || tstype==DE_ARCH_TSTYPE_UNIX_U) {
		if(tstype==DE_ARCH_TSTYPE_UNIX_U) {
			n1 = dbuf_getu32x(d->inf, *ppos, d->is_le);
		}
		else {
			n1 = dbuf_geti32x(d->inf, *ppos, d->is_le);
		}
		de_unix_time_to_timestamp(n1, ts, 0x1);
		is_set = 1;
	}
	else if(tstype==DE_ARCH_TSTYPE_DOS_DT || tstype==DE_ARCH_TSTYPE_DOS_TD ||
		tstype==DE_ARCH_TSTYPE_DOS_DXT)
	{
		i64 dosdt, dostm;

		n1 = dbuf_getu16x(d->inf, *ppos, d->is_le);
		if(tstype==DE_ARCH_TSTYPE_DOS_DXT) {
			// Date, then 2 unused bytes, then time.
			n2 = dbuf_getu16x(d->inf, *ppos+4, d->is_le);
		}
		else {
			n2 = dbuf_getu16x(d->inf, *ppos+2, d->is_le);
		}

		if(tstype==DE_ARCH_TSTYPE_DOS_TD) {
			dosdt = n2;
			dostm = n1;
		}
		else {
			dosdt = n1;
			dostm = n2;
		}

		if(dostm!=0 || dosdt!=0) {
			is_set = 1;
			de_dos_datetime_to_timestamp(ts, dosdt, dostm);
			ts->tzcode = DE_TZCODE_LOCAL;
		}
	}
	else if(tstype==DE_ARCH_TSTYPE_FILETIME) {
		n1 = dbuf_geti64x(d->inf, *ppos, d->is_le);
		if(n1!=0) {
			de_FILETIME_to_timestamp(n1, ts, 0x1);
			is_set = 1;
		}
	}

	if(is_set) {
		de_timestamp_to_string(ts, timestamp_buf, sizeof(timestamp_buf), 0);
	}
	else {
		de_snprintf(timestamp_buf, sizeof(timestamp_buf), "[not set]");
	}
	de_dbg(d->c, "%s time: %s", name, timestamp_buf);

	if(tstype==DE_ARCH_TSTYPE_FILETIME || tstype==DE_ARCH_TSTYPE_DOS_DXT) {
		*ppos += 8;
	}
	else {
		*ppos += 4;
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %r8, %rbx
movl %ecx, %r14d
movq %rdx, %r15
movq %rsi, %r13
movq %rdi, %r12
movb $0x0, (%rsi)
leal -0x1(%r14), %eax
cmpl $0x1, %eax
ja 0xf18ad
movq 0x8(%r12), %rdi
movq (%rbx), %rsi
movl 0x10(%r12), %edx
cmpl $0x2, %r14d
jne 0xf1927
callq 0xe41cb
jmp 0xf192c
leal -0x3(%r14), %eax
cmpl $0x2, %eax
ja 0xf194e
movq %r15, 0x8(%rsp)
xorl %r15d, %r15d
cmpl $0x5, %r14d
sete %r15b
movq 0x8(%r12), %rdi
movq (%rbx), %rsi
movl 0x10(%r12), %edx
callq 0xe41b1
movq %rax, %rbp
movq 0x8(%r12), %rdi
movq (%rbx), %rax
movl 0x10(%r12), %edx
leaq (%rax,%r15,2), %rsi
addq $0x2, %rsi
movq 0x8(%rsp), %r15
callq 0xe41b1
cmpl $0x4, %r14d
movq %rbp, %rsi
cmoveq %rax, %rsi
cmoveq %rbp, %rax
movq %rax, %rcx
orq %rsi, %rcx
je 0xf197b
movq %r13, %rdi
movq %rax, %rdx
callq 0xe0110
movb $0x2, 0x1(%r13)
jmp 0xf193a
callq 0xe41d8
pushq $0x1
popq %rdx
movq %rax, %rdi
movq %r13, %rsi
callq 0xe002e
leaq 0x10(%rsp), %rsi
pushq $0x40
popq %rdx
movq %r13, %rdi
xorl %ecx, %ecx
callq 0xe0644
jmp 0xf1991
cmpl $0x6, %r14d
jne 0xf197b
movq 0x8(%r12), %rdi
movq (%rbx), %rsi
movl 0x10(%r12), %edx
callq 0xe41e5
testq %rax, %rax
je 0xf197b
pushq $0x1
popq %rdx
movq %rax, %rdi
movq %r13, %rsi
callq 0xe0051
jmp 0xf193a
leaq 0x3357e(%rip), %rdx     # 0x124f00
leaq 0x10(%rsp), %rdi
pushq $0x40
popq %rsi
xorl %eax, %eax
callq 0xde40c
movq (%r12), %rdi
leaq 0x19a9a(%rip), %rsi     # 0x10b436
leaq 0x10(%rsp), %rcx
movq %r15, %rdx
xorl %eax, %eax
callq 0xde896
addl $-0x5, %r14d
xorl %eax, %eax
cmpl $0x2, %r14d
setb %al
movq (%rbx), %rcx
leaq (%rcx,%rax,4), %rax
addq $0x4, %rax
movq %rax, (%rbx)
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq