// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movb $0x0, 0x17592(%rip)     # 0x26588
movb $0x0, 0x175db(%rip)     # 0x265d8
movq -0x10(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x2c(%rbp)
subl $0x1, %eax
je 0xf01e
jmp 0xf00d
movl -0x2c(%rbp), %eax
subl $0x2, %eax
je 0xf109
jmp 0xf2f1
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movl -0x14(%rbp), %esi
callq 0x123e0
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0xf046
movq $0x0, -0x8(%rbp)
jmp 0xf306
movq -0x20(%rbp), %rsi
addq $0x808, %rsi            # imm = 0x808
leaq 0x17530(%rip), %rdi     # 0x26588
callq 0x30c0
movq -0x20(%rbp), %rsi
addq $0x858, %rsi            # imm = 0x858
leaq 0x17569(%rip), %rdi     # 0x265d8
callq 0x30c0
movq -0x20(%rbp), %rax
movq 0x888(%rax), %rax
movq %rax, 0x17582(%rip)     # 0x26608
movq -0x20(%rbp), %rax
movl 0x884(%rax), %eax
movl %eax, 0x1756e(%rip)     # 0x26604
leaq 0x17573(%rip), %rdi     # 0x26610
leaq 0xd620(%rip), %rsi      # 0x1c6c4
callq 0x30c0
movq -0x20(%rbp), %rax
movb 0x8c8(%rax), %al
movb %al, 0x175a7(%rip)      # 0x26660
movl $0x1, 0x1753d(%rip)     # 0x26600
movl $0x0, 0x1759b(%rip)     # 0x26668
movl $0x0, 0x175f9(%rip)     # 0x266d0
movq -0x20(%rbp), %rsi
addq $0x890, %rsi            # imm = 0x890
leaq 0x1749f(%rip), %rdi     # 0x26588
addq $0x1b0, %rdi            # imm = 0x1B0
movl $0x38, %edx
callq 0x3330
movl $0x0, 0x1766c(%rip)     # 0x26770
jmp 0xf2fb
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
movl -0x14(%rbp), %esi
callq 0x15c30
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0xf131
movq $0x0, -0x8(%rbp)
jmp 0xf306
movl $0x0, 0x174c5(%rip)     # 0x26600
movl $0x0, 0x17523(%rip)     # 0x26668
movl $0x0, 0x17581(%rip)     # 0x266d0
movq -0x28(%rbp), %rax
movq 0x80(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, 0x174a3(%rip)     # 0x26608
movq -0x28(%rbp), %rax
movq 0x80(%rax), %rax
movl 0x10(%rax), %eax
movl %eax, 0x1748b(%rip)     # 0x26604
movq -0x28(%rbp), %rax
movq 0x80(%rax), %rsi
addq $0x14, %rsi
leaq 0x17481(%rip), %rdi     # 0x26610
callq 0x30c0
movq -0x28(%rbp), %rax
movq 0x80(%rax), %rax
movb 0x64(%rax), %al
movb %al, 0x174b8(%rip)      # 0x26660
movl $0x1, 0x1744e(%rip)     # 0x26600
movq -0x28(%rbp), %rax
cmpq $0x0, 0x88(%rax)
je 0xf223
movq -0x28(%rbp), %rax
movq 0x88(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, 0x1749a(%rip)     # 0x26670
movq -0x28(%rbp), %rax
movq 0x88(%rax), %rax
movl 0x10(%rax), %eax
movl %eax, 0x17482(%rip)     # 0x2666c
movq -0x28(%rbp), %rax
movq 0x88(%rax), %rsi
addq $0x14, %rsi
leaq 0x17478(%rip), %rdi     # 0x26678
callq 0x30c0
movq -0x28(%rbp), %rax
movq 0x88(%rax), %rax
movb 0x64(%rax), %al
movb %al, 0x174af(%rip)      # 0x266c8
movl $0x1, 0x17445(%rip)     # 0x26668
movq -0x28(%rbp), %rax
cmpq $0x0, 0x90(%rax)
je 0xf294
movq -0x28(%rbp), %rax
movq 0x90(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, 0x17491(%rip)     # 0x266d8
movq -0x28(%rbp), %rax
movq 0x90(%rax), %rax
movl 0x10(%rax), %eax
movl %eax, 0x17479(%rip)     # 0x266d4
movq -0x28(%rbp), %rax
movq 0x90(%rax), %rsi
addq $0x14, %rsi
leaq 0x1746f(%rip), %rdi     # 0x266e0
callq 0x30c0
movq -0x28(%rbp), %rax
movq 0x90(%rax), %rax
movb 0x64(%rax), %al
movb %al, 0x174a6(%rip)      # 0x26730
movl $0x1, 0x1743c(%rip)     # 0x266d0
movq -0x28(%rbp), %rsi
addq $0x98, %rsi
leaq 0x172e2(%rip), %rdi     # 0x26588
addq $0x1b0, %rdi            # imm = 0x1B0
movl $0x38, %edx
callq 0x3330
movq -0x28(%rbp), %rax
movl 0xd4(%rax), %eax
movl %eax, 0x174a9(%rip)     # 0x26770
movq -0x28(%rbp), %rsi
addq $0x2, %rsi
leaq 0x172b2(%rip), %rdi     # 0x26588
callq 0x30c0
movq -0x28(%rbp), %rsi
addq $0x52, %rsi
leaq 0x172ee(%rip), %rdi     # 0x265d8
callq 0x30c0
jmp 0xf2fb
movq $0x0, -0x8(%rbp)
jmp 0xf306
leaq 0x17286(%rip), %rax     # 0x26588
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x30, %rsp
popq %rbp
retq