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

/* Variables and functions */
int CEC_MSG_TIMER_STATUS;
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_msg_timer_status(struct cec_msg *msg, __u8 timer_overlap_warning,
                          __u8 media_info, __u8 prog_info, __u8 prog_error,
                          __u8 duration_hr, __u8 duration_min) {
  msg->len = 3;
  msg->msg[1] = CEC_MSG_TIMER_STATUS;
  msg->msg[2] = (timer_overlap_warning << 7) | (media_info << 5) |
                (prog_info ? 0x10 : 0) | (prog_info ? prog_info : prog_error);
  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) {
    msg->len += 2;
    msg->msg[3] = ((duration_hr / 10) << 4) | (duration_hr % 10);
    msg->msg[4] = ((duration_min / 10) << 4) | (duration_min % 10);
  }
}


x86 assembly (clang, -O0):
<cec_msg_timer_status>:
push   %rbp
mov    %rsp,%rbp
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
mov    %r9d,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
movl   $0x3,(%rax)
mov    0x2eab(%rip),%rax
mov    (%rax),%ecx
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    %ecx,0x4(%rax)
mov    -0xc(%rbp),%eax
shl    $0x7,%eax
mov    -0x10(%rbp),%ecx
shl    $0x5,%ecx
or     %ecx,%eax
mov    -0x14(%rbp),%esi
xor    %ecx,%ecx
mov    $0x10,%edx
cmp    $0x0,%esi
cmovne %edx,%ecx
or     %ecx,%eax
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     1172 <cec_msg_timer_status+0x72>
mov    -0x14(%rbp),%eax
mov    %eax,-0x24(%rbp)
jmp    1178 <cec_msg_timer_status+0x78>
mov    -0x18(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%ecx
mov    -0x24(%rbp),%eax
or     %eax,%ecx
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    %ecx,0x8(%rax)
mov    -0x14(%rbp),%eax
mov    0x2e63(%rip),%rcx
cmp    (%rcx),%eax
je     11c1 <cec_msg_timer_status+0xc1>
mov    -0x14(%rbp),%eax
mov    0x2e21(%rip),%rcx
cmp    (%rcx),%eax
je     11c1 <cec_msg_timer_status+0xc1>
mov    -0x18(%rbp),%eax
mov    0x2e2f(%rip),%rcx
cmp    (%rcx),%eax
jne    121c <cec_msg_timer_status+0x11c>
mov    -0x8(%rbp),%rax
mov    (%rax),%ecx
add    $0x2,%ecx
mov    %ecx,(%rax)
mov    -0x1c(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
shl    $0x4,%ecx
mov    -0x1c(%rbp),%eax
mov    $0xa,%esi
cltd
idiv   %esi
or     %edx,%ecx
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    %ecx,0xc(%rax)
mov    0x10(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
shl    $0x4,%ecx
mov    0x10(%rbp),%eax
mov    $0xa,%esi
cltd
idiv   %esi
or     %edx,%ecx
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    %ecx,0x10(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<cec_msg_timer_status>:
shl    $0x7,%esi
shl    $0x5,%edx
or     %esi,%edx
xor    %esi,%esi
test   %ecx,%ecx
movl   $0x3,(%rdi)
mov    0x2ebf(%rip),%rax
mov    (%rax),%eax
mov    0x8(%rdi),%r10
mov    %eax,0x4(%r10)
mov    %ecx,%eax
cmove  %r8d,%eax
setne  %sil
shl    $0x4,%esi
or     %edx,%esi
or     %eax,%esi
mov    %esi,0x8(%r10)
mov    0x2eb9(%rip),%rax
cmp    %ecx,(%rax)
je     115b <cec_msg_timer_status+0x5b>
mov    0x2e7e(%rip),%rax
cmp    %ecx,(%rax)
je     115b <cec_msg_timer_status+0x5b>
mov    0x2e93(%rip),%rax
cmp    %r8d,(%rax)
je     115b <cec_msg_timer_status+0x5b>
ret
addl   $0x2,(%rdi)
mov    0x8(%rsp),%eax
movslq %r9d,%rcx
imul   $0x66666667,%rcx,%rdx
mov    %rdx,%rsi
shr    $0x3f,%rsi
sar    $0x22,%rdx
add    %esi,%edx
mov    %edx,%esi
shl    $0x4,%esi
add    %edx,%edx
lea    (%rdx,%rdx,4),%edx
sub    %edx,%ecx
or     %esi,%ecx
mov    %ecx,0xc(%r10)
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
mov    %ecx,%edx
shl    $0x4,%edx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
or     %edx,%eax
mov    %eax,0x10(%r10)
ret

LLVM IR (-O0):
%struct.cec_msg = type { i32, i32* }
@CEC_MSG_TIMER_STATUS = global i32 0
@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_msg_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
store i32 3, i32* %16
%17 = load i32, i32* @CEC_MSG_TIMER_STATUS
%18 = load %struct.cec_msg*, %struct.cec_msg** %8
%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 1
store i32 %17, i32* %21
%22 = load i32, i32* %9
%23 = shl i32 %22, 7
%24 = load i32, i32* %10
%25 = shl i32 %24, 5
%26 = or i32 %23, %25
%27 = load i32, i32* %11
%28 = icmp ne i32 %27, 0
%29 = zext i1 %28 to i64
%30 = select i1 %28, i32 16, i32 0
%31 = or i32 %26, %30
%32 = load i32, i32* %11
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %36
34: ; preds = %7
%35 = load i32, i32* %11
br label %38
36: ; preds = %7
%37 = load i32, i32* %12
br label %38
38: ; preds = %36, %34
%39 = phi i32 [ %35, %34 ], [ %37, %36 ]
%40 = or i32 %31, %39
%41 = load %struct.cec_msg*, %struct.cec_msg** %8
%42 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %41, i32 0, i32 1
%43 = load i32*, i32** %42
%44 = getelementptr inbounds i32, i32* %43, i64 2
store i32 %40, i32* %44
%45 = load i32, i32* %11
%46 = load i32, i32* @CEC_OP_PROG_INFO_NOT_ENOUGH_SPACE
%47 = icmp eq i32 %45, %46
br i1 %47, label %56, label %48
48: ; preds = %38
%49 = load i32, i32* %11
%50 = load i32, i32* @CEC_OP_PROG_INFO_MIGHT_NOT_BE_ENOUGH_SPACE
%51 = icmp eq i32 %49, %50
br i1 %51, label %56, label %52
52: ; preds = %48
%53 = load i32, i32* %12
%54 = load i32, i32* @CEC_OP_PROG_ERROR_DUPLICATE
%55 = icmp eq i32 %53, %54
br i1 %55, label %56, label %81
56: ; preds = %52, %48, %38
%57 = load %struct.cec_msg*, %struct.cec_msg** %8
%58 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %57, i32 0, i32 0
%59 = load i32, i32* %58
%60 = add nsw i32 %59, 2
store i32 %60, i32* %58
%61 = load i32, i32* %13
%62 = sdiv i32 %61, 10
%63 = shl i32 %62, 4
%64 = load i32, i32* %13
%65 = srem i32 %64, 10
%66 = or i32 %63, %65
%67 = load %struct.cec_msg*, %struct.cec_msg** %8
%68 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %67, i32 0, i32 1
%69 = load i32*, i32** %68
%70 = getelementptr inbounds i32, i32* %69, i64 3
store i32 %66, i32* %70
%71 = load i32, i32* %14
%72 = sdiv i32 %71, 10
%73 = shl i32 %72, 4
%74 = load i32, i32* %14
%75 = srem i32 %74, 10
%76 = or i32 %73, %75
%77 = load %struct.cec_msg*, %struct.cec_msg** %8
%78 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %77, i32 0, i32 1
%79 = load i32*, i32** %78
%80 = getelementptr inbounds i32, i32* %79, i64 4
store i32 %76, i32* %80
br label %81
81: ; preds = %56, %52
ret void
}

LLVM IR (-O2):
%struct.cec_msg = type { i32, i32* }
@CEC_MSG_TIMER_STATUS = global i32 0
@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_msg_timer_status(%struct.cec_msg* nocapture %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6) {
%8 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %0, i64 0, i32 0
store i32 3, i32* %8
%9 = load i32, i32* @CEC_MSG_TIMER_STATUS
%10 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %0, i64 0, i32 1
%11 = load i32*, i32** %10
%12 = getelementptr inbounds i32, i32* %11, i64 1
store i32 %9, i32* %12
%13 = shl i32 %1, 7
%14 = shl i32 %2, 5
%15 = or i32 %14, %13
%16 = icmp eq i32 %3, 0
%17 = select i1 %16, i32 0, i32 16
%18 = or i32 %15, %17
%19 = select i1 %16, i32 %4, i32 %3
%20 = or i32 %18, %19
%21 = getelementptr inbounds i32, i32* %11, i64 2
store i32 %20, i32* %21
%22 = load i32, i32* @CEC_OP_PROG_INFO_NOT_ENOUGH_SPACE
%23 = icmp eq i32 %22, %3
%24 = load i32, i32* @CEC_OP_PROG_INFO_MIGHT_NOT_BE_ENOUGH_SPACE
%25 = icmp eq i32 %24, %3
%26 = select i1 %23, i1 true, i1 %25
%27 = load i32, i32* @CEC_OP_PROG_ERROR_DUPLICATE
%28 = icmp eq i32 %27, %4
%29 = select i1 %26, i1 true, i1 %28
br i1 %29, label %30, label %43
30: ; preds = %7
%31 = load i32, i32* %8
%32 = add nsw i32 %31, 2
store i32 %32, i32* %8
%33 = sdiv i32 %5, 10
%34 = shl i32 %33, 4
%35 = srem i32 %5, 10
%36 = or i32 %34, %35
%37 = getelementptr inbounds i32, i32* %11, i64 3
store i32 %36, i32* %37
%38 = sdiv i32 %6, 10
%39 = shl i32 %38, 4
%40 = srem i32 %6, 10
%41 = or i32 %39, %40
%42 = getelementptr inbounds i32, i32* %11, i64 4
store i32 %41, i32* %42
br label %43
43: ; preds = %7, %30
ret void
}