#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 */
char getchar();
int /*<<< orphan*/ puts(char *);
int scanf(char *, char *);
char chose(void) {
  char c;
  puts("Input your chose:");
  while (1) {
    if (1 != scanf("%c", &c)) {
      puts("Please input u, d, l or r");
      while (getchar() != '\n')
        continue;
      continue;
    }
    switch (c) {
    case 'u':
    case 'd':
    case 'l':
    case 'r':
      while (getchar() != '\n')
        continue;
      return c;
    default:
      puts("Please input u, d, l or r");
      while (getchar() != '\n')
        continue;
    }
  }
}


x86 assembly (clang, -O0):
<chose>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
call   1030 <puts@plt>
lea    0xec7(%rip),%rdi
lea    -0x1(%rbp),%rsi
call   1050 <scanf@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    %ecx,%eax
je     118c <chose+0x5c>
lea    0xeab(%rip),%rdi
call   1030 <puts@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
movsbl %al,%eax
cmp    $0xa,%eax
je     1187 <chose+0x57>
jmp    116f <chose+0x3f>
jmp    1144 <chose+0x14>
movsbl -0x1(%rbp),%eax
mov    %eax,-0x8(%rbp)
sub    $0x64,%eax
je     11d4 <chose+0xa4>
jmp    11a1 <chose+0x71>
mov    -0x8(%rbp),%eax
sub    $0x6c,%eax
je     11d4 <chose+0xa4>
jmp    11b2 <chose+0x82>
mov    -0x8(%rbp),%eax
sub    $0x72,%eax
je     11d4 <chose+0xa4>
jmp    11c3 <chose+0x93>
mov    -0x8(%rbp),%eax
sub    $0x75,%eax
jne    11fb <chose+0xcb>
jmp    11d4 <chose+0xa4>
jmp    11d9 <chose+0xa9>
mov    $0x0,%al
call   1040 <getchar@plt>
movsbl %al,%eax
cmp    $0xa,%eax
je     11f1 <chose+0xc1>
jmp    11d9 <chose+0xa9>
movsbl -0x1(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret
lea    0xe13(%rip),%rdi
call   1030 <puts@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
movsbl %al,%eax
cmp    $0xa,%eax
je     121f <chose+0xef>
jmp    1207 <chose+0xd7>
jmp    1224 <chose+0xf4>
jmp    1144 <chose+0x14>

x86 assembly (clang, -O2):
<chose>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xec2(%rip),%rdi
call   1030 <puts@plt>
lea    0xec8(%rip),%r14
lea    0x7(%rsp),%rbx
lea    0xebf(%rip),%r15
mov    $0x24101,%ebp
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
cmp    $0x1,%eax
jne    11a0 <chose+0x70>
movsbl 0x7(%rsp),%eax
add    $0xffffff9c,%eax
cmp    $0x11,%eax
ja     1182 <chose+0x52>
bt     %eax,%ebp
jb     11c0 <chose+0x90>
mov    %r15,%rdi
call   1030 <puts@plt>
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0xa,%al
jne    1190 <chose+0x60>
jmp    1160 <chose+0x30>
nopl   (%rax)
mov    %r15,%rdi
call   1030 <puts@plt>
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0xa,%al
jne    11b0 <chose+0x80>
jmp    1160 <chose+0x30>
nopl   (%rax)
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0xa,%al
jne    11c0 <chose+0x90>
mov    0x7(%rsp),%al
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [18 x i8] c"Input your chose:\00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [26 x i8] c"Please input u, d, l or r\00"
define signext i8 @chose() {
%1 = alloca i8
%2 = call i32 @puts(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
br label %3
3: ; preds = %0, %13, %33
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%5 = icmp ne i32 1, %4
br i1 %5, label %6, label %14
6: ; preds = %3
%7 = call i32 @puts(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
br label %8
8: ; preds = %12, %6
%9 = call signext i8 (...) @getchar()
%10 = sext i8 %9 to i32
%11 = icmp ne i32 %10, 10
br i1 %11, label %12, label %13
12: ; preds = %8
br label %8
13: ; preds = %8
br label %3
14: ; preds = %3
%15 = load i8, i8* %1
%16 = sext i8 %15 to i32
switch i32 %16, label %25 [
i32 117, label %17
i32 100, label %17
i32 108, label %17
i32 114, label %17
]
17: ; preds = %14, %14, %14, %14
br label %18
18: ; preds = %22, %17
%19 = call signext i8 (...) @getchar()
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %20, 10
br i1 %21, label %22, label %23
22: ; preds = %18
br label %18
23: ; preds = %18
%24 = load i8, i8* %1
ret i8 %24
25: ; preds = %14
%26 = call i32 @puts(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
br label %27
27: ; preds = %31, %25
%28 = call signext i8 (...) @getchar()
%29 = sext i8 %28 to i32
%30 = icmp ne i32 %29, 10
br i1 %30, label %31, label %32
31: ; preds = %27
br label %27
32: ; preds = %27
br label %33
33: ; preds = %32
br label %3
}

LLVM IR (-O2):
@.str = [18 x i8] c"Input your chose:\00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [26 x i8] c"Please input u, d, l or r\00"
define signext i8 @chose() {
%1 = alloca i8
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
br label %4
3: ; preds = %9, %23
br label %4
4: ; preds = %3, %0
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%6 = icmp eq i32 %5, 1
br i1 %6, label %12, label %7
7: ; preds = %4
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
br label %9
9: ; preds = %9, %7
%10 = call signext i8 (...) @getchar()
%11 = icmp eq i8 %10, 10
br i1 %11, label %3, label %9
12: ; preds = %4
%13 = load i8, i8* %1
%14 = sext i8 %13 to i32
switch i32 %14, label %21 [
i32 117, label %15
i32 100, label %15
i32 108, label %15
i32 114, label %15
]
15: ; preds = %12, %12, %12, %12
br label %16
16: ; preds = %15, %16
%17 = call signext i8 (...) @getchar()
%18 = icmp eq i8 %17, 10
br i1 %18, label %19, label %16
19: ; preds = %16
%20 = load i8, i8* %1
ret i8 %20
21: ; preds = %12
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
br label %23
23: ; preds = %23, %21
%24 = call signext i8 (...) @getchar()
%25 = icmp eq i8 %24, 10
br i1 %25, label %3, label %23
}