#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*/ isdigit(char const);
int strtol(char const *, char **, int);
int parse_range(const char *str, int *a, int *b, char **endptr) {
  if (!isdigit(*str))
    return -1;
  *a = *b = strtol(str, endptr, 10);
  if (**endptr == '-') {
    str = *endptr + 1;
    if (!isdigit(*str))
      return -1;
    *b = strtol(str, endptr, 10);
    if (*a > *b)
      return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<parse_range>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
jne    1159 <parse_range+0x39>
movl   $0xffffffff,-0x4(%rbp)
jmp    1200 <parse_range+0xe0>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x28(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    11f9 <parse_range+0xd9>
mov    -0x28(%rbp),%rax
mov    (%rax),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
jne    11bc <parse_range+0x9c>
movl   $0xffffffff,-0x4(%rbp)
jmp    1200 <parse_range+0xe0>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    -0x20(%rbp),%rcx
cmp    (%rcx),%eax
jle    11f4 <parse_range+0xd4>
movl   $0xffffffff,-0x4(%rbp)
jmp    1200 <parse_range+0xe0>
jmp    11f9 <parse_range+0xd9>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_range>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rcx,%rbx
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%rbp
movsbl (%rdi),%edi
call   1030 <isdigit@plt>
mov    $0xffffffff,%r12d
test   %eax,%eax
je     1191 <parse_range+0x71>
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %eax,(%r15)
mov    %eax,(%r14)
mov    (%rbx),%rbp
cmpb   $0x2d,0x0(%rbp)
jne    118e <parse_range+0x6e>
movsbl 0x1(%rbp),%edi
call   1030 <isdigit@plt>
test   %eax,%eax
je     1191 <parse_range+0x71>
add    $0x1,%rbp
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %eax,(%r15)
cmp    %eax,(%r14)
jg     1191 <parse_range+0x71>
xor    %r12d,%r12d
mov    %r12d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @parse_range(i8* %0, i32* %1, i32* %2, i8** %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i8**
store i8* %0, i8** %6
store i32* %1, i32** %7
store i32* %2, i32** %8
store i8** %3, i8*** %9
%10 = load i8*, i8** %6
%11 = load i8, i8* %10
%12 = call i32 @isdigit(i8 signext %11)
%13 = icmp ne i32 %12, 0
br i1 %13, label %15, label %14
14: ; preds = %4
store i32 -1, i32* %5
br label %48
15: ; preds = %4
%16 = load i8*, i8** %6
%17 = load i8**, i8*** %9
%18 = call i32 @strtol(i8* %16, i8** %17, i32 10)
%19 = load i32*, i32** %8
store i32 %18, i32* %19
%20 = load i32*, i32** %7
store i32 %18, i32* %20
%21 = load i8**, i8*** %9
%22 = load i8*, i8** %21
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 45
br i1 %25, label %26, label %47
26: ; preds = %15
%27 = load i8**, i8*** %9
%28 = load i8*, i8** %27
%29 = getelementptr inbounds i8, i8* %28, i64 1
store i8* %29, i8** %6
%30 = load i8*, i8** %6
%31 = load i8, i8* %30
%32 = call i32 @isdigit(i8 signext %31)
%33 = icmp ne i32 %32, 0
br i1 %33, label %35, label %34
34: ; preds = %26
store i32 -1, i32* %5
br label %48
35: ; preds = %26
%36 = load i8*, i8** %6
%37 = load i8**, i8*** %9
%38 = call i32 @strtol(i8* %36, i8** %37, i32 10)
%39 = load i32*, i32** %8
store i32 %38, i32* %39
%40 = load i32*, i32** %7
%41 = load i32, i32* %40
%42 = load i32*, i32** %8
%43 = load i32, i32* %42
%44 = icmp sgt i32 %41, %43
br i1 %44, label %45, label %46
45: ; preds = %35
store i32 -1, i32* %5
br label %48
46: ; preds = %35
br label %47
47: ; preds = %46, %15
store i32 0, i32* %5
br label %48
48: ; preds = %47, %45, %34, %14
%49 = load i32, i32* %5
ret i32 %49
}

LLVM IR (-O2):
define i32 @parse_range(i8* %0, i32* nocapture %1, i32* nocapture writeonly %2, i8** nocapture %3) {
%5 = load i8, i8* %0
%6 = tail call i32 @isdigit(i8 signext %5)
%7 = icmp eq i32 %6, 0
br i1 %7, label %23, label %8
8: ; preds = %4
%9 = tail call i32 @strtol(i8* %0, i8** %3, i32 10)
store i32 %9, i32* %2
store i32 %9, i32* %1
%10 = load i8*, i8** %3
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 45
br i1 %12, label %13, label %22
13: ; preds = %8
%14 = getelementptr inbounds i8, i8* %10, i64 1
%15 = load i8, i8* %14
%16 = tail call i32 @isdigit(i8 signext %15)
%17 = icmp eq i32 %16, 0
br i1 %17, label %23, label %18
18: ; preds = %13
%19 = tail call i32 @strtol(i8* %14, i8** %3, i32 10)
store i32 %19, i32* %2
%20 = load i32, i32* %1
%21 = icmp sgt i32 %20, %19
br i1 %21, label %23, label %22
22: ; preds = %18, %8
br label %23
23: ; preds = %18, %13, %4, %22
%24 = phi i32 [ 0, %22 ], [ -1, %4 ], [ -1, %13 ], [ -1, %18 ]
ret i32 %24
}