#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 __u16;

/* Variables and functions */
int CEC_MSG_CDC_HEC_INQUIRE_STATE;
int CEC_MSG_CDC_MESSAGE;
void cec_msg_cdc_hec_inquire_state(struct cec_msg *msg, __u16 phys_addr1,
                                   __u16 phys_addr2) {
  msg->len = 9;
  msg->msg[0] |= 0xf;
  msg->msg[1] = CEC_MSG_CDC_MESSAGE;
  msg->msg[4] = CEC_MSG_CDC_HEC_INQUIRE_STATE;
  msg->msg[5] = phys_addr1 >> 8;
  msg->msg[6] = phys_addr1 & 0xff;
  msg->msg[7] = phys_addr2 >> 8;
  msg->msg[8] = phys_addr2 & 0xff;
}


x86 assembly (clang, -O0):
<cec_msg_cdc_hec_inquire_state>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movl   $0x9,(%rax)
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    (%rax),%ecx
or     $0xf,%ecx
mov    %ecx,(%rax)
mov    0x2eaa(%rip),%rax
mov    (%rax),%ecx
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    %ecx,0x4(%rax)
mov    0x2ea6(%rip),%rax
mov    (%rax),%ecx
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    %ecx,0x10(%rax)
mov    -0xc(%rbp),%ecx
sar    $0x8,%ecx
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    %ecx,0x14(%rax)
mov    -0xc(%rbp),%ecx
and    $0xff,%ecx
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    %ecx,0x18(%rax)
mov    -0x10(%rbp),%ecx
sar    $0x8,%ecx
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    %ecx,0x1c(%rax)
mov    -0x10(%rbp),%ecx
and    $0xff,%ecx
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    %ecx,0x20(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<cec_msg_cdc_hec_inquire_state>:
movl   $0x9,(%rdi)
mov    0x8(%rdi),%rax
orl    $0xf,(%rax)
mov    0x2ec4(%rip),%rcx
mov    (%rcx),%ecx
mov    %ecx,0x4(%rax)
mov    0x2ec8(%rip),%rcx
mov    (%rcx),%ecx
mov    %ecx,0x10(%rax)
movzbl %sil,%ecx
sar    $0x8,%esi
mov    %esi,0x14(%rax)
mov    %ecx,0x18(%rax)
movzbl %dl,%ecx
sar    $0x8,%edx
mov    %edx,0x1c(%rax)
mov    %ecx,0x20(%rax)
ret

LLVM IR (-O0):
%struct.cec_msg = type { i32, i32* }
@CEC_MSG_CDC_MESSAGE = global i32 0
@CEC_MSG_CDC_HEC_INQUIRE_STATE = global i32 0
define void @cec_msg_cdc_hec_inquire_state(%struct.cec_msg* %0, i32 %1, i32 %2) {
%4 = alloca %struct.cec_msg*
%5 = alloca i32
%6 = alloca i32
store %struct.cec_msg* %0, %struct.cec_msg** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%7 = load %struct.cec_msg*, %struct.cec_msg** %4
%8 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %7, i32 0, i32 0
store i32 9, i32* %8
%9 = load %struct.cec_msg*, %struct.cec_msg** %4
%10 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %9, i32 0, i32 1
%11 = load i32*, i32** %10
%12 = getelementptr inbounds i32, i32* %11, i64 0
%13 = load i32, i32* %12
%14 = or i32 %13, 15
store i32 %14, i32* %12
%15 = load i32, i32* @CEC_MSG_CDC_MESSAGE
%16 = load %struct.cec_msg*, %struct.cec_msg** %4
%17 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %16, i32 0, i32 1
%18 = load i32*, i32** %17
%19 = getelementptr inbounds i32, i32* %18, i64 1
store i32 %15, i32* %19
%20 = load i32, i32* @CEC_MSG_CDC_HEC_INQUIRE_STATE
%21 = load %struct.cec_msg*, %struct.cec_msg** %4
%22 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %21, i32 0, i32 1
%23 = load i32*, i32** %22
%24 = getelementptr inbounds i32, i32* %23, i64 4
store i32 %20, i32* %24
%25 = load i32, i32* %5
%26 = ashr i32 %25, 8
%27 = load %struct.cec_msg*, %struct.cec_msg** %4
%28 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %27, i32 0, i32 1
%29 = load i32*, i32** %28
%30 = getelementptr inbounds i32, i32* %29, i64 5
store i32 %26, i32* %30
%31 = load i32, i32* %5
%32 = and i32 %31, 255
%33 = load %struct.cec_msg*, %struct.cec_msg** %4
%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 6
store i32 %32, i32* %36
%37 = load i32, i32* %6
%38 = ashr i32 %37, 8
%39 = load %struct.cec_msg*, %struct.cec_msg** %4
%40 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %39, i32 0, i32 1
%41 = load i32*, i32** %40
%42 = getelementptr inbounds i32, i32* %41, i64 7
store i32 %38, i32* %42
%43 = load i32, i32* %6
%44 = and i32 %43, 255
%45 = load %struct.cec_msg*, %struct.cec_msg** %4
%46 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %45, i32 0, i32 1
%47 = load i32*, i32** %46
%48 = getelementptr inbounds i32, i32* %47, i64 8
store i32 %44, i32* %48
ret void
}

LLVM IR (-O2):
%struct.cec_msg = type { i32, i32* }
@CEC_MSG_CDC_MESSAGE = global i32 0
@CEC_MSG_CDC_HEC_INQUIRE_STATE = global i32 0
define void @cec_msg_cdc_hec_inquire_state(%struct.cec_msg* nocapture %0, i32 %1, i32 %2) {
%4 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %0, i64 0, i32 0
store i32 9, i32* %4
%5 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %0, i64 0, i32 1
%6 = load i32*, i32** %5
%7 = load i32, i32* %6
%8 = or i32 %7, 15
store i32 %8, i32* %6
%9 = load i32, i32* @CEC_MSG_CDC_MESSAGE
%10 = getelementptr inbounds i32, i32* %6, i64 1
store i32 %9, i32* %10
%11 = load i32, i32* @CEC_MSG_CDC_HEC_INQUIRE_STATE
%12 = getelementptr inbounds i32, i32* %6, i64 4
store i32 %11, i32* %12
%13 = ashr i32 %1, 8
%14 = getelementptr inbounds i32, i32* %6, i64 5
store i32 %13, i32* %14
%15 = and i32 %1, 255
%16 = getelementptr inbounds i32, i32* %6, i64 6
store i32 %15, i32* %16
%17 = ashr i32 %2, 8
%18 = getelementptr inbounds i32, i32* %6, i64 7
store i32 %17, i32* %18
%19 = and i32 %2, 255
%20 = getelementptr inbounds i32, i32* %6, i64 8
store i32 %19, i32* %20
ret void
}