#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 *msg;
  int len;
};
typedef int __u8;
typedef int __u16;

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


x86 assembly (clang, -O0):
<cec_ops_report_current_latency>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    0x8(%rax),%ecx
shl    $0x8,%ecx
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
or     0xc(%rax),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    0x10(%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    0x14(%rax),%ecx
sar    $0x2,%ecx
and    $0x1,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    0x14(%rax),%ecx
and    $0x3,%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x28(%rbp),%rax
cmpl   $0x3,(%rax)
jne    11a2 <cec_ops_report_current_latency+0xa2>
mov    -0x8(%rbp),%rax
cmpl   $0x7,0x8(%rax)
jl     11a2 <cec_ops_report_current_latency+0xa2>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    0x18(%rax),%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,(%rax)
jmp    11ac <cec_ops_report_current_latency+0xac>
mov    -0x30(%rbp),%rax
movl   $0x0,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<cec_ops_report_current_latency>:
mov    (%rdi),%r10
mov    0x8(%r10),%eax
shl    $0x8,%eax
or     0xc(%r10),%eax
mov    %eax,(%rsi)
mov    0x10(%r10),%eax
mov    %eax,(%rdx)
mov    0x14(%r10),%eax
shr    $0x2,%eax
and    $0x1,%eax
mov    %eax,(%rcx)
mov    0x14(%r10),%eax
and    $0x3,%eax
mov    %eax,(%r8)
xor    %ecx,%ecx
cmp    $0x3,%eax
jne    113d <cec_ops_report_current_latency+0x3d>
cmpl   $0x7,0x8(%rdi)
jl     113d <cec_ops_report_current_latency+0x3d>
mov    0x18(%r10),%ecx
mov    %ecx,(%r9)
ret

LLVM IR (-O0):
%struct.cec_msg = type { i32*, i32 }
define void @cec_ops_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
%15 = load i32*, i32** %14
%16 = getelementptr inbounds i32, i32* %15, i64 2
%17 = load i32, i32* %16
%18 = shl i32 %17, 8
%19 = load %struct.cec_msg*, %struct.cec_msg** %7
%20 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %19, i32 0, i32 0
%21 = load i32*, i32** %20
%22 = getelementptr inbounds i32, i32* %21, i64 3
%23 = load i32, i32* %22
%24 = or i32 %18, %23
%25 = load i32*, i32** %8
store i32 %24, i32* %25
%26 = load %struct.cec_msg*, %struct.cec_msg** %7
%27 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %26, i32 0, i32 0
%28 = load i32*, i32** %27
%29 = getelementptr inbounds i32, i32* %28, i64 4
%30 = load i32, i32* %29
%31 = load i32*, i32** %9
store i32 %30, i32* %31
%32 = load %struct.cec_msg*, %struct.cec_msg** %7
%33 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %32, i32 0, i32 0
%34 = load i32*, i32** %33
%35 = getelementptr inbounds i32, i32* %34, i64 5
%36 = load i32, i32* %35
%37 = ashr i32 %36, 2
%38 = and i32 %37, 1
%39 = load i32*, i32** %10
store i32 %38, i32* %39
%40 = load %struct.cec_msg*, %struct.cec_msg** %7
%41 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %40, i32 0, i32 0
%42 = load i32*, i32** %41
%43 = getelementptr inbounds i32, i32* %42, i64 5
%44 = load i32, i32* %43
%45 = and i32 %44, 3
%46 = load i32*, i32** %11
store i32 %45, i32* %46
%47 = load i32*, i32** %11
%48 = load i32, i32* %47
%49 = icmp eq i32 %48, 3
br i1 %49, label %50, label %62
50: ; preds = %6
%51 = load %struct.cec_msg*, %struct.cec_msg** %7
%52 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %51, i32 0, i32 1
%53 = load i32, i32* %52
%54 = icmp sge i32 %53, 7
br i1 %54, label %55, label %62
55: ; preds = %50
%56 = load %struct.cec_msg*, %struct.cec_msg** %7
%57 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %56, i32 0, i32 0
%58 = load i32*, i32** %57
%59 = getelementptr inbounds i32, i32* %58, i64 6
%60 = load i32, i32* %59
%61 = load i32*, i32** %12
store i32 %60, i32* %61
br label %64
62: ; preds = %50, %6
%63 = load i32*, i32** %12
store i32 0, i32* %63
br label %64
64: ; preds = %62, %55
ret void
}

LLVM IR (-O2):
%struct.cec_msg = type { i32*, i32 }
define void @cec_ops_report_current_latency(%struct.cec_msg* nocapture %0, i32* nocapture writeonly %1, i32* nocapture writeonly %2, i32* nocapture writeonly %3, i32* nocapture writeonly %4, i32* nocapture writeonly %5) {
%7 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %0, i64 0, i32 0
%8 = load i32*, i32** %7
%9 = getelementptr inbounds i32, i32* %8, i64 2
%10 = load i32, i32* %9
%11 = shl i32 %10, 8
%12 = getelementptr inbounds i32, i32* %8, i64 3
%13 = load i32, i32* %12
%14 = or i32 %11, %13
store i32 %14, i32* %1
%15 = getelementptr inbounds i32, i32* %8, i64 4
%16 = load i32, i32* %15
store i32 %16, i32* %2
%17 = getelementptr inbounds i32, i32* %8, i64 5
%18 = load i32, i32* %17
%19 = lshr i32 %18, 2
%20 = and i32 %19, 1
store i32 %20, i32* %3
%21 = load i32, i32* %17
%22 = and i32 %21, 3
store i32 %22, i32* %4
%23 = icmp eq i32 %22, 3
br i1 %23, label %24, label %31
24: ; preds = %6
%25 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %0, i64 0, i32 1
%26 = load i32, i32* %25
%27 = icmp sgt i32 %26, 6
br i1 %27, label %28, label %31
28: ; preds = %24
%29 = getelementptr inbounds i32, i32* %8, i64 6
%30 = load i32, i32* %29
br label %31
31: ; preds = %6, %24, %28
%32 = phi i32 [ %30, %28 ], [ 0, %24 ], [ 0, %6 ]
store i32 %32, i32* %5
ret void
}