// File: /workspace/github_c_makefile_star2_O3/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
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
testl %eax, %eax
jne 0x323c
movq %r8, %r15
movq %rdx, %rbx
movq %rsi, %r12
movq %rcx, (%rsp)
movq %rdi, 0x10(%rsp)
movq %rsi, %rdi
callq 0x3dee
movl %eax, %r14d
xorl %r13d, %r13d
movq %r12, %rdi
xorl %eax, %eax
callq 0x3dfd
movl %eax, %ebp
movq %r12, %rdi
xorl %eax, %eax
callq 0x3e0b
movq %rbx, %rdi
movl %r14d, %esi
movl %ebp, %edx
movl %eax, %ecx
callq 0x26e2
movl %eax, %r12d
cmpl $-0x1, %eax
setne %al
cmpl $0x1b, %r14d
setb %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x323c
movl %r14d, %ebp
movslq %r12d, %rax
leaq (,%rbp,4), %rcx
addq %rbp, %rcx
shlq $0x4, %rcx
addq %rbx, %rcx
movq (%rcx,%rax,8), %rax
testq %rax, %rax
je 0x323c
movl %r14d, 0xc(%rsp)
movq %rax, %r13
movq %rax, %rdi
callq 0x39f3
cmpw $0x1, %ax
jne 0x31c7
movq %r13, %rax
movl $0xb, %r13d
movq 0x10(%rsp), %r14
cmpl $0xa, 0x8(%r14)
je 0x323c
movq %rax, %r13
movq %rax, %rdi
callq 0x398d
movq (%rsp), %rdi
movq %rax, %rsi
callq 0x1050
movq %r13, %rdi
xorl %esi, %esi
callq 0x3927
movq %r13, %rdi
callq 0x39b7
movl %eax, (%rsp)
movq %r13, %rdi
callq 0x39c6
movq (%r15), %rcx
movq (%rcx,%rbp,8), %rdi
movl (%rsp), %esi
movl %eax, %edx
movl $0x20, %ecx
callq 0x3d3d
movq %r13, %rdi
callq 0x3a5c
movq (%r14), %rcx
movslq 0x8(%r14), %rdx
movq %rax, (%rcx,%rdx,8)
leal 0x1(%rdx), %eax
movl %eax, 0x8(%r14)
movq %rbx, %rdi
movl 0xc(%rsp), %esi
movl %r12d, %edx
callq 0x2805
movl $0x1, %r13d
jmp 0x323c
movq %r13, %rdi
callq 0x39d5
movq %r13, %rbx
movl $0x7, %r13d
cmpw $0x1, %ax
je 0x323c
movq %rbx, %rdi
callq 0x39e4
movl $0x9, %r13d
cmpw $0x1, %ax
je 0x323c
movq %rbx, %rdi
callq 0x3999
movl $0x8, %r13d
cmpl $0x2, %eax
je 0x323c
movq %rbx, %rdi
callq 0x3999
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
cmpl $0x1, %eax
jne 0x323c
movq %rbx, %rdi
callq 0x3a11
movl $0x0, %r13d
testl %eax, %eax
jle 0x323c
decl %eax
movq %rbx, %rdi
movl %eax, %esi
callq 0x3943
movl $0xa, %r13d
movl %r13d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq