#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 scalar_t__ uint32_t;

/* Variables and functions */
void SHAMD5ResultRead(uint32_t ui32Base, uint32_t *pui32Dest) {
  uint32_t ui32Idx, ui32Count;
  ;
  switch ((*((volatile unsigned long *)(ui32Base + 0x00000044))) & 0x00000007) {
  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) {
    *pui32Dest++ =
        (*((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    $0x7,%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    11ba <SHAMD5ResultRead+0xba>
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x20(%rbp),%rax
jge    11ba <SHAMD5ResultRead+0xba>
mov    -0x8(%rbp),%rax
add    $0x20,%rax
add    -0x18(%rbp),%rax
mov    (%rax),%rcx
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x8,%rdx
mov    %rdx,-0x10(%rbp)
mov    %rcx,(%rax)
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    $0x7,%eax
cmp    $0x7,%rax
je     1142 <SHAMD5ResultRead+0x42>
mov    $0x55,%ecx
bt     %eax,%ecx
jae    1142 <SHAMD5ResultRead+0x42>
lea    0xee2(%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,2)
add    $0x4,%rcx
cmp    %rax,%rcx
jb     1130 <SHAMD5ResultRead+0x30>
ret

LLVM IR (-O0):
define void @SHAMD5ResultRead(i64 %0, i64* %1) {
%3 = alloca i64
%4 = alloca i64*
%5 = alloca i64
%6 = alloca i64
store i64 %0, i64* %3
store i64* %1, i64** %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, 7
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 %34
17: ; preds = %15, %14, %13, %12
store i64 0, i64* %5
br label %18
18: ; preds = %31, %17
%19 = load i64, i64* %5
%20 = load i64, i64* %6
%21 = icmp slt i64 %19, %20
br i1 %21, label %22, label %34
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 i64*, i64** %4
%30 = getelementptr inbounds i64, i64* %29, i32 1
store i64* %30, i64** %4
store i64 %28, i64* %29
br label %31
31: ; preds = %22
%32 = load i64, i64* %5
%33 = add nsw i64 %32, 4
store i64 %33, i64* %5
br label %18
34: ; 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, i64* 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, 7
%7 = icmp eq i64 %6, 7
br i1 %7, label %26, label %8
8: ; preds = %2
%9 = trunc i64 %6 to i8
%10 = lshr i8 85, %9
%11 = and i8 %10, 1
%12 = icmp eq i8 %11, 0
br i1 %12, label %26, label %13
13: ; preds = %8
%14 = getelementptr inbounds [7 x i64], [7 x i64]* @switch.table.SHAMD5ResultRead, i64 0, i64 %6
%15 = load i64, i64* %14
%16 = add nsw i64 %0, 32
br label %17
17: ; preds = %13, %17
%18 = phi i64 [ 0, %13 ], [ %24, %17 ]
%19 = phi i64* [ %1, %13 ], [ %23, %17 ]
%20 = add nsw i64 %16, %18
%21 = inttoptr i64 %20 to i64*
%22 = load volatile i64, i64* %21
%23 = getelementptr inbounds i64, i64* %19, i64 1
store i64 %22, i64* %19
%24 = add nuw nsw i64 %18, 4
%25 = icmp ult i64 %24, %15
br i1 %25, label %17, label %26
26: ; preds = %17, %8, %2
ret void
}