#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*/ flush();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, char *);
int toupper(char);
int select_char_coord() {
  int x;
  char x_c;
  do {
    printf("Select x: ");
    scanf("%c", &x_c);
    flush();
    x = toupper(x_c) - 65;
  } while (x < 0 || x > 10);
  return x;
}


x86 assembly (clang, -O0):
<select_char_coord>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xeb1(%rip),%rdi
call   1050 <printf@plt>
lea    0xeb0(%rip),%rdi
lea    -0x5(%rbp),%rsi
call   1060 <scanf@plt>
mov    $0x0,%al
call   1030 <flush@plt>
movsbl -0x5(%rbp),%edi
call   1040 <toupper@plt>
sub    $0x41,%eax
mov    %eax,-0x4(%rbp)
mov    $0x1,%al
cmpl   $0x0,-0x4(%rbp)
mov    %al,-0x6(%rbp)
jl     1193 <select_char_coord+0x53>
cmpl   $0xa,-0x4(%rbp)
setg   %al
mov    %al,-0x6(%rbp)
mov    -0x6(%rbp),%al
test   $0x1,%al
jne    1148 <select_char_coord+0x8>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<select_char_coord>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xeb0(%rip),%r14
lea    0xeb4(%rip),%r15
lea    0xf(%rsp),%rbx
nopl   0x0(%rax)
mov    %r14,%rdi
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
xor    %eax,%eax
call   1030 <flush@plt>
movsbl 0xf(%rsp),%edi
call   1040 <toupper@plt>
lea    -0x4c(%rax),%ecx
cmp    $0xfffffff5,%ecx
jb     1160 <select_char_coord+0x20>
add    $0xffffffbf,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [11 x i8] c"Select x: \00"
@.str.1 = [3 x i8] c"%c\00"
define i32 @select_char_coord() {
%1 = alloca i32
%2 = alloca i8
br label %3
3: ; preds = %16, %0
%4 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%6 = call i32 (...) @flush()
%7 = load i8, i8* %2
%8 = call i32 @toupper(i8 signext %7)
%9 = sub nsw i32 %8, 65
store i32 %9, i32* %1
br label %10
10: ; preds = %3
%11 = load i32, i32* %1
%12 = icmp slt i32 %11, 0
br i1 %12, label %16, label %13
13: ; preds = %10
%14 = load i32, i32* %1
%15 = icmp sgt i32 %14, 10
br label %16
16: ; preds = %13, %10
%17 = phi i1 [ true, %10 ], [ %15, %13 ]
br i1 %17, label %3, label %18
18: ; preds = %16
%19 = load i32, i32* %1
ret i32 %19
}

LLVM IR (-O2):
@.str = [11 x i8] c"Select x: \00"
@.str.1 = [3 x i8] c"%c\00"
define i32 @select_char_coord() {
%1 = alloca i8
br label %2
2: ; preds = %2, %0
%3 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%5 = call i32 (...) @flush()
%6 = load i8, i8* %1
%7 = call i32 @toupper(i8 signext %6)
%8 = add i32 %7, -76
%9 = icmp ult i32 %8, -11
br i1 %9, label %2, label %10
10: ; preds = %2
%11 = add nsw i32 %7, -65
ret i32 %11
}