#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_RECORD_ON;
int CEC_OP_RECORD_SRC_EXT_PHYS_ADDR;
void cec_msg_record_on_phys_addr(struct cec_msg *msg, __u16 phys_addr) {
  msg->len = 5;
  msg->msg[1] = CEC_MSG_RECORD_ON;
  msg->msg[2] = CEC_OP_RECORD_SRC_EXT_PHYS_ADDR;
  msg->msg[3] = phys_addr >> 8;
  msg->msg[4] = phys_addr & 0xff;
}


x86 assembly (clang, -O0):
<cec_msg_record_on_phys_addr>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movl   $0x5,(%rax)
mov    0x2ebc(%rip),%rax
mov    (%rax),%ecx
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    %ecx,0x4(%rax)
mov    0x2ec0(%rip),%rax
mov    (%rax),%ecx
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    %ecx,0x8(%rax)
mov    -0xc(%rbp),%ecx
sar    $0x8,%ecx
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    %ecx,0xc(%rax)
mov    -0xc(%rbp),%ecx
and    $0xff,%ecx
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    %ecx,0x10(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<cec_msg_record_on_phys_addr>:
movl   $0x5,(%rdi)
mov    0x2ecb(%rip),%rax
mov    (%rax),%eax
mov    0x8(%rdi),%rcx
mov    %eax,0x4(%rcx)
mov    0x2ed3(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x8(%rcx)
movzbl %sil,%eax
sar    $0x8,%esi
mov    %esi,0xc(%rcx)
mov    %eax,0x10(%rcx)
ret

LLVM IR (-O0):
%struct.cec_msg = type { i32, i32* }
@CEC_MSG_RECORD_ON = global i32 0
@CEC_OP_RECORD_SRC_EXT_PHYS_ADDR = global i32 0
define void @cec_msg_record_on_phys_addr(%struct.cec_msg* %0, i32 %1) {
%3 = alloca %struct.cec_msg*
%4 = alloca i32
store %struct.cec_msg* %0, %struct.cec_msg** %3
store i32 %1, i32* %4
%5 = load %struct.cec_msg*, %struct.cec_msg** %3
%6 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %5, i32 0, i32 0
store i32 5, i32* %6
%7 = load i32, i32* @CEC_MSG_RECORD_ON
%8 = load %struct.cec_msg*, %struct.cec_msg** %3
%9 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %8, i32 0, i32 1
%10 = load i32*, i32** %9
%11 = getelementptr inbounds i32, i32* %10, i64 1
store i32 %7, i32* %11
%12 = load i32, i32* @CEC_OP_RECORD_SRC_EXT_PHYS_ADDR
%13 = load %struct.cec_msg*, %struct.cec_msg** %3
%14 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %13, i32 0, i32 1
%15 = load i32*, i32** %14
%16 = getelementptr inbounds i32, i32* %15, i64 2
store i32 %12, i32* %16
%17 = load i32, i32* %4
%18 = ashr i32 %17, 8
%19 = load %struct.cec_msg*, %struct.cec_msg** %3
%20 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %19, i32 0, i32 1
%21 = load i32*, i32** %20
%22 = getelementptr inbounds i32, i32* %21, i64 3
store i32 %18, i32* %22
%23 = load i32, i32* %4
%24 = and i32 %23, 255
%25 = load %struct.cec_msg*, %struct.cec_msg** %3
%26 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %25, i32 0, i32 1
%27 = load i32*, i32** %26
%28 = getelementptr inbounds i32, i32* %27, i64 4
store i32 %24, i32* %28
ret void
}

LLVM IR (-O2):
%struct.cec_msg = type { i32, i32* }
@CEC_MSG_RECORD_ON = global i32 0
@CEC_OP_RECORD_SRC_EXT_PHYS_ADDR = global i32 0
define void @cec_msg_record_on_phys_addr(%struct.cec_msg* nocapture %0, i32 %1) {
%3 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %0, i64 0, i32 0
store i32 5, i32* %3
%4 = load i32, i32* @CEC_MSG_RECORD_ON
%5 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %0, i64 0, i32 1
%6 = load i32*, i32** %5
%7 = getelementptr inbounds i32, i32* %6, i64 1
store i32 %4, i32* %7
%8 = load i32, i32* @CEC_OP_RECORD_SRC_EXT_PHYS_ADDR
%9 = getelementptr inbounds i32, i32* %6, i64 2
store i32 %8, i32* %9
%10 = ashr i32 %1, 8
%11 = getelementptr inbounds i32, i32* %6, i64 3
store i32 %10, i32* %11
%12 = and i32 %1, 255
%13 = getelementptr inbounds i32, i32* %6, i64 4
store i32 %12, i32* %13
ret void
}