#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 validateThresholdRange(char *inputString) {
  int result = atoi(inputString);
  if (*inputString == '-') {
    inputString++;
  }
  while (*inputString) {
    if (isdigit(*inputString++) == 0) {
      throwError(2);
    }
  }
  return result;
}


x86 assembly (clang, -O0):
<validateThresholdRange>:
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
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    1164 <validateThresholdRange+0x34>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1169 <validateThresholdRange+0x39>
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     11a6 <validateThresholdRange+0x76>
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    11a1 <validateThresholdRange+0x71>
mov    $0x2,%edi
call   1040 <throwError@plt>
jmp    1169 <validateThresholdRange+0x39>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<validateThresholdRange>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1050 <atoi@plt>
xor    %ecx,%ecx
cmpb   $0x2d,(%rbx)
mov    %eax,%ebp
sete   %cl
mov    (%rbx,%rcx,1),%al
test   %al,%al
je     1184 <validateThresholdRange+0x54>
add    %rcx,%rbx
add    $0x1,%rbx
jmp    116b <validateThresholdRange+0x3b>
cs nopw 0x0(%rax,%rax,1)
nop
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     1184 <validateThresholdRange+0x54>
movsbl %al,%edi
call   1030 <isdigit@plt>
test   %rax,%rax
jne    1160 <validateThresholdRange+0x30>
mov    $0x2,%edi
call   1040 <throwError@plt>
jmp    1160 <validateThresholdRange+0x30>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @validateThresholdRange(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
%6 = load i8*, i8** %2
%7 = load i8, i8* %6
%8 = sext i8 %7 to i32
%9 = icmp eq i32 %8, 45
br i1 %9, label %10, label %13
10: ; preds = %1
%11 = load i8*, i8** %2
%12 = getelementptr inbounds i8, i8* %11, i32 1
store i8* %12, i8** %2
br label %13
13: ; preds = %10, %1
br label %14
14: ; preds = %27, %13
%15 = load i8*, i8** %2
%16 = load i8, i8* %15
%17 = icmp ne i8 %16, 0
br i1 %17, label %18, label %28
18: ; preds = %14
%19 = load i8*, i8** %2
%20 = getelementptr inbounds i8, i8* %19, i32 1
store i8* %20, i8** %2
%21 = load i8, i8* %19
%22 = sext i8 %21 to i32
%23 = call i64 @isdigit(i32 %22)
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %18
%26 = call i32 @throwError(i32 2)
br label %27
27: ; preds = %25, %18
br label %14
28: ; preds = %14
%29 = load i32, i32* %3
ret i32 %29
}

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