// File: /workspace/github_c_makefile_star2_O1/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 %rdx, %rbx
movq %rsi, %r13
testq %rdi, %rdi
sete %al
testq %rsi, %rsi
sete %sil
orb %al, %sil
testq %rdx, %rdx
sete %al
testq %r8, %r8
sete %dl
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
orb %al, %dl
orb %sil, %dl
jne 0x3227
movq %r8, %r12
movq %rcx, 0x10(%rsp)
movq %rdi, 0x8(%rsp)
movq %r13, %rdi
callq 0x3e48
movl %eax, %r14d
xorl %r15d, %r15d
movq %r13, %rdi
xorl %eax, %eax
callq 0x3e57
movl %eax, %ebp
movq %r13, %rdi
xorl %eax, %eax
callq 0x3e65
movq %rbx, %rdi
movl %r14d, %esi
movl %ebp, %edx
movl %eax, %ecx
callq 0x26c2
cmpl $-0x1, %eax
je 0x3227
movl %eax, %r13d
xorl %r15d, %r15d
cmpl $0x1a, %r14d
ja 0x3102
movl %r14d, %eax
movslq %r13d, %rcx
leaq (%rax,%rax,4), %rax
shlq $0x4, %rax
addq %rbx, %rax
movq (%rax,%rcx,8), %rbp
jmp 0x3104
xorl %ebp, %ebp
testq %rbp, %rbp
je 0x3227
movq %rbp, %rdi
callq 0x39c6
cmpw $0x1, %ax
jne 0x31b5
movl $0xb, %r15d
movq 0x8(%rsp), %rax
cmpl $0xa, 0x8(%rax)
je 0x3227
movq %rbp, %rdi
callq 0x3960
movq 0x10(%rsp), %rdi
movq %rax, %rsi
callq 0x1050
movq %rbp, %rdi
xorl %esi, %esi
callq 0x38ee
movq %rbp, %rdi
callq 0x398a
movq %rbp, %r15
movl %eax, %ebp
movq %r15, %rdi
callq 0x3999
movq (%r12), %rcx
movslq %r14d, %rdx
movq (%rcx,%rdx,8), %rdi
movl %ebp, %esi
movl %eax, %edx
movl $0x20, %ecx
callq 0x3d8b
movq %r15, %rdi
callq 0x3a2f
movq 0x8(%rsp), %rsi
movq (%rsi), %rcx
movslq 0x8(%rsi), %rdx
movq %rax, (%rcx,%rdx,8)
leal 0x1(%rdx), %eax
movl %eax, 0x8(%rsi)
movq %rbx, %rdi
movl %r14d, %esi
movl %r13d, %edx
callq 0x27f7
movl $0x1, %r15d
jmp 0x3227
movq %rbp, %rdi
callq 0x39a8
movl $0x7, %r15d
cmpw $0x1, %ax
je 0x3227
movq %rbp, %rdi
callq 0x39b7
movl $0x9, %r15d
cmpw $0x1, %ax
je 0x3227
movq %rbp, %rdi
callq 0x396c
movl $0x8, %r15d
cmpl $0x2, %eax
je 0x3227
movq %rbp, %rdi
callq 0x396c
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
cmpl $0x1, %eax
jne 0x3227
movq %rbp, %rdi
callq 0x39e4
movl $0x0, %r15d
testl %eax, %eax
jle 0x3227
decl %eax
movq %rbp, %rdi
movl %eax, %esi
callq 0x390a
movl $0xa, %r15d
movl %r15d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq