// File: /workspace/github_cpp_makefile_star2_O1/essarrdee[P]mutantaliens/mutantaliens.cpp
// Function: add_device(int, int, int, bool)
item* add_device(int type,int x,int y,bool in_inv)
{
	item* dev = new item();
	if(type == HOLOGRAM_PROJECTOR)
	{
		dev->projection = add_actor(zoo[0],false,-500,-500,true);
	}
	dev->device_type = type;
	dev->colour = COLOR_RED;
	dev->wavelength = -1;
	dev->time_remaining = -1;
	dev->species_stored = -1;
	dev->current_action = NULL_STIMULUS;
	dev->next_action = NULL_STIMULUS;
	dev->configuration = UNCONFIGURED;
	dev->power_remaining = 100;
	dev->player_has = false;
	switch (type)
	{
	case 0:
		dev->name = "low explosive";
		dev->ch = 'A';
		dev->description = "Inflicts damage on creatures and walls within a 3x3 area. Including you.";
		break;
	case 1:
		dev->name = "high explosive";
		dev->ch = 'B';
		dev->description = "Inflicts great damage on creatures and walls within a 5x5 area. Including you.";
		break;
	case 2:
		dev->name = "hologram projector";
		dev->description = "Projects holograms that confuse creatures that rely on sight. Such as you.";
		dev->ch = 'C';
		break;
	case 3:
		dev->name = "noise generator";
		dev->description = "Confuses or deafens creatures that rely on hearing. Like you.";
		dev->ch = 'D';
		break;
	case 4:
		dev->name = "scent generator";
		dev->ch = 'E';
		dev->description = "Confuses creatures with a sense of smell. For instance... your dog.";
		break;
	case 5:
		dev->name = "brain slice";
		dev->description = "Confuses creatures with a psychic sense. Like that guy from the infotainment datalinks.";
		dev->ch = 'F';
		break;
	default:
		delete dev;
		return NULL;
	}
	dev->base_description = dev->description;
	if (in_inv)
	{
		dev->x = p_ptr->x;
		dev->y = p_ptr->y;
		device_to_inventory(dev);
	}
	else
	{
		item_to_location(dev,x,y);
	}
	return dev;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %ecx, 0x4(%rsp)
movl %edx, 0xc(%rsp)
movl %esi, 0x8(%rsp)
movl %edi, %r14d
movl $0xa0, %edi
callq 0x5250
movq %rax, %r12
movq %rax, %rbx
xorl %r15d, %r15d
movl $0xa0, %edx
movq %rax, %rdi
xorl %esi, %esi
callq 0x5180
leaq 0x20(%r12), %rax
movq %rax, 0x10(%rsp)
movq %rax, 0x10(%r12)
movq %r15, 0x18(%r12)
movb %r15b, 0x20(%r12)
leaq 0x40(%r12), %r13
movq %r13, 0x30(%r12)
movq %r15, 0x38(%r12)
movb %r15b, 0x40(%r12)
leaq 0x60(%r12), %rbp
movq %rbp, 0x50(%r12)
movq %r15, 0x58(%r12)
movb %r15b, 0x60(%r12)
cmpl $0x2, %r14d
jne 0xdd15
movq 0x60708(%rip), %rax     # 0x6e400
movq (%rax), %rdi
xorl %esi, %esi
movl $0xfffffe0c, %edx       # imm = 0xFFFFFE0C
movl $0xfffffe0c, %ecx       # imm = 0xFFFFFE0C
movl $0x1, %r8d
callq 0xbc6a
movq %rax, (%rbx)
leaq 0x10(%r12), %rdi
leaq 0x30(%r12), %r15
addq $0x50, %r12
movl %r14d, 0x70(%rbx)
movl $0x1, 0x8(%rbx)
movq $0x0, 0x84(%rbx)
movl $0x0, 0x8c(%rbx)
movaps 0xa466(%rip), %xmm0     # 0x181b0
movups %xmm0, 0x74(%rbx)
movb $0x0, 0x98(%rbx)
cmpl $0x5, %r14d
ja 0xdefd
movl %r14d, %eax
leaq 0xa457(%rip), %rcx      # 0x181c0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x18(%rbx), %rdx
leaq 0xae68(%rip), %rcx      # 0x18be5
movl $0xd, %r8d
xorl %esi, %esi
callq 0x5380
movb $0x41, 0xc(%rbx)
movq 0x38(%rbx), %rdx
leaq 0xae5a(%rip), %rcx      # 0x18bf3
movl $0x48, %r8d
jmp 0xde78
movq 0x18(%rbx), %rdx
leaq 0xaf97(%rip), %rcx      # 0x18d46
movl $0xf, %r8d
xorl %esi, %esi
callq 0x5380
movb $0x45, 0xc(%rbx)
movq 0x38(%rbx), %rdx
leaq 0xaf8b(%rip), %rcx      # 0x18d56
movl $0x43, %r8d
jmp 0xde78
movq 0x18(%rbx), %rdx
leaq 0xaeb9(%rip), %rcx      # 0x18c9a
movl $0x12, %r8d
xorl %esi, %esi
callq 0x5380
movq 0x38(%rbx), %rdx
leaq 0xaeb4(%rip), %rcx      # 0x18cad
movl $0x4a, %r8d
movq %r15, %rdi
xorl %esi, %esi
callq 0x5380
movb $0x43, 0xc(%rbx)
jmp 0xdebb
movq 0x18(%rbx), %rdx
leaq 0xaedb(%rip), %rcx      # 0x18cf8
movl $0xf, %r8d
xorl %esi, %esi
callq 0x5380
movq 0x38(%rbx), %rdx
leaq 0xaed3(%rip), %rcx      # 0x18d08
movl $0x3d, %r8d
movq %r15, %rdi
xorl %esi, %esi
callq 0x5380
movb $0x44, 0xc(%rbx)
jmp 0xdebb
movq 0x18(%rbx), %rdx
leaq 0xade6(%rip), %rcx      # 0x18c3c
movl $0xe, %r8d
xorl %esi, %esi
callq 0x5380
movb $0x42, 0xc(%rbx)
movq 0x38(%rbx), %rdx
leaq 0xadd9(%rip), %rcx      # 0x18c4b
movl $0x4e, %r8d
movq %r15, %rdi
xorl %esi, %esi
callq 0x5380
jmp 0xdebb
movq 0x18(%rbx), %rdx
leaq 0xaf0b(%rip), %rcx      # 0x18d9a
movl $0xb, %r8d
xorl %esi, %esi
callq 0x5380
movq 0x38(%rbx), %rdx
leaq 0xaeff(%rip), %rcx      # 0x18da6
movl $0x57, %r8d
movq %r15, %rdi
xorl %esi, %esi
callq 0x5380
movb $0x46, 0xc(%rbx)
movl 0x4(%rsp), %ebp
movq %r12, %rdi
movq %r15, %rsi
callq 0x5170
testb %bpl, %bpl
je 0xdeeb
movq 0x6061a(%rip), %rax     # 0x6e4f0
movq 0x20(%rax), %rax
movq %rax, 0x90(%rbx)
movq %rbx, %rdi
callq 0xbacc
jmp 0xdf34
movq %rbx, %rdi
movl 0x8(%rsp), %esi
movl 0xc(%rsp), %edx
callq 0xb9a6
jmp 0xdf34
movq %rdi, %r14
movq (%r12), %rdi
cmpq %rbp, %rdi
je 0xdf0e
callq 0x5230
movq (%r15), %rdi
cmpq %r13, %rdi
je 0xdf1b
callq 0x5230
movq (%r14), %rdi
cmpq 0x10(%rsp), %rdi
je 0xdf2a
callq 0x5230
movq %rbx, %rdi
callq 0x5230
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq