#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 */
struct rangeElement {
  int dummy;
};
typedef int /*<<< orphan*/ numbuf;

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
struct rangeElement *rangeAddGreaterEqual(int, struct rangeElement *);
struct rangeElement *rangeAddSingle(int, struct rangeElement *);
struct rangeElement *rangeAddStartEnd(int, int, struct rangeElement *);
int /*<<< orphan*/ stderr;
int strlen(char const *);
struct rangeElement *parseIntRanges(const char *text) {
  int state = 0;
  int flag_dash = 0x01;
  int i;
  char numbuf[1024];
  int numbufi;
  struct rangeElement *rv = NULL;
  int start = 0;
  int end = 0;
  memset(numbuf, 0, sizeof(numbuf));
  numbufi = 0;
  for (i = 0; i < strlen(text); i++) {
    if (text[i] >= '0' && text[i] <= '9') {
      numbuf[numbufi] = text[i];
      numbufi++;
    } else if (text[i] == '-') {
      if (state & flag_dash) {
        fprintf(stderr, "error: too many dashes in range\n");
        exit(-1);
      }
      state |= flag_dash;
      if (numbufi == 0) {
        fprintf(stderr, "error: range cannot start with '-'\n");
        exit(-1);
      }
      start = atoi(numbuf);
      if (start <= 0) {
        fprintf(stderr, "error: start range <= 0\n");
        exit(-1);
      }
      memset(numbuf, 0, sizeof(numbuf));
      numbufi = 0;
    } else if (text[i] == ',') {
      if (numbufi == 0) {
        if (flag_dash) {
          rv = rangeAddGreaterEqual(start, rv);
        }
      } else if (start > 0) {
        end = atoi(numbuf);
        if (end <= 0 || start > end) {
          fprintf(stderr, "error: illegal start/end ranges\n");
          exit(-1);
        }
        rv = rangeAddStartEnd(start, end, rv);
      } else {
        start = atoi(numbuf);
        rv = rangeAddSingle(start, rv);
      }
      memset(numbuf, 0, sizeof(numbuf));
      numbufi = 0;
      start = 0;
      end = 0;
      state = 0;
    }
  }
  if (numbufi == 0) {
    if (flag_dash) {
      rv = rangeAddGreaterEqual(start, rv);
    }
  } else if (start > 0) {
    end = atoi(numbuf);
    if (end <= 0 || start > end) {
      fprintf(stderr, "error: illegal start/end range %s\n", text);
      exit(-1);
    }
    rv = rangeAddStartEnd(start, end, rv);
  } else {
    start = atoi(numbuf);
    rv = rangeAddSingle(start, rv);
  }
  return rv;
}


x86 assembly (clang, -O0):
<parseIntRanges>:
push   %rbp
mov    %rsp,%rbp
sub    $0x440,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
movq   $0x0,-0x430(%rbp)
movl   $0x0,-0x434(%rbp)
movl   $0x0,-0x438(%rbp)
lea    -0x420(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1050 <memset@plt>
movl   $0x0,-0x424(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x43c(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x43c(%rbp),%eax
cmp    %ecx,%eax
jge    1489 <parseIntRanges+0x309>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x30,%eax
jl     1259 <parseIntRanges+0xd9>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x39,%eax
jg     1259 <parseIntRanges+0xd9>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,1),%cl
movslq -0x424(%rbp),%rax
mov    %cl,-0x420(%rbp,%rax,1)
mov    -0x424(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x424(%rbp)
jmp    1476 <parseIntRanges+0x2f6>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2d,%eax
jne    1337 <parseIntRanges+0x1b7>
mov    -0xc(%rbp),%eax
and    -0x10(%rbp),%eax
cmp    $0x0,%eax
je     129e <parseIntRanges+0x11e>
mov    0x2d5c(%rip),%rax
mov    (%rax),%edi
lea    0xd73(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0xffffffff,%edi
call   10a0 <exit@plt>
mov    -0x10(%rbp),%eax
or     -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0x424(%rbp)
jne    12d5 <parseIntRanges+0x155>
mov    0x2d25(%rip),%rax
mov    (%rax),%edi
lea    0xd5d(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0xffffffff,%edi
call   10a0 <exit@plt>
lea    -0x420(%rbp),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x434(%rbp)
cmpl   $0x0,-0x434(%rbp)
jg     1315 <parseIntRanges+0x195>
mov    0x2ce5(%rip),%rax
mov    (%rax),%edi
lea    0xd41(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0xffffffff,%edi
call   10a0 <exit@plt>
lea    -0x420(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1050 <memset@plt>
movl   $0x0,-0x424(%rbp)
jmp    1471 <parseIntRanges+0x2f1>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2c,%eax
jne    146c <parseIntRanges+0x2ec>
cmpl   $0x0,-0x424(%rbp)
jne    1381 <parseIntRanges+0x201>
cmpl   $0x0,-0x10(%rbp)
je     137c <parseIntRanges+0x1fc>
mov    -0x434(%rbp),%edi
mov    -0x430(%rbp),%rsi
call   1080 <rangeAddGreaterEqual@plt>
mov    %rax,-0x430(%rbp)
jmp    1434 <parseIntRanges+0x2b4>
cmpl   $0x0,-0x434(%rbp)
jle    1404 <parseIntRanges+0x284>
lea    -0x420(%rbp),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x438(%rbp)
cmpl   $0x0,-0x438(%rbp)
jle    13bf <parseIntRanges+0x23f>
mov    -0x434(%rbp),%eax
cmp    -0x438(%rbp),%eax
jle    13e0 <parseIntRanges+0x260>
mov    0x2c1a(%rip),%rax
mov    (%rax),%edi
lea    0xc8f(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0xffffffff,%edi
call   10a0 <exit@plt>
mov    -0x434(%rbp),%edi
mov    -0x438(%rbp),%esi
mov    -0x430(%rbp),%rdx
call   1030 <rangeAddStartEnd@plt>
mov    %rax,-0x430(%rbp)
jmp    142f <parseIntRanges+0x2af>
lea    -0x420(%rbp),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x434(%rbp)
mov    -0x434(%rbp),%edi
mov    -0x430(%rbp),%rsi
call   1070 <rangeAddSingle@plt>
mov    %rax,-0x430(%rbp)
jmp    1434 <parseIntRanges+0x2b4>
lea    -0x420(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1050 <memset@plt>
movl   $0x0,-0x424(%rbp)
movl   $0x0,-0x434(%rbp)
movl   $0x0,-0x438(%rbp)
movl   $0x0,-0xc(%rbp)
jmp    1471 <parseIntRanges+0x2f1>
jmp    1476 <parseIntRanges+0x2f6>
jmp    147b <parseIntRanges+0x2fb>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11e0 <parseIntRanges+0x60>
cmpl   $0x0,-0x424(%rbp)
jne    14be <parseIntRanges+0x33e>
cmpl   $0x0,-0x10(%rbp)
je     14b9 <parseIntRanges+0x339>
mov    -0x434(%rbp),%edi
mov    -0x430(%rbp),%rsi
call   1080 <rangeAddGreaterEqual@plt>
mov    %rax,-0x430(%rbp)
jmp    1575 <parseIntRanges+0x3f5>
cmpl   $0x0,-0x434(%rbp)
jle    1545 <parseIntRanges+0x3c5>
lea    -0x420(%rbp),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x438(%rbp)
cmpl   $0x0,-0x438(%rbp)
jle    14fc <parseIntRanges+0x37c>
mov    -0x434(%rbp),%eax
cmp    -0x438(%rbp),%eax
jle    1521 <parseIntRanges+0x3a1>
mov    0x2add(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xb6f(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0xffffffff,%edi
call   10a0 <exit@plt>
mov    -0x434(%rbp),%edi
mov    -0x438(%rbp),%esi
mov    -0x430(%rbp),%rdx
call   1030 <rangeAddStartEnd@plt>
mov    %rax,-0x430(%rbp)
jmp    1570 <parseIntRanges+0x3f0>
lea    -0x420(%rbp),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x434(%rbp)
mov    -0x434(%rbp),%edi
mov    -0x430(%rbp),%rsi
call   1070 <rangeAddSingle@plt>
mov    %rax,-0x430(%rbp)
jmp    1575 <parseIntRanges+0x3f5>
mov    -0x430(%rbp),%rax
add    $0x440,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parseIntRanges>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x408,%rsp
mov    %rdi,%r13
mov    %rsp,%rdi
xor    %r12d,%r12d
xor    %esi,%esi
mov    $0x400,%edx
call   1050 <memset@plt>
mov    %r13,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    12df <parseIntRanges+0x15f>
xor    %ebx,%ebx
xor    %r12d,%r12d
xor    %r14d,%r14d
xor    %ebp,%ebp
xor    %r15d,%r15d
jmp    11f0 <parseIntRanges+0x70>
cs nopw 0x0(%rax,%rax,1)
nop
movslq %ebp,%rcx
mov    %al,(%rsp,%rcx,1)
add    $0x1,%ebp
add    $0x1,%rbx
mov    %r13,%rdi
call   1040 <strlen@plt>
cltq
cmp    %rax,%rbx
jge    12ae <parseIntRanges+0x12e>
movzbl 0x0(%r13,%rbx,1),%eax
lea    -0x30(%rax),%ecx
cmp    $0x9,%cl
jbe    11d0 <parseIntRanges+0x50>
cmp    $0x2c,%al
je     1247 <parseIntRanges+0xc7>
cmp    $0x2d,%al
jne    11d9 <parseIntRanges+0x59>
test   $0x1,%r15b
jne    130b <parseIntRanges+0x18b>
test   %ebp,%ebp
mov    %rsp,%r15
je     131d <parseIntRanges+0x19d>
mov    %r15,%rdi
call   1090 <atoi@plt>
test   %eax,%eax
jle    132f <parseIntRanges+0x1af>
mov    %eax,%r12d
xor    %ebp,%ebp
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1050 <memset@plt>
mov    $0x1,%r15d
jmp    11d9 <parseIntRanges+0x59>
test   %ebp,%ebp
je     1278 <parseIntRanges+0xf8>
mov    %rsp,%rdi
call   1090 <atoi@plt>
test   %r12d,%r12d
jle    1285 <parseIntRanges+0x105>
test   %eax,%eax
jle    1341 <parseIntRanges+0x1c1>
cmp    %eax,%r12d
jg     1341 <parseIntRanges+0x1c1>
mov    %r12d,%edi
mov    %eax,%esi
mov    %r14,%rdx
call   1030 <rangeAddStartEnd@plt>
jmp    128f <parseIntRanges+0x10f>
mov    %r12d,%edi
mov    %r14,%rsi
call   1080 <rangeAddGreaterEqual@plt>
jmp    128f <parseIntRanges+0x10f>
mov    %eax,%edi
mov    %r14,%rsi
call   1070 <rangeAddSingle@plt>
mov    %rax,%r14
xor    %r15d,%r15d
mov    %rsp,%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1050 <memset@plt>
xor    %ebp,%ebp
xor    %r12d,%r12d
jmp    11d9 <parseIntRanges+0x59>
test   %ebp,%ebp
je     12e2 <parseIntRanges+0x162>
mov    %rsp,%rdi
call   1090 <atoi@plt>
test   %r12d,%r12d
jle    12ff <parseIntRanges+0x17f>
test   %eax,%eax
jle    1362 <parseIntRanges+0x1e2>
cmp    %eax,%r12d
jg     1362 <parseIntRanges+0x1e2>
mov    %r12d,%edi
mov    %eax,%esi
mov    %r14,%rdx
call   1030 <rangeAddStartEnd@plt>
jmp    12ed <parseIntRanges+0x16d>
xor    %r14d,%r14d
mov    %r12d,%edi
mov    %r14,%rsi
call   1080 <rangeAddGreaterEqual@plt>
add    $0x408,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %eax,%edi
mov    %r14,%rsi
call   1070 <rangeAddSingle@plt>
jmp    12ed <parseIntRanges+0x16d>
mov    0x2cce(%rip),%rax
mov    (%rax),%edi
lea    0xce5(%rip),%rsi
jmp    1351 <parseIntRanges+0x1d1>
mov    0x2cbc(%rip),%rax
mov    (%rax),%edi
lea    0xcf4(%rip),%rsi
jmp    1351 <parseIntRanges+0x1d1>
mov    0x2caa(%rip),%rax
mov    (%rax),%edi
lea    0xd06(%rip),%rsi
jmp    1351 <parseIntRanges+0x1d1>
mov    0x2c98(%rip),%rax
mov    (%rax),%edi
lea    0xd0d(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0xffffffff,%edi
call   10a0 <exit@plt>
mov    0x2c77(%rip),%rax
mov    (%rax),%edi
lea    0xd0d(%rip),%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0xffffffff,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
%struct.rangeElement = type { i32 }
@stderr = global i32 0
@.str = [33 x i8] c"error: too many dashes in range\0A\00"
@.str.1 = [36 x i8] c"error: range cannot start with '-'\0A\00"
@.str.2 = [25 x i8] c"error: start range <= 0\0A\00"
@.str.3 = [33 x i8] c"error: illegal start/end ranges\0A\00"
@.str.4 = [35 x i8] c"error: illegal start/end range %s\0A\00"
define %struct.rangeElement* @parseIntRanges(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [1024 x i8]
%7 = alloca i32
%8 = alloca %struct.rangeElement*
%9 = alloca i32
%10 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
store i32 1, i32* %4
store %struct.rangeElement* null, %struct.rangeElement** %8
store i32 0, i32* %9
store i32 0, i32* %10
%11 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%12 = call i32 @memset(i8* %11, i32 0, i32 1024)
store i32 0, i32* %7
store i32 0, i32* %5
br label %13
13: ; preds = %137, %1
%14 = load i32, i32* %5
%15 = load i8*, i8** %2
%16 = call i32 @strlen(i8* %15)
%17 = icmp slt i32 %14, %16
br i1 %17, label %18, label %140
18: ; preds = %13
%19 = load i8*, i8** %2
%20 = load i32, i32* %5
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %19, i64 %21
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp sge i32 %24, 48
br i1 %25, label %26, label %45
26: ; preds = %18
%27 = load i8*, i8** %2
%28 = load i32, i32* %5
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %27, i64 %29
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp sle i32 %32, 57
br i1 %33, label %34, label %45
34: ; preds = %26
%35 = load i8*, i8** %2
%36 = load i32, i32* %5
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %35, i64 %37
%39 = load i8, i8* %38
%40 = load i32, i32* %7
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 %41
store i8 %39, i8* %42
%43 = load i32, i32* %7
%44 = add nsw i32 %43, 1
store i32 %44, i32* %7
br label %136
45: ; preds = %26, %18
%46 = load i8*, i8** %2
%47 = load i32, i32* %5
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i8, i8* %46, i64 %48
%50 = load i8, i8* %49
%51 = sext i8 %50 to i32
%52 = icmp eq i32 %51, 45
br i1 %52, label %53, label %84
53: ; preds = %45
%54 = load i32, i32* %3
%55 = load i32, i32* %4
%56 = and i32 %54, %55
%57 = icmp ne i32 %56, 0
br i1 %57, label %58, label %62
58: ; preds = %53
%59 = load i32, i32* @stderr
%60 = call i32 (i32, i8*, ...) @fprintf(i32 %59, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%61 = call i32 @exit(i32 -1)
unreachable
62: ; preds = %53
%63 = load i32, i32* %4
%64 = load i32, i32* %3
%65 = or i32 %64, %63
store i32 %65, i32* %3
%66 = load i32, i32* %7
%67 = icmp eq i32 %66, 0
br i1 %67, label %68, label %72
68: ; preds = %62
%69 = load i32, i32* @stderr
%70 = call i32 (i32, i8*, ...) @fprintf(i32 %69, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
%71 = call i32 @exit(i32 -1)
unreachable
72: ; preds = %62
%73 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%74 = call i32 @atoi(i8* %73)
store i32 %74, i32* %9
%75 = load i32, i32* %9
%76 = icmp sle i32 %75, 0
br i1 %76, label %77, label %81
77: ; preds = %72
%78 = load i32, i32* @stderr
%79 = call i32 (i32, i8*, ...) @fprintf(i32 %78, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%80 = call i32 @exit(i32 -1)
unreachable
81: ; preds = %72
%82 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%83 = call i32 @memset(i8* %82, i32 0, i32 1024)
store i32 0, i32* %7
br label %135
84: ; preds = %45
%85 = load i8*, i8** %2
%86 = load i32, i32* %5
%87 = sext i32 %86 to i64
%88 = getelementptr inbounds i8, i8* %85, i64 %87
%89 = load i8, i8* %88
%90 = sext i8 %89 to i32
%91 = icmp eq i32 %90, 44
br i1 %91, label %92, label %134
92: ; preds = %84
%93 = load i32, i32* %7
%94 = icmp eq i32 %93, 0
br i1 %94, label %95, label %103
95: ; preds = %92
%96 = load i32, i32* %4
%97 = icmp ne i32 %96, 0
br i1 %97, label %98, label %102
98: ; preds = %95
%99 = load i32, i32* %9
%100 = load %struct.rangeElement*, %struct.rangeElement** %8
%101 = call %struct.rangeElement* @rangeAddGreaterEqual(i32 %99, %struct.rangeElement* %100)
store %struct.rangeElement* %101, %struct.rangeElement** %8
br label %102
102: ; preds = %98, %95
br label %131
103: ; preds = %92
%104 = load i32, i32* %9
%105 = icmp sgt i32 %104, 0
br i1 %105, label %106, label %124
106: ; preds = %103
%107 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%108 = call i32 @atoi(i8* %107)
store i32 %108, i32* %10
%109 = load i32, i32* %10
%110 = icmp sle i32 %109, 0
br i1 %110, label %115, label %111
111: ; preds = %106
%112 = load i32, i32* %9
%113 = load i32, i32* %10
%114 = icmp sgt i32 %112, %113
br i1 %114, label %115, label %119
115: ; preds = %111, %106
%116 = load i32, i32* @stderr
%117 = call i32 (i32, i8*, ...) @fprintf(i32 %116, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0))
%118 = call i32 @exit(i32 -1)
unreachable
119: ; preds = %111
%120 = load i32, i32* %9
%121 = load i32, i32* %10
%122 = load %struct.rangeElement*, %struct.rangeElement** %8
%123 = call %struct.rangeElement* @rangeAddStartEnd(i32 %120, i32 %121, %struct.rangeElement* %122)
store %struct.rangeElement* %123, %struct.rangeElement** %8
br label %130
124: ; preds = %103
%125 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%126 = call i32 @atoi(i8* %125)
store i32 %126, i32* %9
%127 = load i32, i32* %9
%128 = load %struct.rangeElement*, %struct.rangeElement** %8
%129 = call %struct.rangeElement* @rangeAddSingle(i32 %127, %struct.rangeElement* %128)
store %struct.rangeElement* %129, %struct.rangeElement** %8
br label %130
130: ; preds = %124, %119
br label %131
131: ; preds = %130, %102
%132 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%133 = call i32 @memset(i8* %132, i32 0, i32 1024)
store i32 0, i32* %7
store i32 0, i32* %9
store i32 0, i32* %10
store i32 0, i32* %3
br label %134
134: ; preds = %131, %84
br label %135
135: ; preds = %134, %81
br label %136
136: ; preds = %135, %34
br label %137
137: ; preds = %136
%138 = load i32, i32* %5
%139 = add nsw i32 %138, 1
store i32 %139, i32* %5
br label %13
140: ; preds = %13
%141 = load i32, i32* %7
%142 = icmp eq i32 %141, 0
br i1 %142, label %143, label %151
143: ; preds = %140
%144 = load i32, i32* %4
%145 = icmp ne i32 %144, 0
br i1 %145, label %146, label %150
146: ; preds = %143
%147 = load i32, i32* %9
%148 = load %struct.rangeElement*, %struct.rangeElement** %8
%149 = call %struct.rangeElement* @rangeAddGreaterEqual(i32 %147, %struct.rangeElement* %148)
store %struct.rangeElement* %149, %struct.rangeElement** %8
br label %150
150: ; preds = %146, %143
br label %180
151: ; preds = %140
%152 = load i32, i32* %9
%153 = icmp sgt i32 %152, 0
br i1 %153, label %154, label %173
154: ; preds = %151
%155 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%156 = call i32 @atoi(i8* %155)
store i32 %156, i32* %10
%157 = load i32, i32* %10
%158 = icmp sle i32 %157, 0
br i1 %158, label %163, label %159
159: ; preds = %154
%160 = load i32, i32* %9
%161 = load i32, i32* %10
%162 = icmp sgt i32 %160, %161
br i1 %162, label %163, label %168
163: ; preds = %159, %154
%164 = load i32, i32* @stderr
%165 = load i8*, i8** %2
%166 = call i32 (i32, i8*, ...) @fprintf(i32 %164, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0), i8* %165)
%167 = call i32 @exit(i32 -1)
unreachable
168: ; preds = %159
%169 = load i32, i32* %9
%170 = load i32, i32* %10
%171 = load %struct.rangeElement*, %struct.rangeElement** %8
%172 = call %struct.rangeElement* @rangeAddStartEnd(i32 %169, i32 %170, %struct.rangeElement* %171)
store %struct.rangeElement* %172, %struct.rangeElement** %8
br label %179
173: ; preds = %151
%174 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%175 = call i32 @atoi(i8* %174)
store i32 %175, i32* %9
%176 = load i32, i32* %9
%177 = load %struct.rangeElement*, %struct.rangeElement** %8
%178 = call %struct.rangeElement* @rangeAddSingle(i32 %176, %struct.rangeElement* %177)
store %struct.rangeElement* %178, %struct.rangeElement** %8
br label %179
179: ; preds = %173, %168
br label %180
180: ; preds = %179, %150
%181 = load %struct.rangeElement*, %struct.rangeElement** %8
ret %struct.rangeElement* %181
}

LLVM IR (-O2):
%struct.rangeElement = type { i32 }
@stderr = global i32 0
@.str = [33 x i8] c"error: too many dashes in range\0A\00"
@.str.1 = [36 x i8] c"error: range cannot start with '-'\0A\00"
@.str.2 = [25 x i8] c"error: start range <= 0\0A\00"
@.str.3 = [33 x i8] c"error: illegal start/end ranges\0A\00"
@.str.4 = [35 x i8] c"error: illegal start/end range %s\0A\00"
define %struct.rangeElement* @parseIntRanges(i8* %0) {
%2 = alloca [1024 x i8]
%3 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%4 = call i32 @memset(i8* %3, i32 0, i32 1024)
%5 = call i32 @strlen(i8* %0)
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %77
7: ; preds = %1, %66
%8 = phi i64 [ %71, %66 ], [ 0, %1 ]
%9 = phi i32 [ %70, %66 ], [ 0, %1 ]
%10 = phi %struct.rangeElement* [ %69, %66 ], [ null, %1 ]
%11 = phi i32 [ %68, %66 ], [ 0, %1 ]
%12 = phi i32 [ %67, %66 ], [ 0, %1 ]
%13 = getelementptr inbounds i8, i8* %0, i64 %8
%14 = load i8, i8* %13
%15 = add i8 %14, -48
%16 = icmp ult i8 %15, 10
br i1 %16, label %17, label %21
17: ; preds = %7
%18 = sext i32 %11 to i64
%19 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 %18
store i8 %14, i8* %19
%20 = add nsw i32 %11, 1
br label %66
21: ; preds = %7
switch i8 %14, label %66 [
i8 45, label %22
i8 44, label %44
]
22: ; preds = %21
%23 = and i32 %12, 1
%24 = icmp eq i32 %23, 0
br i1 %24, label %29, label %25
25: ; preds = %22
%26 = load i32, i32* @stderr
%27 = call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%28 = call i32 @exit(i32 -1)
unreachable
29: ; preds = %22
%30 = icmp eq i32 %11, 0
br i1 %30, label %31, label %35
31: ; preds = %29
%32 = load i32, i32* @stderr
%33 = call i32 (i32, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
%34 = call i32 @exit(i32 -1)
unreachable
35: ; preds = %29
%36 = call i32 @atoi(i8* %3)
%37 = icmp slt i32 %36, 1
br i1 %37, label %38, label %42
38: ; preds = %35
%39 = load i32, i32* @stderr
%40 = call i32 (i32, i8*, ...) @fprintf(i32 %39, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%41 = call i32 @exit(i32 -1)
unreachable
42: ; preds = %35
%43 = call i32 @memset(i8* %3, i32 0, i32 1024)
br label %66
44: ; preds = %21
%45 = icmp eq i32 %11, 0
br i1 %45, label %46, label %48
46: ; preds = %44
%47 = call %struct.rangeElement* @rangeAddGreaterEqual(i32 %9, %struct.rangeElement* %10)
br label %63
48: ; preds = %44
%49 = icmp sgt i32 %9, 0
%50 = call i32 @atoi(i8* %3)
br i1 %49, label %51, label %61
51: ; preds = %48
%52 = icmp slt i32 %50, 1
%53 = icmp sgt i32 %9, %50
%54 = select i1 %52, i1 true, i1 %53
br i1 %54, label %55, label %59
55: ; preds = %51
%56 = load i32, i32* @stderr
%57 = call i32 (i32, i8*, ...) @fprintf(i32 %56, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0))
%58 = call i32 @exit(i32 -1)
unreachable
59: ; preds = %51
%60 = call %struct.rangeElement* @rangeAddStartEnd(i32 %9, i32 %50, %struct.rangeElement* %10)
br label %63
61: ; preds = %48
%62 = call %struct.rangeElement* @rangeAddSingle(i32 %50, %struct.rangeElement* %10)
br label %63
63: ; preds = %59, %61, %46
%64 = phi %struct.rangeElement* [ %47, %46 ], [ %60, %59 ], [ %62, %61 ]
%65 = call i32 @memset(i8* %3, i32 0, i32 1024)
br label %66
66: ; preds = %21, %17, %63, %42
%67 = phi i32 [ %12, %17 ], [ 1, %42 ], [ 0, %63 ], [ %12, %21 ]
%68 = phi i32 [ %20, %17 ], [ 0, %42 ], [ 0, %63 ], [ %11, %21 ]
%69 = phi %struct.rangeElement* [ %10, %17 ], [ %10, %42 ], [ %64, %63 ], [ %10, %21 ]
%70 = phi i32 [ %9, %17 ], [ %36, %42 ], [ 0, %63 ], [ %9, %21 ]
%71 = add nuw nsw i64 %8, 1
%72 = call i32 @strlen(i8* %0)
%73 = sext i32 %72 to i64
%74 = icmp slt i64 %71, %73
br i1 %74, label %7, label %75
75: ; preds = %66
%76 = icmp eq i32 %68, 0
br i1 %76, label %77, label %81
77: ; preds = %1, %75
%78 = phi i32 [ %70, %75 ], [ 0, %1 ]
%79 = phi %struct.rangeElement* [ %69, %75 ], [ null, %1 ]
%80 = call %struct.rangeElement* @rangeAddGreaterEqual(i32 %78, %struct.rangeElement* %79)
br label %96
81: ; preds = %75
%82 = icmp sgt i32 %70, 0
%83 = call i32 @atoi(i8* %3)
br i1 %82, label %84, label %94
84: ; preds = %81
%85 = icmp slt i32 %83, 1
%86 = icmp sgt i32 %70, %83
%87 = select i1 %85, i1 true, i1 %86
br i1 %87, label %88, label %92
88: ; preds = %84
%89 = load i32, i32* @stderr
%90 = call i32 (i32, i8*, ...) @fprintf(i32 %89, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0), i8* %0)
%91 = call i32 @exit(i32 -1)
unreachable
92: ; preds = %84
%93 = call %struct.rangeElement* @rangeAddStartEnd(i32 %70, i32 %83, %struct.rangeElement* %69)
br label %96
94: ; preds = %81
%95 = call %struct.rangeElement* @rangeAddSingle(i32 %83, %struct.rangeElement* %69)
br label %96
96: ; preds = %92, %94, %77
%97 = phi %struct.rangeElement* [ %80, %77 ], [ %93, %92 ], [ %95, %94 ]
ret %struct.rangeElement* %97
}