#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;

/* Variables and functions */
int const CEC_OP_FEAT_EXT;
void cec_ops_report_features(const struct cec_msg *msg, __u8 *cec_version,
                             __u8 *all_device_types, const __u8 **rc_profile,
                             const __u8 **dev_features) {
  const __u8 *p = &msg->msg[4];
  *cec_version = msg->msg[2];
  *all_device_types = msg->msg[3];
  *rc_profile = p;
  while (p < &msg->msg[14] && (*p & CEC_OP_FEAT_EXT))
    p++;
  if (!(*p & CEC_OP_FEAT_EXT)) {
    *dev_features = p + 1;
    while (p < &msg->msg[15] && (*p & CEC_OP_FEAT_EXT))
      p++;
  }
  if (*p & CEC_OP_FEAT_EXT)
    *rc_profile = *dev_features = NULL;
}


x86 assembly (clang, -O0):
<cec_ops_report_features>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
add    $0x10,%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    0x8(%rax),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    0xc(%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x30(%rbp),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x30(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    (%rax),%rdx
add    $0x38,%rdx
xor    %eax,%eax
cmp    %rdx,%rcx
mov    %al,-0x31(%rbp)
jae    1187 <cec_ops_report_features+0x87>
mov    -0x30(%rbp),%rax
mov    (%rax),%eax
mov    0x2e6c(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%al
test   $0x1,%al
jne    1197 <cec_ops_report_features+0x97>
jmp    11a8 <cec_ops_report_features+0xa8>
mov    -0x30(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x30(%rbp)
jmp    1152 <cec_ops_report_features+0x52>
mov    -0x30(%rbp),%rax
mov    (%rax),%eax
mov    0x2e33(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
jne    122a <cec_ops_report_features+0x12a>
mov    -0x30(%rbp),%rcx
add    $0x4,%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x30(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    (%rax),%rdx
add    $0x3c,%rdx
xor    %eax,%eax
cmp    %rdx,%rcx
mov    %al,-0x32(%rbp)
jae    1204 <cec_ops_report_features+0x104>
mov    -0x30(%rbp),%rax
mov    (%rax),%eax
mov    0x2def(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x32(%rbp)
mov    -0x32(%rbp),%al
test   $0x1,%al
jne    1214 <cec_ops_report_features+0x114>
jmp    1225 <cec_ops_report_features+0x125>
mov    -0x30(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x30(%rbp)
jmp    11cf <cec_ops_report_features+0xcf>
jmp    122a <cec_ops_report_features+0x12a>
mov    -0x30(%rbp),%rax
mov    (%rax),%eax
mov    0x2db1(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1258 <cec_ops_report_features+0x158>
mov    -0x28(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x20(%rbp),%rax
movq   $0x0,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<cec_ops_report_features>:
mov    (%rdi),%rax
lea    0x10(%rax),%r9
mov    0x8(%rax),%edi
mov    %edi,(%rsi)
mov    0xc(%rax),%esi
mov    %esi,(%rdx)
mov    %r9,(%rcx)
add    $0x14,%rax
mov    %rax,(%r8)
ret

LLVM IR (-O0):
%struct.cec_msg = type { i32* }
@CEC_OP_FEAT_EXT = constant i32 0
define void @cec_ops_report_features(%struct.cec_msg* %0, i32* %1, i32* %2, i32** %3, i32** %4) {
%6 = alloca %struct.cec_msg*
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32**
%10 = alloca i32**
%11 = alloca i32*
store %struct.cec_msg* %0, %struct.cec_msg** %6
store i32* %1, i32** %7
store i32* %2, i32** %8
store i32** %3, i32*** %9
store i32** %4, i32*** %10
%12 = load %struct.cec_msg*, %struct.cec_msg** %6
%13 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %12, i32 0, i32 0
%14 = load i32*, i32** %13
%15 = getelementptr inbounds i32, i32* %14, i64 4
store i32* %15, i32** %11
%16 = load %struct.cec_msg*, %struct.cec_msg** %6
%17 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %16, i32 0, i32 0
%18 = load i32*, i32** %17
%19 = getelementptr inbounds i32, i32* %18, i64 2
%20 = load i32, i32* %19
%21 = load i32*, i32** %7
store i32 %20, i32* %21
%22 = load %struct.cec_msg*, %struct.cec_msg** %6
%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 3
%26 = load i32, i32* %25
%27 = load i32*, i32** %8
store i32 %26, i32* %27
%28 = load i32*, i32** %11
%29 = load i32**, i32*** %9
store i32* %28, i32** %29
br label %30
30: ; preds = %45, %5
%31 = load i32*, i32** %11
%32 = load %struct.cec_msg*, %struct.cec_msg** %6
%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 14
%36 = icmp ult i32* %31, %35
br i1 %36, label %37, label %43
37: ; preds = %30
%38 = load i32*, i32** %11
%39 = load i32, i32* %38
%40 = load i32, i32* @CEC_OP_FEAT_EXT
%41 = and i32 %39, %40
%42 = icmp ne i32 %41, 0
br label %43
43: ; preds = %37, %30
%44 = phi i1 [ false, %30 ], [ %42, %37 ]
br i1 %44, label %45, label %48
45: ; preds = %43
%46 = load i32*, i32** %11
%47 = getelementptr inbounds i32, i32* %46, i32 1
store i32* %47, i32** %11
br label %30
48: ; preds = %43
%49 = load i32*, i32** %11
%50 = load i32, i32* %49
%51 = load i32, i32* @CEC_OP_FEAT_EXT
%52 = and i32 %50, %51
%53 = icmp ne i32 %52, 0
br i1 %53, label %77, label %54
54: ; preds = %48
%55 = load i32*, i32** %11
%56 = getelementptr inbounds i32, i32* %55, i64 1
%57 = load i32**, i32*** %10
store i32* %56, i32** %57
br label %58
58: ; preds = %73, %54
%59 = load i32*, i32** %11
%60 = load %struct.cec_msg*, %struct.cec_msg** %6
%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 15
%64 = icmp ult i32* %59, %63
br i1 %64, label %65, label %71
65: ; preds = %58
%66 = load i32*, i32** %11
%67 = load i32, i32* %66
%68 = load i32, i32* @CEC_OP_FEAT_EXT
%69 = and i32 %67, %68
%70 = icmp ne i32 %69, 0
br label %71
71: ; preds = %65, %58
%72 = phi i1 [ false, %58 ], [ %70, %65 ]
br i1 %72, label %73, label %76
73: ; preds = %71
%74 = load i32*, i32** %11
%75 = getelementptr inbounds i32, i32* %74, i32 1
store i32* %75, i32** %11
br label %58
76: ; preds = %71
br label %77
77: ; preds = %76, %48
%78 = load i32*, i32** %11
%79 = load i32, i32* %78
%80 = load i32, i32* @CEC_OP_FEAT_EXT
%81 = and i32 %79, %80
%82 = icmp ne i32 %81, 0
br i1 %82, label %83, label %86
83: ; preds = %77
%84 = load i32**, i32*** %10
store i32* null, i32** %84
%85 = load i32**, i32*** %9
store i32* null, i32** %85
br label %86
86: ; preds = %83, %77
ret void
}

LLVM IR (-O2):
%struct.cec_msg = type { i32* }
@CEC_OP_FEAT_EXT = constant i32 0
define void @cec_ops_report_features(%struct.cec_msg* nocapture %0, i32* nocapture writeonly %1, i32* nocapture writeonly %2, i32** nocapture writeonly %3, i32** nocapture writeonly %4) {
%6 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %0, i64 0, i32 0
%7 = load i32*, i32** %6
%8 = getelementptr inbounds i32, i32* %7, i64 4
%9 = getelementptr inbounds i32, i32* %7, i64 2
%10 = load i32, i32* %9
store i32 %10, i32* %1
%11 = getelementptr inbounds i32, i32* %7, i64 3
%12 = load i32, i32* %11
store i32 %12, i32* %2
store i32* %8, i32** %3
%13 = getelementptr inbounds i32, i32* %7, i64 5
store i32* %13, i32** %4
ret void
}