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

/* Variables and functions */
int CEC_MSG_SELECT_ANALOGUE_SERVICE;
void cec_msg_select_analogue_service(struct cec_msg *msg, __u8 ana_bcast_type,
                                     __u16 ana_freq, __u8 bcast_system) {
  msg->len = 6;
  msg->msg[1] = CEC_MSG_SELECT_ANALOGUE_SERVICE;
  msg->msg[2] = ana_bcast_type;
  msg->msg[3] = ana_freq >> 8;
  msg->msg[4] = ana_freq & 0xff;
  msg->msg[5] = bcast_system;
}


x86 assembly (clang, -O0):
<cec_msg_select_analogue_service>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movl   $0x6,(%rax)
mov    0x2ec4(%rip),%rax
mov    (%rax),%ecx
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    %ecx,0x4(%rax)
mov    -0x10(%rbp),%rax
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    %ecx,0x8(%rax)
mov    -0x14(%rbp),%ecx
sar    $0x8,%ecx
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    %ecx,0xc(%rax)
mov    -0x14(%rbp),%ecx
and    $0xff,%ecx
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    %ecx,0x10(%rax)
mov    -0x20(%rbp),%rax
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    %ecx,0x14(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<cec_msg_select_analogue_service>:
movl   $0x6,(%rdi)
mov    0x2edb(%rip),%rax
mov    (%rax),%eax
mov    0x8(%rdi),%rdi
mov    %eax,0x4(%rdi)
mov    %esi,0x8(%rdi)
movzbl %dl,%eax
sar    $0x8,%edx
mov    %edx,0xc(%rdi)
mov    %eax,0x10(%rdi)
mov    %ecx,0x14(%rdi)
ret

LLVM IR (-O0):
%struct.cec_msg = type { i32, i32* }
@CEC_MSG_SELECT_ANALOGUE_SERVICE = global i32 0
define void @cec_msg_select_analogue_service(%struct.cec_msg* %0, i8* %1, i32 %2, i8* %3) {
%5 = alloca %struct.cec_msg*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
store %struct.cec_msg* %0, %struct.cec_msg** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i8* %3, i8** %8
%9 = load %struct.cec_msg*, %struct.cec_msg** %5
%10 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %9, i32 0, i32 0
store i32 6, i32* %10
%11 = load i32, i32* @CEC_MSG_SELECT_ANALOGUE_SERVICE
%12 = load %struct.cec_msg*, %struct.cec_msg** %5
%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 1
store i32 %11, i32* %15
%16 = load i8*, i8** %6
%17 = ptrtoint i8* %16 to i32
%18 = load %struct.cec_msg*, %struct.cec_msg** %5
%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 2
store i32 %17, i32* %21
%22 = load i32, i32* %7
%23 = ashr i32 %22, 8
%24 = load %struct.cec_msg*, %struct.cec_msg** %5
%25 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %24, i32 0, i32 1
%26 = load i32*, i32** %25
%27 = getelementptr inbounds i32, i32* %26, i64 3
store i32 %23, i32* %27
%28 = load i32, i32* %7
%29 = and i32 %28, 255
%30 = load %struct.cec_msg*, %struct.cec_msg** %5
%31 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %30, i32 0, i32 1
%32 = load i32*, i32** %31
%33 = getelementptr inbounds i32, i32* %32, i64 4
store i32 %29, i32* %33
%34 = load i8*, i8** %8
%35 = ptrtoint i8* %34 to i32
%36 = load %struct.cec_msg*, %struct.cec_msg** %5
%37 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %36, i32 0, i32 1
%38 = load i32*, i32** %37
%39 = getelementptr inbounds i32, i32* %38, i64 5
store i32 %35, i32* %39
ret void
}

LLVM IR (-O2):
%struct.cec_msg = type { i32, i32* }
@CEC_MSG_SELECT_ANALOGUE_SERVICE = global i32 0
define void @cec_msg_select_analogue_service(%struct.cec_msg* nocapture %0, i8* %1, i32 %2, i8* %3) {
%5 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %0, i64 0, i32 0
store i32 6, i32* %5
%6 = load i32, i32* @CEC_MSG_SELECT_ANALOGUE_SERVICE
%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 1
store i32 %6, i32* %9
%10 = ptrtoint i8* %1 to i64
%11 = trunc i64 %10 to i32
%12 = getelementptr inbounds i32, i32* %8, i64 2
store i32 %11, i32* %12
%13 = ashr i32 %2, 8
%14 = getelementptr inbounds i32, i32* %8, i64 3
store i32 %13, i32* %14
%15 = and i32 %2, 255
%16 = getelementptr inbounds i32, i32* %8, i64 4
store i32 %15, i32* %16
%17 = ptrtoint i8* %3 to i64
%18 = trunc i64 %17 to i32
%19 = getelementptr inbounds i32, i32* %8, i64 5
store i32 %18, i32* %19
ret void
}