#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*/ _addRange(int *, int, int, int);
int atoi(char *);
char *index(char *, char);
int strlen(char *);
void addRange(int channels[], int cmax, char *range) {
  char *ranger;
  if ((ranger = index(range, '-')) != 0 || (ranger = index(range, ':')) != 0) {
    int len = strlen(range);
    *ranger = '\0';
    if (ranger == range) {
      if (len == 1) {
        _addRange(channels, cmax, 1, cmax);
      } else {
        _addRange(channels, cmax, 1, atoi(range + 1));
      }
    } else if (ranger == range + len - 1) {
      _addRange(channels, cmax, atoi(range), cmax);
    } else {
      _addRange(channels, cmax, atoi(range), atoi(ranger + 1));
    }
  } else {
    _addRange(channels, cmax, atoi(range), atoi(range));
  }
}


x86 assembly (clang, -O0):
<addRange>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x2d,%esi
call   1040 <index@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    118b <addRange+0x4b>
mov    -0x18(%rbp),%rdi
mov    $0x3a,%esi
call   1040 <index@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     128d <addRange+0x14d>
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
jne    1202 <addRange+0xc2>
cmpl   $0x1,-0x24(%rbp)
jne    11cf <addRange+0x8f>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0xc(%rbp),%ecx
mov    $0x1,%edx
call   1050 <_addRange@plt>
jmp    11fd <addRange+0xbd>
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
add    $0x1,%rdi
call   1060 <atoi@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%esi
mov    %eax,%ecx
mov    $0x1,%edx
call   1050 <_addRange@plt>
jmp    1288 <addRange+0x148>
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%rcx
movslq -0x24(%rbp),%rdx
add    %rdx,%rcx
add    $0xffffffffffffffff,%rcx
cmp    %rcx,%rax
jne    124b <addRange+0x10b>
mov    -0x8(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <atoi@plt>
mov    -0x40(%rbp),%rdi
mov    -0x34(%rbp),%esi
mov    %eax,%edx
mov    -0xc(%rbp),%ecx
call   1050 <_addRange@plt>
jmp    1283 <addRange+0x143>
mov    -0x8(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x48(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x44(%rbp)
mov    -0x20(%rbp),%rdi
add    $0x1,%rdi
call   1060 <atoi@plt>
mov    -0x50(%rbp),%rdi
mov    -0x48(%rbp),%esi
mov    -0x44(%rbp),%edx
mov    %eax,%ecx
call   1050 <_addRange@plt>
jmp    1288 <addRange+0x148>
jmp    12c1 <addRange+0x181>
mov    -0x8(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x58(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x54(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <atoi@plt>
mov    -0x60(%rbp),%rdi
mov    -0x58(%rbp),%esi
mov    -0x54(%rbp),%edx
mov    %eax,%ecx
call   1050 <_addRange@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<addRange>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdx,%rbx
mov    %esi,%r15d
mov    %rdi,%r14
mov    %rdx,%rdi
mov    $0x2d,%esi
call   1040 <index@plt>
mov    %rax,%rbp
test   %rax,%rax
jne    117b <addRange+0x3b>
mov    %rbx,%rdi
mov    $0x3a,%esi
call   1040 <index@plt>
mov    %rax,%rbp
test   %rax,%rax
je     11f3 <addRange+0xb3>
mov    %rbx,%rdi
call   1030 <strlen@plt>
movb   $0x0,0x0(%rbp)
cmp    %rbx,%rbp
je     11bb <addRange+0x7b>
cltq
lea    (%rbx,%rax,1),%r12
add    $0xffffffffffffffff,%r12
mov    %rbx,%rdi
call   1060 <atoi@plt>
mov    %eax,%ebx
cmp    %r12,%rbp
je     11cd <addRange+0x8d>
add    $0x1,%rbp
mov    %rbp,%rdi
call   1060 <atoi@plt>
mov    %r14,%rdi
mov    %r15d,%esi
mov    %ebx,%edx
jmp    1203 <addRange+0xc3>
cmp    $0x1,%eax
jne    11da <addRange+0x9a>
mov    %r14,%rdi
mov    %r15d,%esi
mov    $0x1,%edx
jmp    11d5 <addRange+0x95>
mov    %r14,%rdi
mov    %r15d,%esi
mov    %ebx,%edx
mov    %r15d,%ecx
jmp    1205 <addRange+0xc5>
add    $0x1,%rbx
mov    %rbx,%rdi
call   1060 <atoi@plt>
mov    %r14,%rdi
mov    %r15d,%esi
mov    $0x1,%edx
jmp    1203 <addRange+0xc3>
mov    %rbx,%rdi
call   1060 <atoi@plt>
mov    %r14,%rdi
mov    %r15d,%esi
mov    %eax,%edx
mov    %eax,%ecx
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <_addRange@plt>

LLVM IR (-O0):
define void @addRange(i32* %0, i32 %1, i8* %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
store i8* %2, i8** %6
%9 = load i8*, i8** %6
%10 = call i8* @index(i8* %9, i8 signext 45)
store i8* %10, i8** %7
%11 = icmp ne i8* %10, null
br i1 %11, label %16, label %12
12: ; preds = %3
%13 = load i8*, i8** %6
%14 = call i8* @index(i8* %13, i8 signext 58)
store i8* %14, i8** %7
%15 = icmp ne i8* %14, null
br i1 %15, label %16, label %65
16: ; preds = %12, %3
%17 = load i8*, i8** %6
%18 = call i32 @strlen(i8* %17)
store i32 %18, i32* %8
%19 = load i8*, i8** %7
store i8 0, i8* %19
%20 = load i8*, i8** %7
%21 = load i8*, i8** %6
%22 = icmp eq i8* %20, %21
br i1 %22, label %23, label %39
23: ; preds = %16
%24 = load i32, i32* %8
%25 = icmp eq i32 %24, 1
br i1 %25, label %26, label %31
26: ; preds = %23
%27 = load i32*, i32** %4
%28 = load i32, i32* %5
%29 = load i32, i32* %5
%30 = call i32 @_addRange(i32* %27, i32 %28, i32 1, i32 %29)
br label %38
31: ; preds = %23
%32 = load i32*, i32** %4
%33 = load i32, i32* %5
%34 = load i8*, i8** %6
%35 = getelementptr inbounds i8, i8* %34, i64 1
%36 = call i32 @atoi(i8* %35)
%37 = call i32 @_addRange(i32* %32, i32 %33, i32 1, i32 %36)
br label %38
38: ; preds = %31, %26
br label %64
39: ; preds = %16
%40 = load i8*, i8** %7
%41 = load i8*, i8** %6
%42 = load i32, i32* %8
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8, i8* %41, i64 %43
%45 = getelementptr inbounds i8, i8* %44, i64 -1
%46 = icmp eq i8* %40, %45
br i1 %46, label %47, label %54
47: ; preds = %39
%48 = load i32*, i32** %4
%49 = load i32, i32* %5
%50 = load i8*, i8** %6
%51 = call i32 @atoi(i8* %50)
%52 = load i32, i32* %5
%53 = call i32 @_addRange(i32* %48, i32 %49, i32 %51, i32 %52)
br label %63
54: ; preds = %39
%55 = load i32*, i32** %4
%56 = load i32, i32* %5
%57 = load i8*, i8** %6
%58 = call i32 @atoi(i8* %57)
%59 = load i8*, i8** %7
%60 = getelementptr inbounds i8, i8* %59, i64 1
%61 = call i32 @atoi(i8* %60)
%62 = call i32 @_addRange(i32* %55, i32 %56, i32 %58, i32 %61)
br label %63
63: ; preds = %54, %47
br label %64
64: ; preds = %63, %38
br label %73
65: ; preds = %12
%66 = load i32*, i32** %4
%67 = load i32, i32* %5
%68 = load i8*, i8** %6
%69 = call i32 @atoi(i8* %68)
%70 = load i8*, i8** %6
%71 = call i32 @atoi(i8* %70)
%72 = call i32 @_addRange(i32* %66, i32 %67, i32 %69, i32 %71)
br label %73
73: ; preds = %65, %64
ret void
}

LLVM IR (-O2):
define void @addRange(i32* %0, i32 %1, i8* %2) {
%4 = tail call i8* @index(i8* %2, i8 signext 45)
%5 = icmp eq i8* %4, null
br i1 %5, label %6, label %9
6: ; preds = %3
%7 = tail call i8* @index(i8* %2, i8 signext 58)
%8 = icmp eq i8* %7, null
br i1 %8, label %33, label %9
9: ; preds = %6, %3
%10 = phi i8* [ %4, %3 ], [ %7, %6 ]
%11 = tail call i32 @strlen(i8* %2)
store i8 0, i8* %10
%12 = icmp eq i8* %10, %2
br i1 %12, label %13, label %21
13: ; preds = %9
%14 = icmp eq i32 %11, 1
br i1 %14, label %15, label %17
15: ; preds = %13
%16 = tail call i32 @_addRange(i32* %0, i32 %1, i32 1, i32 %1)
br label %36
17: ; preds = %13
%18 = getelementptr inbounds i8, i8* %2, i64 1
%19 = tail call i32 @atoi(i8* %18)
%20 = tail call i32 @_addRange(i32* %0, i32 %1, i32 1, i32 %19)
br label %36
21: ; preds = %9
%22 = sext i32 %11 to i64
%23 = getelementptr inbounds i8, i8* %2, i64 %22
%24 = getelementptr inbounds i8, i8* %23, i64 -1
%25 = icmp eq i8* %10, %24
%26 = tail call i32 @atoi(i8* %2)
br i1 %25, label %27, label %29
27: ; preds = %21
%28 = tail call i32 @_addRange(i32* %0, i32 %1, i32 %26, i32 %1)
br label %36
29: ; preds = %21
%30 = getelementptr inbounds i8, i8* %10, i64 1
%31 = tail call i32 @atoi(i8* %30)
%32 = tail call i32 @_addRange(i32* %0, i32 %1, i32 %26, i32 %31)
br label %36
33: ; preds = %6
%34 = tail call i32 @atoi(i8* %2)
%35 = tail call i32 @_addRange(i32* %0, i32 %1, i32 %34, i32 %34)
br label %36
36: ; preds = %17, %15, %29, %27, %33
ret void
}