// File: /workspace/github_c_makefile_star2_O0/wierton[P]socket-based-naive-game/server.c
// Function: client_command_fire
int client_command_fire(int uid) {
	log("user %s fire\n", sessions[uid].user_name);
	int bid = sessions[uid].bid;
	int item_id = get_unused_item(bid);
	log("alloc item %d for bullet\n", item_id);
	if(item_id == -1) return 0;

	if(battles[bid].users[uid].nr_bullets <= 0) {
		send_to_client(uid, SERVER_MESSAGE_YOUR_MAGAZINE_IS_EMPTY);
		return 0;
	}

	int dir = battles[bid].users[uid].dir;
	int x = battles[bid].users[uid].pos.x;
	int y = battles[bid].users[uid].pos.y;
	log("bullet, %s@(%d, %d), direct to %d\n",
			sessions[uid].user_name, x, y, dir);
	battles[bid].items[item_id].kind = ITEM_BULLET;
	battles[bid].items[item_id].dir = dir;
	battles[bid].items[item_id].owner = uid;
	battles[bid].items[item_id].pos.x = x;
	battles[bid].items[item_id].pos.y = y;

	battles[bid].users[uid].nr_bullets --;

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movl %edi, -0x8(%rbp)
movq 0x5136(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
movslq -0x8(%rbp), %rax
leaq 0x5350(%rip), %r8       # 0xa220
imulq $0x48, %rax, %rax
addq %rax, %r8
leaq 0x2636(%rip), %rsi      # 0x7514
leaq 0x2655(%rip), %rdx      # 0x753a
movl $0x368, %ecx            # imm = 0x368
movb $0x0, %al
callq 0x10f0
movslq -0x8(%rbp), %rcx
leaq 0x5324(%rip), %rax      # 0xa220
imulq $0x48, %rcx, %rcx
addq %rcx, %rax
movl 0x10(%rax), %eax
movl %eax, -0xc(%rbp)
movl -0xc(%rbp), %edi
callq 0x1e70
movl %eax, -0x10(%rbp)
movq 0x50dd(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
movl -0x10(%rbp), %r8d
leaq 0x2625(%rip), %rsi      # 0x754e
leaq 0x260a(%rip), %rdx      # 0x753a
movl $0x36b, %ecx            # imm = 0x36B
movb $0x0, %al
callq 0x10f0
cmpl $-0x1, -0x10(%rbp)
jne 0x4f4e
movl $0x0, -0x4(%rbp)
jmp 0x5165
movslq -0xc(%rbp), %rcx
leaq 0x5437(%rip), %rax      # 0xa390
imulq $0xb08, %rcx, %rcx      # imm = 0xB08
addq %rcx, %rax
addq $0x10, %rax
movslq -0x8(%rbp), %rcx
imulq $0x14, %rcx, %rcx
addq %rcx, %rax
cmpl $0x0, 0x4(%rax)
jg 0x4f91
movl -0x8(%rbp), %edi
movl $0x24, %esi
callq 0x25e0
movl $0x0, -0x4(%rbp)
jmp 0x5165
movslq -0xc(%rbp), %rcx
leaq 0x53f4(%rip), %rax      # 0xa390
imulq $0xb08, %rcx, %rcx      # imm = 0xB08
addq %rcx, %rax
addq $0x10, %rax
movslq -0x8(%rbp), %rcx
imulq $0x14, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movl %eax, -0x14(%rbp)
movslq -0xc(%rbp), %rcx
leaq 0x53ca(%rip), %rax      # 0xa390
imulq $0xb08, %rcx, %rcx      # imm = 0xB08
addq %rcx, %rax
addq $0x10, %rax
movslq -0x8(%rbp), %rcx
imulq $0x14, %rcx, %rcx
addq %rcx, %rax
movzbl 0x10(%rax), %eax
movl %eax, -0x18(%rbp)
movslq -0xc(%rbp), %rcx
leaq 0x539f(%rip), %rax      # 0xa390
imulq $0xb08, %rcx, %rcx      # imm = 0xB08
addq %rcx, %rax
addq $0x10, %rax
movslq -0x8(%rbp), %rcx
imulq $0x14, %rcx, %rcx
addq %rcx, %rax
movzbl 0x11(%rax), %eax
movl %eax, -0x1c(%rbp)
movq 0x4fe0(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
movslq -0x8(%rbp), %rax
leaq 0x51fa(%rip), %r8       # 0xa220
imulq $0x48, %rax, %rax
addq %rax, %r8
movl -0x18(%rbp), %r9d
movl -0x1c(%rbp), %r10d
movl -0x14(%rbp), %eax
leaq 0x2541(%rip), %rsi      # 0x7580
leaq 0x24f4(%rip), %rdx      # 0x753a
movl $0x377, %ecx            # imm = 0x377
movl %r10d, (%rsp)
movl %eax, 0x8(%rsp)
movb $0x0, %al
callq 0x10f0
movslq -0xc(%rbp), %rcx
leaq 0x532b(%rip), %rax      # 0xa390
imulq $0xb08, %rcx, %rcx      # imm = 0xB08
addq %rcx, %rax
addq $0x78, %rax
movslq -0x10(%rbp), %rcx
imulq $0x14, %rcx, %rcx
addq %rcx, %rax
movl $0x6, 0xc(%rax)
movl -0x14(%rbp), %ecx
movslq -0xc(%rbp), %rdx
leaq 0x52fd(%rip), %rax      # 0xa390
imulq $0xb08, %rdx, %rdx      # imm = 0xB08
addq %rdx, %rax
addq $0x78, %rax
movslq -0x10(%rbp), %rdx
imulq $0x14, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x4(%rax)
movl -0x8(%rbp), %ecx
movslq -0xc(%rbp), %rdx
leaq 0x52d3(%rip), %rax      # 0xa390
imulq $0xb08, %rdx, %rdx      # imm = 0xB08
addq %rdx, %rax
addq $0x78, %rax
movslq -0x10(%rbp), %rdx
imulq $0x14, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x8(%rax)
movl -0x18(%rbp), %eax
movb %al, %cl
movslq -0xc(%rbp), %rdx
leaq 0x52a7(%rip), %rax      # 0xa390
imulq $0xb08, %rdx, %rdx      # imm = 0xB08
addq %rdx, %rax
addq $0x78, %rax
movslq -0x10(%rbp), %rdx
imulq $0x14, %rdx, %rdx
addq %rdx, %rax
movb %cl, 0x10(%rax)
movl -0x1c(%rbp), %eax
movb %al, %cl
movslq -0xc(%rbp), %rdx
leaq 0x527b(%rip), %rax      # 0xa390
imulq $0xb08, %rdx, %rdx      # imm = 0xB08
addq %rdx, %rax
addq $0x78, %rax
movslq -0x10(%rbp), %rdx
imulq $0x14, %rdx, %rdx
addq %rdx, %rax
movb %cl, 0x11(%rax)
movslq -0xc(%rbp), %rcx
leaq 0x5254(%rip), %rax      # 0xa390
imulq $0xb08, %rcx, %rcx      # imm = 0xB08
addq %rcx, %rax
addq $0x10, %rax
movslq -0x8(%rbp), %rcx
imulq $0x14, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x4(%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nop