#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 */
int /*<<< orphan*/ ASSERT(int volatile);
void HibernateCalendarMatchGet(uint32_t ui32Index, struct tm *psTime) {
  uint32_t ui32Date, ui32Time;
  ASSERT((*((volatile uint32_t *)(0x400FC300))) & 0x00000001);
  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
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x400fc300,%eax
mov    (%rax),%edi
and    $0x1,%edi
call   1030 <ASSERT@plt>
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    1164 <HibernateCalendarMatchGet+0x54>
mov    -0x10(%rbp),%rax
movl   $0xff,(%rax)
jmp    1176 <HibernateCalendarMatchGet+0x66>
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    1195 <HibernateCalendarMatchGet+0x85>
mov    -0x10(%rbp),%rax
movl   $0xff,0x4(%rax)
jmp    11a5 <HibernateCalendarMatchGet+0x95>
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    11c8 <HibernateCalendarMatchGet+0xb8>
mov    -0x10(%rbp),%rax
movl   $0xff,0x8(%rax)
jmp    11db <HibernateCalendarMatchGet+0xcb>
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    11fa <HibernateCalendarMatchGet+0xea>
mov    -0x10(%rbp),%rax
movl   $0xff,0xc(%rax)
jmp    120a <HibernateCalendarMatchGet+0xfa>
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    123b <HibernateCalendarMatchGet+0x12b>
mov    -0x18(%rbp),%eax
and    $0x400000,%eax
cmp    $0x0,%eax
je     123b <HibernateCalendarMatchGet+0x12b>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%ecx
add    $0xc,%ecx
mov    %ecx,0x8(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<HibernateCalendarMatchGet>:
push   %rbx
mov    %rsi,%rbx
mov    0x400fc300,%edi
and    $0x1,%edi
call   1030 <ASSERT@plt>
mov    0x400fc334,%edx
mov    0x400fc330,%eax
mov    %eax,%ecx
and    $0x3f00,%ecx
mov    %ecx,%esi
shr    $0x8,%esi
cmp    $0x3f00,%ecx
mov    $0xff,%r8d
cmove  %r8d,%esi
mov    %esi,(%rbx)
mov    %eax,%esi
and    $0x3f,%esi
cmp    $0x3f,%esi
cmove  %r8d,%esi
mov    %eax,%ecx
and    $0x1f0000,%ecx
mov    %ecx,%edi
shr    $0x10,%edi
cmp    $0x1f0000,%ecx
cmove  %r8d,%edi
mov    %esi,0x4(%rbx)
and    $0x1f,%edx
cmove  %r8d,%edx
mov    %edi,0x8(%rbx)
mov    %edx,0xc(%rbx)
testl  $0x4,0x400fc300
jne    119d <HibernateCalendarMatchGet+0x8d>
and    $0x400000,%eax
je     119d <HibernateCalendarMatchGet+0x8d>
add    $0xc,%edi
mov    %edi,0x8(%rbx)
pop    %rbx
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 1074774784 to i32*)
%8 = and i32 %7, 1
%9 = call i32 @ASSERT(i32 %8)
%10 = load volatile i32, i32* inttoptr (i64 1074774836 to i32*)
store i32 %10, i32* %5
%11 = load volatile i32, i32* inttoptr (i64 1074774832 to i32*)
store i32 %11, i32* %6
%12 = load i32, i32* %6
%13 = and i32 %12, 16128
%14 = icmp eq i32 %13, 16128
br i1 %14, label %15, label %18
15: ; preds = %2
%16 = load %struct.tm*, %struct.tm** %4
%17 = getelementptr inbounds %struct.tm, %struct.tm* %16, i32 0, i32 0
store i32 255, i32* %17
br label %24
18: ; preds = %2
%19 = load i32, i32* %6
%20 = and i32 %19, 16128
%21 = ashr i32 %20, 8
%22 = load %struct.tm*, %struct.tm** %4
%23 = getelementptr inbounds %struct.tm, %struct.tm* %22, i32 0, i32 0
store i32 %21, i32* %23
br label %24
24: ; preds = %18, %15
%25 = load i32, i32* %6
%26 = and i32 %25, 63
%27 = icmp eq i32 %26, 63
br i1 %27, label %28, label %31
28: ; preds = %24
%29 = load %struct.tm*, %struct.tm** %4
%30 = getelementptr inbounds %struct.tm, %struct.tm* %29, i32 0, i32 1
store i32 255, i32* %30
br label %37
31: ; preds = %24
%32 = load i32, i32* %6
%33 = and i32 %32, 63
%34 = ashr i32 %33, 0
%35 = load %struct.tm*, %struct.tm** %4
%36 = getelementptr inbounds %struct.tm, %struct.tm* %35, i32 0, i32 1
store i32 %34, i32* %36
br label %37
37: ; preds = %31, %28
%38 = load i32, i32* %6
%39 = and i32 %38, 2031616
%40 = icmp eq i32 %39, 2031616
br i1 %40, label %41, label %44
41: ; preds = %37
%42 = load %struct.tm*, %struct.tm** %4
%43 = getelementptr inbounds %struct.tm, %struct.tm* %42, i32 0, i32 2
store i32 255, i32* %43
br label %50
44: ; preds = %37
%45 = load i32, i32* %6
%46 = and i32 %45, 2031616
%47 = ashr i32 %46, 16
%48 = load %struct.tm*, %struct.tm** %4
%49 = getelementptr inbounds %struct.tm, %struct.tm* %48, i32 0, i32 2
store i32 %47, i32* %49
br label %50
50: ; preds = %44, %41
%51 = load i32, i32* %5
%52 = and i32 %51, 31
%53 = icmp eq i32 %52, 0
br i1 %53, label %54, label %57
54: ; preds = %50
%55 = load %struct.tm*, %struct.tm** %4
%56 = getelementptr inbounds %struct.tm, %struct.tm* %55, i32 0, i32 3
store i32 255, i32* %56
br label %63
57: ; preds = %50
%58 = load i32, i32* %5
%59 = and i32 %58, 31
%60 = ashr i32 %59, 0
%61 = load %struct.tm*, %struct.tm** %4
%62 = getelementptr inbounds %struct.tm, %struct.tm* %61, i32 0, i32 3
store i32 %60, i32* %62
br label %63
63: ; preds = %57, %54
%64 = load volatile i32, i32* inttoptr (i64 1074774784 to i32*)
%65 = and i32 %64, 4
%66 = icmp eq i32 %65, 0
br i1 %66, label %67, label %76
67: ; preds = %63
%68 = load i32, i32* %6
%69 = and i32 %68, 4194304
%70 = icmp ne i32 %69, 0
br i1 %70, label %71, label %76
71: ; preds = %67
%72 = load %struct.tm*, %struct.tm** %4
%73 = getelementptr inbounds %struct.tm, %struct.tm* %72, i32 0, i32 2
%74 = load i32, i32* %73
%75 = add nsw i32 %74, 12
store i32 %75, i32* %73
br label %76
76: ; preds = %71, %67, %63
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 1074774784 to i32*)
%4 = and i32 %3, 1
%5 = tail call i32 @ASSERT(i32 %4)
%6 = load volatile i32, i32* inttoptr (i64 1074774836 to i32*)
%7 = load volatile i32, i32* inttoptr (i64 1074774832 to i32*)
%8 = and i32 %7, 16128
%9 = icmp eq i32 %8, 16128
%10 = lshr exact i32 %8, 8
%11 = select i1 %9, i32 255, i32 %10
%12 = getelementptr inbounds %struct.tm, %struct.tm* %1, i64 0, i32 0
store i32 %11, i32* %12
%13 = and i32 %7, 63
%14 = icmp eq i32 %13, 63
%15 = select i1 %14, i32 255, i32 %13
%16 = getelementptr inbounds %struct.tm, %struct.tm* %1, i64 0, i32 1
store i32 %15, i32* %16
%17 = and i32 %7, 2031616
%18 = icmp eq i32 %17, 2031616
%19 = lshr exact i32 %17, 16
%20 = select i1 %18, i32 255, i32 %19
%21 = getelementptr inbounds %struct.tm, %struct.tm* %1, i64 0, i32 2
store i32 %20, i32* %21
%22 = and i32 %6, 31
%23 = icmp eq i32 %22, 0
%24 = select i1 %23, i32 255, i32 %22
%25 = getelementptr inbounds %struct.tm, %struct.tm* %1, i64 0, i32 3
store i32 %24, i32* %25
%26 = load volatile i32, i32* inttoptr (i64 1074774784 to i32*)
%27 = and i32 %26, 4
%28 = icmp ne i32 %27, 0
%29 = and i32 %7, 4194304
%30 = icmp eq i32 %29, 0
%31 = select i1 %28, i1 true, i1 %30
br i1 %31, label %34, label %32
32: ; preds = %2
%33 = add nuw nsw i32 %20, 12
store i32 %33, i32* %21
br label %34
34: ; preds = %32, %2
ret void
}