#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 uint32_t;
struct tm {
  int tm_min;
  int tm_sec;
  int tm_hour;
  int tm_mday;
};

/* Variables and functions */
void HibernateCalendarMatchGet(uint32_t ui32Index, struct tm *psTime) {
  uint32_t ui32Date, ui32Time;
  ;
  ui32Date = (*((volatile uint32_t *)(0x400FC334)));
  ui32Time = (*((volatile uint32_t *)(0x400FC330)));
  if ((ui32Time & 0x00003F00) == 0x00003F00) {
    psTime->tm_min = 0xFF;
  } else {
    psTime->tm_min = (ui32Time & 0x00003F00) >> 8;
  }
  if ((ui32Time & 0x0000003F) == 0x0000003F) {
    psTime->tm_sec = 0xFF;
  } else {
    psTime->tm_sec = (ui32Time & 0x0000003F) >> 0;
  }
  if ((ui32Time & 0x001F0000) == 0x001F0000) {
    psTime->tm_hour = 0xFF;
  } else {
    psTime->tm_hour = (ui32Time & 0x001F0000) >> 16;
  }
  if ((ui32Date & 0x0000001F) == 0) {
    psTime->tm_mday = 0xFF;
  } else {
    psTime->tm_mday = (ui32Date & 0x0000001F) >> 0;
  }
  if ((((*((volatile uint32_t *)(0x400FC300))) & 0x00000004) == 0) &&
      (ui32Time & 0x00400000)) {
    psTime->tm_hour += 12;
  }
}


x86 assembly (clang, -O0):
<HibernateCalendarMatchGet>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x400fc334,%eax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    $0x400fc330,%eax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
and    $0x3f00,%eax
cmp    $0x3f00,%eax
jne    1141 <HibernateCalendarMatchGet+0x41>
mov    -0x10(%rbp),%rax
movl   $0xff,(%rax)
jmp    1153 <HibernateCalendarMatchGet+0x53>
mov    -0x18(%rbp),%ecx
and    $0x3f00,%ecx
sar    $0x8,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%eax
and    $0x3f,%eax
cmp    $0x3f,%eax
jne    1172 <HibernateCalendarMatchGet+0x72>
mov    -0x10(%rbp),%rax
movl   $0xff,0x4(%rax)
jmp    1182 <HibernateCalendarMatchGet+0x82>
mov    -0x18(%rbp),%ecx
and    $0x3f,%ecx
sar    $0x0,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x18(%rbp),%eax
and    $0x1f0000,%eax
cmp    $0x1f0000,%eax
jne    11a5 <HibernateCalendarMatchGet+0xa5>
mov    -0x10(%rbp),%rax
movl   $0xff,0x8(%rax)
jmp    11b8 <HibernateCalendarMatchGet+0xb8>
mov    -0x18(%rbp),%ecx
and    $0x1f0000,%ecx
sar    $0x10,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x8(%rax)
mov    -0x14(%rbp),%eax
and    $0x1f,%eax
cmp    $0x0,%eax
jne    11d7 <HibernateCalendarMatchGet+0xd7>
mov    -0x10(%rbp),%rax
movl   $0xff,0xc(%rax)
jmp    11e7 <HibernateCalendarMatchGet+0xe7>
mov    -0x14(%rbp),%ecx
and    $0x1f,%ecx
sar    $0x0,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0xc(%rax)
mov    $0x400fc300,%eax
mov    (%rax),%eax
and    $0x4,%eax
cmp    $0x0,%eax
jne    1218 <HibernateCalendarMatchGet+0x118>
mov    -0x18(%rbp),%eax
and    $0x400000,%eax
cmp    $0x0,%eax
je     1218 <HibernateCalendarMatchGet+0x118>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%ecx
add    $0xc,%ecx
mov    %ecx,0x8(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<HibernateCalendarMatchGet>:
mov    0x400fc334,%edx
mov    0x400fc330,%r9d
40
mov    %r9d,%ecx
and    $0x3f00,%ecx
mov    %ecx,%edi
shr    $0x8,%edi
cmp    $0x3f00,%ecx
mov    $0xff,%r8d
cmove  %r8d,%edi
mov    %edi,(%rsi)
mov    %r9d,%edi
and    $0x3f,%edi
cmp    $0x3f,%edi
cmove  %r8d,%edi
mov    %r9d,%ecx
and    $0x1f0000,%ecx
mov    %ecx,%eax
shr    $0x10,%eax
cmp    $0x1f0000,%ecx
cmove  %r8d,%eax
mov    %edi,0x4(%rsi)
and    $0x1f,%edx
cmove  %r8d,%edx
mov    %eax,0x8(%rsi)
mov    %edx,0xc(%rsi)
testl  $0x4,0x400fc300
jne    1180 <HibernateCalendarMatchGet+0x80>
and    $0x400000,%r9d
je     1180 <HibernateCalendarMatchGet+0x80>
add    $0xc,%eax
mov    %eax,0x8(%rsi)
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i32 }
define void @HibernateCalendarMatchGet(i32 %0, %struct.tm* %1) {
%3 = alloca i32
%4 = alloca %struct.tm*
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
store %struct.tm* %1, %struct.tm** %4
%7 = load volatile i32, i32* inttoptr (i64 1074774836 to i32*)
store i32 %7, i32* %5
%8 = load volatile i32, i32* inttoptr (i64 1074774832 to i32*)
store i32 %8, i32* %6
%9 = load i32, i32* %6
%10 = and i32 %9, 16128
%11 = icmp eq i32 %10, 16128
br i1 %11, label %12, label %15
12: ; preds = %2
%13 = load %struct.tm*, %struct.tm** %4
%14 = getelementptr inbounds %struct.tm, %struct.tm* %13, i32 0, i32 0
store i32 255, i32* %14
br label %21
15: ; preds = %2
%16 = load i32, i32* %6
%17 = and i32 %16, 16128
%18 = ashr i32 %17, 8
%19 = load %struct.tm*, %struct.tm** %4
%20 = getelementptr inbounds %struct.tm, %struct.tm* %19, i32 0, i32 0
store i32 %18, i32* %20
br label %21
21: ; preds = %15, %12
%22 = load i32, i32* %6
%23 = and i32 %22, 63
%24 = icmp eq i32 %23, 63
br i1 %24, label %25, label %28
25: ; preds = %21
%26 = load %struct.tm*, %struct.tm** %4
%27 = getelementptr inbounds %struct.tm, %struct.tm* %26, i32 0, i32 1
store i32 255, i32* %27
br label %34
28: ; preds = %21
%29 = load i32, i32* %6
%30 = and i32 %29, 63
%31 = ashr i32 %30, 0
%32 = load %struct.tm*, %struct.tm** %4
%33 = getelementptr inbounds %struct.tm, %struct.tm* %32, i32 0, i32 1
store i32 %31, i32* %33
br label %34
34: ; preds = %28, %25
%35 = load i32, i32* %6
%36 = and i32 %35, 2031616
%37 = icmp eq i32 %36, 2031616
br i1 %37, label %38, label %41
38: ; preds = %34
%39 = load %struct.tm*, %struct.tm** %4
%40 = getelementptr inbounds %struct.tm, %struct.tm* %39, i32 0, i32 2
store i32 255, i32* %40
br label %47
41: ; preds = %34
%42 = load i32, i32* %6
%43 = and i32 %42, 2031616
%44 = ashr i32 %43, 16
%45 = load %struct.tm*, %struct.tm** %4
%46 = getelementptr inbounds %struct.tm, %struct.tm* %45, i32 0, i32 2
store i32 %44, i32* %46
br label %47
47: ; preds = %41, %38
%48 = load i32, i32* %5
%49 = and i32 %48, 31
%50 = icmp eq i32 %49, 0
br i1 %50, label %51, label %54
51: ; preds = %47
%52 = load %struct.tm*, %struct.tm** %4
%53 = getelementptr inbounds %struct.tm, %struct.tm* %52, i32 0, i32 3
store i32 255, i32* %53
br label %60
54: ; preds = %47
%55 = load i32, i32* %5
%56 = and i32 %55, 31
%57 = ashr i32 %56, 0
%58 = load %struct.tm*, %struct.tm** %4
%59 = getelementptr inbounds %struct.tm, %struct.tm* %58, i32 0, i32 3
store i32 %57, i32* %59
br label %60
60: ; preds = %54, %51
%61 = load volatile i32, i32* inttoptr (i64 1074774784 to i32*)
%62 = and i32 %61, 4
%63 = icmp eq i32 %62, 0
br i1 %63, label %64, label %73
64: ; preds = %60
%65 = load i32, i32* %6
%66 = and i32 %65, 4194304
%67 = icmp ne i32 %66, 0
br i1 %67, label %68, label %73
68: ; preds = %64
%69 = load %struct.tm*, %struct.tm** %4
%70 = getelementptr inbounds %struct.tm, %struct.tm* %69, i32 0, i32 2
%71 = load i32, i32* %70
%72 = add nsw i32 %71, 12
store i32 %72, i32* %70
br label %73
73: ; preds = %68, %64, %60
ret void
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i32 }
define void @HibernateCalendarMatchGet(i32 %0, %struct.tm* nocapture %1) {
%3 = load volatile i32, i32* inttoptr (i64 1074774836 to i32*)
%4 = load volatile i32, i32* inttoptr (i64 1074774832 to i32*)
%5 = and i32 %4, 16128
%6 = icmp eq i32 %5, 16128
%7 = lshr exact i32 %5, 8
%8 = select i1 %6, i32 255, i32 %7
%9 = getelementptr inbounds %struct.tm, %struct.tm* %1, i64 0, i32 0
store i32 %8, i32* %9
%10 = and i32 %4, 63
%11 = icmp eq i32 %10, 63
%12 = select i1 %11, i32 255, i32 %10
%13 = getelementptr inbounds %struct.tm, %struct.tm* %1, i64 0, i32 1
store i32 %12, i32* %13
%14 = and i32 %4, 2031616
%15 = icmp eq i32 %14, 2031616
%16 = lshr exact i32 %14, 16
%17 = select i1 %15, i32 255, i32 %16
%18 = getelementptr inbounds %struct.tm, %struct.tm* %1, i64 0, i32 2
store i32 %17, i32* %18
%19 = and i32 %3, 31
%20 = icmp eq i32 %19, 0
%21 = select i1 %20, i32 255, i32 %19
%22 = getelementptr inbounds %struct.tm, %struct.tm* %1, i64 0, i32 3
store i32 %21, i32* %22
%23 = load volatile i32, i32* inttoptr (i64 1074774784 to i32*)
%24 = and i32 %23, 4
%25 = icmp ne i32 %24, 0
%26 = and i32 %4, 4194304
%27 = icmp eq i32 %26, 0
%28 = select i1 %25, i1 true, i1 %27
br i1 %28, label %31, label %29
29: ; preds = %2
%30 = add nuw nsw i32 %17, 12
store i32 %30, i32* %18
br label %31
31: ; preds = %29, %2
ret void
}