#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 */
void cec_ops_system_audio_mode_request(const struct cec_msg *msg,
                                       __u16 *phys_addr) {
  if (msg->len < 4) {
    *phys_addr = 0xffff;
  } else {
    *phys_addr = (msg->msg[2] << 8) | msg->msg[3];
  }
}


x86 assembly (clang, -O0):
<cec_ops_system_audio_mode_request>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
cmpl   $0x4,(%rax)
jge    1128 <cec_ops_system_audio_mode_request+0x28>
mov    -0x10(%rbp),%rax
movl   $0xffff,(%rax)
jmp    1147 <cec_ops_system_audio_mode_request+0x47>
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    0x8(%rax),%ecx
shl    $0x8,%ecx
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
or     0xc(%rax),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<cec_ops_system_audio_mode_request>:
mov    $0xffff,%eax
cmpl   $0x4,(%rdi)
jl     1117 <cec_ops_system_audio_mode_request+0x17>
mov    0x8(%rdi),%rcx
mov    0x8(%rcx),%eax
shl    $0x8,%eax
or     0xc(%rcx),%eax
mov    %eax,(%rsi)
ret

LLVM IR (-O0):
%struct.cec_msg = type { i32, i32* }
define void @cec_ops_system_audio_mode_request(%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
%7 = load i32, i32* %6
%8 = icmp slt i32 %7, 4
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = load i32*, i32** %4
store i32 65535, i32* %10
br label %25
11: ; preds = %2
%12 = load %struct.cec_msg*, %struct.cec_msg** %3
%13 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %12, i32 0, i32 1
%14 = load i32*, i32** %13
%15 = getelementptr inbounds i32, i32* %14, i64 2
%16 = load i32, i32* %15
%17 = shl i32 %16, 8
%18 = load %struct.cec_msg*, %struct.cec_msg** %3
%19 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %18, i32 0, i32 1
%20 = load i32*, i32** %19
%21 = getelementptr inbounds i32, i32* %20, i64 3
%22 = load i32, i32* %21
%23 = or i32 %17, %22
%24 = load i32*, i32** %4
store i32 %23, i32* %24
br label %25
25: ; preds = %11, %9
ret void
}

LLVM IR (-O2):
%struct.cec_msg = type { i32, i32* }
define void @cec_ops_system_audio_mode_request(%struct.cec_msg* nocapture %0, i32* nocapture writeonly %1) {
%3 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %0, i64 0, i32 0
%4 = load i32, i32* %3
%5 = icmp slt i32 %4, 4
br i1 %5, label %15, label %6
6: ; preds = %2
%7 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %0, i64 0, i32 1
%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
br label %15
15: ; preds = %2, %6
%16 = phi i32 [ %14, %6 ], [ 65535, %2 ]
store i32 %16, i32* %1
ret void
}