#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 strlen(char *);
int register_number(char *s) {
  if (*s != 'S') {
    return (-1);
  }
  if (strlen(s) != 2) {
    return (-1);
  }
  if ((*(s + 1) >= '0') && (*(s + 1) <= '7')) {
    return (*(s + 1) - '0');
  } else {
    return (-1);
  }
}


x86 assembly (clang, -O0):
<register_number>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x53,%eax
je     1138 <register_number+0x28>
movl   $0xffffffff,-0x4(%rbp)
jmp    1192 <register_number+0x82>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x2,%eax
je     1156 <register_number+0x46>
movl   $0xffffffff,-0x4(%rbp)
jmp    1192 <register_number+0x82>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x30,%eax
jl     118b <register_number+0x7b>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x37,%eax
jg     118b <register_number+0x7b>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
sub    $0x30,%eax
mov    %eax,-0x4(%rbp)
jmp    1192 <register_number+0x82>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<register_number>:
push   %rbp
push   %rbx
push   %rax
mov    $0xffffffff,%ebp
cmpb   $0x53,(%rdi)
jne    113d <register_number+0x2d>
mov    %rdi,%rbx
call   1030 <strlen@plt>
cmp    $0x2,%eax
jne    113d <register_number+0x2d>
movzbl 0x1(%rbx),%eax
mov    %eax,%ecx
and    $0xf8,%cl
cmp    $0x30,%cl
jne    113d <register_number+0x2d>
add    $0xffffffd0,%eax
mov    %eax,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @register_number(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = load i8, i8* %4
%6 = sext i8 %5 to i32
%7 = icmp ne i32 %6, 83
br i1 %7, label %8, label %9
8: ; preds = %1
store i32 -1, i32* %2
br label %33
9: ; preds = %1
%10 = load i8*, i8** %3
%11 = call i32 @strlen(i8* %10)
%12 = icmp ne i32 %11, 2
br i1 %12, label %13, label %14
13: ; preds = %9
store i32 -1, i32* %2
br label %33
14: ; preds = %9
%15 = load i8*, i8** %3
%16 = getelementptr inbounds i8, i8* %15, i64 1
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp sge i32 %18, 48
br i1 %19, label %20, label %32
20: ; preds = %14
%21 = load i8*, i8** %3
%22 = getelementptr inbounds i8, i8* %21, i64 1
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp sle i32 %24, 55
br i1 %25, label %26, label %32
26: ; preds = %20
%27 = load i8*, i8** %3
%28 = getelementptr inbounds i8, i8* %27, i64 1
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = sub nsw i32 %30, 48
store i32 %31, i32* %2
br label %33
32: ; preds = %20, %14
store i32 -1, i32* %2
br label %33
33: ; preds = %32, %26, %13, %8
%34 = load i32, i32* %2
ret i32 %34
}

LLVM IR (-O2):
define i32 @register_number(i8* %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 83
br i1 %3, label %4, label %15
4: ; preds = %1
%5 = tail call i32 @strlen(i8* %0)
%6 = icmp eq i32 %5, 2
br i1 %6, label %7, label %15
7: ; preds = %4
%8 = getelementptr inbounds i8, i8* %0, i64 1
%9 = load i8, i8* %8
%10 = and i8 %9, -8
%11 = icmp eq i8 %10, 48
br i1 %11, label %12, label %15
12: ; preds = %7
%13 = zext i8 %9 to i32
%14 = add nsw i32 %13, -48
br label %15
15: ; preds = %7, %4, %1, %12
%16 = phi i32 [ %14, %12 ], [ -1, %1 ], [ -1, %4 ], [ -1, %7 ]
ret i32 %16
}