#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 atoi(char *);
scalar_t__ isdigit(int /*<<< orphan*/);
int /*<<< orphan*/ throwError(int);
int parseGPIO(char *inputString) {
  int result = atoi(inputString);
  while (*inputString) {
    if (isdigit(*inputString++) == 0) {
      throwError(1);
    }
  }
  if (result < 0 || result > 31) {
    throwError(1);
  }
  return result;
}


x86 assembly (clang, -O0):
<parseGPIO>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     1185 <parseGPIO+0x55>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
jne    1180 <parseGPIO+0x50>
mov    $0x1,%edi
call   1040 <throwError@plt>
jmp    1148 <parseGPIO+0x18>
cmpl   $0x0,-0xc(%rbp)
jl     1199 <parseGPIO+0x69>
cmpl   $0x1f,-0xc(%rbp)
jle    11a3 <parseGPIO+0x73>
mov    $0x1,%edi
call   1040 <throwError@plt>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parseGPIO>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1050 <atoi@plt>
mov    %eax,%ebp
mov    (%rbx),%al
test   %al,%al
je     1174 <parseGPIO+0x44>
add    $0x1,%rbx
jmp    115b <parseGPIO+0x2b>
nopl   0x0(%rax)
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     1174 <parseGPIO+0x44>
movsbl %al,%edi
call   1030 <isdigit@plt>
test   %rax,%rax
jne    1150 <parseGPIO+0x20>
mov    $0x1,%edi
call   1040 <throwError@plt>
jmp    1150 <parseGPIO+0x20>
cmp    $0x20,%ebp
jb     1183 <parseGPIO+0x53>
mov    $0x1,%edi
call   1040 <throwError@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @parseGPIO(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i32 @atoi(i8* %4)
store i32 %5, i32* %3
br label %6
6: ; preds = %19, %1
%7 = load i8*, i8** %2
%8 = load i8, i8* %7
%9 = icmp ne i8 %8, 0
br i1 %9, label %10, label %20
10: ; preds = %6
%11 = load i8*, i8** %2
%12 = getelementptr inbounds i8, i8* %11, i32 1
store i8* %12, i8** %2
%13 = load i8, i8* %11
%14 = sext i8 %13 to i32
%15 = call i64 @isdigit(i32 %14)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %10
%18 = call i32 @throwError(i32 1)
br label %19
19: ; preds = %17, %10
br label %6
20: ; preds = %6
%21 = load i32, i32* %3
%22 = icmp slt i32 %21, 0
br i1 %22, label %26, label %23
23: ; preds = %20
%24 = load i32, i32* %3
%25 = icmp sgt i32 %24, 31
br i1 %25, label %26, label %28
26: ; preds = %23, %20
%27 = call i32 @throwError(i32 1)
br label %28
28: ; preds = %26, %23
%29 = load i32, i32* %3
ret i32 %29
}

LLVM IR (-O2):
define i32 @parseGPIO(i8* nocapture %0) {
%2 = tail call i32 @atoi(i8* %0)
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 0
br i1 %4, label %17, label %5
5: ; preds = %1, %14
%6 = phi i8 [ %15, %14 ], [ %3, %1 ]
%7 = phi i8* [ %8, %14 ], [ %0, %1 ]
%8 = getelementptr inbounds i8, i8* %7, i64 1
%9 = sext i8 %6 to i32
%10 = tail call i64 @isdigit(i32 %9)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %5
%13 = tail call i32 @throwError(i32 1)
br label %14
14: ; preds = %12, %5
%15 = load i8, i8* %8
%16 = icmp eq i8 %15, 0
br i1 %16, label %17, label %5
17: ; preds = %14, %1
%18 = icmp ugt i32 %2, 31
br i1 %18, label %19, label %21
19: ; preds = %17
%20 = tail call i32 @throwError(i32 1)
br label %21
21: ; preds = %17, %19
ret i32 %2
}