// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq %r8, -0x28(%rbp)
movl $0x0, -0x84(%rbp)
movq -0x10(%rbp), %rax
movb $0x0, (%rax)
cmpl $0x1, -0x1c(%rbp)
je 0x17c5bb
cmpl $0x2, -0x1c(%rbp)
jne 0x17c622
cmpl $0x2, -0x1c(%rbp)
jne 0x17c5e2
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x28(%rbp), %rax
movq (%rax), %rsi
movq -0x8(%rbp), %rax
movl 0x10(%rax), %edx
callq 0x1658c0
movq %rax, -0x30(%rbp)
jmp 0x17c601
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x28(%rbp), %rax
movq (%rax), %rsi
movq -0x8(%rbp), %rax
movl 0x10(%rax), %edx
callq 0x165910
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl $0x1, %edx
callq 0x15d530
movl $0x1, -0x84(%rbp)
jmp 0x17c766
cmpl $0x3, -0x1c(%rbp)
je 0x17c638
cmpl $0x4, -0x1c(%rbp)
je 0x17c638
cmpl $0x5, -0x1c(%rbp)
jne 0x17c718
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x28(%rbp), %rax
movq (%rax), %rsi
movq -0x8(%rbp), %rax
movl 0x10(%rax), %edx
callq 0x165820
movq %rax, -0x30(%rbp)
cmpl $0x5, -0x1c(%rbp)
jne 0x17c682
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x28(%rbp), %rax
movq (%rax), %rsi
addq $0x4, %rsi
movq -0x8(%rbp), %rax
movl 0x10(%rax), %edx
callq 0x165820
movq %rax, -0x38(%rbp)
jmp 0x17c6a5
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x28(%rbp), %rax
movq (%rax), %rsi
addq $0x2, %rsi
movq -0x8(%rbp), %rax
movl 0x10(%rax), %edx
callq 0x165820
movq %rax, -0x38(%rbp)
cmpl $0x4, -0x1c(%rbp)
jne 0x17c6c3
movq -0x38(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x98(%rbp)
jmp 0x17c6d9
movq -0x30(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x98(%rbp)
cmpq $0x0, -0x98(%rbp)
jne 0x17c6ed
cmpq $0x0, -0x90(%rbp)
je 0x17c716
movl $0x1, -0x84(%rbp)
movq -0x10(%rbp), %rdi
movq -0x90(%rbp), %rsi
movq -0x98(%rbp), %rdx
callq 0x15d750
movq -0x10(%rbp), %rax
movb $0x2, 0x1(%rax)
jmp 0x17c764
cmpl $0x6, -0x1c(%rbp)
jne 0x17c762
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x28(%rbp), %rax
movq (%rax), %rsi
movq -0x8(%rbp), %rax
movl 0x10(%rax), %edx
callq 0x165960
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x17c760
movq -0x30(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl $0x1, %edx
callq 0x15d580
movl $0x1, -0x84(%rbp)
jmp 0x17c762
jmp 0x17c764
jmp 0x17c766
cmpl $0x0, -0x84(%rbp)
je 0x17c785
movq -0x10(%rbp), %rdi
leaq -0x80(%rbp), %rsi
movl $0x40, %edx
xorl %ecx, %ecx
callq 0x15e130
jmp 0x17c79c
leaq -0x80(%rbp), %rdi
movl $0x40, %esi
leaq 0x4140e(%rip), %rdx     # 0x1bdba3
movb $0x0, %al
callq 0x15a980
movq -0x8(%rbp), %rax
movq (%rax), %rdi
movq -0x18(%rbp), %rdx
leaq -0x80(%rbp), %rcx
leaq 0x27a91(%rip), %rsi     # 0x1a4243
movb $0x0, %al
callq 0x15b0d0
cmpl $0x6, -0x1c(%rbp)
je 0x17c7c5
cmpl $0x5, -0x1c(%rbp)
jne 0x17c7d5
movq -0x28(%rbp), %rax
movq (%rax), %rcx
addq $0x8, %rcx
movq %rcx, (%rax)
jmp 0x17c7e3
movq -0x28(%rbp), %rax
movq (%rax), %rcx
addq $0x4, %rcx
movq %rcx, (%rax)
addq $0xa0, %rsp
popq %rbp
retq
nopl (%rax)