// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/modules/cpio.c
// Function: read_header_binary
static int read_header_binary(deark *c, lctx *d, struct member_data *md)
{
	i64 pos;
	i64 n;
	i64 modtime_msw, modtime_lsw;
	i64 modtime_unix;
	i64 filesize_msw, filesize_lsw;
	int retval = 0;
	char timestamp_buf[64];

	pos = md->startpos;

	pos += 2; // c_magic
	pos += 2; // c_dev

	n = dbuf_getu16x(c->infile, pos, md->is_le);
	de_dbg(c, "c_ino: %d", (int)n);
	pos += 2;

	md->mode = dbuf_getu16x(c->infile, pos, md->is_le);
	de_dbg(c, "c_mode: octal(%06o)", (unsigned int)md->mode);
	pos += 2;

	pos += 2; // c_uid
	pos += 2; // c_gid
	pos += 2; // c_nlink
	pos += 2; // c_rdev

	modtime_msw = dbuf_getu16x(c->infile, pos, md->is_le);
	modtime_lsw = dbuf_getu16x(c->infile, pos+2, md->is_le);
	modtime_unix = (modtime_msw<<16) | modtime_lsw;
	de_unix_time_to_timestamp(modtime_unix, &md->fi->timestamp[DE_TIMESTAMPIDX_MODIFY], 0x1);
	de_timestamp_to_string(&md->fi->timestamp[DE_TIMESTAMPIDX_MODIFY], timestamp_buf, sizeof(timestamp_buf), 0);
	de_dbg(c, "c_mtime: %d (%s)", (int)modtime_unix, timestamp_buf);
	pos += 4;

	md->namesize = dbuf_getu16x(c->infile, pos, md->is_le);
	de_dbg(c, "c_namesize: %d", (int)md->namesize);
	pos += 2;

	filesize_msw = dbuf_getu16x(c->infile, pos, md->is_le);
	filesize_lsw = dbuf_getu16x(c->infile, pos+2, md->is_le);
	md->filesize = (filesize_msw<<16) | filesize_lsw;
	de_dbg(c, "c_filesize: %d", (int)md->filesize);
	pos += 4;

	md->fixed_header_size = pos - md->startpos;
	md->namesize_padded = de_pad_to_2(md->namesize);
	md->filesize_padded = de_pad_to_2(md->filesize);

	retval = 1;
	return retval;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x40, %rsp
movq %rsi, %rbx
movq %rdi, %r14
movq 0x8(%rsi), %r13
leaq 0x4(%r13), %rsi
movq 0x18(%rdi), %rdi
movl 0x4(%rbx), %edx
callq 0xe41b1
leaq 0xcf551(%rip), %rsi     # 0x10d390
movq %r14, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
leaq 0x6(%r13), %rsi
movq 0x18(%r14), %rdi
movl 0x4(%rbx), %edx
callq 0xe41b1
movq %rax, 0x38(%rbx)
leaq 0xcf534(%rip), %rsi     # 0x10d39a
movq %r14, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
leaq 0x10(%r13), %rsi
movq 0x18(%r14), %rdi
movl 0x4(%rbx), %edx
callq 0xe41b1
movq %rax, %r15
movq 0x18(%r14), %rdi
leaq 0x12(%r13), %rsi
movl 0x4(%rbx), %edx
callq 0xe41b1
shlq $0x10, %r15
orq %rax, %r15
movq 0x50(%rbx), %rsi
addq $0x18, %rsi
pushq $0x1
popq %rdx
movq %r15, %rdi
callq 0xe002e
movq 0x50(%rbx), %rdi
addq $0x18, %rdi
movq %rsp, %r12
pushq $0x40
popq %rdx
movq %r12, %rsi
xorl %ecx, %ecx
callq 0xe0644
leaq 0xcf4e0(%rip), %rsi     # 0x10d3ae
movq %r14, %rdi
movl %r15d, %edx
movq %r12, %rcx
xorl %eax, %eax
callq 0xde896
leaq 0x14(%r13), %rsi
movq 0x18(%r14), %rdi
movl 0x4(%rbx), %edx
callq 0xe41b1
movq %rax, 0x18(%rbx)
leaq 0xcf4c6(%rip), %rsi     # 0x10d3bf
movq %r14, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
leaq 0x16(%r13), %rsi
movq 0x18(%r14), %rdi
movl 0x4(%rbx), %edx
callq 0xe41b1
movq %rax, %r15
movq 0x18(%r14), %rdi
leaq 0x18(%r13), %rsi
movl 0x4(%rbx), %edx
callq 0xe41b1
shlq $0x10, %r15
orq %rax, %r15
movq %r15, 0x28(%rbx)
leaq 0xcf494(%rip), %rsi     # 0x10d3ce
movq %r14, %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0xde896
subq 0x8(%rbx), %r13
addq $0x1a, %r13
movq %r13, 0x10(%rbx)
movq 0x18(%rbx), %rdi
callq 0xdfb87
movq %rax, 0x20(%rbx)
movq 0x28(%rbx), %rdi
callq 0xdfb87
movq %rax, 0x30(%rbx)
addq $0x40, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
nop