#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 */
typedef int uint8_t;
struct tm {
  int tm_sec;
  int tm_min;
  int tm_hour;
  int tm_wday;
  int tm_mday;
  int tm_mon;
  int tm_year;
};

/* Variables and functions */
void rtc_time_set(uint8_t *regs, struct tm *tm) {
  regs[0x00] = (((tm->tm_sec) % 10) | (((tm->tm_sec) / 10) << 4));
  regs[0x01] = (((tm->tm_min) % 10) | (((tm->tm_min) / 10) << 4));
  regs[0x02] = (((tm->tm_hour) % 10) | (((tm->tm_hour) / 10) << 4));
  regs[0x06] = (((tm->tm_wday + 1) % 10) | (((tm->tm_wday + 1) / 10) << 4));
  regs[0x03] = (((tm->tm_mday) % 10) | (((tm->tm_mday) / 10) << 4));
  regs[0x04] = (((tm->tm_mon + 1) % 10) | (((tm->tm_mon + 1) / 10) << 4));
  regs[0x05] = (((tm->tm_year % 100) % 10) | (((tm->tm_year % 100) / 10) << 4));
}


x86 assembly (clang, -O0):
<rtc_time_set>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    -0x2c(%rbp),%edx
shl    $0x4,%eax
or     %eax,%edx
mov    -0x8(%rbp),%rax
mov    %edx,(%rax)
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    -0x28(%rbp),%edx
shl    $0x4,%eax
or     %eax,%edx
mov    -0x8(%rbp),%rax
mov    %edx,0x4(%rax)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    -0x24(%rbp),%edx
shl    $0x4,%eax
or     %eax,%edx
mov    -0x8(%rbp),%rax
mov    %edx,0x8(%rax)
mov    -0x10(%rbp),%rax
mov    0xc(%rax),%eax
add    $0x1,%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0xc(%rax),%eax
add    $0x1,%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    -0x20(%rbp),%edx
shl    $0x4,%eax
or     %eax,%edx
mov    -0x8(%rbp),%rax
mov    %edx,0x18(%rax)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    -0x1c(%rbp),%edx
shl    $0x4,%eax
or     %eax,%edx
mov    -0x8(%rbp),%rax
mov    %edx,0xc(%rax)
mov    -0x10(%rbp),%rax
mov    0x14(%rax),%eax
add    $0x1,%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x14(%rax),%eax
add    $0x1,%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    -0x18(%rbp),%edx
shl    $0x4,%eax
or     %eax,%edx
mov    -0x8(%rbp),%rax
mov    %edx,0x10(%rax)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    -0x14(%rbp),%edx
shl    $0x4,%eax
or     %eax,%edx
mov    -0x8(%rbp),%rax
mov    %edx,0x14(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<rtc_time_set>:
movslq (%rsi),%rax
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,1),%edx
lea    (%rdx,%rdx,4),%edx
sub    %edx,%eax
shl    $0x4,%ecx
or     %eax,%ecx
mov    %ecx,(%rdi)
movslq 0x4(%rsi),%rax
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,1),%edx
lea    (%rdx,%rdx,4),%edx
sub    %edx,%eax
shl    $0x4,%ecx
or     %eax,%ecx
mov    %ecx,0x4(%rdi)
movslq 0x8(%rsi),%rax
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,1),%edx
lea    (%rdx,%rdx,4),%edx
sub    %edx,%eax
shl    $0x4,%ecx
or     %eax,%ecx
mov    %ecx,0x8(%rdi)
mov    0xc(%rsi),%eax
mov    %eax,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
imul   $0x66666667,%rcx,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,1),%edx
lea    (%rdx,%rdx,4),%edx
neg    %edx
add    %edx,%eax
add    $0x1,%eax
shl    $0x4,%ecx
or     %eax,%ecx
mov    %ecx,0x18(%rdi)
movslq 0x10(%rsi),%rax
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,1),%edx
lea    (%rdx,%rdx,4),%edx
sub    %edx,%eax
shl    $0x4,%ecx
or     %eax,%ecx
mov    %ecx,0xc(%rdi)
mov    0x14(%rsi),%eax
mov    %eax,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
imul   $0x66666667,%rcx,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,1),%edx
lea    (%rdx,%rdx,4),%edx
neg    %edx
add    %edx,%eax
add    $0x1,%eax
shl    $0x4,%ecx
or     %eax,%ecx
mov    %ecx,0x10(%rdi)
movslq 0x18(%rsi),%rax
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x25,%rcx
add    %edx,%ecx
imul   $0x64,%ecx,%ecx
sub    %ecx,%eax
movsbl %al,%ecx
imul   $0x67,%ecx,%ecx
movzwl %cx,%ecx
movswl %cx,%edx
shr    $0xf,%ecx
shr    $0xa,%edx
add    %cl,%dl
movzbl %dl,%ecx
lea    (%rcx,%rcx,1),%edx
lea    (%rdx,%rdx,4),%edx
sub    %dl,%al
movsbl %al,%eax
movsbl %cl,%ecx
shl    $0x4,%ecx
or     %eax,%ecx
mov    %ecx,0x14(%rdi)
ret

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

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i32, i32, i32, i32 }
define void @rtc_time_set(i32* nocapture writeonly %0, %struct.tm* nocapture %1) {
%3 = getelementptr inbounds %struct.tm, %struct.tm* %1, i64 0, i32 0
%4 = load i32, i32* %3
%5 = srem i32 %4, 10
%6 = sdiv i32 %4, 10
%7 = shl i32 %6, 4
%8 = or i32 %7, %5
store i32 %8, i32* %0
%9 = getelementptr inbounds %struct.tm, %struct.tm* %1, i64 0, i32 1
%10 = load i32, i32* %9
%11 = srem i32 %10, 10
%12 = sdiv i32 %10, 10
%13 = shl i32 %12, 4
%14 = or i32 %13, %11
%15 = getelementptr inbounds i32, i32* %0, i64 1
store i32 %14, i32* %15
%16 = getelementptr inbounds %struct.tm, %struct.tm* %1, i64 0, i32 2
%17 = load i32, i32* %16
%18 = srem i32 %17, 10
%19 = sdiv i32 %17, 10
%20 = shl i32 %19, 4
%21 = or i32 %20, %18
%22 = getelementptr inbounds i32, i32* %0, i64 2
store i32 %21, i32* %22
%23 = getelementptr inbounds %struct.tm, %struct.tm* %1, i64 0, i32 3
%24 = load i32, i32* %23
%25 = add nsw i32 %24, 1
%26 = srem i32 %25, 10
%27 = sdiv i32 %25, 10
%28 = shl i32 %27, 4
%29 = or i32 %28, %26
%30 = getelementptr inbounds i32, i32* %0, i64 6
store i32 %29, i32* %30
%31 = getelementptr inbounds %struct.tm, %struct.tm* %1, i64 0, i32 4
%32 = load i32, i32* %31
%33 = srem i32 %32, 10
%34 = sdiv i32 %32, 10
%35 = shl i32 %34, 4
%36 = or i32 %35, %33
%37 = getelementptr inbounds i32, i32* %0, i64 3
store i32 %36, i32* %37
%38 = getelementptr inbounds %struct.tm, %struct.tm* %1, i64 0, i32 5
%39 = load i32, i32* %38
%40 = add nsw i32 %39, 1
%41 = srem i32 %40, 10
%42 = sdiv i32 %40, 10
%43 = shl i32 %42, 4
%44 = or i32 %43, %41
%45 = getelementptr inbounds i32, i32* %0, i64 4
store i32 %44, i32* %45
%46 = getelementptr inbounds %struct.tm, %struct.tm* %1, i64 0, i32 6
%47 = load i32, i32* %46
%48 = srem i32 %47, 100
%49 = trunc i32 %48 to i8
%50 = srem i8 %49, 10
%51 = sext i8 %50 to i32
%52 = sdiv i8 %49, 10
%53 = sext i8 %52 to i32
%54 = shl nsw i32 %53, 4
%55 = or i32 %54, %51
%56 = getelementptr inbounds i32, i32* %0, i64 5
store i32 %55, i32* %56
ret void
}