#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*/ add_single_signal(int **, int *, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *);
int sscanf(char const *, char *, int *, int *, ...);
int /*<<< orphan*/ stderr;
void add_signal_range(int **signalSet, int *nbSignals, const char *s,
                      const char *e) {
  int i;
  int rangeSize;
  int rangeEnd = -1;
  int rangeStart = -1;
  int bytesMatched = -1;
  int expected = ((e - s) - 1);
  int itemsMatched =
      sscanf(s, "%d-%d%n", &rangeStart, &rangeEnd, &bytesMatched);
  if (2 == itemsMatched && expected == bytesMatched) {
    if (rangeEnd < rangeStart) {
      int t = rangeEnd;
      rangeEnd = rangeStart;
      rangeStart = t;
    }
  } else {
    itemsMatched = sscanf(s, "%d%n", &rangeStart, &bytesMatched);
    if (1 == itemsMatched && expected == bytesMatched) {
      if (0 <= rangeStart) {
        rangeEnd = rangeStart;
      }
    }
  }
  rangeSize = (rangeEnd - rangeStart);
  if (rangeEnd < 0 || rangeStart < 0 || rangeSize < 0) {
    fprintf(stderr,
            "incorrect signal range specification\"%s\" found in command line, "
            "aborting\n",
            s);
    exit(1);
  }
  for (i = rangeStart; i <= rangeEnd; ++i) {
    add_single_signal(signalSet, nbSignals, i);
  }
}


x86 assembly (clang, -O0):
<add_signal_range>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0xffffffff,-0x2c(%rbp)
movl   $0xffffffff,-0x30(%rbp)
movl   $0xffffffff,-0x34(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%rcx
sub    %rcx,%rax
sub    $0x1,%rax
mov    %eax,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe76(%rip),%rsi
lea    -0x30(%rbp),%rdx
lea    -0x2c(%rbp),%rcx
lea    -0x34(%rbp),%r8
mov    $0x0,%al
call   1040 <sscanf@plt>
mov    %eax,-0x3c(%rbp)
mov    $0x2,%eax
cmp    -0x3c(%rbp),%eax
jne    11dd <add_signal_range+0x9d>
mov    -0x38(%rbp),%eax
cmp    -0x34(%rbp),%eax
jne    11dd <add_signal_range+0x9d>
mov    -0x2c(%rbp),%eax
cmp    -0x30(%rbp),%eax
jge    11d8 <add_signal_range+0x98>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x40(%rbp)
mov    -0x30(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x40(%rbp),%eax
mov    %eax,-0x30(%rbp)
jmp    122f <add_signal_range+0xef>
mov    -0x18(%rbp),%rdi
lea    0xe1b(%rip),%rsi
lea    -0x30(%rbp),%rdx
lea    -0x34(%rbp),%rcx
mov    $0x0,%al
call   1040 <sscanf@plt>
mov    %eax,-0x3c(%rbp)
mov    $0x1,%eax
cmp    -0x3c(%rbp),%eax
jne    122a <add_signal_range+0xea>
mov    -0x38(%rbp),%eax
cmp    -0x34(%rbp),%eax
jne    122a <add_signal_range+0xea>
xor    %eax,%eax
cmp    -0x30(%rbp),%eax
jg     1225 <add_signal_range+0xe5>
mov    -0x30(%rbp),%eax
mov    %eax,-0x2c(%rbp)
jmp    122a <add_signal_range+0xea>
jmp    122f <add_signal_range+0xef>
mov    -0x2c(%rbp),%eax
sub    -0x30(%rbp),%eax
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jl     1256 <add_signal_range+0x116>
cmpl   $0x0,-0x30(%rbp)
jl     1256 <add_signal_range+0x116>
cmpl   $0x0,-0x28(%rbp)
jge    1279 <add_signal_range+0x139>
mov    0x2d83(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xd9e(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x30(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jg     12a9 <add_signal_range+0x169>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1050 <add_single_signal@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    127f <add_signal_range+0x13f>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<add_signal_range>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rcx,%r12
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%r13
movl   $0xffffffff,0x8(%rsp)
ff
movl   $0xffffffff,0x4(%rsp)
ff
movl   $0xffffffff,0xc(%rsp)
ff
mov    %r15d,%eax
not    %eax
add    %eax,%r12d
lea    0xe80(%rip),%rsi
lea    0x4(%rsp),%rdx
lea    0x8(%rsp),%rcx
lea    0xc(%rsp),%r8
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <sscanf@plt>
cmp    $0x2,%eax
jne    11bb <add_signal_range+0x7b>
cmp    %r12d,0xc(%rsp)
jne    11bb <add_signal_range+0x7b>
mov    0x8(%rsp),%ebx
mov    0x4(%rsp),%eax
cmp    %eax,%ebx
jge    11f0 <add_signal_range+0xb0>
mov    %eax,0x8(%rsp)
mov    %ebx,0x4(%rsp)
jmp    11f8 <add_signal_range+0xb8>
lea    0xe41(%rip),%rsi
lea    0x4(%rsp),%rdx
lea    0xc(%rsp),%rcx
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <sscanf@plt>
cmp    $0x1,%eax
jne    11f4 <add_signal_range+0xb4>
mov    0x4(%rsp),%ebx
cmp    %r12d,0xc(%rsp)
jne    11f8 <add_signal_range+0xb8>
test   %ebx,%ebx
js     11f8 <add_signal_range+0xb8>
mov    %ebx,0x8(%rsp)
jmp    11f8 <add_signal_range+0xb8>
mov    %eax,%ebx
jmp    11f8 <add_signal_range+0xb8>
mov    0x4(%rsp),%ebx
mov    0x8(%rsp),%eax
test   %eax,%eax
js     1236 <add_signal_range+0xf6>
test   %ebx,%ebx
js     1236 <add_signal_range+0xf6>
cmp    %ebx,%eax
jl     1236 <add_signal_range+0xf6>
nopl   0x0(%rax,%rax,1)
mov    %r13,%rdi
mov    %r14,%rsi
mov    %ebx,%edx
call   1050 <add_single_signal@plt>
lea    0x1(%rbx),%eax
cmp    0x8(%rsp),%ebx
mov    %eax,%ebx
jl     1210 <add_signal_range+0xd0>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
mov    0x2da3(%rip),%rax
mov    (%rax),%edi
lea    0xdc2(%rip),%rsi
mov    %r15,%rdx
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"%d-%d%n\00"
@.str.1 = [5 x i8] c"%d%n\00"
@stderr = global i32 0
@.str.2 = [74 x i8] c"incorrect signal range specification\22%s\22 found in command line, aborting\0A\00"
define void @add_signal_range(i32** %0, i32* %1, i8* %2, i8* %3) {
%5 = alloca i32**
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
store i32** %0, i32*** %5
store i32* %1, i32** %6
store i8* %2, i8** %7
store i8* %3, i8** %8
store i32 -1, i32* %11
store i32 -1, i32* %12
store i32 -1, i32* %13
%17 = load i8*, i8** %8
%18 = load i8*, i8** %7
%19 = ptrtoint i8* %17 to i64
%20 = ptrtoint i8* %18 to i64
%21 = sub i64 %19, %20
%22 = sub nsw i64 %21, 1
%23 = trunc i64 %22 to i32
store i32 %23, i32* %14
%24 = load i8*, i8** %7
%25 = call i32 (i8*, i8*, i32*, i32*, ...) @sscanf(i8* %24, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32* %12, i32* %11, i32* %13)
store i32 %25, i32* %15
%26 = load i32, i32* %15
%27 = icmp eq i32 2, %26
br i1 %27, label %28, label %41
28: ; preds = %4
%29 = load i32, i32* %14
%30 = load i32, i32* %13
%31 = icmp eq i32 %29, %30
br i1 %31, label %32, label %41
32: ; preds = %28
%33 = load i32, i32* %11
%34 = load i32, i32* %12
%35 = icmp slt i32 %33, %34
br i1 %35, label %36, label %40
36: ; preds = %32
%37 = load i32, i32* %11
store i32 %37, i32* %16
%38 = load i32, i32* %12
store i32 %38, i32* %11
%39 = load i32, i32* %16
store i32 %39, i32* %12
br label %40
40: ; preds = %36, %32
br label %57
41: ; preds = %28, %4
%42 = load i8*, i8** %7
%43 = call i32 (i8*, i8*, i32*, i32*, ...) @sscanf(i8* %42, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* %12, i32* %13)
store i32 %43, i32* %15
%44 = load i32, i32* %15
%45 = icmp eq i32 1, %44
br i1 %45, label %46, label %56
46: ; preds = %41
%47 = load i32, i32* %14
%48 = load i32, i32* %13
%49 = icmp eq i32 %47, %48
br i1 %49, label %50, label %56
50: ; preds = %46
%51 = load i32, i32* %12
%52 = icmp sle i32 0, %51
br i1 %52, label %53, label %55
53: ; preds = %50
%54 = load i32, i32* %12
store i32 %54, i32* %11
br label %55
55: ; preds = %53, %50
br label %56
56: ; preds = %55, %46, %41
br label %57
57: ; preds = %56, %40
%58 = load i32, i32* %11
%59 = load i32, i32* %12
%60 = sub nsw i32 %58, %59
store i32 %60, i32* %10
%61 = load i32, i32* %11
%62 = icmp slt i32 %61, 0
br i1 %62, label %69, label %63
63: ; preds = %57
%64 = load i32, i32* %12
%65 = icmp slt i32 %64, 0
br i1 %65, label %69, label %66
66: ; preds = %63
%67 = load i32, i32* %10
%68 = icmp slt i32 %67, 0
br i1 %68, label %69, label %74
69: ; preds = %66, %63, %57
%70 = load i32, i32* @stderr
%71 = load i8*, i8** %7
%72 = call i32 @fprintf(i32 %70, i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.2, i64 0, i64 0), i8* %71)
%73 = call i32 @exit(i32 1)
unreachable
74: ; preds = %66
%75 = load i32, i32* %12
store i32 %75, i32* %9
br label %76
76: ; preds = %85, %74
%77 = load i32, i32* %9
%78 = load i32, i32* %11
%79 = icmp sle i32 %77, %78
br i1 %79, label %80, label %88
80: ; preds = %76
%81 = load i32**, i32*** %5
%82 = load i32*, i32** %6
%83 = load i32, i32* %9
%84 = call i32 @add_single_signal(i32** %81, i32* %82, i32 %83)
br label %85
85: ; preds = %80
%86 = load i32, i32* %9
%87 = add nsw i32 %86, 1
store i32 %87, i32* %9
br label %76
88: ; preds = %76
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"%d-%d%n\00"
@.str.1 = [5 x i8] c"%d%n\00"
@stderr = global i32 0
@.str.2 = [74 x i8] c"incorrect signal range specification\22%s\22 found in command line, aborting\0A\00"
define void @add_signal_range(i32** %0, i32* %1, i8* %2, i8* %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = bitcast i32* %5 to i8*
store i32 -1, i32* %5
%9 = bitcast i32* %6 to i8*
store i32 -1, i32* %6
%10 = bitcast i32* %7 to i8*
store i32 -1, i32* %7
%11 = ptrtoint i8* %3 to i64
%12 = ptrtoint i8* %2 to i64
%13 = xor i64 %12, -1
%14 = add i64 %11, %13
%15 = trunc i64 %14 to i32
%16 = call i32 (i8*, i8*, i32*, i32*, ...) @sscanf(i8* %2, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32* %6, i32* %5, i32* %7)
%17 = icmp eq i32 %16, 2
%18 = load i32, i32* %7
%19 = icmp eq i32 %18, %15
%20 = select i1 %17, i1 %19, i1 false
br i1 %20, label %21, label %26
21: ; preds = %4
%22 = load i32, i32* %5
%23 = load i32, i32* %6
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %38
25: ; preds = %21
store i32 %23, i32* %5
store i32 %22, i32* %6
br label %38
26: ; preds = %4
%27 = call i32 (i8*, i8*, i32*, i32*, ...) @sscanf(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* %6, i32* %7)
%28 = icmp eq i32 %27, 1
br i1 %28, label %31, label %29
29: ; preds = %26
%30 = load i32, i32* %6
br label %38
31: ; preds = %26
%32 = load i32, i32* %7
%33 = icmp eq i32 %32, %15
%34 = load i32, i32* %6
%35 = icmp sgt i32 %34, -1
%36 = select i1 %33, i1 %35, i1 false
br i1 %36, label %37, label %38
37: ; preds = %31
store i32 %34, i32* %5
br label %38
38: ; preds = %29, %31, %37, %21, %25
%39 = phi i32 [ %30, %29 ], [ %34, %31 ], [ %34, %37 ], [ %23, %21 ], [ %22, %25 ]
%40 = load i32, i32* %5
%41 = icmp slt i32 %40, 0
%42 = icmp slt i32 %39, 0
%43 = select i1 %41, i1 true, i1 %42
%44 = icmp slt i32 %40, %39
%45 = select i1 %43, i1 true, i1 %44
br i1 %45, label %46, label %50
46: ; preds = %38
%47 = load i32, i32* @stderr
%48 = call i32 @fprintf(i32 %47, i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.2, i64 0, i64 0), i8* %2)
%49 = call i32 @exit(i32 1)
unreachable
50: ; preds = %38, %50
%51 = phi i32 [ %53, %50 ], [ %39, %38 ]
%52 = call i32 @add_single_signal(i32** %0, i32* %1, i32 %51)
%53 = add nsw i32 %51, 1
%54 = load i32, i32* %5
%55 = icmp slt i32 %51, %54
br i1 %55, label %50, label %56
56: ; preds = %50
ret void
}