// File: /workspace/github_c_makefile_star2_O3/j-hoppe[P]tu58fs/filesystem.c
// Function: filesystem_file_get
file_t *filesystem_file_get(filesystem_t *_this, int fileidx) {
	static file_t result;

	result.filnam[0] = 0;
	result.ext[0] = 0;
	switch (_this->type) {
	case fsXXDP: {
		xxdp_file_t *f = xxdp_filesystem_file_get(_this->xxdp, fileidx);
		if (!f)
			return NULL;
		strcpy(result.filnam, f->filnam);
		strcpy(result.ext, f->ext);
		result.stream[0].data = f->data;
		result.stream[0].data_size = f->data_size;
		strcpy(result.stream[0].name, ""); // main data
		result.stream[0].changed = f->changed;
		result.stream[0].valid = 1;
		result.stream[1].valid = 0;
		result.stream[2].valid = 0;
		result.date = f->date;
		result.fixed = 0;
	}
		break;
	case fsRT11: {
		rt11_file_t *f = rt11_filesystem_file_get(_this->rt11, fileidx);
		if (!f)
			return NULL;
		result.stream[0].valid = 0;
		result.stream[1].valid = 0;
		result.stream[2].valid = 0;

		// may have 3 streams
		result.stream[0].data = f->data->data;
		result.stream[0].data_size = f->data->data_size;
		strcpy(result.stream[0].name, f->data->name);
		result.stream[0].changed = f->data->changed;
		result.stream[0].valid = 1;
		if (f->prefix) {
			result.stream[1].data = f->prefix->data;
			result.stream[1].data_size = f->prefix->data_size;
			strcpy(result.stream[1].name, f->prefix->name);
			result.stream[1].changed = f->prefix->changed;
			result.stream[1].valid = 1;
		}
		if (f->dir_ext) {
			result.stream[2].data = f->dir_ext->data;
			result.stream[2].data_size = f->dir_ext->data_size;
			strcpy(result.stream[2].name, f->dir_ext->name);
			result.stream[2].changed = f->dir_ext->changed;
			result.stream[2].valid = 1;
		}
		result.date = f->date;
		result.fixed = f->fixed;

		strcpy(result.filnam, f->filnam);
		strcpy(result.ext, f->ext);
	}
		break;
	default:
		return NULL;
	}
	return &result;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
xorl %r14d, %r14d
movb %r14b, 0x139a6(%rip)    # 0x1f288
movb %r14b, 0x139ef(%rip)    # 0x1f2d8
movl (%rdi), %eax
cmpl $0x2, %eax
je 0xb9cd
cmpl $0x1, %eax
jne 0xbb3d
movq 0x8(%rdi), %rdi
callq 0xd8d2
xorl %r14d, %r14d
testq %rax, %rax
je 0xbb3d
movq %rax, %rbx
leaq 0x808(%rax), %rsi
leaq 0x13965(%rip), %r15     # 0x1f288
movq %r15, %rdi
callq 0x30c0
movq %rbx, %rsi
addq $0x858, %rsi            # imm = 0x858
leaq 0x1399c(%rip), %rdi     # 0x1f2d8
callq 0x30c0
movq 0x888(%rbx), %rax
movq %rax, 0x139b9(%rip)     # 0x1f308
movl 0x884(%rbx), %eax
movl %eax, 0x139a9(%rip)     # 0x1f304
movb $0x0, 0x139ae(%rip)     # 0x1f310
movb 0x8c8(%rbx), %al
movb %al, 0x139f2(%rip)      # 0x1f360
movl $0x1, 0x13988(%rip)     # 0x1f300
movl %r14d, 0x139e9(%rip)    # 0x1f368
movl %r14d, 0x13a4a(%rip)    # 0x1f3d0
movq 0x8c0(%rbx), %rax
movq %rax, 0x13ad4(%rip)     # 0x1f468
movups 0x890(%rbx), %xmm0
movups 0x8a0(%rbx), %xmm1
movups 0x8b0(%rbx), %xmm2
movups %xmm2, 0x13aa8(%rip)    # 0x1f458
movups %xmm1, 0x13a91(%rip)    # 0x1f448
movups %xmm0, 0x13a7a(%rip)    # 0x1f438
movl %r14d, 0x13aab(%rip)    # 0x1f470
movq %r15, %r14
jmp 0xbb3d
movq 0x10(%rdi), %rdi
callq 0xff5c
xorl %r14d, %r14d
testq %rax, %rax
je 0xbb3d
movq %rax, %rbx
movl %r14d, 0x13914(%rip)    # 0x1f300
movl %r14d, 0x13975(%rip)    # 0x1f368
movl %r14d, 0x139d6(%rip)    # 0x1f3d0
movq 0x80(%rax), %rsi
movq 0x8(%rsi), %rax
movq %rax, 0x138fc(%rip)     # 0x1f308
movl 0x10(%rsi), %eax
movl %eax, 0x138ef(%rip)     # 0x1f304
addq $0x14, %rsi
leaq 0x138f0(%rip), %rdi     # 0x1f310
callq 0x30c0
movq 0x80(%rbx), %rax
movb 0x64(%rax), %al
movb %al, 0x1392b(%rip)      # 0x1f360
movl $0x1, 0x138c1(%rip)     # 0x1f300
movq 0x88(%rbx), %rsi
testq %rsi, %rsi
je 0xba89
movq 0x8(%rsi), %rax
movq %rax, 0x1391a(%rip)     # 0x1f370
movl 0x10(%rsi), %eax
movl %eax, 0x1390d(%rip)     # 0x1f36c
addq $0x14, %rsi
leaq 0x1390e(%rip), %rdi     # 0x1f378
callq 0x30c0
movq 0x88(%rbx), %rax
movb 0x64(%rax), %al
movb %al, 0x13949(%rip)      # 0x1f3c8
movl $0x1, 0x138df(%rip)     # 0x1f368
movq 0x90(%rbx), %rsi
testq %rsi, %rsi
je 0xbad3
movq 0x8(%rsi), %rax
movq %rax, 0x13938(%rip)     # 0x1f3d8
movl 0x10(%rsi), %eax
movl %eax, 0x1392b(%rip)     # 0x1f3d4
addq $0x14, %rsi
leaq 0x1392c(%rip), %rdi     # 0x1f3e0
callq 0x30c0
movq 0x90(%rbx), %rax
movb 0x64(%rax), %al
movb %al, 0x13967(%rip)      # 0x1f430
movl $0x1, 0x138fd(%rip)     # 0x1f3d0
movq 0xc8(%rbx), %rax
movq %rax, 0x13987(%rip)     # 0x1f468
movups 0x98(%rbx), %xmm0
movups 0xa8(%rbx), %xmm1
movups 0xb8(%rbx), %xmm2
movups %xmm2, 0x1395b(%rip)    # 0x1f458
movups %xmm1, 0x13944(%rip)    # 0x1f448
movups %xmm0, 0x1392d(%rip)    # 0x1f438
leaq 0x13776(%rip), %r14     # 0x1f288
movl 0xd4(%rbx), %eax
movl %eax, 0x13952(%rip)     # 0x1f470
leaq 0x2(%rbx), %rsi
movq %r14, %rdi
callq 0x30c0
addq $0x52, %rbx
leaq 0x137a3(%rip), %rdi     # 0x1f2d8
movq %rbx, %rsi
callq 0x30c0
movq %r14, %rax
popq %rbx
popq %r14
popq %r15
retq