#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);
unsigned char RtnCen(unsigned char UcCmdPar) {
  unsigned char UcSndDat = 1;
  if (!UcCmdPar) {
    RamWrite32A(0xF010, 0x00000003);
  } else if (UcCmdPar == 0x01) {
    RamWrite32A(0xF010, 0x00000001);
  } else if (UcCmdPar == 0x02) {
    RamWrite32A(0xF010, 0x00000002);
  } else {
    RamWrite32A(0xF010, 0x00000000);
  }
  while (UcSndDat) {
    UcSndDat = RdStatus(1);
  }
  return (UcSndDat);
}


x86 assembly (clang, -O0):
<RtnCen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movb   $0x1,-0x2(%rbp)
cmpb   $0x0,-0x1(%rbp)
jne    1150 <RtnCen+0x30>
mov    $0xf010,%edi
mov    $0x3,%esi
call   1030 <RamWrite32A@plt>
jmp    11a8 <RtnCen+0x88>
movzbl -0x1(%rbp),%eax
cmp    $0x1,%eax
jne    1171 <RtnCen+0x51>
mov    $0xf010,%edi
mov    $0x1,%esi
call   1030 <RamWrite32A@plt>
jmp    11a3 <RtnCen+0x83>
movzbl -0x1(%rbp),%eax
cmp    $0x2,%eax
jne    1192 <RtnCen+0x72>
mov    $0xf010,%edi
mov    $0x2,%esi
call   1030 <RamWrite32A@plt>
jmp    119e <RtnCen+0x7e>
mov    $0xf010,%edi
xor    %esi,%esi
call   1030 <RamWrite32A@plt>
jmp    11a3 <RtnCen+0x83>
jmp    11a8 <RtnCen+0x88>
jmp    11ad <RtnCen+0x8d>
cmpb   $0x0,-0x2(%rbp)
je     11c9 <RtnCen+0xa9>
mov    $0x1,%edi
call   1040 <RdStatus@plt>
mov    %al,-0x2(%rbp)
jmp    11ad <RtnCen+0x8d>
movzbl -0x2(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<RtnCen>:
push   %rax
xor    %esi,%esi
cmp    $0x2,%dil
ja     1137 <RtnCen+0x17>
movsbq %dil,%rax
lea    0xecc(%rip),%rcx
mov    (%rcx,%rax,4),%esi
mov    $0xf010,%edi
call   1030 <RamWrite32A@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0x1,%edi
call   1040 <RdStatus@plt>
test   %al,%al
jne    1150 <RtnCen+0x30>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
define zeroext i8 @RtnCen(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 = icmp ne i8 %4, 0
br i1 %5, label %8, label %6
6: ; preds = %1
%7 = call i32 @RamWrite32A(i32 61456, i32 3)
br label %24
8: ; preds = %1
%9 = load i8, i8* %2
%10 = zext i8 %9 to i32
%11 = icmp eq i32 %10, 1
br i1 %11, label %12, label %14
12: ; preds = %8
%13 = call i32 @RamWrite32A(i32 61456, i32 1)
br label %23
14: ; preds = %8
%15 = load i8, i8* %2
%16 = zext i8 %15 to i32
%17 = icmp eq i32 %16, 2
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = call i32 @RamWrite32A(i32 61456, i32 2)
br label %22
20: ; preds = %14
%21 = call i32 @RamWrite32A(i32 61456, i32 0)
br label %22
22: ; preds = %20, %18
br label %23
23: ; preds = %22, %12
br label %24
24: ; preds = %23, %6
br label %25
25: ; preds = %28, %24
%26 = load i8, i8* %3
%27 = icmp ne i8 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %25
%29 = call zeroext i8 @RdStatus(i32 1)
store i8 %29, i8* %3
br label %25
30: ; preds = %25
%31 = load i8, i8* %3
ret i8 %31
}

LLVM IR (-O2):
@switch.table.RtnCen = [3 x i32] [i32 3, i32 1, i32 2]
define zeroext i8 @RtnCen(i8 zeroext %0) {
%2 = icmp ult i8 %0, 3
br i1 %2, label %3, label %7
3: ; preds = %1
%4 = sext i8 %0 to i64
%5 = getelementptr inbounds [3 x i32], [3 x i32]* @switch.table.RtnCen, i64 0, i64 %4
%6 = load i32, i32* %5
br label %7
7: ; preds = %1, %3
%8 = phi i32 [ %6, %3 ], [ 0, %1 ]
%9 = tail call i32 @RamWrite32A(i32 61456, i32 %8)
br label %10
10: ; preds = %7, %10
%11 = tail call zeroext i8 @RdStatus(i32 1)
%12 = icmp eq i8 %11, 0
br i1 %12, label %13, label %10
13: ; preds = %10
ret i8 0
}