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

/* Variables and functions */
void cec_ops_cdc_hpd_set_state(const struct cec_msg *msg, __u16 *phys_addr,
                               __u8 *input_port, __u8 *hpd_state) {
  *phys_addr = (msg->msg[2] << 8) | msg->msg[3];
  *input_port = msg->msg[5] >> 4;
  *hpd_state = msg->msg[5] & 0xf;
}


x86 assembly (clang, -O0):
<cec_ops_cdc_hpd_set_state>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%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
sar    $0x4,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    0x14(%rax),%ecx
and    $0xf,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<cec_ops_cdc_hpd_set_state>:
mov    (%rdi),%rax
mov    0x8(%rax),%edi
shl    $0x8,%edi
or     0xc(%rax),%edi
mov    %edi,(%rsi)
mov    0x14(%rax),%esi
sar    $0x4,%esi
mov    %esi,(%rdx)
mov    0x14(%rax),%eax
and    $0xf,%eax
mov    %eax,(%rcx)
ret

LLVM IR (-O0):
%struct.cec_msg = type { i32* }
define void @cec_ops_cdc_hpd_set_state(%struct.cec_msg* %0, i32* %1, i32* %2, i32* %3) {
%5 = alloca %struct.cec_msg*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32*
store %struct.cec_msg* %0, %struct.cec_msg** %5
store i32* %1, i32** %6
store i32* %2, i32** %7
store i32* %3, i32** %8
%9 = load %struct.cec_msg*, %struct.cec_msg** %5
%10 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %9, i32 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 = load %struct.cec_msg*, %struct.cec_msg** %5
%16 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %15, i32 0, i32 0
%17 = load i32*, i32** %16
%18 = getelementptr inbounds i32, i32* %17, i64 3
%19 = load i32, i32* %18
%20 = or i32 %14, %19
%21 = load i32*, i32** %6
store i32 %20, i32* %21
%22 = load %struct.cec_msg*, %struct.cec_msg** %5
%23 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %22, i32 0, i32 0
%24 = load i32*, i32** %23
%25 = getelementptr inbounds i32, i32* %24, i64 5
%26 = load i32, i32* %25
%27 = ashr i32 %26, 4
%28 = load i32*, i32** %7
store i32 %27, i32* %28
%29 = load %struct.cec_msg*, %struct.cec_msg** %5
%30 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %29, i32 0, i32 0
%31 = load i32*, i32** %30
%32 = getelementptr inbounds i32, i32* %31, i64 5
%33 = load i32, i32* %32
%34 = and i32 %33, 15
%35 = load i32*, i32** %8
store i32 %34, i32* %35
ret void
}

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