#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_op_digital_service_id {
  int dummy;
};
struct cec_msg {
  int len;
  int *msg;
  int /*<<< orphan*/ reply;
};
typedef int __u8;

/* Variables and functions */
int CEC_MSG_CLEAR_DIGITAL_TIMER;
int /*<<< orphan*/ CEC_MSG_TIMER_CLEARED_STATUS;
int /*<<< orphan*/
cec_set_digital_service_id(int *, struct cec_op_digital_service_id const *);
void cec_msg_clear_digital_timer(
    struct cec_msg *msg, int reply, __u8 day, __u8 month, __u8 start_hr,
    __u8 start_min, __u8 duration_hr, __u8 duration_min, __u8 recording_seq,
    const struct cec_op_digital_service_id *digital) {
  msg->len = 16;
  msg->reply = reply ? CEC_MSG_TIMER_CLEARED_STATUS : 0;
  msg->msg[1] = CEC_MSG_CLEAR_DIGITAL_TIMER;
  msg->msg[2] = day;
  msg->msg[3] = month;
  msg->msg[4] = ((start_hr / 10) << 4) | (start_hr % 10);
  msg->msg[5] = ((start_min / 10) << 4) | (start_min % 10);
  msg->msg[6] = ((duration_hr / 10) << 4) | (duration_hr % 10);
  msg->msg[7] = ((duration_min / 10) << 4) | (duration_min % 10);
  msg->msg[8] = recording_seq;
  cec_set_digital_service_id(msg->msg + 9, digital);
}


x86 assembly (clang, -O0):
<cec_msg_clear_digital_timer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0x28(%rbp),%rax
mov    0x20(%rbp),%eax
mov    0x18(%rbp),%eax
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   $0x10,(%rax)
cmpl   $0x0,-0xc(%rbp)
je     115f <cec_msg_clear_digital_timer+0x4f>
mov    0x2e93(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
jmp    1169 <cec_msg_clear_digital_timer+0x59>
xor    %eax,%eax
mov    %eax,-0x20(%rbp)
jmp    1169 <cec_msg_clear_digital_timer+0x59>
mov    -0x20(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x10(%rax)
mov    0x2e66(%rip),%rax
mov    (%rax),%ecx
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    %ecx,0x4(%rax)
mov    -0x10(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    %ecx,0x8(%rax)
mov    -0x14(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    %ecx,0xc(%rax)
mov    -0x18(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
shl    $0x4,%ecx
mov    -0x18(%rbp),%eax
mov    $0xa,%esi
cltd
idiv   %esi
or     %edx,%ecx
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    %ecx,0x10(%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,0x14(%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,0x18(%rax)
mov    0x18(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
shl    $0x4,%ecx
mov    0x18(%rbp),%eax
mov    $0xa,%esi
cltd
idiv   %esi
or     %edx,%ecx
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    %ecx,0x1c(%rax)
mov    0x20(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    %ecx,0x20(%rax)
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rdi
add    $0x24,%rdi
mov    0x28(%rbp),%rsi
call   1030 <cec_set_digital_service_id@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cec_msg_clear_digital_timer>:
mov    %esi,%eax
mov    0x20(%rsp),%rsi
mov    0x18(%rsp),%r10d
movl   $0x10,(%rdi)
test   %eax,%eax
je     112f <cec_msg_clear_digital_timer+0x1f>
mov    0x2ebb(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x10(%rdi)
mov    0x2ea7(%rip),%rax
mov    (%rax),%eax
mov    0x8(%rdi),%rdi
mov    %eax,0x4(%rdi)
mov    %edx,0x8(%rdi)
mov    %ecx,0xc(%rdi)
movd   0x10(%rsp),%xmm0
movd   0x8(%rsp),%xmm1
punpckldq %xmm0,%xmm1
movd   %r9d,%xmm2
movd   %r8d,%xmm0
punpckldq %xmm2,%xmm0
punpcklqdq %xmm1,%xmm0
movdqa 0xe8e(%rip),%xmm1
movdqa %xmm0,%xmm2
pmuludq %xmm1,%xmm2
pshufd $0xed,%xmm2,%xmm2
pshufd $0xf5,%xmm0,%xmm3
pmuludq %xmm1,%xmm3
pshufd $0xed,%xmm3,%xmm3
punpckldq %xmm3,%xmm2
pxor   %xmm3,%xmm3
pcmpgtd %xmm0,%xmm3
pand   %xmm1,%xmm3
psubd  %xmm3,%xmm2
movdqa %xmm2,%xmm1
psrld  $0x1f,%xmm1
psrad  $0x2,%xmm2
paddd  %xmm1,%xmm2
movdqa 0xe55(%rip),%xmm1
movdqa %xmm2,%xmm3
pslld  $0x4,%xmm3
pshufd $0xf5,%xmm2,%xmm4
pmuludq %xmm1,%xmm2
pshufd $0xe8,%xmm2,%xmm2
pmuludq %xmm1,%xmm4
pshufd $0xe8,%xmm4,%xmm1
punpckldq %xmm1,%xmm2
psubd  %xmm2,%xmm0
por    %xmm3,%xmm0
movdqu %xmm0,0x10(%rdi)
mov    %r10d,0x20(%rdi)
add    $0x24,%rdi
jmp    1030 <cec_set_digital_service_id@plt>

LLVM IR (-O0):
%struct.cec_msg = type { i32, i32*, i32 }
%struct.cec_op_digital_service_id = type { i32 }
@CEC_MSG_TIMER_CLEARED_STATUS = global i32 0
@CEC_MSG_CLEAR_DIGITAL_TIMER = global i32 0
define void @cec_msg_clear_digital_timer(%struct.cec_msg* %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6, i32 %7, i32 %8, %struct.cec_op_digital_service_id* %9) {
%11 = alloca %struct.cec_msg*
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca %struct.cec_op_digital_service_id*
store %struct.cec_msg* %0, %struct.cec_msg** %11
store i32 %1, i32* %12
store i32 %2, i32* %13
store i32 %3, i32* %14
store i32 %4, i32* %15
store i32 %5, i32* %16
store i32 %6, i32* %17
store i32 %7, i32* %18
store i32 %8, i32* %19
store %struct.cec_op_digital_service_id* %9, %struct.cec_op_digital_service_id** %20
%21 = load %struct.cec_msg*, %struct.cec_msg** %11
%22 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %21, i32 0, i32 0
store i32 16, i32* %22
%23 = load i32, i32* %12
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %10
%26 = load i32, i32* @CEC_MSG_TIMER_CLEARED_STATUS
br label %28
27: ; preds = %10
br label %28
28: ; preds = %27, %25
%29 = phi i32 [ %26, %25 ], [ 0, %27 ]
%30 = load %struct.cec_msg*, %struct.cec_msg** %11
%31 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %30, i32 0, i32 2
store i32 %29, i32* %31
%32 = load i32, i32* @CEC_MSG_CLEAR_DIGITAL_TIMER
%33 = load %struct.cec_msg*, %struct.cec_msg** %11
%34 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %33, i32 0, i32 1
%35 = load i32*, i32** %34
%36 = getelementptr inbounds i32, i32* %35, i64 1
store i32 %32, i32* %36
%37 = load i32, i32* %13
%38 = load %struct.cec_msg*, %struct.cec_msg** %11
%39 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %38, i32 0, i32 1
%40 = load i32*, i32** %39
%41 = getelementptr inbounds i32, i32* %40, i64 2
store i32 %37, i32* %41
%42 = load i32, i32* %14
%43 = load %struct.cec_msg*, %struct.cec_msg** %11
%44 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %43, i32 0, i32 1
%45 = load i32*, i32** %44
%46 = getelementptr inbounds i32, i32* %45, i64 3
store i32 %42, i32* %46
%47 = load i32, i32* %15
%48 = sdiv i32 %47, 10
%49 = shl i32 %48, 4
%50 = load i32, i32* %15
%51 = srem i32 %50, 10
%52 = or i32 %49, %51
%53 = load %struct.cec_msg*, %struct.cec_msg** %11
%54 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %53, i32 0, i32 1
%55 = load i32*, i32** %54
%56 = getelementptr inbounds i32, i32* %55, i64 4
store i32 %52, i32* %56
%57 = load i32, i32* %16
%58 = sdiv i32 %57, 10
%59 = shl i32 %58, 4
%60 = load i32, i32* %16
%61 = srem i32 %60, 10
%62 = or i32 %59, %61
%63 = load %struct.cec_msg*, %struct.cec_msg** %11
%64 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %63, i32 0, i32 1
%65 = load i32*, i32** %64
%66 = getelementptr inbounds i32, i32* %65, i64 5
store i32 %62, i32* %66
%67 = load i32, i32* %17
%68 = sdiv i32 %67, 10
%69 = shl i32 %68, 4
%70 = load i32, i32* %17
%71 = srem i32 %70, 10
%72 = or i32 %69, %71
%73 = load %struct.cec_msg*, %struct.cec_msg** %11
%74 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %73, i32 0, i32 1
%75 = load i32*, i32** %74
%76 = getelementptr inbounds i32, i32* %75, i64 6
store i32 %72, i32* %76
%77 = load i32, i32* %18
%78 = sdiv i32 %77, 10
%79 = shl i32 %78, 4
%80 = load i32, i32* %18
%81 = srem i32 %80, 10
%82 = or i32 %79, %81
%83 = load %struct.cec_msg*, %struct.cec_msg** %11
%84 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %83, i32 0, i32 1
%85 = load i32*, i32** %84
%86 = getelementptr inbounds i32, i32* %85, i64 7
store i32 %82, i32* %86
%87 = load i32, i32* %19
%88 = load %struct.cec_msg*, %struct.cec_msg** %11
%89 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %88, i32 0, i32 1
%90 = load i32*, i32** %89
%91 = getelementptr inbounds i32, i32* %90, i64 8
store i32 %87, i32* %91
%92 = load %struct.cec_msg*, %struct.cec_msg** %11
%93 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %92, i32 0, i32 1
%94 = load i32*, i32** %93
%95 = getelementptr inbounds i32, i32* %94, i64 9
%96 = load %struct.cec_op_digital_service_id*, %struct.cec_op_digital_service_id** %20
%97 = call i32 @cec_set_digital_service_id(i32* %95, %struct.cec_op_digital_service_id* %96)
ret void
}

LLVM IR (-O2):
%struct.cec_msg = type { i32, i32*, i32 }
%struct.cec_op_digital_service_id = type { i32 }
@CEC_MSG_TIMER_CLEARED_STATUS = global i32 0
@CEC_MSG_CLEAR_DIGITAL_TIMER = global i32 0
define void @cec_msg_clear_digital_timer(%struct.cec_msg* nocapture %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6, i32 %7, i32 %8, %struct.cec_op_digital_service_id* %9) {
%11 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %0, i64 0, i32 0
store i32 16, i32* %11
%12 = icmp eq i32 %1, 0
%13 = load i32, i32* @CEC_MSG_TIMER_CLEARED_STATUS
%14 = select i1 %12, i32 0, i32 %13
%15 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %0, i64 0, i32 2
store i32 %14, i32* %15
%16 = load i32, i32* @CEC_MSG_CLEAR_DIGITAL_TIMER
%17 = getelementptr inbounds %struct.cec_msg, %struct.cec_msg* %0, i64 0, i32 1
%18 = load i32*, i32** %17
%19 = getelementptr inbounds i32, i32* %18, i64 1
store i32 %16, i32* %19
%20 = getelementptr inbounds i32, i32* %18, i64 2
store i32 %2, i32* %20
%21 = getelementptr inbounds i32, i32* %18, i64 3
store i32 %3, i32* %21
%22 = getelementptr inbounds i32, i32* %18, i64 4
%23 = insertelement <4 x i32> poison, i32 %4, i64 0
%24 = insertelement <4 x i32> %23, i32 %5, i64 1
%25 = insertelement <4 x i32> %24, i32 %6, i64 2
%26 = insertelement <4 x i32> %25, i32 %7, i64 3
%27 = freeze <4 x i32> %26
%28 = sdiv <4 x i32> %27, <i32 10, i32 10, i32 10, i32 10>
%29 = shl <4 x i32> %28, <i32 4, i32 4, i32 4, i32 4>
%30 = mul <4 x i32> %28, <i32 10, i32 10, i32 10, i32 10>
%31 = sub <4 x i32> %27, %30
%32 = or <4 x i32> %29, %31
%33 = bitcast i32* %22 to <4 x i32>*
store <4 x i32> %32, <4 x i32>* %33
%34 = getelementptr inbounds i32, i32* %18, i64 8
store i32 %8, i32* %34
%35 = getelementptr inbounds i32, i32* %18, i64 9
%36 = tail call i32 @cec_set_digital_service_id(i32* %35, %struct.cec_op_digital_service_id* %9)
ret void
}