#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;
  int /*<<< orphan*/ reply;
};

/* Variables and functions */
int /*<<< orphan*/ CEC_MSG_ACTIVE_SOURCE;
int CEC_MSG_REQUEST_ACTIVE_SOURCE;
void cec_msg_request_active_source(struct cec_msg *msg, int reply) {
  msg->len = 2;
  msg->msg[0] |= 0xf;
  msg->msg[1] = CEC_MSG_REQUEST_ACTIVE_SOURCE;
  msg->reply = reply ? CEC_MSG_ACTIVE_SOURCE : 0;
}


x86 assembly (clang, -O0):
<cec_msg_request_active_source>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movl   $0x2,(%rax)
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    (%rax),%ecx
or     $0xf,%ecx
mov    %ecx,(%rax)
mov    0x2ec5(%rip),%rax
mov    (%rax),%ecx
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    %ecx,0x4(%rax)
cmpl   $0x0,-0xc(%rbp)
je     1153 <cec_msg_request_active_source+0x53>
mov    0x2e97(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
jmp    115d <cec_msg_request_active_source+0x5d>
xor    %eax,%eax
mov    %eax,-0x10(%rbp)
jmp    115d <cec_msg_request_active_source+0x5d>
mov    -0x10(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x10(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<cec_msg_request_active_source>:
movl   $0x2,(%rdi)
mov    0x8(%rdi),%rax
orl    $0xf,(%rax)
mov    0x2edc(%rip),%rcx
mov    (%rcx),%ecx
mov    %ecx,0x4(%rax)
test   %esi,%esi
je     1126 <cec_msg_request_active_source+0x26>
mov    0x2ebc(%rip),%rax
mov    (%rax),%esi
mov    %esi,0x10(%rdi)
ret

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

LLVM IR (-O2):
%struct.cec_msg = type { i32, i32*, i32 }
@CEC_MSG_REQUEST_ACTIVE_SOURCE = global i32 0
@CEC_MSG_ACTIVE_SOURCE = global i32 0
define void @cec_msg_request_active_source(%struct.cec_msg* nocapture %0, i32 %1) {
%3 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %0, i64 0, i32 0
store i32 2, i32* %3
%4 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %0, i64 0, i32 1
%5 = load i32*, i32** %4
%6 = load i32, i32* %5
%7 = or i32 %6, 15
store i32 %7, i32* %5
%8 = load i32, i32* @CEC_MSG_REQUEST_ACTIVE_SOURCE
%9 = getelementptr inbounds i32, i32* %5, i64 1
store i32 %8, i32* %9
%10 = icmp eq i32 %1, 0
%11 = load i32, i32* @CEC_MSG_ACTIVE_SOURCE
%12 = select i1 %10, i32 0, i32 %11
%13 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %0, i64 0, i32 2
store i32 %12, i32* %13
ret void
}