#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;
  int /*<<< orphan*/ reply;
};
typedef int __u16;

/* Variables and functions */
int CEC_MSG_ROUTING_CHANGE;
int /*<<< orphan*/ CEC_MSG_ROUTING_INFORMATION;
void cec_msg_routing_change(struct cec_msg *msg, int reply,
                            __u16 orig_phys_addr, __u16 new_phys_addr) {
  msg->len = 6;
  msg->msg[0] |= 0xf;
  msg->msg[1] = CEC_MSG_ROUTING_CHANGE;
  msg->msg[2] = orig_phys_addr >> 8;
  msg->msg[3] = orig_phys_addr & 0xff;
  msg->msg[4] = new_phys_addr >> 8;
  msg->msg[5] = new_phys_addr & 0xff;
  msg->reply = reply ? CEC_MSG_ROUTING_INFORMATION : 0;
}


x86 assembly (clang, -O0):
<cec_msg_routing_change>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movl   $0x6,(%rax)
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    (%rax),%ecx
or     $0xf,%ecx
mov    %ecx,(%rax)
mov    0x2eb7(%rip),%rax
mov    (%rax),%ecx
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    %ecx,0x4(%rax)
mov    -0x10(%rbp),%ecx
sar    $0x8,%ecx
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    %ecx,0x8(%rax)
mov    -0x10(%rbp),%ecx
and    $0xff,%ecx
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    %ecx,0xc(%rax)
mov    -0x14(%rbp),%ecx
sar    $0x8,%ecx
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    %ecx,0x10(%rax)
mov    -0x14(%rbp),%ecx
and    $0xff,%ecx
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    %ecx,0x14(%rax)
cmpl   $0x0,-0xc(%rbp)
je     11a3 <cec_msg_routing_change+0xa3>
mov    0x2e3f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
jmp    11ad <cec_msg_routing_change+0xad>
xor    %eax,%eax
mov    %eax,-0x18(%rbp)
jmp    11ad <cec_msg_routing_change+0xad>
mov    -0x18(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x10(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<cec_msg_routing_change>:
movl   $0x6,(%rdi)
mov    0x8(%rdi),%r8
orl    $0xf,(%r8)
mov    0x2ed3(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x4(%r8)
movzbl %dl,%eax
sar    $0x8,%edx
mov    %edx,0x8(%r8)
mov    %eax,0xc(%r8)
movzbl %cl,%eax
sar    $0x8,%ecx
mov    %ecx,0x10(%r8)
mov    %eax,0x14(%r8)
test   %esi,%esi
je     1144 <cec_msg_routing_change+0x44>
mov    0x2e96(%rip),%rax
mov    (%rax),%esi
mov    %esi,0x10(%rdi)
ret

LLVM IR (-O0):
%struct.cec_msg = type { i32, i32*, i32 }
@CEC_MSG_ROUTING_CHANGE = global i32 0
@CEC_MSG_ROUTING_INFORMATION = global i32 0
define void @cec_msg_routing_change(%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
store i32 6, i32* %10
%11 = load %struct.cec_msg*, %struct.cec_msg** %5
%12 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %11, i32 0, i32 1
%13 = load i32*, i32** %12
%14 = getelementptr inbounds i32, i32* %13, i64 0
%15 = load i32, i32* %14
%16 = or i32 %15, 15
store i32 %16, i32* %14
%17 = load i32, i32* @CEC_MSG_ROUTING_CHANGE
%18 = load %struct.cec_msg*, %struct.cec_msg** %5
%19 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %18, i32 0, i32 1
%20 = load i32*, i32** %19
%21 = getelementptr inbounds i32, i32* %20, i64 1
store i32 %17, i32* %21
%22 = load i32, i32* %7
%23 = ashr i32 %22, 8
%24 = load %struct.cec_msg*, %struct.cec_msg** %5
%25 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %24, i32 0, i32 1
%26 = load i32*, i32** %25
%27 = getelementptr inbounds i32, i32* %26, i64 2
store i32 %23, i32* %27
%28 = load i32, i32* %7
%29 = and i32 %28, 255
%30 = load %struct.cec_msg*, %struct.cec_msg** %5
%31 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %30, i32 0, i32 1
%32 = load i32*, i32** %31
%33 = getelementptr inbounds i32, i32* %32, i64 3
store i32 %29, i32* %33
%34 = load i32, i32* %8
%35 = ashr i32 %34, 8
%36 = load %struct.cec_msg*, %struct.cec_msg** %5
%37 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %36, i32 0, i32 1
%38 = load i32*, i32** %37
%39 = getelementptr inbounds i32, i32* %38, i64 4
store i32 %35, i32* %39
%40 = load i32, i32* %8
%41 = and i32 %40, 255
%42 = load %struct.cec_msg*, %struct.cec_msg** %5
%43 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %42, i32 0, i32 1
%44 = load i32*, i32** %43
%45 = getelementptr inbounds i32, i32* %44, i64 5
store i32 %41, i32* %45
%46 = load i32, i32* %6
%47 = icmp ne i32 %46, 0
br i1 %47, label %48, label %50
48: ; preds = %4
%49 = load i32, i32* @CEC_MSG_ROUTING_INFORMATION
br label %51
50: ; preds = %4
br label %51
51: ; preds = %50, %48
%52 = phi i32 [ %49, %48 ], [ 0, %50 ]
%53 = load %struct.cec_msg*, %struct.cec_msg** %5
%54 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %53, i32 0, i32 2
store i32 %52, i32* %54
ret void
}

LLVM IR (-O2):
%struct.cec_msg = type { i32, i32*, i32 }
@CEC_MSG_ROUTING_CHANGE = global i32 0
@CEC_MSG_ROUTING_INFORMATION = global i32 0
define void @cec_msg_routing_change(%struct.cec_msg* nocapture %0, i32 %1, i32 %2, i32 %3) {
%5 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %0, i64 0, i32 0
store i32 6, i32* %5
%6 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %0, i64 0, i32 1
%7 = load i32*, i32** %6
%8 = load i32, i32* %7
%9 = or i32 %8, 15
store i32 %9, i32* %7
%10 = load i32, i32* @CEC_MSG_ROUTING_CHANGE
%11 = getelementptr inbounds i32, i32* %7, i64 1
store i32 %10, i32* %11
%12 = ashr i32 %2, 8
%13 = getelementptr inbounds i32, i32* %7, i64 2
store i32 %12, i32* %13
%14 = and i32 %2, 255
%15 = getelementptr inbounds i32, i32* %7, i64 3
store i32 %14, i32* %15
%16 = ashr i32 %3, 8
%17 = getelementptr inbounds i32, i32* %7, i64 4
store i32 %16, i32* %17
%18 = and i32 %3, 255
%19 = getelementptr inbounds i32, i32* %7, i64 5
store i32 %18, i32* %19
%20 = icmp eq i32 %1, 0
%21 = load i32, i32* @CEC_MSG_ROUTING_INFORMATION
%22 = select i1 %20, i32 0, i32 %21
%23 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %0, i64 0, i32 2
store i32 %22, i32* %23
ret void
}