#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*/ addch(int);
int /*<<< orphan*/ addstr(char *);
int getch();
int /*<<< orphan*/ refresh();
int sgetc(char *);
char getcoord() {
  int ch, x, y;
redo:
  y = sgetc("ABCDEFGHIJ");
  do {
    ch = getch();
    if (ch == 0x7F || ch == 8) {
      addstr("\b \b");
      refresh();
      goto redo;
    }
  } while (ch < '0' || ch > '9');
  addch(x = ch);
  refresh();
  return ((y - 'A') * 10 + x - '0');
}


x86 assembly (clang, -O0):
<getcoord>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xea1(%rip),%rdi
call   1030 <sgetc@plt>
mov    %eax,-0xc(%rbp)
mov    $0x0,%al
call   1060 <getch@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x7f,-0x4(%rbp)
je     1185 <getcoord+0x35>
cmpl   $0x8,-0x4(%rbp)
jne    119d <getcoord+0x4d>
lea    0xe7f(%rip),%rdi
call   1070 <addstr@plt>
mov    $0x0,%al
call   1050 <refresh@plt>
jmp    1158 <getcoord+0x8>
jmp    11a2 <getcoord+0x52>
mov    $0x1,%al
cmpl   $0x30,-0x4(%rbp)
mov    %al,-0xd(%rbp)
jl     11bb <getcoord+0x6b>
cmpl   $0x39,-0x4(%rbp)
setg   %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
test   $0x1,%al
jne    1167 <getcoord+0x17>
mov    -0x4(%rbp),%edi
mov    %edi,-0x8(%rbp)
call   1040 <addch@plt>
mov    $0x0,%al
call   1050 <refresh@plt>
mov    -0xc(%rbp),%eax
sub    $0x41,%eax
imul   $0xa,%eax,%eax
add    -0x8(%rbp),%eax
sub    $0x30,%eax
movsbl %al,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getcoord>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xea1(%rip),%r15
lea    0xea5(%rip),%r14
jmp    117f <getcoord+0x2f>
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1070 <addstr@plt>
xor    %eax,%eax
call   1050 <refresh@plt>
mov    %r15,%rdi
call   1030 <sgetc@plt>
mov    %eax,%r12d
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1060 <getch@plt>
cmp    $0x7f,%eax
je     1170 <getcoord+0x20>
mov    %eax,%ebx
cmp    $0x8,%eax
je     1170 <getcoord+0x20>
lea    -0x3a(%rbx),%eax
cmp    $0xfffffff6,%eax
jb     1190 <getcoord+0x40>
mov    %ebx,%edi
call   1040 <addch@plt>
xor    %eax,%eax
call   1050 <refresh@plt>
lea    (%r12,%r12,4),%eax
lea    (%rbx,%rax,2),%eax
add    $0x46,%al
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [11 x i8] c"ABCDEFGHIJ\00"
@.str.1 = [4 x i8] c"\08 \08\00"
define signext i8 @getcoord() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
br label %4
4: ; preds = %13, %0
%5 = call i32 @sgetc(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
store i32 %5, i32* %3
br label %6
6: ; preds = %23, %4
%7 = call i32 (...) @getch()
store i32 %7, i32* %1
%8 = load i32, i32* %1
%9 = icmp eq i32 %8, 127
br i1 %9, label %13, label %10
10: ; preds = %6
%11 = load i32, i32* %1
%12 = icmp eq i32 %11, 8
br i1 %12, label %13, label %16
13: ; preds = %10, %6
%14 = call i32 @addstr(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%15 = call i32 (...) @refresh()
br label %4
16: ; preds = %10
br label %17
17: ; preds = %16
%18 = load i32, i32* %1
%19 = icmp slt i32 %18, 48
br i1 %19, label %23, label %20
20: ; preds = %17
%21 = load i32, i32* %1
%22 = icmp sgt i32 %21, 57
br label %23
23: ; preds = %20, %17
%24 = phi i1 [ true, %17 ], [ %22, %20 ]
br i1 %24, label %6, label %25
25: ; preds = %23
%26 = load i32, i32* %1
store i32 %26, i32* %2
%27 = call i32 @addch(i32 %26)
%28 = call i32 (...) @refresh()
%29 = load i32, i32* %3
%30 = sub nsw i32 %29, 65
%31 = mul nsw i32 %30, 10
%32 = load i32, i32* %2
%33 = add nsw i32 %31, %32
%34 = sub nsw i32 %33, 48
%35 = trunc i32 %34 to i8
ret i8 %35
}

LLVM IR (-O2):
@.str = [11 x i8] c"ABCDEFGHIJ\00"
@.str.1 = [4 x i8] c"\08 \08\00"
define signext i8 @getcoord() {
br label %1
1: ; preds = %5, %0
%2 = tail call i32 @sgetc(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
br label %3
3: ; preds = %8, %1
%4 = tail call i32 (...) @getch()
switch i32 %4, label %8 [
i32 127, label %5
i32 8, label %5
]
5: ; preds = %3, %3
%6 = tail call i32 @addstr(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%7 = tail call i32 (...) @refresh()
br label %1
8: ; preds = %3
%9 = add i32 %4, -58
%10 = icmp ult i32 %9, -10
br i1 %10, label %3, label %11
11: ; preds = %8
%12 = tail call i32 @addch(i32 %4)
%13 = tail call i32 (...) @refresh()
%14 = mul i32 %2, 10
%15 = add i32 %14, 118
%16 = add i32 %15, %4
%17 = trunc i32 %16 to i8
%18 = add i8 %17, -48
ret i8 %18
}