// File: /workspace/github_c_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %xmm0
movq %rdi, %xmm1
punpcklqdq %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0]
movq %r8, %xmm0
movq %rdx, %xmm2
punpcklqdq %xmm0, %xmm2    # xmm2 = xmm2[0],xmm0[0]
pxor %xmm0, %xmm0
pcmpeqd %xmm0, %xmm2
pcmpeqd %xmm0, %xmm1
movdqa %xmm1, %xmm0
shufps $0xdd, %xmm2, %xmm0     # xmm0 = xmm0[1,3],xmm2[1,3]
shufps $0x88, %xmm2, %xmm1     # xmm1 = xmm1[0,2],xmm2[0,2]
andps %xmm0, %xmm1
movmskps %xmm1, %eax
pushq $-0x1
popq %rbp
testl %eax, %eax
jne 0x3042
movq %r8, %r15
movq %rdx, %rbx
movq %rsi, %r12
movq %rcx, (%rsp)
movq %rdi, 0x10(%rsp)
movq %rsi, %rdi
callq 0x3b74
movl %eax, %r14d
movq %r12, %rdi
xorl %eax, %eax
callq 0x3b81
movl %eax, %r13d
movq %r12, %rdi
xorl %eax, %eax
callq 0x3b8d
movq %rbx, %rdi
movl %r14d, %esi
movl %r13d, %edx
movl %eax, %ecx
callq 0x2554
movl %eax, %r12d
cmpl $-0x1, %eax
setne %al
cmpl $0x1b, %r14d
setb %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x2f73
movl %r14d, %r13d
movslq %r12d, %rax
imulq $0x50, %r13, %rcx
addq %rbx, %rcx
movq (%rcx,%rax,8), %rax
testq %rax, %rax
je 0x2f73
movl %r14d, 0xc(%rsp)
movq %rax, %r14
movq %rax, %rdi
callq 0x37ad
cmpw $0x1, %ax
jne 0x2f7a
movq %r14, %rbp
movq 0x10(%rsp), %r14
cmpl $0xa, 0x8(%r14)
jne 0x2f8f
pushq $0xb
jmp 0x3041
xorl %ebp, %ebp
jmp 0x3042
movq %r14, %rdi
callq 0x378f
cmpw $0x1, %ax
jne 0x2ff2
pushq $0x7
jmp 0x3041
movq %rbp, %rdi
callq 0x374d
movq (%rsp), %rdi
movq %rax, %rsi
callq 0x1050
movq %rbp, %rdi
xorl %esi, %esi
callq 0x36e7
movq %rbp, %rdi
callq 0x3775
movl %eax, (%rsp)
movq %rbp, %rdi
callq 0x3782
movq (%r15), %rcx
movq (%rcx,%r13,8), %rdi
pushq $0x20
popq %rcx
movl (%rsp), %esi
movl %eax, %edx
callq 0x3ad3
movq %r14, %rdi
movq %rbp, %rsi
callq 0x2227
movq %rbx, %rdi
movl 0xc(%rsp), %esi
movl %r12d, %edx
callq 0x2681
pushq $0x1
jmp 0x3041
movq %r14, %rdi
callq 0x379e
cmpw $0x1, %ax
jne 0x3004
pushq $0x9
jmp 0x3041
movq %r14, %rdi
callq 0x3759
cmpl $0x2, %eax
jne 0x3015
pushq $0x8
jmp 0x3041
movq %r14, %rdi
callq 0x3759
cmpl $0x1, %eax
jne 0x3042
movq %r14, %rdi
callq 0x37cb
movl $0x0, %ebp
testl %eax, %eax
jle 0x3042
decl %eax
movq %r14, %rdi
movl %eax, %esi
callq 0x3703
pushq $0xa
popq %rbp
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq