#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_cdc_hec_report_state(const struct cec_msg *msg, __u16 *phys_addr,
                                  __u16 *target_phys_addr, __u8 *hec_func_state,
                                  __u8 *host_func_state, __u8 *enc_func_state,
                                  __u8 *cdc_errcode, __u8 *has_field,
                                  __u16 *hec_field) {
  *phys_addr = (msg->msg[2] << 8) | msg->msg[3];
  *target_phys_addr = (msg->msg[5] << 8) | msg->msg[6];
  *hec_func_state = msg->msg[7] >> 6;
  *host_func_state = (msg->msg[7] >> 4) & 3;
  *enc_func_state = (msg->msg[7] >> 4) & 3;
  *cdc_errcode = msg->msg[7] & 3;
  *has_field = msg->len >= 10;
  *hec_field = *has_field ? ((msg->msg[8] << 8) | msg->msg[9]) : 0;
}


x86 assembly (clang, -O0):
<cec_ops_cdc_hec_report_state>:
push   %rbp
mov    %rsp,%rbp
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
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    0x14(%rax),%ecx
shl    $0x8,%ecx
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
or     0x18(%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    0x1c(%rax),%ecx
sar    $0x6,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    0x1c(%rax),%ecx
sar    $0x4,%ecx
and    $0x3,%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    0x1c(%rax),%ecx
sar    $0x4,%ecx
and    $0x3,%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    0x1c(%rax),%ecx
and    $0x3,%ecx
mov    0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
cmpl   $0xa,0x8(%rax)
setge  %al
and    $0x1,%al
movzbl %al,%ecx
mov    0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    0x18(%rbp),%rax
cmpl   $0x0,(%rax)
je     11f6 <cec_ops_cdc_hec_report_state+0xf6>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    0x20(%rax),%eax
shl    $0x8,%eax
mov    -0x8(%rbp),%rcx
mov    (%rcx),%rcx
or     0x24(%rcx),%eax
mov    %eax,-0x34(%rbp)
jmp    1200 <cec_ops_cdc_hec_report_state+0x100>
xor    %eax,%eax
mov    %eax,-0x34(%rbp)
jmp    1200 <cec_ops_cdc_hec_report_state+0x100>
mov    -0x34(%rbp),%ecx
mov    0x20(%rbp),%rax
mov    %ecx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<cec_ops_cdc_hec_report_state>:
push   %rbp
push   %rbx
mov    0x28(%rsp),%r10
mov    0x20(%rsp),%r11
mov    0x18(%rsp),%rbx
mov    (%rdi),%rax
mov    0x8(%rax),%ebp
shl    $0x8,%ebp
or     0xc(%rax),%ebp
mov    %ebp,(%rsi)
mov    0x14(%rax),%esi
shl    $0x8,%esi
or     0x18(%rax),%esi
mov    %esi,(%rdx)
mov    0x1c(%rax),%edx
sar    $0x6,%edx
mov    %edx,(%rcx)
mov    0x1c(%rax),%ecx
shr    $0x4,%ecx
and    $0x3,%ecx
mov    %ecx,(%r8)
mov    0x1c(%rax),%ecx
shr    $0x4,%ecx
and    $0x3,%ecx
mov    %ecx,(%r9)
mov    0x1c(%rax),%ecx
and    $0x3,%ecx
mov    %ecx,(%rbx)
xor    %ecx,%ecx
xor    %edx,%edx
cmpl   $0xa,0x8(%rdi)
setge  %dl
mov    %edx,(%r11)
jl     116b <cec_ops_cdc_hec_report_state+0x6b>
mov    0x20(%rax),%ecx
shl    $0x8,%ecx
or     0x24(%rax),%ecx
mov    %ecx,(%r10)
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.cec_msg = type { i32*, i32 }
define void @cec_ops_cdc_hec_report_state(%struct.cec_msg* %0, i32* %1, i32* %2, i32* %3, i32* %4, i32* %5, i32* %6, i32* %7, i32* %8) {
%10 = alloca %struct.cec_msg*
%11 = alloca i32*
%12 = alloca i32*
%13 = alloca i32*
%14 = alloca i32*
%15 = alloca i32*
%16 = alloca i32*
%17 = alloca i32*
%18 = alloca i32*
store %struct.cec_msg* %0, %struct.cec_msg** %10
store i32* %1, i32** %11
store i32* %2, i32** %12
store i32* %3, i32** %13
store i32* %4, i32** %14
store i32* %5, i32** %15
store i32* %6, i32** %16
store i32* %7, i32** %17
store i32* %8, i32** %18
%19 = load %struct.cec_msg*, %struct.cec_msg** %10
%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 2
%23 = load i32, i32* %22
%24 = shl i32 %23, 8
%25 = load %struct.cec_msg*, %struct.cec_msg** %10
%26 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %25, i32 0, i32 0
%27 = load i32*, i32** %26
%28 = getelementptr inbounds i32, i32* %27, i64 3
%29 = load i32, i32* %28
%30 = or i32 %24, %29
%31 = load i32*, i32** %11
store i32 %30, i32* %31
%32 = load %struct.cec_msg*, %struct.cec_msg** %10
%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 = shl i32 %36, 8
%38 = load %struct.cec_msg*, %struct.cec_msg** %10
%39 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %38, i32 0, i32 0
%40 = load i32*, i32** %39
%41 = getelementptr inbounds i32, i32* %40, i64 6
%42 = load i32, i32* %41
%43 = or i32 %37, %42
%44 = load i32*, i32** %12
store i32 %43, i32* %44
%45 = load %struct.cec_msg*, %struct.cec_msg** %10
%46 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %45, i32 0, i32 0
%47 = load i32*, i32** %46
%48 = getelementptr inbounds i32, i32* %47, i64 7
%49 = load i32, i32* %48
%50 = ashr i32 %49, 6
%51 = load i32*, i32** %13
store i32 %50, i32* %51
%52 = load %struct.cec_msg*, %struct.cec_msg** %10
%53 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %52, i32 0, i32 0
%54 = load i32*, i32** %53
%55 = getelementptr inbounds i32, i32* %54, i64 7
%56 = load i32, i32* %55
%57 = ashr i32 %56, 4
%58 = and i32 %57, 3
%59 = load i32*, i32** %14
store i32 %58, i32* %59
%60 = load %struct.cec_msg*, %struct.cec_msg** %10
%61 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %60, i32 0, i32 0
%62 = load i32*, i32** %61
%63 = getelementptr inbounds i32, i32* %62, i64 7
%64 = load i32, i32* %63
%65 = ashr i32 %64, 4
%66 = and i32 %65, 3
%67 = load i32*, i32** %15
store i32 %66, i32* %67
%68 = load %struct.cec_msg*, %struct.cec_msg** %10
%69 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %68, i32 0, i32 0
%70 = load i32*, i32** %69
%71 = getelementptr inbounds i32, i32* %70, i64 7
%72 = load i32, i32* %71
%73 = and i32 %72, 3
%74 = load i32*, i32** %16
store i32 %73, i32* %74
%75 = load %struct.cec_msg*, %struct.cec_msg** %10
%76 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %75, i32 0, i32 1
%77 = load i32, i32* %76
%78 = icmp sge i32 %77, 10
%79 = zext i1 %78 to i32
%80 = load i32*, i32** %17
store i32 %79, i32* %80
%81 = load i32*, i32** %17
%82 = load i32, i32* %81
%83 = icmp ne i32 %82, 0
br i1 %83, label %84, label %97
84: ; preds = %9
%85 = load %struct.cec_msg*, %struct.cec_msg** %10
%86 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %85, i32 0, i32 0
%87 = load i32*, i32** %86
%88 = getelementptr inbounds i32, i32* %87, i64 8
%89 = load i32, i32* %88
%90 = shl i32 %89, 8
%91 = load %struct.cec_msg*, %struct.cec_msg** %10
%92 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %91, i32 0, i32 0
%93 = load i32*, i32** %92
%94 = getelementptr inbounds i32, i32* %93, i64 9
%95 = load i32, i32* %94
%96 = or i32 %90, %95
br label %98
97: ; preds = %9
br label %98
98: ; preds = %97, %84
%99 = phi i32 [ %96, %84 ], [ 0, %97 ]
%100 = load i32*, i32** %18
store i32 %99, i32* %100
ret void
}

LLVM IR (-O2):
%struct.cec_msg = type { i32*, i32 }
define void @cec_ops_cdc_hec_report_state(%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, i32* nocapture writeonly %6, i32* nocapture writeonly %7, i32* nocapture writeonly %8) {
%10 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %0, i64 0, i32 0
%11 = load i32*, i32** %10
%12 = getelementptr inbounds i32, i32* %11, i64 2
%13 = load i32, i32* %12
%14 = shl i32 %13, 8
%15 = getelementptr inbounds i32, i32* %11, i64 3
%16 = load i32, i32* %15
%17 = or i32 %14, %16
store i32 %17, i32* %1
%18 = getelementptr inbounds i32, i32* %11, i64 5
%19 = load i32, i32* %18
%20 = shl i32 %19, 8
%21 = getelementptr inbounds i32, i32* %11, i64 6
%22 = load i32, i32* %21
%23 = or i32 %20, %22
store i32 %23, i32* %2
%24 = getelementptr inbounds i32, i32* %11, i64 7
%25 = load i32, i32* %24
%26 = ashr i32 %25, 6
store i32 %26, i32* %3
%27 = load i32, i32* %24
%28 = lshr i32 %27, 4
%29 = and i32 %28, 3
store i32 %29, i32* %4
%30 = load i32, i32* %24
%31 = lshr i32 %30, 4
%32 = and i32 %31, 3
store i32 %32, i32* %5
%33 = load i32, i32* %24
%34 = and i32 %33, 3
store i32 %34, i32* %6
%35 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %0, i64 0, i32 1
%36 = load i32, i32* %35
%37 = icmp sgt i32 %36, 9
%38 = zext i1 %37 to i32
store i32 %38, i32* %7
br i1 %37, label %39, label %46
39: ; preds = %9
%40 = getelementptr inbounds i32, i32* %11, i64 8
%41 = load i32, i32* %40
%42 = shl i32 %41, 8
%43 = getelementptr inbounds i32, i32* %11, i64 9
%44 = load i32, i32* %43
%45 = or i32 %42, %44
br label %46
46: ; preds = %9, %39
%47 = phi i32 [ %45, %39 ], [ 0, %9 ]
store i32 %47, i32* %8
ret void
}