// File: /workspace/github_c_makefile_star2_O1/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 0x22c0
movq %rdi, %r14
movl $0x10, %edi
callq 0x1130
testq %rax, %rax
je 0x22c0
movq %rax, %rbx
leaq 0x3f43(%rip), %rsi      # 0x603a
movq %r14, %rdi
callq 0x1190
testq %rax, %rax
je 0x22b8
movq %rax, %r14
xorl %r13d, %r13d
xorl %eax, %eax
callq 0x37bc
testq %rax, %rax
je 0x22b0
movq %rax, %r15
movl $0x50, %edi
callq 0x1130
movq %rax, %rbp
movq %rax, (%rbx)
movq %r14, %rdi
callq 0x10f0
testl %eax, %eax
jne 0x229a
xorl %r13d, %r13d
leaq 0x130(%rsp), %r12
movq %r12, %rdi
movl $0x400, %esi            # imm = 0x400
movq %r14, %rdx
callq 0x10e0
movq %r12, %rdi
leaq 0x3fbe(%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 0x22d7
movq %r15, %rdi
leaq 0x30(%rsp), %rsi
callq 0x382b
movl 0x2c(%rsp), %esi
movq %r15, %rdi
callq 0x3850
movswl 0x28(%rsp), %esi
movq %r15, %rdi
callq 0x385f
movl 0x24(%rsp), %esi
movl 0x20(%rsp), %edx
movq %r15, %rdi
callq 0x387a
movswl 0xa(%rsp), %esi
movq %r15, %rdi
callq 0x389a
movswl 0x4(%rsp), %esi
movq %r15, %rdi
callq 0x38b6
movswl 0x8(%rsp), %esi
movq %r15, %rdi
callq 0x38d2
movswl 0x6(%rsp), %esi
movq %r15, %rdi
callq 0x38ee
movl 0x1c(%rsp), %esi
movq %r15, %rdi
callq 0x390a
movl 0x18(%rsp), %esi
movq %r15, %rdi
callq 0x3924
movl 0x14(%rsp), %esi
movq %r15, %rdi
callq 0x3933
movl 0x10(%rsp), %esi
movq %r15, %rdi
callq 0x3942
movl 0xc(%rsp), %esi
movq %r15, %rdi
callq 0x3951
movq %r15, %rdi
callq 0x3a2f
movq %rax, (%rbp,%r13,8)
incq %r13
movq %r14, %rdi
callq 0x10f0
testl %eax, %eax
je 0x2144
movl %r13d, 0x8(%rbx)
movq %r15, %rdi
callq 0x380b
movq %r14, %rdi
callq 0x1070
jmp 0x22c2
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