// File: /workspace/github_c_makefile_star2_O2/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 $0x548, %rsp            # imm = 0x548
testq %rdi, %rdi
je 0x2171
movq %rdi, %rbx
pushq $0x10
popq %rdi
callq 0x1130
testq %rax, %rax
je 0x2171
movq %rax, %r13
leaq 0x408b(%rip), %rsi      # 0x603a
movq %rbx, %rdi
callq 0x11a0
testq %rax, %rax
je 0x2169
movq %rax, %r14
xorl %eax, %eax
callq 0x35c0
testq %rax, %rax
je 0x2161
movq %rax, %r15
pushq $0x50
popq %rdi
callq 0x1130
movq %rax, %r12
movq %r13, 0x38(%rsp)
movq %rax, (%r13)
leaq 0x140(%rsp), %r13
leaq 0x40(%rsp), %rbx
xorl %ebp, %ebp
movq %r14, %rdi
callq 0x10f0
testl %eax, %eax
jne 0x2147
movq %r13, %rdi
movl $0x400, %esi            # imm = 0x400
movq %r14, %rdx
callq 0x10e0
movq %r13, %rdi
leaq 0x4101(%rip), %rsi      # 0x6124
movq %rbx, %rdx
leaq 0x34(%rsp), %rcx
leaq 0x30(%rsp), %r8
leaq 0x2c(%rsp), %r9
xorl %eax, %eax
leaq 0x14(%rsp), %r10
pushq %r10
leaq 0x20(%rsp), %r10
pushq %r10
leaq 0x2c(%rsp), %r10
pushq %r10
leaq 0x38(%rsp), %r10
pushq %r10
leaq 0x44(%rsp), %r10
pushq %r10
leaq 0x36(%rsp), %r10
pushq %r10
leaq 0x40(%rsp), %r10
pushq %r10
leaq 0x44(%rsp), %r10
pushq %r10
leaq 0x52(%rsp), %r10
pushq %r10
leaq 0x70(%rsp), %r10
pushq %r10
callq 0x1150
addq $0x50, %rsp
cmpl $0xe, %eax
jne 0x2188
movq %r15, %rdi
movq %rbx, %rsi
callq 0x3627
movl 0x34(%rsp), %esi
movq %r15, %rdi
callq 0x364c
movswl 0x30(%rsp), %esi
movq %r15, %rdi
callq 0x3658
movl 0x2c(%rsp), %esi
movl 0x28(%rsp), %edx
movq %r15, %rdi
callq 0x3673
movswl 0x12(%rsp), %esi
movq %r15, %rdi
callq 0x3693
movswl 0xc(%rsp), %esi
movq %r15, %rdi
callq 0x36af
movswl 0x10(%rsp), %esi
movq %r15, %rdi
callq 0x36cb
movswl 0xe(%rsp), %esi
movq %r15, %rdi
callq 0x36e7
movl 0x24(%rsp), %esi
movq %r15, %rdi
callq 0x3703
movl 0x20(%rsp), %esi
movq %r15, %rdi
callq 0x371d
movl 0x1c(%rsp), %esi
movq %r15, %rdi
callq 0x3729
movl 0x18(%rsp), %esi
movq %r15, %rdi
callq 0x3735
movl 0x14(%rsp), %esi
movq %r15, %rdi
callq 0x3741
movq %r15, %rdi
callq 0x380c
movq %rax, (%r12,%rbp,8)
incq %rbp
jmp 0x1ff9
movq 0x38(%rsp), %rbx
movl %ebp, 0x8(%rbx)
movq %r15, %rdi
callq 0x360c
movq %r14, %rdi
callq 0x1070
jmp 0x2173
movq %r14, %rdi
callq 0x1070
movq %r13, %rdi
callq 0x1030
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x548, %rsp            # imm = 0x548
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $-0x1
popq %rdi
callq 0x11c0