// File: /workspace/github_c_makefile_star2_O0/rafa9811[P]theIndiependenceGame/background.c
// Function: bg_pick
int bg_pick(Inventory* in, Player *c,Mobjects *m,char *name,Map *map){
	Object *o, *oaux;
	int id,roomid,px,py,uses;

	if(!in || !c || !m || !map) return -1;

	roomid=player_get_room(c);
	px=player_get_px(c);
	py=player_get_py(c);

    id = mobjects_search(m,roomid,px,py);

    if(id==-1) return B_NOTHING;
    o = mobjects_get(m,roomid,id);
	if(!o) return B_NOTHING;
	if(object_getIsPick(o)==1){
	    if(inventory_full(in)) return B_FULL;
	    strcpy(name,object_getName(o));
			object_setOnOff(o,0);
			px=object_getPx(o);
			py=object_getPy(o);
			place_drawchar(map->map[roomid],px,py,' ');
			inventory_insert(in,o);
	    mobjects_erase(m,roomid,id);
	    return B_PICK;
	}
	else if(object_getNPC(o)==1) return B_NPC;
	else if(object_getMeeting(o)==1) return B_MEETING;
	else if(object_getId(o)==ID_SHOP) return B_SHOP;
	else if(object_getId(o)==ID_PRINTER){
	    if((uses = object_getUses(o))>0){
	        object_setUses(o,uses-1);
	        return B_PRINTER;
	    }
	    else return B_NOTHING;
	}
	return -1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x3e68
cmpq $0x0, -0x18(%rbp)
je 0x3e68
cmpq $0x0, -0x20(%rbp)
je 0x3e68
cmpq $0x0, -0x30(%rbp)
jne 0x3e74
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4034
movq -0x18(%rbp), %rdi
callq 0x58e0
movl %eax, -0x48(%rbp)
movq -0x18(%rbp), %rdi
movb $0x0, %al
callq 0x5910
movl %eax, -0x4c(%rbp)
movq -0x18(%rbp), %rdi
movb $0x0, %al
callq 0x5940
movl %eax, -0x50(%rbp)
movq -0x20(%rbp), %rdi
movl -0x48(%rbp), %esi
movl -0x4c(%rbp), %edx
movl -0x50(%rbp), %ecx
callq 0x2e70
movl %eax, -0x44(%rbp)
cmpl $-0x1, -0x44(%rbp)
jne 0x3ec3
movl $0x0, -0x4(%rbp)
jmp 0x4034
movq -0x20(%rbp), %rdi
movl -0x48(%rbp), %esi
movl -0x44(%rbp), %edx
callq 0x3000
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x3ee9
movl $0x0, -0x4(%rbp)
jmp 0x4034
movq -0x38(%rbp), %rdi
callq 0x4d90
cwtl
cmpl $0x1, %eax
jne 0x3f9e
movq -0x10(%rbp), %rdi
callq 0x2990
cmpw $0x0, %ax
je 0x3f17
movl $0xb, -0x4(%rbp)
jmp 0x4034
movq -0x28(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x38(%rbp), %rdi
callq 0x4c00
movq -0x60(%rbp), %rdi
movq %rax, %rsi
callq 0x1040
movq -0x38(%rbp), %rdi
xorl %esi, %esi
callq 0x4a70
movq -0x38(%rbp), %rdi
callq 0x4cb0
movl %eax, -0x4c(%rbp)
movq -0x38(%rbp), %rdi
callq 0x4ce0
movl %eax, -0x50(%rbp)
movq -0x30(%rbp), %rax
movq (%rax), %rax
movslq -0x48(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movl -0x4c(%rbp), %esi
movl -0x50(%rbp), %edx
movl $0x20, %ecx
callq 0x56f0
movq -0x10(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x2920
movq -0x20(%rbp), %rdi
movl -0x48(%rbp), %esi
movl -0x44(%rbp), %edx
callq 0x3050
movl $0x1, -0x4(%rbp)
jmp 0x4034
movq -0x38(%rbp), %rdi
callq 0x4d10
cwtl
cmpl $0x1, %eax
jne 0x3fb6
movl $0x7, -0x4(%rbp)
jmp 0x4034
movq -0x38(%rbp), %rdi
callq 0x4d50
cwtl
cmpl $0x1, %eax
jne 0x3fce
movl $0x9, -0x4(%rbp)
jmp 0x4034
movq -0x38(%rbp), %rdi
callq 0x4c40
cmpl $0x2, %eax
jne 0x3fe5
movl $0x8, -0x4(%rbp)
jmp 0x4034
movq -0x38(%rbp), %rdi
callq 0x4c40
cmpl $0x1, %eax
jne 0x4025
movq -0x38(%rbp), %rdi
callq 0x4e10
movl %eax, -0x54(%rbp)
cmpl $0x0, %eax
jle 0x401c
movq -0x38(%rbp), %rdi
movl -0x54(%rbp), %esi
subl $0x1, %esi
callq 0x4ac0
movl $0xa, -0x4(%rbp)
jmp 0x4034
movl $0x0, -0x4(%rbp)
jmp 0x4034
jmp 0x4027
jmp 0x4029
jmp 0x402b
jmp 0x402d
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax)