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

/* Variables and functions */
int /*<<< orphan*/ print_arg1_reg(int /*<<< orphan*/ *);
int /*<<< orphan*/ print_cmdtm_reg(int /*<<< orphan*/ *);
int /*<<< orphan*/ print_control0_reg(int /*<<< orphan*/ *);
int /*<<< orphan*/ print_control1_reg(int /*<<< orphan*/ *);
int /*<<< orphan*/ print_control2_reg(int /*<<< orphan*/ *);
int /*<<< orphan*/ print_interrupt_reg(int /*<<< orphan*/ *);
int /*<<< orphan*/ print_response_reg(int /*<<< orphan*/ *);
int /*<<< orphan*/ print_status_reg(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, char *);
char toupper(char);
void view_register(uint32_t *emmc) {
  char in;
  while (toupper(in) != 'Q') {
    printf("(C)MDTM | (A)RG1 | (R)esponse | (S)tatus | (I)nterrupt | "
           "Control(0-2) | (Q)uit\n");
    scanf(" %c", &in);
    printf("\n");
    switch (toupper(in)) {
    case 'C':
      print_cmdtm_reg(emmc);
      continue;
    case 'A':
      print_arg1_reg(emmc);
      continue;
    case 'R':
      print_response_reg(emmc);
      continue;
    case 'S':
      print_status_reg(emmc);
      continue;
    case 'I':
      print_interrupt_reg(emmc);
      continue;
    case '0':
      print_control0_reg(emmc);
      continue;
    case '1':
      print_control1_reg(emmc);
      continue;
    case '2':
      print_control2_reg(emmc);
      continue;
    case 'Q':
      break;
    default:
      continue;
    }
  }
}


x86 assembly (clang, -O0):
<view_register>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movsbl -0x9(%rbp),%edi
call   1050 <toupper@plt>
movsbl %al,%eax
cmp    $0x51,%eax
je     12aa <view_register+0xfa>
lea    0xeb8(%rip),%rdi
call   1070 <printf@plt>
lea    0xefc(%rip),%rdi
lea    -0x9(%rbp),%rsi
call   10b0 <scanf@plt>
lea    0xeea(%rip),%rdi
call   1070 <printf@plt>
movsbl -0x9(%rbp),%edi
call   1050 <toupper@plt>
movsbl %al,%eax
add    $0xffffffd0,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x23,%eax
ja     12a0 <view_register+0xf0>
mov    -0x18(%rbp),%rax
lea    0xdde(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x8(%rbp),%rdi
call   1090 <print_cmdtm_reg@plt>
jmp    11bc <view_register+0xc>
mov    -0x8(%rbp),%rdi
call   10a0 <print_arg1_reg@plt>
jmp    11bc <view_register+0xc>
mov    -0x8(%rbp),%rdi
call   10c0 <print_response_reg@plt>
jmp    11bc <view_register+0xc>
mov    -0x8(%rbp),%rdi
call   1060 <print_status_reg@plt>
jmp    11bc <view_register+0xc>
mov    -0x8(%rbp),%rdi
call   1080 <print_interrupt_reg@plt>
jmp    11bc <view_register+0xc>
mov    -0x8(%rbp),%rdi
call   10d0 <print_control0_reg@plt>
jmp    11bc <view_register+0xc>
mov    -0x8(%rbp),%rdi
call   1030 <print_control1_reg@plt>
jmp    11bc <view_register+0xc>
mov    -0x8(%rbp),%rdi
call   1040 <print_control2_reg@plt>
jmp    11bc <view_register+0xc>
jmp    12a5 <view_register+0xf5>
jmp    11bc <view_register+0xc>
jmp    11bc <view_register+0xc>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<view_register>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%r13
xor    %edi,%edi
call   1060 <toupper@plt>
cmp    $0x51,%al
jne    11e9 <view_register+0x29>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
lea    0xea4(%rip),%r14
lea    0xe99(%rip),%r15
lea    0xf(%rsp),%r12
lea    0xdfd(%rip),%rbx
jmp    121e <view_register+0x5e>
mov    %r13,%rdi
call   10a0 <print_cmdtm_reg@plt>
nopl   (%rax)
movsbl 0xf(%rsp),%edi
call   1060 <toupper@plt>
cmp    $0x51,%al
je     11db <view_register+0x1b>
mov    %r14,%rdi
call   1070 <puts@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   10c0 <scanf@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
movsbl 0xf(%rsp),%edi
call   1060 <toupper@plt>
movsbl %al,%eax
add    $0xffffffd0,%eax
cmp    $0x23,%eax
ja     1210 <view_register+0x50>
movslq (%rbx,%rax,4),%rax
add    %rbx,%rax
jmp    *%rax
mov    %r13,%rdi
call   10e0 <print_control0_reg@plt>
jmp    1210 <view_register+0x50>
mov    %r13,%rdi
call   1030 <print_control1_reg@plt>
jmp    1210 <view_register+0x50>
mov    %r13,%rdi
call   1050 <print_control2_reg@plt>
jmp    1210 <view_register+0x50>
mov    %r13,%rdi
call   10b0 <print_arg1_reg@plt>
jmp    1210 <view_register+0x50>
mov    %r13,%rdi
call   1090 <print_interrupt_reg@plt>
jmp    1210 <view_register+0x50>
mov    %r13,%rdi
call   10d0 <print_response_reg@plt>
jmp    1210 <view_register+0x50>
mov    %r13,%rdi
call   1080 <print_status_reg@plt>
jmp    1210 <view_register+0x50>

LLVM IR (-O0):
@.str = [80 x i8] c"(C)MDTM | (A)RG1 | (R)esponse | (S)tatus | (I)nterrupt | Control(0-2) | (Q)uit\0A\00"
@.str.1 = [4 x i8] c" %c\00"
@.str.2 = [2 x i8] c"\0A\00"
define void @view_register(i32* %0) {
%2 = alloca i32*
%3 = alloca i8
store i32* %0, i32** %2
br label %4
4: ; preds = %42, %41, %37, %34, %31, %28, %25, %22, %19, %16, %1
%5 = load i8, i8* %3
%6 = call signext i8 @toupper(i8 signext %5)
%7 = sext i8 %6 to i32
%8 = icmp ne i32 %7, 81
br i1 %8, label %9, label %43
9: ; preds = %4
%10 = call i32 @printf(i8* getelementptr inbounds ([80 x i8], [80 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%12 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%13 = load i8, i8* %3
%14 = call signext i8 @toupper(i8 signext %13)
%15 = sext i8 %14 to i32
switch i32 %15, label %41 [
i32 67, label %16
i32 65, label %19
i32 82, label %22
i32 83, label %25
i32 73, label %28
i32 48, label %31
i32 49, label %34
i32 50, label %37
i32 81, label %40
]
16: ; preds = %9
%17 = load i32*, i32** %2
%18 = call i32 @print_cmdtm_reg(i32* %17)
br label %4
19: ; preds = %9
%20 = load i32*, i32** %2
%21 = call i32 @print_arg1_reg(i32* %20)
br label %4
22: ; preds = %9
%23 = load i32*, i32** %2
%24 = call i32 @print_response_reg(i32* %23)
br label %4
25: ; preds = %9
%26 = load i32*, i32** %2
%27 = call i32 @print_status_reg(i32* %26)
br label %4
28: ; preds = %9
%29 = load i32*, i32** %2
%30 = call i32 @print_interrupt_reg(i32* %29)
br label %4
31: ; preds = %9
%32 = load i32*, i32** %2
%33 = call i32 @print_control0_reg(i32* %32)
br label %4
34: ; preds = %9
%35 = load i32*, i32** %2
%36 = call i32 @print_control1_reg(i32* %35)
br label %4
37: ; preds = %9
%38 = load i32*, i32** %2
%39 = call i32 @print_control2_reg(i32* %38)
br label %4
40: ; preds = %9
br label %42
41: ; preds = %9
br label %4
42: ; preds = %40
br label %4
43: ; preds = %4
ret void
}

LLVM IR (-O2):
@.str.1 = [4 x i8] c" %c\00"
@str = [79 x i8] c"(C)MDTM | (A)RG1 | (R)esponse | (S)tatus | (I)nterrupt | Control(0-2) | (Q)uit\00"
define void @view_register(i32* %0) {
%2 = alloca i8
%3 = call signext i8 @toupper(i8 signext undef)
%4 = icmp eq i8 %3, 81
br i1 %4, label %32, label %5
5: ; preds = %1, %14
%6 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([79 x i8], [79 x i8]* @str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%8 = call i32 @putchar(i32 10)
%9 = load i8, i8* %2
%10 = call signext i8 @toupper(i8 signext %9)
%11 = sext i8 %10 to i32
switch i32 %11, label %14 [
i32 67, label %12
i32 65, label %18
i32 82, label %20
i32 83, label %22
i32 73, label %24
i32 48, label %26
i32 49, label %28
i32 50, label %30
]
12: ; preds = %5
%13 = call i32 @print_cmdtm_reg(i32* %0)
br label %14
14: ; preds = %12, %18, %20, %22, %24, %26, %28, %30, %5
%15 = load i8, i8* %2
%16 = call signext i8 @toupper(i8 signext %15)
%17 = icmp eq i8 %16, 81
br i1 %17, label %32, label %5
18: ; preds = %5
%19 = call i32 @print_arg1_reg(i32* %0)
br label %14
20: ; preds = %5
%21 = call i32 @print_response_reg(i32* %0)
br label %14
22: ; preds = %5
%23 = call i32 @print_status_reg(i32* %0)
br label %14
24: ; preds = %5
%25 = call i32 @print_interrupt_reg(i32* %0)
br label %14
26: ; preds = %5
%27 = call i32 @print_control0_reg(i32* %0)
br label %14
28: ; preds = %5
%29 = call i32 @print_control1_reg(i32* %0)
br label %14
30: ; preds = %5
%31 = call i32 @print_control2_reg(i32* %0)
br label %14
32: ; preds = %14, %1
ret void
}