// File: /workspace/github_c_makefile_star2_O0/QwazyWabbitWOS[P]lmctf60/g_save.c
// Function: ReadField
void ReadField(FILE* f, field_t* field, byte* base)
{
	void* p;
	int			len;
	int			index;

	if (field->flags & FFL_SPAWNTEMP)
		return;

	p = (void*)(base + field->ofs);
	switch (field->type)
	{
	case F_INT:
	case F_FLOAT:
	case F_ANGLEHACK:
	case F_VECTOR:
	case F_IGNORE:
		break;

	case F_LSTRING:
		len = *(int*)p;
		if (!len)
			*(char**)p = NULL;
		else
		{
			*(char**)p = gi.TagMalloc(len, TAG_LEVEL);
			size_t count = fread(*(char**)p, len, 1, f);
			if (count)
				; // don't worry, be happy
		}
		break;
	case F_EDICT:
		index = *(int*)p;
		if (index == -1)
			*(edict_t**)p = NULL;
		else
			*(edict_t**)p = &g_edicts[index];
		break;
	case F_CLIENT:
		index = *(int*)p;
		if (index == -1)
			*(gclient_t**)p = NULL;
		else
			*(gclient_t**)p = &game.clients[index];
		break;
	case F_ITEM:
		index = *(int*)p;
		if (index == -1)
			*(gitem_t**)p = NULL;
		else
			*(gitem_t**)p = &itemlist[index];
		break;

		//relative to code segment
	case F_FUNCTION:
		index = *(int*)p;
		if (index == 0)
			*(byte**)p = NULL;
		else
			*(byte**)p = ((byte*)InitGame) + index;
		break;

		//relative to data segment
	case F_MMOVE:
		index = *(int*)p;
		if (index == 0)
			*(byte**)p = NULL;
		else
			*(byte**)p = (byte*)&mmove_reloc + index;
		break;

	default:
		gi.error("ReadEdict: unknown field type");
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x10(%rbp), %rax
movl 0x10(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x49768
jmp 0x4994b
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
movslq 0x8(%rcx), %rcx
addq %rcx, %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movl 0xc(%rax), %eax
movq %rax, -0x38(%rbp)
subq $0xb, %rax
ja 0x49938
movq -0x38(%rbp), %rax
leaq 0x2b065(%rip), %rcx     # 0x74800
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
jmp 0x4994b
movq -0x20(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
jne 0x497c5
movq -0x20(%rbp), %rax
movq $0x0, (%rax)
jmp 0x4980f
movq 0x38e34(%rip), %rax     # 0x82600
movq 0x108(%rax), %rax
movl -0x24(%rbp), %edi
movl $0x2fe, %esi            # imm = 0x2FE
callq *%rax
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movq -0x20(%rbp), %rax
movq (%rax), %rdi
movslq -0x24(%rbp), %rsi
movq -0x8(%rbp), %rcx
movl $0x1, %edx
callq 0x18430
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x4980d
jmp 0x4980d
jmp 0x4980f
jmp 0x4994b
movq -0x20(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x28(%rbp)
cmpl $-0x1, -0x28(%rbp)
jne 0x49830
movq -0x20(%rbp), %rax
movq $0x0, (%rax)
jmp 0x4984f
movq 0x38d21(%rip), %rax     # 0x82558
movq (%rax), %rcx
movslq -0x28(%rbp), %rax
imulq $0x4a8, %rax, %rax      # imm = 0x4A8
addq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
jmp 0x4994b
movq -0x20(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x28(%rbp)
cmpl $-0x1, -0x28(%rbp)
jne 0x49870
movq -0x20(%rbp), %rax
movq $0x0, (%rax)
jmp 0x49893
movq 0x394c9(%rip), %rax     # 0x82d40
movq 0x408(%rax), %rcx
movslq -0x28(%rbp), %rax
imulq $0x9140, %rax, %rax     # imm = 0x9140
addq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
jmp 0x4994b
movq -0x20(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x28(%rbp)
cmpl $-0x1, -0x28(%rbp)
jne 0x498b4
movq -0x20(%rbp), %rax
movq $0x0, (%rax)
jmp 0x498d0
movslq -0x28(%rbp), %rax
movq 0x39581(%rip), %rcx     # 0x82e40
imulq $0x88, %rax, %rax
addq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
jmp 0x4994b
movq -0x20(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x28(%rbp)
cmpl $0x0, -0x28(%rbp)
jne 0x498ee
movq -0x20(%rbp), %rax
movq $0x0, (%rax)
jmp 0x49903
movslq -0x28(%rbp), %rax
movq 0x38d8f(%rip), %rcx     # 0x82688
addq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
jmp 0x4994b
movq -0x20(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x28(%rbp)
cmpl $0x0, -0x28(%rbp)
jne 0x49921
movq -0x20(%rbp), %rax
movq $0x0, (%rax)
jmp 0x49936
movslq -0x28(%rbp), %rax
movq 0x3905c(%rip), %rcx     # 0x82988
addq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
jmp 0x4994b
leaq 0x2b454(%rip), %rdi     # 0x74d93
movq 0x38cba(%rip), %rcx     # 0x82600
movb $0x0, %al
callq *0x38(%rcx)
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)