#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 INT_MAX;
int /*<<< orphan*/ fatal(int, char *, char *);
int strtol(char *, char **, int /*<<< orphan*/);
void parse_range(char *s, int *first, int *last) {
  char *s2 = s;
  (*first) = (*last) = strtol(s, &s, 0);
  if (!s)
    return;
  if (*(s++) != ',')
    goto badrange;
  if (!*s) {
    (*last) = INT_MAX;
    return;
  }
  (*last) = strtol(s, &s, 0);
  if (!s)
    goto badrange;
  if ((*first) > (*last))
    goto badrange;
  return;
badrange:
  fatal(1, "bad range syntax: '%s'\n", s2);
}


x86 assembly (clang, -O0):
<parse_range>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x8(%rbp),%rsi
xor    %edx,%edx
call   1030 <strtol@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
cmpq   $0x0,-0x8(%rbp)
jne    1169 <parse_range+0x49>
jmp    1202 <parse_range+0xe2>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movsbl (%rax),%eax
cmp    $0x2c,%eax
je     1189 <parse_range+0x69>
jmp    11ed <parse_range+0xcd>
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
jne    11aa <parse_range+0x8a>
mov    0x2e4b(%rip),%rax
mov    (%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
jmp    1202 <parse_range+0xe2>
mov    -0x8(%rbp),%rdi
lea    -0x8(%rbp),%rsi
xor    %edx,%edx
call   1030 <strtol@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
cmpq   $0x0,-0x8(%rbp)
jne    11d1 <parse_range+0xb1>
jmp    11ed <parse_range+0xcd>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    -0x18(%rbp),%rcx
cmp    (%rcx),%eax
jle    11e8 <parse_range+0xc8>
jmp    11ed <parse_range+0xcd>
jmp    1202 <parse_range+0xe2>
mov    -0x20(%rbp),%rdx
mov    $0x1,%edi
lea    0xe03(%rip),%rsi
call   1040 <fatal@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_range>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %rdi,0x8(%rsp)
lea    0x8(%rsp),%rsi
xor    %edx,%edx
call   1030 <strtol@plt>
mov    %eax,(%r15)
mov    %eax,(%r14)
mov    0x8(%rsp),%rax
test   %rax,%rax
je     11ab <parse_range+0x8b>
lea    0x1(%rax),%rdi
mov    %rdi,0x8(%rsp)
cmpb   $0x2c,(%rax)
jne    1182 <parse_range+0x62>
cmpb   $0x0,(%rdi)
je     119f <parse_range+0x7f>
lea    0x8(%rsp),%rsi
xor    %edx,%edx
call   1030 <strtol@plt>
mov    %eax,(%r15)
cmpq   $0x0,0x8(%rsp)
je     1182 <parse_range+0x62>
cmp    %eax,(%r14)
jle    11ab <parse_range+0x8b>
lea    0xe77(%rip),%rsi
mov    $0x1,%edi
mov    %rbx,%rdx
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <fatal@plt>
mov    0x2e42(%rip),%rax
mov    (%rax),%eax
mov    %eax,(%r15)
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@INT_MAX = global i32 0
@.str = [24 x i8] c"bad range syntax: '%s'\0A\00"
define void @parse_range(i8* %0, i32* %1, i32* %2) {
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i8*
store i8* %0, i8** %4
store i32* %1, i32** %5
store i32* %2, i32** %6
%8 = load i8*, i8** %4
store i8* %8, i8** %7
%9 = load i8*, i8** %4
%10 = call i32 @strtol(i8* %9, i8** %4, i32 0)
%11 = load i32*, i32** %6
store i32 %10, i32* %11
%12 = load i32*, i32** %5
store i32 %10, i32* %12
%13 = load i8*, i8** %4
%14 = icmp ne i8* %13, null
br i1 %14, label %16, label %15
15: ; preds = %3
br label %48
16: ; preds = %3
%17 = load i8*, i8** %4
%18 = getelementptr inbounds i8, i8* %17, i32 1
store i8* %18, i8** %4
%19 = load i8, i8* %17
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %20, 44
br i1 %21, label %22, label %23
22: ; preds = %16
br label %45
23: ; preds = %16
%24 = load i8*, i8** %4
%25 = load i8, i8* %24
%26 = icmp ne i8 %25, 0
br i1 %26, label %30, label %27
27: ; preds = %23
%28 = load i32, i32* @INT_MAX
%29 = load i32*, i32** %6
store i32 %28, i32* %29
br label %48
30: ; preds = %23
%31 = load i8*, i8** %4
%32 = call i32 @strtol(i8* %31, i8** %4, i32 0)
%33 = load i32*, i32** %6
store i32 %32, i32* %33
%34 = load i8*, i8** %4
%35 = icmp ne i8* %34, null
br i1 %35, label %37, label %36
36: ; preds = %30
br label %45
37: ; preds = %30
%38 = load i32*, i32** %5
%39 = load i32, i32* %38
%40 = load i32*, i32** %6
%41 = load i32, i32* %40
%42 = icmp sgt i32 %39, %41
br i1 %42, label %43, label %44
43: ; preds = %37
br label %45
44: ; preds = %37
br label %48
45: ; preds = %43, %36, %22
%46 = load i8*, i8** %7
%47 = call i32 @fatal(i32 1, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %46)
br label %48
48: ; preds = %45, %44, %27, %15
ret void
}

LLVM IR (-O2):
@INT_MAX = global i32 0
@.str = [24 x i8] c"bad range syntax: '%s'\0A\00"
define void @parse_range(i8* %0, i32* nocapture %1, i32* nocapture writeonly %2) {
%4 = alloca i8*
store i8* %0, i8** %4
%5 = call i32 @strtol(i8* %0, i8** %4, i32 0)
store i32 %5, i32* %2
store i32 %5, i32* %1
%6 = load i8*, i8** %4
%7 = icmp eq i8* %6, null
br i1 %7, label %26, label %8
8: ; preds = %3
%9 = getelementptr inbounds i8, i8* %6, i64 1
store i8* %9, i8** %4
%10 = load i8, i8* %6
%11 = icmp eq i8 %10, 44
br i1 %11, label %12, label %24
12: ; preds = %8
%13 = load i8, i8* %9
%14 = icmp eq i8 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = load i32, i32* @INT_MAX
store i32 %16, i32* %2
br label %26
17: ; preds = %12
%18 = call i32 @strtol(i8* %9, i8** %4, i32 0)
store i32 %18, i32* %2
%19 = load i8*, i8** %4
%20 = icmp eq i8* %19, null
br i1 %20, label %24, label %21
21: ; preds = %17
%22 = load i32, i32* %1
%23 = icmp sgt i32 %22, %18
br i1 %23, label %24, label %26
24: ; preds = %21, %17, %8
%25 = tail call i32 @fatal(i32 1, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %26
26: ; preds = %21, %3, %24, %15
ret void
}