// File: /workspace/github_c_makefile_star2_O1/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 %r14
pushq %rbx
pushq %rax
xorl %r14d, %r14d
movb %r14b, 0x1393f(%rip)    # 0x1f298
movb %r14b, 0x13988(%rip)    # 0x1f2e8
movl (%rdi), %eax
cmpl $0x2, %eax
je 0xba3e
cmpl $0x1, %eax
jne 0xbbb4
movq 0x8(%rdi), %rdi
callq 0xd9fd
xorl %r14d, %r14d
testq %rax, %rax
je 0xbbb4
movq %rax, %rbx
leaq 0x808(%rax), %rsi
leaq 0x138fe(%rip), %rdi     # 0x1f298
callq 0x30d0
movq %rbx, %rsi
addq $0x858, %rsi            # imm = 0x858
leaq 0x13938(%rip), %rdi     # 0x1f2e8
callq 0x30d0
movq 0x888(%rbx), %rax
movq %rax, 0x13955(%rip)     # 0x1f318
movl 0x884(%rbx), %eax
movl %eax, 0x13945(%rip)     # 0x1f314
movb $0x0, 0x1394a(%rip)     # 0x1f320
movb 0x8c8(%rbx), %al
movb %al, 0x1398e(%rip)      # 0x1f370
movl $0x1, 0x13924(%rip)     # 0x1f310
movl %r14d, 0x13985(%rip)    # 0x1f378
movl %r14d, 0x139e6(%rip)    # 0x1f3e0
movq 0x8c0(%rbx), %rax
movq %rax, 0x13a70(%rip)     # 0x1f478
movups 0x890(%rbx), %xmm0
movups 0x8a0(%rbx), %xmm1
movups 0x8b0(%rbx), %xmm2
movups %xmm2, 0x13a44(%rip)    # 0x1f468
movups %xmm1, 0x13a2d(%rip)    # 0x1f458
movups %xmm0, 0x13a16(%rip)    # 0x1f448
movl %r14d, 0x13a47(%rip)    # 0x1f480
jmp 0xbbad
movq 0x10(%rdi), %rdi
callq 0xfff3
xorl %r14d, %r14d
testq %rax, %rax
je 0xbbb4
movq %rax, %rbx
movl %r14d, 0x138b3(%rip)    # 0x1f310
movl %r14d, 0x13914(%rip)    # 0x1f378
movl %r14d, 0x13975(%rip)    # 0x1f3e0
movq 0x80(%rax), %rsi
movq 0x8(%rsi), %rax
movq %rax, 0x1389b(%rip)     # 0x1f318
movl 0x10(%rsi), %eax
movl %eax, 0x1388e(%rip)     # 0x1f314
addq $0x14, %rsi
leaq 0x1388f(%rip), %rdi     # 0x1f320
callq 0x30d0
movq 0x80(%rbx), %rax
movb 0x64(%rax), %al
movb %al, 0x138ca(%rip)      # 0x1f370
movl $0x1, 0x13860(%rip)     # 0x1f310
movq 0x88(%rbx), %rsi
testq %rsi, %rsi
je 0xbafa
movq 0x8(%rsi), %rax
movq %rax, 0x138b9(%rip)     # 0x1f380
movl 0x10(%rsi), %eax
movl %eax, 0x138ac(%rip)     # 0x1f37c
addq $0x14, %rsi
leaq 0x138ad(%rip), %rdi     # 0x1f388
callq 0x30d0
movq 0x88(%rbx), %rax
movb 0x64(%rax), %al
movb %al, 0x138e8(%rip)      # 0x1f3d8
movl $0x1, 0x1387e(%rip)     # 0x1f378
movq 0x90(%rbx), %rsi
testq %rsi, %rsi
je 0xbb44
movq 0x8(%rsi), %rax
movq %rax, 0x138d7(%rip)     # 0x1f3e8
movl 0x10(%rsi), %eax
movl %eax, 0x138ca(%rip)     # 0x1f3e4
addq $0x14, %rsi
leaq 0x138cb(%rip), %rdi     # 0x1f3f0
callq 0x30d0
movq 0x90(%rbx), %rax
movb 0x64(%rax), %al
movb %al, 0x13906(%rip)      # 0x1f440
movl $0x1, 0x1389c(%rip)     # 0x1f3e0
movq 0xc8(%rbx), %rax
movq %rax, 0x13926(%rip)     # 0x1f478
movups 0x98(%rbx), %xmm0
movups 0xa8(%rbx), %xmm1
movups 0xb8(%rbx), %xmm2
movups %xmm2, 0x138fa(%rip)    # 0x1f468
movups %xmm1, 0x138e3(%rip)    # 0x1f458
movups %xmm0, 0x138cc(%rip)    # 0x1f448
leaq 0x13715(%rip), %rdi     # 0x1f298
movl 0xd4(%rbx), %eax
movl %eax, 0x138f1(%rip)     # 0x1f480
leaq 0x2(%rbx), %rsi
callq 0x30d0
leaq 0x52(%rbx), %rsi
leaq 0x13745(%rip), %rdi     # 0x1f2e8
callq 0x30d0
testq %rbx, %rbx
je 0xbbbf
leaq 0x136e4(%rip), %r14     # 0x1f298
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
xorl %r14d, %r14d
jmp 0xbbb4