#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 /*<<< orphan*/ uint8_t;
typedef scalar_t__ uint32_t;

/* Variables and functions */
void SHAMD5ResultRead(uint32_t ui32Base, uint8_t *pui8Dest) {
  uint32_t ui32Idx, ui32Count;
  ;
  switch ((*((volatile unsigned long *)(ui32Base + 0x00000044))) & 0x00000006) {
  case 0x00000000: {
    ui32Count = 16;
    break;
  }
  case 0x00000002: {
    ui32Count = 20;
    break;
  }
  case 0x00000004: {
    ui32Count = 28;
    break;
  }
  case 0x00000006: {
    ui32Count = 32;
    break;
  }
  default: {
    return;
  }
  }
  for (ui32Idx = 0; ui32Idx < ui32Count; ui32Idx += 4) {
    *((uint32_t *)(pui8Dest + ui32Idx)) =
        (*((volatile unsigned long *)(ui32Base + 0x00000020 + ui32Idx)));
  }
}


x86 assembly (clang, -O0):
<SHAMD5ResultRead>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    0x44(%rax),%rax
and    $0x6,%eax
mov    %rax,-0x28(%rbp)
sub    $0x6,%rax
ja     116d <SHAMD5ResultRead+0x6d>
mov    -0x28(%rbp),%rax
lea    0xed0(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movq   $0x10,-0x20(%rbp)
jmp    1172 <SHAMD5ResultRead+0x72>
movq   $0x14,-0x20(%rbp)
jmp    1172 <SHAMD5ResultRead+0x72>
movq   $0x1c,-0x20(%rbp)
jmp    1172 <SHAMD5ResultRead+0x72>
movq   $0x20,-0x20(%rbp)
jmp    1172 <SHAMD5ResultRead+0x72>
jmp    11b4 <SHAMD5ResultRead+0xb4>
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x20(%rbp),%rax
jge    11b4 <SHAMD5ResultRead+0xb4>
mov    -0x8(%rbp),%rax
add    $0x20,%rax
add    -0x18(%rbp),%rax
mov    (%rax),%rdx
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    %rdx,(%rax,%rcx,4)
mov    -0x18(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x18(%rbp)
jmp    117a <SHAMD5ResultRead+0x7a>
pop    %rbp
ret

x86 assembly (clang, -O2):
<SHAMD5ResultRead>:
mov    0x44(%rdi),%rax
and    $0x6,%eax
lea    0xef2(%rip),%rcx
mov    (%rcx,%rax,8),%rax
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x20(%rcx,%rdi,1),%rdx
mov    %rdx,(%rsi,%rcx,4)
add    $0x4,%rcx
cmp    %rax,%rcx
jb     1120 <SHAMD5ResultRead+0x20>
ret

LLVM IR (-O0):
define void @SHAMD5ResultRead(i64 %0, i32* %1) {
%3 = alloca i64
%4 = alloca i32*
%5 = alloca i64
%6 = alloca i64
store i64 %0, i64* %3
store i32* %1, i32** %4
%7 = load i64, i64* %3
%8 = add nsw i64 %7, 68
%9 = inttoptr i64 %8 to i64*
%10 = load volatile i64, i64* %9
%11 = and i64 %10, 6
switch i64 %11, label %16 [
i64 0, label %12
i64 2, label %13
i64 4, label %14
i64 6, label %15
]
12: ; preds = %2
store i64 16, i64* %6
br label %17
13: ; preds = %2
store i64 20, i64* %6
br label %17
14: ; preds = %2
store i64 28, i64* %6
br label %17
15: ; preds = %2
store i64 32, i64* %6
br label %17
16: ; preds = %2
br label %36
17: ; preds = %15, %14, %13, %12
store i64 0, i64* %5
br label %18
18: ; preds = %33, %17
%19 = load i64, i64* %5
%20 = load i64, i64* %6
%21 = icmp slt i64 %19, %20
br i1 %21, label %22, label %36
22: ; preds = %18
%23 = load i64, i64* %3
%24 = add nsw i64 %23, 32
%25 = load i64, i64* %5
%26 = add nsw i64 %24, %25
%27 = inttoptr i64 %26 to i64*
%28 = load volatile i64, i64* %27
%29 = load i32*, i32** %4
%30 = load i64, i64* %5
%31 = getelementptr inbounds i32, i32* %29, i64 %30
%32 = bitcast i32* %31 to i64*
store i64 %28, i64* %32
br label %33
33: ; preds = %22
%34 = load i64, i64* %5
%35 = add nsw i64 %34, 4
store i64 %35, i64* %5
br label %18
36: ; preds = %16, %18
ret void
}

LLVM IR (-O2):
@switch.table.SHAMD5ResultRead = [7 x i64] [i64 16, i64 16, i64 20, i64 16, i64 28, i64 16, i64 32]
define void @SHAMD5ResultRead(i64 %0, i32* nocapture writeonly %1) {
%3 = add nsw i64 %0, 68
%4 = inttoptr i64 %3 to i64*
%5 = load volatile i64, i64* %4
%6 = and i64 %5, 6
%7 = getelementptr inbounds [7 x i64], [7 x i64]* @switch.table.SHAMD5ResultRead, i64 0, i64 %6
%8 = load i64, i64* %7
%9 = add nsw i64 %0, 32
br label %10
10: ; preds = %2, %10
%11 = phi i64 [ 0, %2 ], [ %17, %10 ]
%12 = add nsw i64 %9, %11
%13 = inttoptr i64 %12 to i64*
%14 = load volatile i64, i64* %13
%15 = getelementptr inbounds i32, i32* %1, i64 %11
%16 = bitcast i32* %15 to i64*
store i64 %14, i64* %16
%17 = add nuw nsw i64 %11, 4
%18 = icmp ult i64 %17, %8
br i1 %18, label %10, label %19
19: ; preds = %10
ret void
}