#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 unsigned long *)(0x400FC334)));
  ui32Time = (*((volatile unsigned long *)(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 unsigned long *)(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),%rax
mov    %eax,-0x14(%rbp)
mov    $0x400fc330,%eax
mov    (%rax),%rax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
and    $0x3f00,%eax
cmp    $0x3f00,%eax
jne    1143 <HibernateCalendarMatchGet+0x43>
mov    -0x10(%rbp),%rax
movl   $0xff,(%rax)
jmp    1155 <HibernateCalendarMatchGet+0x55>
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    1174 <HibernateCalendarMatchGet+0x74>
mov    -0x10(%rbp),%rax
movl   $0xff,0x4(%rax)
jmp    1184 <HibernateCalendarMatchGet+0x84>
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    11a7 <HibernateCalendarMatchGet+0xa7>
mov    -0x10(%rbp),%rax
movl   $0xff,0x8(%rax)
jmp    11ba <HibernateCalendarMatchGet+0xba>
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    11d9 <HibernateCalendarMatchGet+0xd9>
mov    -0x10(%rbp),%rax
movl   $0xff,0xc(%rax)
jmp    11e9 <HibernateCalendarMatchGet+0xe9>
mov    -0x14(%rbp),%ecx
and    $0x1f,%ecx
sar    $0x0,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0xc(%rax)
mov    $0x400fc300,%eax
mov    (%rax),%rax
and    $0x4,%rax
cmp    $0x0,%rax
jne    121d <HibernateCalendarMatchGet+0x11d>
mov    -0x18(%rbp),%eax
and    $0x400000,%eax
cmp    $0x0,%eax
je     121d <HibernateCalendarMatchGet+0x11d>
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,%rcx
40
mov    0x400fc330,%r9
40
mov    %r9d,%edx
and    $0x3f00,%edx
mov    %edx,%edi
shr    $0x8,%edi
cmp    $0x3f00,%edx
mov    $0xff,%r8d
cmove  %r8d,%edi
mov    %edi,(%rsi)
mov    %r9d,%edi
and    $0x3f,%edi
cmp    $0x3f,%edi
cmove  %r8d,%edi
mov    %r9d,%edx
and    $0x1f0000,%edx
mov    %edx,%eax
shr    $0x10,%eax
cmp    $0x1f0000,%edx
cmove  %r8d,%eax
mov    %edi,0x4(%rsi)
and    $0x1f,%ecx
cmove  %r8d,%ecx
mov    %eax,0x8(%rsi)
mov    %ecx,0xc(%rsi)
testq  $0x4,0x400fc300
jne    1182 <HibernateCalendarMatchGet+0x82>
and    $0x400000,%r9d
je     1182 <HibernateCalendarMatchGet+0x82>
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 i64, i64* inttoptr (i64 1074774836 to i64*)
%8 = trunc i64 %7 to i32
store i32 %8, i32* %5
%9 = load volatile i64, i64* inttoptr (i64 1074774832 to i64*)
%10 = trunc i64 %9 to i32
store i32 %10, i32* %6
%11 = load i32, i32* %6
%12 = and i32 %11, 16128
%13 = icmp eq i32 %12, 16128
br i1 %13, label %14, label %17
14: ; preds = %2
%15 = load %struct.tm*, %struct.tm** %4
%16 = getelementptr inbounds %struct.tm, %struct.tm* %15, i32 0, i32 0
store i32 255, i32* %16
br label %23
17: ; preds = %2
%18 = load i32, i32* %6
%19 = and i32 %18, 16128
%20 = ashr i32 %19, 8
%21 = load %struct.tm*, %struct.tm** %4
%22 = getelementptr inbounds %struct.tm, %struct.tm* %21, i32 0, i32 0
store i32 %20, i32* %22
br label %23
23: ; preds = %17, %14
%24 = load i32, i32* %6
%25 = and i32 %24, 63
%26 = icmp eq i32 %25, 63
br i1 %26, label %27, label %30
27: ; preds = %23
%28 = load %struct.tm*, %struct.tm** %4
%29 = getelementptr inbounds %struct.tm, %struct.tm* %28, i32 0, i32 1
store i32 255, i32* %29
br label %36
30: ; preds = %23
%31 = load i32, i32* %6
%32 = and i32 %31, 63
%33 = ashr i32 %32, 0
%34 = load %struct.tm*, %struct.tm** %4
%35 = getelementptr inbounds %struct.tm, %struct.tm* %34, i32 0, i32 1
store i32 %33, i32* %35
br label %36
36: ; preds = %30, %27
%37 = load i32, i32* %6
%38 = and i32 %37, 2031616
%39 = icmp eq i32 %38, 2031616
br i1 %39, label %40, label %43
40: ; preds = %36
%41 = load %struct.tm*, %struct.tm** %4
%42 = getelementptr inbounds %struct.tm, %struct.tm* %41, i32 0, i32 2
store i32 255, i32* %42
br label %49
43: ; preds = %36
%44 = load i32, i32* %6
%45 = and i32 %44, 2031616
%46 = ashr i32 %45, 16
%47 = load %struct.tm*, %struct.tm** %4
%48 = getelementptr inbounds %struct.tm, %struct.tm* %47, i32 0, i32 2
store i32 %46, i32* %48
br label %49
49: ; preds = %43, %40
%50 = load i32, i32* %5
%51 = and i32 %50, 31
%52 = icmp eq i32 %51, 0
br i1 %52, label %53, label %56
53: ; preds = %49
%54 = load %struct.tm*, %struct.tm** %4
%55 = getelementptr inbounds %struct.tm, %struct.tm* %54, i32 0, i32 3
store i32 255, i32* %55
br label %62
56: ; preds = %49
%57 = load i32, i32* %5
%58 = and i32 %57, 31
%59 = ashr i32 %58, 0
%60 = load %struct.tm*, %struct.tm** %4
%61 = getelementptr inbounds %struct.tm, %struct.tm* %60, i32 0, i32 3
store i32 %59, i32* %61
br label %62
62: ; preds = %56, %53
%63 = load volatile i64, i64* inttoptr (i64 1074774784 to i64*)
%64 = and i64 %63, 4
%65 = icmp eq i64 %64, 0
br i1 %65, label %66, label %75
66: ; preds = %62
%67 = load i32, i32* %6
%68 = and i32 %67, 4194304
%69 = icmp ne i32 %68, 0
br i1 %69, label %70, label %75
70: ; preds = %66
%71 = load %struct.tm*, %struct.tm** %4
%72 = getelementptr inbounds %struct.tm, %struct.tm* %71, i32 0, i32 2
%73 = load i32, i32* %72
%74 = add nsw i32 %73, 12
store i32 %74, i32* %72
br label %75
75: ; preds = %70, %66, %62
ret void
}

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