#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
struct cec_msg {
  int len;
  int *msg;
};
typedef int __u8;
typedef int __u32;

/* Variables and functions */
void cec_ops_vendor_command_with_id(const struct cec_msg *msg, __u32 *vendor_id,
                                    __u8 *size, const __u8 **vendor_cmd) {
  *size = msg->len - 5;
  if (*size > 11)
    *size = 11;
  *vendor_id = (msg->msg[2] << 16) | (msg->msg[3] << 8) | msg->msg[4];
  *vendor_cmd = msg->msg + 5;
}


x86 assembly (clang, -O0):
<cec_ops_vendor_command_with_id>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%ecx
sub    $0x5,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
cmpl   $0xb,(%rax)
jle    113a <cec_ops_vendor_command_with_id+0x3a>
mov    -0x18(%rbp),%rax
movl   $0xb,(%rax)
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    0x8(%rax),%ecx
shl    $0x10,%ecx
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    0xc(%rax),%eax
shl    $0x8,%eax
or     %eax,%ecx
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
or     0x10(%rax),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rcx
add    $0x14,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<cec_ops_vendor_command_with_id>:
mov    (%rdi),%eax
lea    -0x5(%rax),%r8d
cmp    $0x11,%eax
mov    $0xb,%eax
cmovl  %r8d,%eax
mov    %eax,(%rdx)
mov    0x8(%rdi),%rax
mov    0x8(%rax),%edx
mov    0xc(%rax),%edi
shl    $0x10,%edx
shl    $0x8,%edi
or     %edx,%edi
or     0x10(%rax),%edi
mov    %edi,(%rsi)
add    $0x14,%rax
mov    %rax,(%rcx)
ret

LLVM IR (-O0):
%struct.cec_msg = type { i32, i32* }
define void @cec_ops_vendor_command_with_id(%struct.cec_msg* %0, i32* %1, i32* %2, i32** %3) {
%5 = alloca %struct.cec_msg*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32**
store %struct.cec_msg* %0, %struct.cec_msg** %5
store i32* %1, i32** %6
store i32* %2, i32** %7
store i32** %3, i32*** %8
%9 = load %struct.cec_msg*, %struct.cec_msg** %5
%10 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %9, i32 0, i32 0
%11 = load i32, i32* %10
%12 = sub nsw i32 %11, 5
%13 = load i32*, i32** %7
store i32 %12, i32* %13
%14 = load i32*, i32** %7
%15 = load i32, i32* %14
%16 = icmp sgt i32 %15, 11
br i1 %16, label %17, label %19
17: ; preds = %4
%18 = load i32*, i32** %7
store i32 11, i32* %18
br label %19
19: ; preds = %17, %4
%20 = load %struct.cec_msg*, %struct.cec_msg** %5
%21 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %20, i32 0, i32 1
%22 = load i32*, i32** %21
%23 = getelementptr inbounds i32, i32* %22, i64 2
%24 = load i32, i32* %23
%25 = shl i32 %24, 16
%26 = load %struct.cec_msg*, %struct.cec_msg** %5
%27 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %26, i32 0, i32 1
%28 = load i32*, i32** %27
%29 = getelementptr inbounds i32, i32* %28, i64 3
%30 = load i32, i32* %29
%31 = shl i32 %30, 8
%32 = or i32 %25, %31
%33 = load %struct.cec_msg*, %struct.cec_msg** %5
%34 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %33, i32 0, i32 1
%35 = load i32*, i32** %34
%36 = getelementptr inbounds i32, i32* %35, i64 4
%37 = load i32, i32* %36
%38 = or i32 %32, %37
%39 = load i32*, i32** %6
store i32 %38, i32* %39
%40 = load %struct.cec_msg*, %struct.cec_msg** %5
%41 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %40, i32 0, i32 1
%42 = load i32*, i32** %41
%43 = getelementptr inbounds i32, i32* %42, i64 5
%44 = load i32**, i32*** %8
store i32* %43, i32** %44
ret void
}

LLVM IR (-O2):
%struct.cec_msg = type { i32, i32* }
define void @cec_ops_vendor_command_with_id(%struct.cec_msg* nocapture %0, i32* nocapture writeonly %1, i32* nocapture writeonly %2, i32** nocapture writeonly %3) {
%5 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %0, i64 0, i32 0
%6 = load i32, i32* %5
%7 = add nsw i32 %6, -5
%8 = icmp sgt i32 %6, 16
%9 = select i1 %8, i32 11, i32 %7
store i32 %9, i32* %2
%10 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %0, i64 0, i32 1
%11 = load i32*, i32** %10
%12 = getelementptr inbounds i32, i32* %11, i64 2
%13 = load i32, i32* %12
%14 = shl i32 %13, 16
%15 = getelementptr inbounds i32, i32* %11, i64 3
%16 = load i32, i32* %15
%17 = shl i32 %16, 8
%18 = or i32 %17, %14
%19 = getelementptr inbounds i32, i32* %11, i64 4
%20 = load i32, i32* %19
%21 = or i32 %18, %20
store i32 %21, i32* %1
%22 = getelementptr inbounds i32, i32* %11, i64 5
store i32* %22, i32** %3
ret void
}