#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*/ printf(char *);
int isSingleDigit(char input[]) {
  if (input[0] > 47 && input[0] < 58) {
    if (input[1] == 0) {
      return 1;
    } else
      printf("error invalid selection\n");
    return 0;
  } else {
    printf("error invalid selection\n");
    return 0;
  }
}


x86 assembly (clang, -O0):
<isSingleDigit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
jle    1171 <isSingleDigit+0x61>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3a,%eax
jge    1171 <isSingleDigit+0x61>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x0,%eax
jne    1159 <isSingleDigit+0x49>
movl   $0x1,-0x4(%rbp)
jmp    1184 <isSingleDigit+0x74>
lea    0xea0(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1184 <isSingleDigit+0x74>
lea    0xe88(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isSingleDigit>:
push   %rax
mov    (%rdi),%al
add    $0xd0,%al
cmp    $0x9,%al
ja     111f <isSingleDigit+0xf>
cmpb   $0x0,0x1(%rdi)
je     112f <isSingleDigit+0x1f>
lea    0xeda(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret
mov    $0x1,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [25 x i8] c"error invalid selection\0A\00"
define i32 @isSingleDigit(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = getelementptr inbounds i8, i8* %4, i64 0
%6 = load i8, i8* %5
%7 = sext i8 %6 to i32
%8 = icmp sgt i32 %7, 47
br i1 %8, label %9, label %25
9: ; preds = %1
%10 = load i8*, i8** %3
%11 = getelementptr inbounds i8, i8* %10, i64 0
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp slt i32 %13, 58
br i1 %14, label %15, label %25
15: ; preds = %9
%16 = load i8*, i8** %3
%17 = getelementptr inbounds i8, i8* %16, i64 1
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %15
store i32 1, i32* %2
br label %27
22: ; preds = %15
%23 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
br label %24
24: ; preds = %22
store i32 0, i32* %2
br label %27
25: ; preds = %9, %1
%26 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %2
br label %27
27: ; preds = %25, %24, %21
%28 = load i32, i32* %2
ret i32 %28
}

LLVM IR (-O2):
@str.1 = [24 x i8] c"error invalid selection\00"
define i32 @isSingleDigit(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = add i8 %2, -48
%4 = icmp ult i8 %3, 10
br i1 %4, label %5, label %9
5: ; preds = %1
%6 = getelementptr inbounds i8, i8* %0, i64 1
%7 = load i8, i8* %6
%8 = icmp eq i8 %7, 0
br i1 %8, label %12, label %9
9: ; preds = %1, %5
%10 = phi i8* [ getelementptr inbounds ([24 x i8], [24 x i8]* @str.1, i64 0, i64 0), %5 ], [ getelementptr inbounds ([24 x i8], [24 x i8]* @str.1, i64 0, i64 0), %1 ]
%11 = tail call i32 @puts(i8* dereferenceable(1) %10)
br label %12
12: ; preds = %9, %5
%13 = phi i32 [ 1, %5 ], [ 0, %9 ]
ret i32 %13
}