#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 CEC_OP_PROG_ERROR_DUPLICATE;
int CEC_OP_PROG_INFO_MIGHT_NOT_BE_ENOUGH_SPACE;
int CEC_OP_PROG_INFO_NOT_ENOUGH_SPACE;
void cec_ops_timer_status(const struct cec_msg *msg,
                          __u8 *timer_overlap_warning, __u8 *media_info,
                          __u8 *prog_info, __u8 *prog_error, __u8 *duration_hr,
                          __u8 *duration_min) {
  *timer_overlap_warning = msg->msg[2] >> 7;
  *media_info = (msg->msg[2] >> 5) & 3;
  if (msg->msg[2] & 0x10) {
    *prog_info = msg->msg[2] & 0xf;
    *prog_error = 0;
  } else {
    *prog_info = 0;
    *prog_error = msg->msg[2] & 0xf;
  }
  if (*prog_info == CEC_OP_PROG_INFO_NOT_ENOUGH_SPACE ||
      *prog_info == CEC_OP_PROG_INFO_MIGHT_NOT_BE_ENOUGH_SPACE ||
      *prog_error == CEC_OP_PROG_ERROR_DUPLICATE) {
    *duration_hr = (msg->msg[3] >> 4) * 10 + (msg->msg[3] & 0xf);
    *duration_min = (msg->msg[4] >> 4) * 10 + (msg->msg[4] & 0xf);
  } else {
    *duration_hr = *duration_min = 0;
  }
}


x86 assembly (clang, -O0):
<cec_ops_timer_status>:
push   %rbp
mov    %rsp,%rbp
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    0x8(%rax),%ecx
sar    $0x7,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    0x8(%rax),%ecx
sar    $0x5,%ecx
and    $0x3,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    0x8(%rax),%eax
and    $0x10,%eax
cmp    $0x0,%eax
je     1181 <cec_ops_timer_status+0x81>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    0x8(%rax),%ecx
and    $0xf,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x28(%rbp),%rax
movl   $0x0,(%rax)
jmp    119e <cec_ops_timer_status+0x9e>
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    0x8(%rax),%ecx
and    $0xf,%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
mov    0x2e4d(%rip),%rcx
cmp    (%rcx),%eax
je     11dd <cec_ops_timer_status+0xdd>
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
mov    0x2e10(%rip),%rcx
cmp    (%rcx),%eax
je     11dd <cec_ops_timer_status+0xdd>
mov    -0x28(%rbp),%rax
mov    (%rax),%eax
mov    0x2e13(%rip),%rcx
cmp    (%rcx),%eax
jne    122c <cec_ops_timer_status+0x12c>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    0xc(%rax),%eax
sar    $0x4,%eax
imul   $0xa,%eax,%ecx
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    0xc(%rax),%eax
and    $0xf,%eax
add    %eax,%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    0x10(%rax),%eax
sar    $0x4,%eax
imul   $0xa,%eax,%ecx
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    0x10(%rax),%eax
and    $0xf,%eax
add    %eax,%ecx
mov    0x10(%rbp),%rax
mov    %ecx,(%rax)
jmp    1240 <cec_ops_timer_status+0x140>
mov    0x10(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x30(%rbp),%rax
movl   $0x0,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<cec_ops_timer_status>:
mov    (%rdi),%rax
mov    0x8(%rax),%edi
sar    $0x7,%edi
mov    %edi,(%rsi)
mov    0x8(%rax),%esi
shr    $0x5,%esi
and    $0x3,%esi
mov    %esi,(%rdx)
mov    0x8(%rax),%edx
test   $0x10,%dl
jne    112c <cec_ops_timer_status+0x2c>
movl   $0x0,(%rcx)
mov    0x8(%rax),%esi
and    $0xf,%esi
jmp    1133 <cec_ops_timer_status+0x33>
and    $0xf,%edx
mov    %edx,(%rcx)
xor    %esi,%esi
mov    0x8(%rsp),%rdx
mov    %esi,(%r8)
mov    (%rcx),%ecx
mov    0x2eb4(%rip),%rdi
cmp    (%rdi),%ecx
je     116c <cec_ops_timer_status+0x6c>
mov    0x2e81(%rip),%rdi
cmp    (%rdi),%ecx
je     116c <cec_ops_timer_status+0x6c>
mov    0x2e8e(%rip),%rcx
cmp    (%rcx),%esi
je     116c <cec_ops_timer_status+0x6c>
movl   $0x0,(%rdx)
movl   $0x0,(%r9)
ret
mov    0xc(%rax),%ecx
mov    %ecx,%esi
sar    $0x4,%esi
lea    (%rsi,%rsi,4),%esi
and    $0xf,%ecx
lea    (%rcx,%rsi,2),%ecx
mov    %ecx,(%r9)
mov    0x10(%rax),%eax
mov    %eax,%ecx
sar    $0x4,%ecx
lea    (%rcx,%rcx,4),%ecx
and    $0xf,%eax
lea    (%rax,%rcx,2),%eax
mov    %eax,(%rdx)
ret

LLVM IR (-O0):
%struct.cec_msg = type { i32* }
@CEC_OP_PROG_INFO_NOT_ENOUGH_SPACE = global i32 0
@CEC_OP_PROG_INFO_MIGHT_NOT_BE_ENOUGH_SPACE = global i32 0
@CEC_OP_PROG_ERROR_DUPLICATE = global i32 0
define void @cec_ops_timer_status(%struct.cec_msg* %0, i32* %1, i32* %2, i32* %3, i32* %4, i32* %5, i32* %6) {
%8 = alloca %struct.cec_msg*
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca i32*
%12 = alloca i32*
%13 = alloca i32*
%14 = alloca i32*
store %struct.cec_msg* %0, %struct.cec_msg** %8
store i32* %1, i32** %9
store i32* %2, i32** %10
store i32* %3, i32** %11
store i32* %4, i32** %12
store i32* %5, i32** %13
store i32* %6, i32** %14
%15 = load %struct.cec_msg*, %struct.cec_msg** %8
%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 2
%19 = load i32, i32* %18
%20 = ashr i32 %19, 7
%21 = load i32*, i32** %9
store i32 %20, i32* %21
%22 = load %struct.cec_msg*, %struct.cec_msg** %8
%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 2
%26 = load i32, i32* %25
%27 = ashr i32 %26, 5
%28 = and i32 %27, 3
%29 = load i32*, i32** %10
store i32 %28, i32* %29
%30 = load %struct.cec_msg*, %struct.cec_msg** %8
%31 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %30, i32 0, i32 0
%32 = load i32*, i32** %31
%33 = getelementptr inbounds i32, i32* %32, i64 2
%34 = load i32, i32* %33
%35 = and i32 %34, 16
%36 = icmp ne i32 %35, 0
br i1 %36, label %37, label %46
37: ; preds = %7
%38 = load %struct.cec_msg*, %struct.cec_msg** %8
%39 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %38, i32 0, i32 0
%40 = load i32*, i32** %39
%41 = getelementptr inbounds i32, i32* %40, i64 2
%42 = load i32, i32* %41
%43 = and i32 %42, 15
%44 = load i32*, i32** %11
store i32 %43, i32* %44
%45 = load i32*, i32** %12
store i32 0, i32* %45
br label %55
46: ; preds = %7
%47 = load i32*, i32** %11
store i32 0, i32* %47
%48 = load %struct.cec_msg*, %struct.cec_msg** %8
%49 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %48, i32 0, i32 0
%50 = load i32*, i32** %49
%51 = getelementptr inbounds i32, i32* %50, i64 2
%52 = load i32, i32* %51
%53 = and i32 %52, 15
%54 = load i32*, i32** %12
store i32 %53, i32* %54
br label %55
55: ; preds = %46, %37
%56 = load i32*, i32** %11
%57 = load i32, i32* %56
%58 = load i32, i32* @CEC_OP_PROG_INFO_NOT_ENOUGH_SPACE
%59 = icmp eq i32 %57, %58
br i1 %59, label %70, label %60
60: ; preds = %55
%61 = load i32*, i32** %11
%62 = load i32, i32* %61
%63 = load i32, i32* @CEC_OP_PROG_INFO_MIGHT_NOT_BE_ENOUGH_SPACE
%64 = icmp eq i32 %62, %63
br i1 %64, label %70, label %65
65: ; preds = %60
%66 = load i32*, i32** %12
%67 = load i32, i32* %66
%68 = load i32, i32* @CEC_OP_PROG_ERROR_DUPLICATE
%69 = icmp eq i32 %67, %68
br i1 %69, label %70, label %101
70: ; preds = %65, %60, %55
%71 = load %struct.cec_msg*, %struct.cec_msg** %8
%72 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %71, i32 0, i32 0
%73 = load i32*, i32** %72
%74 = getelementptr inbounds i32, i32* %73, i64 3
%75 = load i32, i32* %74
%76 = ashr i32 %75, 4
%77 = mul nsw i32 %76, 10
%78 = load %struct.cec_msg*, %struct.cec_msg** %8
%79 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %78, i32 0, i32 0
%80 = load i32*, i32** %79
%81 = getelementptr inbounds i32, i32* %80, i64 3
%82 = load i32, i32* %81
%83 = and i32 %82, 15
%84 = add nsw i32 %77, %83
%85 = load i32*, i32** %13
store i32 %84, i32* %85
%86 = load %struct.cec_msg*, %struct.cec_msg** %8
%87 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %86, i32 0, i32 0
%88 = load i32*, i32** %87
%89 = getelementptr inbounds i32, i32* %88, i64 4
%90 = load i32, i32* %89
%91 = ashr i32 %90, 4
%92 = mul nsw i32 %91, 10
%93 = load %struct.cec_msg*, %struct.cec_msg** %8
%94 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %93, i32 0, i32 0
%95 = load i32*, i32** %94
%96 = getelementptr inbounds i32, i32* %95, i64 4
%97 = load i32, i32* %96
%98 = and i32 %97, 15
%99 = add nsw i32 %92, %98
%100 = load i32*, i32** %14
store i32 %99, i32* %100
br label %104
101: ; preds = %65
%102 = load i32*, i32** %14
store i32 0, i32* %102
%103 = load i32*, i32** %13
store i32 0, i32* %103
br label %104
104: ; preds = %101, %70
ret void
}

LLVM IR (-O2):
%struct.cec_msg = type { i32* }
@CEC_OP_PROG_INFO_NOT_ENOUGH_SPACE = global i32 0
@CEC_OP_PROG_INFO_MIGHT_NOT_BE_ENOUGH_SPACE = global i32 0
@CEC_OP_PROG_ERROR_DUPLICATE = global i32 0
define void @cec_ops_timer_status(%struct.cec_msg* nocapture %0, i32* nocapture writeonly %1, i32* nocapture writeonly %2, i32* nocapture %3, i32* nocapture %4, i32* nocapture writeonly %5, i32* nocapture writeonly %6) {
%8 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %0, i64 0, i32 0
%9 = load i32*, i32** %8
%10 = getelementptr inbounds i32, i32* %9, i64 2
%11 = load i32, i32* %10
%12 = ashr i32 %11, 7
store i32 %12, i32* %1
%13 = load i32, i32* %10
%14 = lshr i32 %13, 5
%15 = and i32 %14, 3
store i32 %15, i32* %2
%16 = load i32, i32* %10
%17 = and i32 %16, 16
%18 = icmp eq i32 %17, 0
br i1 %18, label %21, label %19
19: ; preds = %7
%20 = and i32 %16, 15
store i32 %20, i32* %3
br label %24
21: ; preds = %7
store i32 0, i32* %3
%22 = load i32, i32* %10
%23 = and i32 %22, 15
br label %24
24: ; preds = %21, %19
%25 = phi i32 [ %23, %21 ], [ 0, %19 ]
store i32 %25, i32* %4
%26 = load i32, i32* %3
%27 = load i32, i32* @CEC_OP_PROG_INFO_NOT_ENOUGH_SPACE
%28 = icmp eq i32 %26, %27
%29 = load i32, i32* @CEC_OP_PROG_INFO_MIGHT_NOT_BE_ENOUGH_SPACE
%30 = icmp eq i32 %26, %29
%31 = select i1 %28, i1 true, i1 %30
%32 = load i32, i32* @CEC_OP_PROG_ERROR_DUPLICATE
%33 = icmp eq i32 %25, %32
%34 = select i1 %31, i1 true, i1 %33
br i1 %34, label %35, label %48
35: ; preds = %24
%36 = getelementptr inbounds i32, i32* %9, i64 3
%37 = load i32, i32* %36
%38 = ashr i32 %37, 4
%39 = mul nsw i32 %38, 10
%40 = and i32 %37, 15
%41 = add nsw i32 %39, %40
store i32 %41, i32* %5
%42 = getelementptr inbounds i32, i32* %9, i64 4
%43 = load i32, i32* %42
%44 = ashr i32 %43, 4
%45 = mul nsw i32 %44, 10
%46 = and i32 %43, 15
%47 = add nsw i32 %45, %46
store i32 %47, i32* %6
br label %49
48: ; preds = %24
store i32 0, i32* %6
store i32 0, i32* %5
br label %49
49: ; preds = %48, %35
ret void
}