// File: /workspace/github_c_makefile_star2_O2/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, 0x1439f(%rip)    # 0x1f288
movb %r14b, 0x143e8(%rip)    # 0x1f2d8
movl (%rdi), %eax
cmpl $0x2, %eax
je 0xafce
cmpl $0x1, %eax
jne 0xb140
movq 0x8(%rdi), %rdi
callq 0xcd50
testq %rax, %rax
je 0xb13d
movq %rax, %rbx
leaq 0x808(%rax), %rsi
leaq 0x14361(%rip), %r14     # 0x1f288
movq %r14, %rdi
callq 0x30c0
movq %rbx, %rsi
addq $0x858, %rsi            # imm = 0x858
leaq 0x14398(%rip), %rdi     # 0x1f2d8
callq 0x30c0
movq 0x888(%rbx), %rax
movq %rax, 0x143b5(%rip)     # 0x1f308
movl 0x884(%rbx), %eax
movl %eax, 0x143a5(%rip)     # 0x1f304
movb $0x0, 0x143aa(%rip)     # 0x1f310
movb 0x8c8(%rbx), %al
movb %al, 0x143ee(%rip)      # 0x1f360
movl $0x1, 0x14384(%rip)     # 0x1f300
andl $0x0, 0x143e5(%rip)     # 0x1f368
andl $0x0, 0x14446(%rip)     # 0x1f3d0
movq 0x8c0(%rbx), %rax
movq %rax, 0x144d0(%rip)     # 0x1f468
movups 0x890(%rbx), %xmm0
movups 0x8a0(%rbx), %xmm1
movups 0x8b0(%rbx), %xmm2
movups %xmm2, 0x144a4(%rip)    # 0x1f458
movups %xmm1, 0x1448d(%rip)    # 0x1f448
movups %xmm0, 0x14476(%rip)    # 0x1f438
andl $0x0, 0x144a7(%rip)     # 0x1f470
jmp 0xb140
movq 0x10(%rdi), %rdi
callq 0xef22
testq %rax, %rax
je 0xb13d
movq %rax, %rbx
andl $0x0, 0x14316(%rip)     # 0x1f300
andl $0x0, 0x14377(%rip)     # 0x1f368
andl $0x0, 0x143d8(%rip)     # 0x1f3d0
movq 0x80(%rax), %rsi
movq 0x8(%rsi), %rax
movq %rax, 0x142fe(%rip)     # 0x1f308
movl 0x10(%rsi), %eax
movl %eax, 0x142f1(%rip)     # 0x1f304
addq $0x14, %rsi
leaq 0x142f2(%rip), %rdi     # 0x1f310
callq 0x30c0
movq 0x80(%rbx), %rax
movb 0x64(%rax), %al
movb %al, 0x1432d(%rip)      # 0x1f360
movl $0x1, 0x142c3(%rip)     # 0x1f300
movq 0x88(%rbx), %rsi
testq %rsi, %rsi
je 0xb087
movq 0x8(%rsi), %rax
movq %rax, 0x1431c(%rip)     # 0x1f370
movl 0x10(%rsi), %eax
movl %eax, 0x1430f(%rip)     # 0x1f36c
addq $0x14, %rsi
leaq 0x14310(%rip), %rdi     # 0x1f378
callq 0x30c0
movq 0x88(%rbx), %rax
movb 0x64(%rax), %al
movb %al, 0x1434b(%rip)      # 0x1f3c8
movl $0x1, 0x142e1(%rip)     # 0x1f368
movq 0x90(%rbx), %rsi
testq %rsi, %rsi
je 0xb0d1
movq 0x8(%rsi), %rax
movq %rax, 0x1433a(%rip)     # 0x1f3d8
movl 0x10(%rsi), %eax
movl %eax, 0x1432d(%rip)     # 0x1f3d4
addq $0x14, %rsi
leaq 0x1432e(%rip), %rdi     # 0x1f3e0
callq 0x30c0
movq 0x90(%rbx), %rax
movb 0x64(%rax), %al
movb %al, 0x14369(%rip)      # 0x1f430
movl $0x1, 0x142ff(%rip)     # 0x1f3d0
movq 0xc8(%rbx), %rax
movq %rax, 0x14389(%rip)     # 0x1f468
movups 0x98(%rbx), %xmm0
movups 0xa8(%rbx), %xmm1
movups 0xb8(%rbx), %xmm2
movups %xmm2, 0x1435d(%rip)    # 0x1f458
movups %xmm1, 0x14346(%rip)    # 0x1f448
movups %xmm0, 0x1432f(%rip)    # 0x1f438
leaq 0x14178(%rip), %r14     # 0x1f288
movl 0xd4(%rbx), %eax
movl %eax, 0x14354(%rip)     # 0x1f470
leaq 0x2(%rbx), %rsi
movq %r14, %rdi
callq 0x30c0
addq $0x52, %rbx
leaq 0x141a5(%rip), %rdi     # 0x1f2d8
movq %rbx, %rsi
callq 0x30c0
jmp 0xb140
xorl %r14d, %r14d
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq