// File: /workspace/github_c_makefile_star2_O0/seuscq[P]rtk_hciattach/hciattach_rtk.c
// Function: rtk_vendor_change_speed_h4
static int rtk_vendor_change_speed_h4(int fd, RT_U32 baudrate)
{
	int res;
	unsigned char bytes[257];
	RT_U8 cmd[8] = { 0 };

	cmd[0] = 1;	//cmd;
	cmd[1] = 0x17;	//ocf
	cmd[2] = 0xfc;	//ogf
	cmd[3] = 4;	//length;

	baudrate = cpu_to_le32(baudrate);
#ifdef BAUDRATE_4BYTES
	memcpy((RT_U16 *) & cmd[4], &baudrate, 4);
#else
	memcpy((RT_U16 *) & cmd[4], &baudrate, 2);
	cmd[6] = 0;
	cmd[7] = 0;
#endif

	//wait for a while for device to up, just h4 need it
	sleep(1);
	RS_DBG("baudrate in change speed command: 0x%x 0x%x 0x%x 0x%x \n",
	       cmd[4], cmd[5], cmd[6], cmd[7]);

	if (write(fd, cmd, 8) != 8) {
		RS_ERR
		    ("H4 change uart speed error when writing vendor command");
		return -1;
	}
	RS_DBG("H4 Change uart Baudrate after write ");

	res = read_hci_evt(fd, bytes, 0x0e);
	if (res < 0) {
		RS_ERR("%s: Failed to read hci evt.\n", __func__);
		return -1;
	}

	if ((0x04 == bytes[0]) && (0x17 == bytes[4]) && (0xfc == bytes[5])) {
		RS_DBG("H4 change uart speed success, receving status:%x",
		       bytes[6]);
		if (bytes[6] == 0)
			return 0;
	}
	return -1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x130, %rsp            # imm = 0x130
movl %edi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
leaq -0x128(%rbp), %rdi
xorl %esi, %esi
movl $0x8, %edx
callq 0x20d0
movb $0x1, -0x128(%rbp)
movb $0x17, -0x127(%rbp)
movb $-0x4, -0x126(%rbp)
movb $0x4, -0x125(%rbp)
movl -0xc(%rbp), %eax
movl %eax, -0xc(%rbp)
movl -0xc(%rbp), %eax
movl %eax, -0x124(%rbp)
movl $0x1, %edi
callq 0x22a0
cmpb $0x0, 0x6760(%rip)      # 0x102d0
je 0x9bb2
movq 0x647f(%rip), %rax      # 0xfff8
movq (%rax), %rdi
movzbl -0x124(%rbp), %ecx
movzbl -0x123(%rbp), %r8d
movzbl -0x122(%rbp), %r9d
movzbl -0x121(%rbp), %eax
leaq 0x1f84(%rip), %rsi      # 0xbb25
leaq 0x19e1(%rip), %rdx      # 0xb589
movl %eax, (%rsp)
movb $0x0, %al
callq 0x2150
jmp 0x9bb4
movl -0x8(%rbp), %edi
leaq -0x128(%rbp), %rsi
movl $0x8, %edx
callq 0x2070
cmpq $0x8, %rax
je 0x9bfb
jmp 0x9bd0
movq 0x6421(%rip), %rax      # 0xfff8
movq (%rax), %rdi
leaq 0x3345(%rip), %rsi      # 0xcf26
leaq 0x19a1(%rip), %rdx      # 0xb589
movb $0x0, %al
callq 0x2150
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x9cf9
jmp 0x9bfd
cmpb $0x0, 0x66cc(%rip)      # 0x102d0
je 0x9c25
movq 0x63eb(%rip), %rax      # 0xfff8
movq (%rax), %rdi
leaq 0x3351(%rip), %rsi      # 0xcf68
leaq 0x196b(%rip), %rdx      # 0xb589
movb $0x0, %al
callq 0x2150
jmp 0x9c27
movl -0x8(%rbp), %edi
leaq -0x120(%rbp), %rsi
movl $0xe, %edx
callq 0x3f70
movl %eax, -0x10(%rbp)
cmpl $0x0, -0x10(%rbp)
jge 0x9c78
jmp 0x9c46
movq 0x63ab(%rip), %rax      # 0xfff8
movq (%rax), %rdi
leaq 0x333b(%rip), %rsi      # 0xcf92
leaq 0x192b(%rip), %rdx      # 0xb589
leaq 0x3355(%rip), %rcx      # 0xcfba
movb $0x0, %al
callq 0x2150
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x9cf9
movzbl -0x120(%rbp), %ecx
movl $0x4, %eax
cmpl %ecx, %eax
jne 0x9cf2
movzbl -0x11c(%rbp), %ecx
movl $0x17, %eax
cmpl %ecx, %eax
jne 0x9cf2
movzbl -0x11b(%rbp), %ecx
movl $0xfc, %eax
cmpl %ecx, %eax
jne 0x9cf2
jmp 0x9caa
cmpb $0x0, 0x661f(%rip)      # 0x102d0
je 0x9cd9
movq 0x633e(%rip), %rax      # 0xfff8
movq (%rax), %rdi
movzbl -0x11a(%rbp), %ecx
leaq 0x330a(%rip), %rsi      # 0xcfd5
leaq 0x18b7(%rip), %rdx      # 0xb589
movb $0x0, %al
callq 0x2150
jmp 0x9cdb
movzbl -0x11a(%rbp), %eax
cmpl $0x0, %eax
jne 0x9cf0
movl $0x0, -0x4(%rbp)
jmp 0x9cf9
jmp 0x9cf2
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x130, %rsp            # imm = 0x130
popq %rbp
retq
nopw %cs:(%rax,%rax)