// File: /workspace/github_c_makefile_star2_O3/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 0xfd67f
movq 0x8(%r12), %rdi
movq (%rbx), %rsi
movl 0x10(%r12), %edx
cmpl $0x2, %r14d
jne 0xfd6f9
callq 0xeeff3
jmp 0xfd6fe
leal -0x3(%r14), %eax
cmpl $0x2, %eax
ja 0xfd724
movq %r15, 0x8(%rsp)
xorl %r15d, %r15d
cmpl $0x5, %r14d
sete %r15b
movq 0x8(%r12), %rdi
movq (%rbx), %rsi
movl 0x10(%r12), %edx
callq 0xeef43
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 0xeef43
cmpl $0x4, %r14d
movq %rbp, %rsi
cmoveq %rax, %rsi
cmoveq %rbp, %rax
movq %rax, %rcx
orq %rsi, %rcx
je 0xfd753
movq %r13, %rdi
movq %rax, %rdx
callq 0xea92a
movb $0x2, 0x1(%r13)
jmp 0xfd70e
callq 0xef033
movq %rax, %rdi
movq %r13, %rsi
movl $0x1, %edx
callq 0xea7f5
leaq 0x10(%rsp), %rsi
movl $0x40, %edx
movq %r13, %rdi
xorl %ecx, %ecx
callq 0xeaf46
jmp 0xfd76b
cmpl $0x6, %r14d
jne 0xfd753
movq 0x8(%r12), %rdi
movq (%rbx), %rsi
movl 0x10(%r12), %edx
callq 0xef065
testq %rax, %rax
je 0xfd753
movq %rax, %rdi
movq %r13, %rsi
movl $0x1, %edx
callq 0xea829
jmp 0xfd70e
leaq 0x34a92(%rip), %rdx     # 0x1321ec
leaq 0x10(%rsp), %rdi
movl $0x40, %esi
xorl %eax, %eax
callq 0xe8193
movq (%r12), %rdi
leaq 0x1adb0(%rip), %rsi     # 0x118526
leaq 0x10(%rsp), %rcx
movq %r15, %rdx
xorl %eax, %eax
callq 0xe8617
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