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

/* Variables and functions */
int CEC_MSG_REPORT_CURRENT_LATENCY;
void cec_msg_report_current_latency(struct cec_msg *msg, __u16 phys_addr,
                                    __u8 video_latency, __u8 low_latency_mode,
                                    __u8 audio_out_compensated,
                                    __u8 audio_out_delay) {
  msg->len = 7;
  msg->msg[0] |= 0xf;
  msg->msg[1] = CEC_MSG_REPORT_CURRENT_LATENCY;
  msg->msg[2] = phys_addr >> 8;
  msg->msg[3] = phys_addr & 0xff;
  msg->msg[4] = video_latency;
  msg->msg[5] = (low_latency_mode << 2) | audio_out_compensated;
  msg->msg[6] = audio_out_delay;
}


x86 assembly (clang, -O0):
<cec_msg_report_current_latency>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
mov    %r9d,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
movl   $0x7,(%rax)
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    (%rax),%ecx
or     $0xf,%ecx
mov    %ecx,(%rax)
mov    0x2eaf(%rip),%rax
mov    (%rax),%ecx
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    %ecx,0x4(%rax)
mov    -0xc(%rbp),%ecx
sar    $0x8,%ecx
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    %ecx,0x8(%rax)
mov    -0xc(%rbp),%ecx
and    $0xff,%ecx
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    %ecx,0xc(%rax)
mov    -0x10(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    %ecx,0x10(%rax)
mov    -0x14(%rbp),%ecx
shl    $0x2,%ecx
or     -0x18(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    %ecx,0x14(%rax)
mov    -0x1c(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    %ecx,0x18(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<cec_msg_report_current_latency>:
movl   $0x7,(%rdi)
mov    0x8(%rdi),%rax
orl    $0xf,(%rax)
mov    0x2ed4(%rip),%rdi
mov    (%rdi),%edi
mov    %edi,0x4(%rax)
movzbl %sil,%edi
sar    $0x8,%esi
mov    %esi,0x8(%rax)
mov    %edi,0xc(%rax)
mov    %edx,0x10(%rax)
shl    $0x2,%ecx
or     %r8d,%ecx
mov    %ecx,0x14(%rax)
mov    %r9d,0x18(%rax)
ret

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

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