// File: /workspace/github_cpp_makefile_star2_O1/t0mm4rx[P]piscine_cpp/day00/ex01/commands.cpp
// Function: search(Contact*, int*)
void search(Contact contacts[8], int *index)
{
	std::string	buffer;
	int					detail;

	print_contacts(contacts, index);
	if (*index == 0)
		return;
	std::cin.ignore();
	std::cout << "Enter the index of the contact: ";
	std::getline(std::cin, buffer);
	try {
		detail = std::stoi(buffer);
		if (detail >= 0 && detail < *index)
		{
			contacts[detail].print();
			std::cout << std::endl;
		}
		else
			std::cout << "No contact with this id!" << std::endl << std::endl;
	}
	catch (std::invalid_argument)
	{
		std::cout << "Invalid index!" << std::endl << std::endl;
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, %r15
movq %rdi, %r14
leaq 0x18(%rsp), %r13
movq %r13, -0x10(%r13)
movq $0x0, -0x8(%r13)
movb $0x0, (%r13)
callq 0x3d26
cmpl $0x0, (%r15)
je 0x3c0e
movq 0x3528(%rip), %r12      # 0x6fe0
movq %r12, %rdi
callq 0x21f0
movq 0x3509(%rip), %rbx      # 0x6fd0
leaq 0x16ed(%rip), %rsi      # 0x51bb
movl $0x20, %edx
movq %rbx, %rdi
callq 0x2120
movq (%r12), %rax
addq -0x18(%rax), %r12
movq %r12, %rdi
movl $0xa, %esi
callq 0x20f0
movsbl %al, %edx
movq 0x34e6(%rip), %rdi      # 0x6fe0
leaq 0x8(%rsp), %rsi
callq 0x2200
movq 0x8(%rsp), %r13
callq 0x2040
movq %rax, %r12
movl (%rax), %eax
movl %eax, 0x4(%rsp)
movl $0x0, (%r12)
leaq 0x28(%rsp), %rbp
movq %r13, %rdi
movq %rbp, %rsi
movl $0xa, %edx
callq 0x2160
cmpq %r13, (%rbp)
je 0x3c34
movslq %eax, %rcx
cmpq %rax, %rcx
jne 0x3c40
movl (%r12), %ecx
cmpl $0x22, %ecx
je 0x3c40
testl %ecx, %ecx
leaq 0x18(%rsp), %r13
jne 0x3b68
movl 0x4(%rsp), %ecx
movl %ecx, (%r12)
testl %eax, %eax
js 0x3b9e
cmpl %eax, (%r15)
jle 0x3b9e
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
imulq $0x160, %rax, %rax      # imm = 0x160
addq %rax, %r14
movq %r14, %rdi
callq 0x45c8
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x20f0
jmp 0x3bfb
movq 0x342b(%rip), %rbx      # 0x6fd0
leaq 0x1630(%rip), %rsi      # 0x51dc
movl $0x18, %edx
movq %rbx, %rdi
callq 0x2120
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x20f0
movsbl %al, %esi
movq 0x33f9(%rip), %rdi      # 0x6fd0
callq 0x2030
movq %rax, %rdi
callq 0x20b0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x20f0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20b0
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
je 0x3c25
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x2100
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1767(%rip), %rdi      # 0x53a2
callq 0x20a0
leaq 0x175b(%rip), %rdi      # 0x53a2
callq 0x2170
movq %rax, %rbx
cmpl $0x0, (%r12)
jne 0x3c8a
movl 0x4(%rsp), %eax
movl %eax, (%r12)
jmp 0x3c8a
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x3c7f
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x2100
movq %rbx, %rdi
callq 0x21d0
movq %rax, %rbx
cmpl $0x1, %edx
jne 0x3c63
movq %rbx, %rdi
callq 0x2140
leaq 0x28(%rsp), %r14
movq %r14, %rdi
movq %rax, %rsi
callq 0x21b0
movq 0x331a(%rip), %rax      # 0x6fc8
addq $0x10, %rax
movq %rax, (%r14)
movq %rbx, %rdi
callq 0x2070
movq 0x330c(%rip), %rdi      # 0x6fd0
leaq 0x152a(%rip), %rsi      # 0x51f5
movl $0xe, %edx
callq 0x2120
movq 0x32f4(%rip), %rdi      # 0x6fd0
callq 0x2080
movq %rax, %rdi
callq 0x2080
leaq 0x28(%rsp), %rdi
callq 0x21a0
callq 0x2190
leaq 0x18(%rsp), %r13
jmp 0x3c0e
jmp 0x3c60
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x21a0
callq 0x2190
jmp 0x3c63
movq %rax, %rdi
callq 0x42f9