#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 = 6;
  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;
  if (audio_out_compensated == 3)
    msg->msg[msg->len++] = 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   $0x6,(%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)
cmpl   $0x3,-0x18(%rbp)
jne    11b5 <cec_msg_report_current_latency+0xb5>
mov    -0x1c(%rbp),%edx
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    -0x8(%rbp),%rsi
mov    (%rsi),%ecx
mov    %ecx,%edi
add    $0x1,%edi
mov    %edi,(%rsi)
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
pop    %rbp
ret

x86 assembly (clang, -O2):
<cec_msg_report_current_latency>:
movl   $0x6,(%rdi)
mov    0x8(%rdi),%r10
orl    $0xf,(%r10)
mov    0x2ed3(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x4(%r10)
movzbl %sil,%eax
sar    $0x8,%esi
mov    %esi,0x8(%r10)
mov    %eax,0xc(%r10)
mov    %edx,0x10(%r10)
shl    $0x2,%ecx
or     %r8d,%ecx
mov    %ecx,0x14(%r10)
cmp    $0x3,%r8d
jne    114a <cec_msg_report_current_latency+0x4a>
movslq (%rdi),%rax
lea    0x1(%rax),%ecx
mov    %ecx,(%rdi)
mov    %r9d,(%r10,%rax,4)
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 6, 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* %11
%52 = icmp eq i32 %51, 3
br i1 %52, label %53, label %64
53: ; preds = %6
%54 = load i32, i32* %12
%55 = load %struct.cec_msg*, %struct.cec_msg** %7
%56 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %55, i32 0, i32 1
%57 = load i32*, i32** %56
%58 = load %struct.cec_msg*, %struct.cec_msg** %7
%59 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %58, i32 0, i32 0
%60 = load i32, i32* %59
%61 = add nsw i32 %60, 1
store i32 %61, i32* %59
%62 = sext i32 %60 to i64
%63 = getelementptr inbounds i32, i32* %57, i64 %62
store i32 %54, i32* %63
br label %64
64: ; preds = %53, %6
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 6, 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 = icmp eq i32 %4, 3
br i1 %22, label %23, label %28
23: ; preds = %6
%24 = load i32, i32* %7
%25 = add nsw i32 %24, 1
store i32 %25, i32* %7
%26 = sext i32 %24 to i64
%27 = getelementptr inbounds i32, i32* %9, i64 %26
store i32 %5, i32* %27
br label %28
28: ; preds = %23, %6
ret void
}