// File: /workspace/github_c_makefile_star2_O3/rafa9811[P]theIndiependenceGame/background.c
// Function: inventory_load
Inventory* inventory_load(char*filename){
	Object* Oaux;
	Inventory* inv;
	FILE *in;
	char buff[1024];
	int i=0;

	char name[256];
	int id,roomid,px,py,uses,motivation,danger,chaos,money;
	short npc,ispick,onoff,meeting;

	if(!filename) return NULL;

	inv=(Inventory*)malloc(sizeof(Inventory));
	if(!inv) return NULL;
	in = (FILE*) fopen(filename, "r");
	if(!in){
		free(inv);
		return NULL;
	}

    Oaux=object_ini();
    if(!Oaux){
		fclose(in);
		free(inv);
		return NULL;
	}

	inv->inv=(Object**)malloc(sizeof(Object*)*MAX_INV);

    while(!feof(in)){
			fgets(buff,1024,in);
      if(14 != sscanf(buff,"%[^\t]%d\t%d\t%d\t%d\t%hd\t%hd\t%hd\t%hd\t%d\t%d\t%d\t%d\t%d",name,&id,&roomid,&px,&py,&npc,&meeting,&ispick,&onoff,&uses,&motivation,&danger,&chaos,&money)) exit(-1);
      object_setName(Oaux,name);
      object_setId(Oaux,id);
      object_setRoomId(Oaux,roomid);
      object_setPosition(Oaux,px,py);
      object_setNPC(Oaux,npc);
      object_setMeeting(Oaux,meeting);
      object_setIsPick(Oaux,ispick);
      object_setOnOff(Oaux,onoff);
      object_setUses(Oaux,uses);
      object_setMotivation(Oaux,motivation);
      object_setDanger(Oaux,danger);
      object_setChaos(Oaux,chaos);
      object_setMoney(Oaux,money);
      inv->inv[i]=object_copy(Oaux);
      i++;
    }
    inv->max=i;
	object_destroy(Oaux);
	fclose(in);

	return(inv);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x538, %rsp            # imm = 0x538
testq %rdi, %rdi
je 0x22cf
movq %rdi, %r14
movl $0x10, %edi
callq 0x1130
testq %rax, %rax
je 0x22cf
movq %rax, %rbx
leaq 0x3f34(%rip), %rsi      # 0x603a
movq %r14, %rdi
callq 0x1190
testq %rax, %rax
je 0x22c7
movq %rax, %r14
xorl %r13d, %r13d
xorl %eax, %eax
callq 0x37f8
testq %rax, %rax
je 0x22bf
movq %rax, %r15
movl $0x50, %edi
callq 0x1130
movq %rax, %rbp
movq %rax, (%rbx)
movq %r14, %rdi
callq 0x10f0
testl %eax, %eax
jne 0x22a9
xorl %r13d, %r13d
leaq 0x130(%rsp), %r12
movq %r12, %rdi
movl $0x400, %esi            # imm = 0x400
movq %r14, %rdx
callq 0x10e0
movq %r12, %rdi
leaq 0x3faf(%rip), %rsi      # 0x6124
leaq 0x30(%rsp), %rdx
leaq 0x2c(%rsp), %rcx
leaq 0x28(%rsp), %r8
leaq 0x24(%rsp), %r9
xorl %eax, %eax
leaq 0xc(%rsp), %r10
pushq %r10
leaq 0x18(%rsp), %r10
pushq %r10
leaq 0x24(%rsp), %r10
pushq %r10
leaq 0x30(%rsp), %r10
pushq %r10
leaq 0x3c(%rsp), %r10
pushq %r10
leaq 0x2e(%rsp), %r10
pushq %r10
leaq 0x38(%rsp), %r10
pushq %r10
leaq 0x3c(%rsp), %r10
pushq %r10
leaq 0x4a(%rsp), %r10
pushq %r10
leaq 0x68(%rsp), %r10
pushq %r10
callq 0x1150
addq $0x50, %rsp
cmpl $0xe, %eax
jne 0x22e6
movq %r15, %rdi
leaq 0x30(%rsp), %rsi
callq 0x3867
movl 0x2c(%rsp), %esi
movq %r15, %rdi
callq 0x388c
movswl 0x28(%rsp), %esi
movq %r15, %rdi
callq 0x3898
movl 0x24(%rsp), %esi
movl 0x20(%rsp), %edx
movq %r15, %rdi
callq 0x38b3
movswl 0xa(%rsp), %esi
movq %r15, %rdi
callq 0x38d3
movswl 0x4(%rsp), %esi
movq %r15, %rdi
callq 0x38ef
movswl 0x8(%rsp), %esi
movq %r15, %rdi
callq 0x390b
movswl 0x6(%rsp), %esi
movq %r15, %rdi
callq 0x3927
movl 0x1c(%rsp), %esi
movq %r15, %rdi
callq 0x3943
movl 0x18(%rsp), %esi
movq %r15, %rdi
callq 0x395d
movl 0x14(%rsp), %esi
movq %r15, %rdi
callq 0x3969
movl 0x10(%rsp), %esi
movq %r15, %rdi
callq 0x3975
movl 0xc(%rsp), %esi
movq %r15, %rdi
callq 0x3981
movq %r15, %rdi
callq 0x3a5c
movq %rax, (%rbp,%r13,8)
incq %r13
movq %r14, %rdi
callq 0x10f0
testl %eax, %eax
je 0x2153
movl %r13d, 0x8(%rbx)
movq %r15, %rdi
callq 0x3847
movq %r14, %rdi
callq 0x1070
jmp 0x22d1
movq %r14, %rdi
callq 0x1070
movq %rbx, %rdi
callq 0x1030
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x538, %rsp            # imm = 0x538
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x11b0