#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 SetStillPreview(unsigned char mode) {
  unsigned char UcStRd = 1;
  switch (mode) {
  case 0:
    RamWrite32A(0xF013, 0x00000001);
    break;
  case 1:
    RamWrite32A(0xF013, 0x00000003);
    break;
  case 2:
    RamWrite32A(0xF013, 0x00000005);
    break;
  case 3:
    RamWrite32A(0xF013, 0x00000007);
    break;
  }
  while (UcStRd) {
    UcStRd = RdStatus(1);
  }
}


x86 assembly (clang, -O0):
<SetStillPreview>:
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     11a3 <SetStillPreview+0x83>
mov    -0x10(%rbp),%rax
lea    0xeb1(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0xf013,%edi
mov    $0x1,%esi
call   1030 <RamWrite32A@plt>
jmp    11a3 <SetStillPreview+0x83>
mov    $0xf013,%edi
mov    $0x3,%esi
call   1030 <RamWrite32A@plt>
jmp    11a3 <SetStillPreview+0x83>
mov    $0xf013,%edi
mov    $0x5,%esi
call   1030 <RamWrite32A@plt>
jmp    11a3 <SetStillPreview+0x83>
mov    $0xf013,%edi
mov    $0x7,%esi
call   1030 <RamWrite32A@plt>
jmp    11a8 <SetStillPreview+0x88>
cmpb   $0x0,-0x2(%rbp)
je     11c4 <SetStillPreview+0xa4>
mov    $0x1,%edi
call   1040 <RdStatus@plt>
mov    %al,-0x2(%rbp)
jmp    11a8 <SetStillPreview+0x88>
add    $0x10,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
define void @SetStillPreview(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 1)
br label %14
8: ; preds = %1
%9 = call i32 @RamWrite32A(i32 61459, i32 3)
br label %14
10: ; preds = %1
%11 = call i32 @RamWrite32A(i32 61459, i32 5)
br label %14
12: ; preds = %1
%13 = call i32 @RamWrite32A(i32 61459, i32 7)
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 @SetStillPreview(i8 zeroext %0) {
%2 = icmp ult i8 %0, 4
br i1 %2, label %3, label %8
3: ; preds = %1
%4 = zext i8 %0 to i32
%5 = shl nuw nsw i32 %4, 1
%6 = or i32 %5, 1
%7 = tail call i32 @RamWrite32A(i32 61459, i32 %6)
br label %8
8: ; preds = %1, %3
br label %9
9: ; preds = %8, %9
%10 = tail call zeroext i8 @RdStatus(i32 1)
%11 = icmp eq i8 %10, 0
br i1 %11, label %12, label %9
12: ; preds = %9
ret void
}