#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*/ line;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int sscanf(char *, char *, char *, int *);
char toupper(char);
int read_move(FILE *f, int *x, int *y) {
  char line[1024];
  if (fgets(line, sizeof(line), f) == NULL) {
    return -1;
  }
  char x_c;
  if (sscanf(line, "%c%d\n", &x_c, y) != 2) {
    return -1;
  };
  *x = (int)(toupper(x_c) - 'A');
  return 0;
}


x86 assembly (clang, -O0):
<read_move>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
lea    -0x420(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x400,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
jne    1172 <read_move+0x42>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c4 <read_move+0x94>
lea    -0x420(%rbp),%rdi
mov    -0x20(%rbp),%rcx
lea    0xe7c(%rip),%rsi
lea    -0x421(%rbp),%rdx
call   1050 <sscanf@plt>
cmp    $0x2,%eax
je     11a5 <read_move+0x75>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c4 <read_move+0x94>
movsbl -0x421(%rbp),%edi
call   1030 <toupper@plt>
movsbl %al,%ecx
sub    $0x41,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_move>:
push   %r14
push   %rbx
sub    $0x418,%rsp
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %rdi,%rdx
lea    0x10(%rsp),%rdi
mov    $0x400,%esi
call   1040 <fgets@plt>
test   %rax,%rax
je     1193 <read_move+0x63>
lea    0xea2(%rip),%rsi
lea    0x10(%rsp),%rdi
lea    0xf(%rsp),%rdx
mov    %rbx,%rcx
call   1050 <sscanf@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    $0x2,%ecx
jne    1198 <read_move+0x68>
movsbl 0xf(%rsp),%edi
call   1030 <toupper@plt>
movsbl %al,%eax
add    $0xffffffbf,%eax
mov    %eax,(%r14)
xor    %eax,%eax
jmp    1198 <read_move+0x68>
mov    $0xffffffff,%eax
add    $0x418,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%c%d\0A\00"
define i32 @read_move(i32* %0, i32* %1, i32* %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca [1024 x i8]
%9 = alloca i8
store i32* %0, i32** %5
store i32* %1, i32** %6
store i32* %2, i32** %7
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%11 = load i32*, i32** %5
%12 = call i32* @fgets(i8* %10, i32 1024, i32* %11)
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %15
14: ; preds = %3
store i32 -1, i32* %4
br label %27
15: ; preds = %3
%16 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%17 = load i32*, i32** %7
%18 = call i32 @sscanf(i8* %16, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %9, i32* %17)
%19 = icmp ne i32 %18, 2
br i1 %19, label %20, label %21
20: ; preds = %15
store i32 -1, i32* %4
br label %27
21: ; preds = %15
%22 = load i8, i8* %9
%23 = call signext i8 @toupper(i8 signext %22)
%24 = sext i8 %23 to i32
%25 = sub nsw i32 %24, 65
%26 = load i32*, i32** %6
store i32 %25, i32* %26
store i32 0, i32* %4
br label %27
27: ; preds = %21, %20, %14
%28 = load i32, i32* %4
ret i32 %28
}

LLVM IR (-O2):
@.str = [6 x i8] c"%c%d\0A\00"
define i32 @read_move(i32* nocapture %0, i32* nocapture writeonly %1, i32* %2) {
%4 = alloca [1024 x i8]
%5 = alloca i8
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%7 = call i32* @fgets(i8* %6, i32 1024, i32* %0)
%8 = icmp eq i32* %7, null
br i1 %8, label %19, label %9
9: ; preds = %3
%10 = call i32 @sscanf(i8* %6, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %5, i32* %2)
%11 = icmp eq i32 %10, 2
br i1 %11, label %12, label %17
12: ; preds = %9
%13 = load i8, i8* %5
%14 = call signext i8 @toupper(i8 signext %13)
%15 = sext i8 %14 to i32
%16 = add nsw i32 %15, -65
store i32 %16, i32* %1
br label %17
17: ; preds = %9, %12
%18 = phi i32 [ 0, %12 ], [ -1, %9 ]
br label %19
19: ; preds = %3, %17
%20 = phi i32 [ %18, %17 ], [ -1, %3 ]
ret i32 %20
}