// File: /workspace/github_c_makefile_star2_O0/rafa9811[P]theIndiependenceGame/background.c
// Function: bg_meeting
int bg_meeting(Meeting *meet, Player *c, Mobjects *m, Stat *s, int question, int answer, char *nextq, int*correct){
	int id,roomid,px,py,oid,solution,uses;
	Object *meeting;

	if(!meet || !c || !m || !s || question>MAX_Q) return -1;

	roomid=player_get_room(c);
	px=player_get_px(c);
	py=player_get_py(c);

  oid = mobjects_search(m,roomid,px,py);
	meeting = mobjects_get(m,roomid,oid);
	id = object_getId(meeting);
	uses = object_getUses(meeting);
	if(uses<=0)return 3;	

	if(question==0 && answer == 0){
		strcpy(nextq,meet->meet[id][0]);
		return 0;
	}
	solution=meet->solution[id][question];
	if(answer==solution){
		stat_add_chaos(s,MEETING_CHAOS);
		*correct = 1;
	}
	else{
		stat_add_chaos(s,-MEETING_CHAOS);
		*correct = 0;
	}
	if(question+1<MAX_Q){
		strcpy(nextq,meet->meet[id][question+1]);
		return 1;
	}
	else{
		object_setUses(meeting,0);
		return 2;
	} 
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movl %r8d, -0x2c(%rbp)
movl %r9d, -0x30(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x45aa
cmpq $0x0, -0x18(%rbp)
je 0x45aa
cmpq $0x0, -0x20(%rbp)
je 0x45aa
cmpq $0x0, -0x28(%rbp)
je 0x45aa
cmpl $0x3, -0x2c(%rbp)
jle 0x45b6
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4706
movq -0x18(%rbp), %rdi
callq 0x58e0
movl %eax, -0x38(%rbp)
movq -0x18(%rbp), %rdi
movb $0x0, %al
callq 0x5910
movl %eax, -0x3c(%rbp)
movq -0x18(%rbp), %rdi
movb $0x0, %al
callq 0x5940
movl %eax, -0x40(%rbp)
movq -0x20(%rbp), %rdi
movl -0x38(%rbp), %esi
movl -0x3c(%rbp), %edx
movl -0x40(%rbp), %ecx
callq 0x2e70
movl %eax, -0x44(%rbp)
movq -0x20(%rbp), %rdi
movl -0x38(%rbp), %esi
movl -0x44(%rbp), %edx
callq 0x3000
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rdi
callq 0x4c40
movl %eax, -0x34(%rbp)
movq -0x58(%rbp), %rdi
callq 0x4e10
movl %eax, -0x4c(%rbp)
cmpl $0x0, -0x4c(%rbp)
jg 0x4630
movl $0x3, -0x4(%rbp)
jmp 0x4706
cmpl $0x0, -0x2c(%rbp)
jne 0x4663
cmpl $0x0, -0x30(%rbp)
jne 0x4663
movq 0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rsi
callq 0x1040
movl $0x0, -0x4(%rbp)
jmp 0x4706
movq -0x10(%rbp), %rax
addq $0x78, %rax
movslq -0x34(%rbp), %rcx
imulq $0x6, %rcx, %rcx
addq %rcx, %rax
movslq -0x2c(%rbp), %rcx
movswl (%rax,%rcx,2), %eax
movl %eax, -0x48(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x48(%rbp), %eax
jne 0x46a3
movq -0x28(%rbp), %rdi
movl $0x64, %esi
callq 0x6150
movq 0x18(%rbp), %rax
movl $0x1, (%rax)
jmp 0x46bb
movq -0x28(%rbp), %rdi
movl $0xffffff9c, %esi       # imm = 0xFFFFFF9C
callq 0x6150
movq 0x18(%rbp), %rax
movl $0x0, (%rax)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
cmpl $0x3, %eax
jge 0x46f4
movq 0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl -0x2c(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rsi
callq 0x1040
movl $0x1, -0x4(%rbp)
jmp 0x4706
movq -0x58(%rbp), %rdi
xorl %esi, %esi
callq 0x4ac0
movl $0x2, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nop