#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 catoi(char);
char to_lowercase(char);
int getxy(char *coord, int *x, int *y) {
  char c;
  int py;
  c = to_lowercase(coord[0]);
  py = catoi(coord[1]);
  if (!c || py == -1 || c > 'e')
    return 0;
  else {
    *x = c - 'a';
    *y = py - 1;
    return 1;
  }
}


x86 assembly (clang, -O0):
<getxy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1040 <to_lowercase@plt>
mov    %al,-0x21(%rbp)
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%edi
call   1030 <catoi@plt>
mov    %eax,-0x28(%rbp)
cmpb   $0x0,-0x21(%rbp)
je     1174 <getxy+0x54>
cmpl   $0xffffffff,-0x28(%rbp)
je     1174 <getxy+0x54>
movsbl -0x21(%rbp),%eax
cmp    $0x65,%eax
jle    1180 <getxy+0x60>
movl   $0x0,-0x4(%rbp)
jmp    11a0 <getxy+0x80>
movsbl -0x21(%rbp),%ecx
sub    $0x61,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x28(%rbp),%ecx
sub    $0x1,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getxy>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
movsbl (%rdi),%edi
call   1040 <to_lowercase@plt>
mov    %eax,%ebp
movsbl 0x1(%rbx),%edi
call   1030 <catoi@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x65,%bpl
jg     116c <getxy+0x4c>
test   %bpl,%bpl
je     116c <getxy+0x4c>
cmp    $0xffffffff,%ecx
je     116c <getxy+0x4c>
movsbl %bpl,%eax
add    $0xffffff9f,%eax
mov    %eax,(%r15)
add    $0xffffffff,%ecx
mov    %ecx,(%r14)
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @getxy(i8* %0, i32* %1, i32* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i8
%9 = alloca i32
store i8* %0, i8** %5
store i32* %1, i32** %6
store i32* %2, i32** %7
%10 = load i8*, i8** %5
%11 = getelementptr inbounds i8, i8* %10, i64 0
%12 = load i8, i8* %11
%13 = call signext i8 @to_lowercase(i8 signext %12)
store i8 %13, i8* %8
%14 = load i8*, i8** %5
%15 = getelementptr inbounds i8, i8* %14, i64 1
%16 = load i8, i8* %15
%17 = call i32 @catoi(i8 signext %16)
store i32 %17, i32* %9
%18 = load i8, i8* %8
%19 = icmp ne i8 %18, 0
br i1 %19, label %20, label %27
20: ; preds = %3
%21 = load i32, i32* %9
%22 = icmp eq i32 %21, -1
br i1 %22, label %27, label %23
23: ; preds = %20
%24 = load i8, i8* %8
%25 = sext i8 %24 to i32
%26 = icmp sgt i32 %25, 101
br i1 %26, label %27, label %28
27: ; preds = %23, %20, %3
store i32 0, i32* %4
br label %36
28: ; preds = %23
%29 = load i8, i8* %8
%30 = sext i8 %29 to i32
%31 = sub nsw i32 %30, 97
%32 = load i32*, i32** %6
store i32 %31, i32* %32
%33 = load i32, i32* %9
%34 = sub nsw i32 %33, 1
%35 = load i32*, i32** %7
store i32 %34, i32* %35
store i32 1, i32* %4
br label %36
36: ; preds = %28, %27
%37 = load i32, i32* %4
ret i32 %37
}

LLVM IR (-O2):
define i32 @getxy(i8* nocapture %0, i32* nocapture writeonly %1, i32* nocapture writeonly %2) {
%4 = load i8, i8* %0
%5 = tail call signext i8 @to_lowercase(i8 signext %4)
%6 = getelementptr inbounds i8, i8* %0, i64 1
%7 = load i8, i8* %6
%8 = tail call i32 @catoi(i8 signext %7)
%9 = icmp eq i8 %5, 0
%10 = icmp eq i32 %8, -1
%11 = select i1 %9, i1 true, i1 %10
%12 = icmp sgt i8 %5, 101
%13 = or i1 %12, %11
br i1 %13, label %18, label %14
14: ; preds = %3
%15 = sext i8 %5 to i32
%16 = add nsw i32 %15, -97
store i32 %16, i32* %1
%17 = add nsw i32 %8, -1
store i32 %17, i32* %2
br label %18
18: ; preds = %3, %14
%19 = phi i32 [ 1, %14 ], [ 0, %3 ]
ret i32 %19
}