// File: /workspace/github_c_makefile_star2_O0/seuscq[P]rtk_hciattach/hciattach_rtk.c
// Function: hci_event_cmd_complete
static void hci_event_cmd_complete(struct sk_buff *skb)
{
	struct hci_event_hdr *hdr = (struct hci_event_hdr *)skb->data;
	struct hci_ev_cmd_complete *ev = NULL;
	RT_U16 opcode = 0;
	RT_U8 status = 0;

	//pull hdr
	skb_pull(skb, HCI_EVENT_HDR_SIZE);
	ev = (struct hci_ev_cmd_complete *)skb->data;
	opcode = le16_to_cpu(ev->opcode);

	RS_DBG("receive hci command complete event with command:%x\n", opcode);

	//pull command complete event header
	skb_pull(skb, sizeof(struct hci_ev_cmd_complete));

	switch (opcode) {
	case HCI_VENDOR_CHANGE_BDRATE:
		status = skb->data[0];
		RS_DBG("Change BD Rate with status:%x", status);
		skb_free(rtk_hw_cfg.host_last_cmd);
		rtk_hw_cfg.host_last_cmd = NULL;
		rtk_hw_cfg.link_estab_state = H5_PATCH;
		break;

	case HCI_CMD_READ_BD_ADDR:
		status = skb->data[0];
		RS_DBG("Read BD Address with Status:%x", status);
		if (!status) {
			RS_DBG("BD Address: %8x%8x", *(int *)&skb->data[1],
			       *(int *)&skb->data[5]);
		}
		break;

	case HCI_CMD_READ_LOCAL_VERISION:
		rtk_hw_cfg.hci_version_cmd_state = event_received;
		status = skb->data[0];
		RS_DBG("Read Local Version Information with Status:%x", status);
		if (0 == status) {
			rtk_hw_cfg.hci_ver = skb->data[1];
			rtk_hw_cfg.hci_rev = (skb->data[2] | skb->data[3] << 8);
			rtk_hw_cfg.lmp_subver =
			    (skb->data[7] | (skb->data[8] << 8));
			RS_DBG("HCI Version 0x%02x", rtk_hw_cfg.hci_ver);
			RS_DBG("HCI Revision 0x%04x", rtk_hw_cfg.hci_rev);
			RS_DBG("LMP Subversion 0x%04x", rtk_hw_cfg.lmp_subver);
		} else {
			RS_ERR("Read Local Version Info status error!");
			//Need to do more
		}
		skb_free(rtk_hw_cfg.host_last_cmd);
		rtk_hw_cfg.host_last_cmd = NULL;
		break;

	case HCI_VENDOR_READ_RTK_ROM_VERISION:
		rtk_hw_cfg.rom_version_cmd_state = event_received;
		status = skb->data[0];
		RS_DBG("Read RTK rom version with Status:%x", status);
		if (0 == status)
			rtk_hw_cfg.eversion = skb->data[1];
		else if (1 == status)
			rtk_hw_cfg.eversion = 0;
		else {
			RS_ERR("READ_RTK_ROM_VERISION return status error!");
			//Need to do more
		}

		skb_free(rtk_hw_cfg.host_last_cmd);
		rtk_hw_cfg.host_last_cmd = NULL;
		break;
	case HCI_VENDOR_READ_CHIP_TYPE:
		rtk_hw_cfg.chip_type_cmd_state = event_received;
		status = skb->data[0];
		RS_DBG("Read RTK chip type with Status:%x", status);
		if (0 == status)
			rtk_hw_cfg.chip_type= (skb->data[1] & 0x0f);
		else
			RS_ERR("READ_RTK_CHIP_TYPE return status error!");
		skb_free(rtk_hw_cfg.host_last_cmd);
		rtk_hw_cfg.host_last_cmd = NULL;
		break;
	default:
		return;
	}
	rtk_hw_cfg.num_of_cmd_sent++;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x10(%rbp)
movq $0x0, -0x18(%rbp)
movw $0x0, -0x1a(%rbp)
movb $0x0, -0x1b(%rbp)
movq -0x8(%rbp), %rdi
movl $0x2, %esi
callq 0x8dd0
movq -0x8(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movw 0x1(%rax), %ax
movw %ax, -0x1a(%rbp)
cmpb $0x0, 0x6fb9(%rip)      # 0x102d0
je 0x933c
movq 0x6cd8(%rip), %rax      # 0xfff8
movq (%rax), %rdi
movzwl -0x1a(%rbp), %ecx
leaq 0x3404(%rip), %rsi      # 0xc732
leaq 0x2254(%rip), %rdx      # 0xb589
movb $0x0, %al
callq 0x2150
jmp 0x933e
movq -0x8(%rbp), %rdi
movl $0x3, %esi
callq 0x8dd0
movzwl -0x1a(%rbp), %eax
movl %eax, -0x20(%rbp)
subl $0x1001, %eax           # imm = 0x1001
je 0x947d
jmp 0x9360
movl -0x20(%rbp), %eax
subl $0x1009, %eax           # imm = 0x1009
je 0x93fd
jmp 0x9370
movl -0x20(%rbp), %eax
subl $0xfc17, %eax           # imm = 0xFC17
je 0x939f
jmp 0x937c
movl -0x20(%rbp), %eax
subl $0xfc61, %eax           # imm = 0xFC61
je 0x969c
jmp 0x938c
movl -0x20(%rbp), %eax
subl $0xfc6d, %eax           # imm = 0xFC6D
je 0x95ea
jmp 0x9737
movq -0x8(%rbp), %rax
movb 0x8(%rax), %al
movb %al, -0x1b(%rbp)
cmpb $0x0, 0x6f20(%rip)      # 0x102d0
je 0x93d5
movq 0x6c3f(%rip), %rax      # 0xfff8
movq (%rax), %rdi
movzbl -0x1b(%rbp), %ecx
leaq 0x33a4(%rip), %rsi      # 0xc76b
leaq 0x21bb(%rip), %rdx      # 0xb589
movb $0x0, %al
callq 0x2150
jmp 0x93d7
movq 0x7312(%rip), %rdi      # 0x106f0
callq 0x66c0
movq $0x0, 0x7302(%rip) # 0x106f0
movl $0x3, 0x72ec(%rip)      # 0x106e4
jmp 0x9739
movq -0x8(%rbp), %rax
movb 0x8(%rax), %al
movb %al, -0x1b(%rbp)
cmpb $0x0, 0x6ec2(%rip)      # 0x102d0
je 0x9433
movq 0x6be1(%rip), %rax      # 0xfff8
movq (%rax), %rdi
movzbl -0x1b(%rbp), %ecx
leaq 0x3369(%rip), %rsi      # 0xc78e
leaq 0x215d(%rip), %rdx      # 0xb589
movb $0x0, %al
callq 0x2150
jmp 0x9435
cmpb $0x0, -0x1b(%rbp)
jne 0x9478
jmp 0x943d
cmpb $0x0, 0x6e8c(%rip)      # 0x102d0
je 0x9474
movq 0x6bab(%rip), %rax      # 0xfff8
movq (%rax), %rdi
movq -0x8(%rbp), %rax
movl 0x9(%rax), %ecx
movq -0x8(%rbp), %rax
movl 0xd(%rax), %r8d
leaq 0x334c(%rip), %rsi      # 0xc7b2
leaq 0x211c(%rip), %rdx      # 0xb589
movb $0x0, %al
callq 0x2150
jmp 0x9476
jmp 0x9478
jmp 0x9739
movl $0x2, 0x72cd(%rip)      # 0x10754
movq -0x8(%rbp), %rax
movb 0x8(%rax), %al
movb %al, -0x1b(%rbp)
cmpb $0x0, 0x6e38(%rip)      # 0x102d0
je 0x94bd
movq 0x6b57(%rip), %rax      # 0xfff8
movq (%rax), %rdi
movzbl -0x1b(%rbp), %ecx
leaq 0x331b(%rip), %rsi      # 0xc7ca
leaq 0x20d3(%rip), %rdx      # 0xb589
movb $0x0, %al
callq 0x2150
jmp 0x94bf
movzbl -0x1b(%rbp), %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x95ab
movq -0x8(%rbp), %rax
movb 0x9(%rax), %al
movb %al, 0x7224(%rip)       # 0x106fe
movq -0x8(%rbp), %rax
movzbl 0xa(%rax), %eax
movq -0x8(%rbp), %rcx
movzbl 0xb(%rcx), %ecx
shll $0x8, %ecx
orl %ecx, %eax
movw %ax, 0x7206(%rip)       # 0x106fc
movq -0x8(%rbp), %rax
movzbl 0xf(%rax), %eax
movq -0x8(%rbp), %rcx
movzbl 0x10(%rcx), %ecx
shll $0x8, %ecx
orl %ecx, %eax
movw %ax, 0x71e8(%rip)       # 0x106fa
cmpb $0x0, 0x6db7(%rip)      # 0x102d0
je 0x9541
movq 0x6ad6(%rip), %rax      # 0xfff8
movq (%rax), %rdi
movzbl 0x71d2(%rip), %ecx      # 0x106fe
leaq 0x32ca(%rip), %rsi      # 0xc7fd
leaq 0x204f(%rip), %rdx      # 0xb589
movb $0x0, %al
callq 0x2150
jmp 0x9543
jmp 0x9545
cmpb $0x0, 0x6d84(%rip)      # 0x102d0
je 0x9574
movq 0x6aa3(%rip), %rax      # 0xfff8
movq (%rax), %rdi
movzwl 0x719d(%rip), %ecx      # 0x106fc
leaq 0x32af(%rip), %rsi      # 0xc815
leaq 0x201c(%rip), %rdx      # 0xb589
movb $0x0, %al
callq 0x2150
jmp 0x9576
jmp 0x9578
cmpb $0x0, 0x6d51(%rip)      # 0x102d0
je 0x95a7
movq 0x6a70(%rip), %rax      # 0xfff8
movq (%rax), %rdi
movzwl 0x7168(%rip), %ecx      # 0x106fa
leaq 0x3295(%rip), %rsi      # 0xc82e
leaq 0x1fe9(%rip), %rdx      # 0xb589
movb $0x0, %al
callq 0x2150
jmp 0x95a9
jmp 0x95ce
jmp 0x95ad
movq 0x6a44(%rip), %rax      # 0xfff8
movq (%rax), %rdi
leaq 0x328b(%rip), %rsi      # 0xc849
leaq 0x1fc4(%rip), %rdx      # 0xb589
movb $0x0, %al
callq 0x2150
jmp 0x95ce
movq 0x711b(%rip), %rdi      # 0x106f0
callq 0x66c0
movq $0x0, 0x710b(%rip) # 0x106f0
jmp 0x9739
movl $0x2, 0x715c(%rip)      # 0x10750
movq -0x8(%rbp), %rax
movb 0x8(%rax), %al
movb %al, -0x1b(%rbp)
cmpb $0x0, 0x6ccb(%rip)      # 0x102d0
je 0x962a
movq 0x69ea(%rip), %rax      # 0xfff8
movq (%rax), %rdi
movzbl -0x1b(%rbp), %ecx
leaq 0x325e(%rip), %rsi      # 0xc87a
leaq 0x1f66(%rip), %rdx      # 0xb589
movb $0x0, %al
callq 0x2150
jmp 0x962c
movzbl -0x1b(%rbp), %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x9645
movq -0x8(%rbp), %rax
movb 0x9(%rax), %al
movb %al, 0x70bc(%rip)       # 0x106ff
jmp 0x9680
movzbl -0x1b(%rbp), %ecx
movl $0x1, %eax
cmpl %ecx, %eax
jne 0x965b
movb $0x0, 0x70a6(%rip)      # 0x106ff
jmp 0x967e
jmp 0x965d
movq 0x6994(%rip), %rax      # 0xfff8
movq (%rax), %rdi
leaq 0x3235(%rip), %rsi      # 0xc8a3
leaq 0x1f14(%rip), %rdx      # 0xb589
movb $0x0, %al
callq 0x2150
jmp 0x967e
jmp 0x9680
movq 0x7069(%rip), %rdi      # 0x106f0
callq 0x66c0
movq $0x0, 0x7059(%rip) # 0x106f0
jmp 0x9739
movl $0x2, 0x70b2(%rip)      # 0x10758
movq -0x8(%rbp), %rax
movb 0x8(%rax), %al
movb %al, -0x1b(%rbp)
cmpb $0x0, 0x6c19(%rip)      # 0x102d0
je 0x96dc
movq 0x6938(%rip), %rax      # 0xfff8
movq (%rax), %rdi
movzbl -0x1b(%rbp), %ecx
leaq 0x320b(%rip), %rsi      # 0xc8d9
leaq 0x1eb4(%rip), %rdx      # 0xb589
movb $0x0, %al
callq 0x2150
jmp 0x96de
movzbl -0x1b(%rbp), %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x96fb
movq -0x8(%rbp), %rax
movzbl 0x9(%rax), %eax
andl $0xf, %eax
movb %al, 0x700b(%rip)       # 0x10704
jmp 0x971e
jmp 0x96fd
movq 0x68f4(%rip), %rax      # 0xfff8
movq (%rax), %rdi
leaq 0x31f2(%rip), %rsi      # 0xc900
leaq 0x1e74(%rip), %rdx      # 0xb589
movb $0x0, %al
callq 0x2150
jmp 0x971e
movq 0x6fcb(%rip), %rdi      # 0x106f0
callq 0x66c0
movq $0x0, 0x6fbb(%rip) # 0x106f0
jmp 0x9739
jmp 0x974b
movw 0x6fb8(%rip), %ax       # 0x106f8
addw $0x1, %ax
movw %ax, 0x6fad(%rip)       # 0x106f8
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)