#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 */

/* Variables and functions */
int /*<<< orphan*/ RamWrite32A(int, int);
unsigned char RdStatus(int);
void SetRecPreview(unsigned char mode) {
  unsigned char UcStRd = 1;
  switch (mode) {
  case 0:
    RamWrite32A(0xF013, 0x00000000);
    break;
  case 1:
    RamWrite32A(0xF013, 0x00000002);
    break;
  case 2:
    RamWrite32A(0xF013, 0x00000004);
    break;
  case 3:
    RamWrite32A(0xF013, 0x00000006);
    break;
  }
  while (UcStRd) {
    UcStRd = RdStatus(1);
  }
}


x86 assembly (clang, -O0):
<SetRecPreview>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movb   $0x1,-0x2(%rbp)
movzbl -0x1(%rbp),%eax
mov    %rax,-0x10(%rbp)
sub    $0x3,%rax
ja     11a0 <SetRecPreview+0x80>
mov    -0x10(%rbp),%rax
lea    0xeb1(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0xf013,%edi
xor    %esi,%esi
call   1030 <RamWrite32A@plt>
jmp    11a0 <SetRecPreview+0x80>
mov    $0xf013,%edi
mov    $0x2,%esi
call   1030 <RamWrite32A@plt>
jmp    11a0 <SetRecPreview+0x80>
mov    $0xf013,%edi
mov    $0x4,%esi
call   1030 <RamWrite32A@plt>
jmp    11a0 <SetRecPreview+0x80>
mov    $0xf013,%edi
mov    $0x6,%esi
call   1030 <RamWrite32A@plt>
jmp    11a5 <SetRecPreview+0x85>
cmpb   $0x0,-0x2(%rbp)
je     11c1 <SetRecPreview+0xa1>
mov    $0x1,%edi
call   1040 <RdStatus@plt>
mov    %al,-0x2(%rbp)
jmp    11a5 <SetRecPreview+0x85>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SetRecPreview>:
push   %rax
cmp    $0x3,%dil
ja     1140 <SetRecPreview+0x20>
movzbl %dil,%esi
add    %esi,%esi
mov    $0xf013,%edi
call   1030 <RamWrite32A@plt>
nopw   0x0(%rax,%rax,1)
mov    $0x1,%edi
call   1040 <RdStatus@plt>
test   %al,%al
jne    1140 <SetRecPreview+0x20>
pop    %rax
ret

LLVM IR (-O0):
define void @SetRecPreview(i8 zeroext %0) {
%2 = alloca i8
%3 = alloca i8
store i8 %0, i8* %2
store i8 1, i8* %3
%4 = load i8, i8* %2
%5 = zext i8 %4 to i32
switch i32 %5, label %14 [
i32 0, label %6
i32 1, label %8
i32 2, label %10
i32 3, label %12
]
6: ; preds = %1
%7 = call i32 @RamWrite32A(i32 61459, i32 0)
br label %14
8: ; preds = %1
%9 = call i32 @RamWrite32A(i32 61459, i32 2)
br label %14
10: ; preds = %1
%11 = call i32 @RamWrite32A(i32 61459, i32 4)
br label %14
12: ; preds = %1
%13 = call i32 @RamWrite32A(i32 61459, i32 6)
br label %14
14: ; preds = %1, %12, %10, %8, %6
br label %15
15: ; preds = %18, %14
%16 = load i8, i8* %3
%17 = icmp ne i8 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = call zeroext i8 @RdStatus(i32 1)
store i8 %19, i8* %3
br label %15
20: ; preds = %15
ret void
}

LLVM IR (-O2):
define void @SetRecPreview(i8 zeroext %0) {
%2 = icmp ult i8 %0, 4
br i1 %2, label %3, label %7
3: ; preds = %1
%4 = zext i8 %0 to i32
%5 = shl nuw nsw i32 %4, 1
%6 = tail call i32 @RamWrite32A(i32 61459, i32 %5)
br label %7
7: ; preds = %1, %3
br label %8
8: ; preds = %7, %8
%9 = tail call zeroext i8 @RdStatus(i32 1)
%10 = icmp eq i8 %9, 0
br i1 %10, label %11, label %8
11: ; preds = %8
ret void
}