#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 */
typedef int ssize_t;

/* Variables and functions */
int /*<<< orphan*/ error(int, int /*<<< orphan*/, char *, char *);
int sscanf(char *, char *, unsigned int *, unsigned int *, int *);
scalar_t__ strchr(char *, char);
char *rangeitem(char *range, unsigned *start, unsigned *length) {
  ssize_t skip;
  while (range && *range && strchr(",;", *range))
    range++;
  if (range == NULL || *range == '\0')
    return NULL;
  if (sscanf(range, "%u:%u%zn", start, length, &skip) < 2)
    error(1, 0, "Invalid ID range '%s'", range);
  return range + skip;
}


x86 assembly (clang, -O0):
<rangeitem>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x10(%rbp)
mov    %al,-0x25(%rbp)
je     1186 <rangeitem+0x56>
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x25(%rbp)
je     1186 <rangeitem+0x56>
mov    -0x10(%rbp),%rax
lea    0xe8c(%rip),%rdi
movsbl (%rax),%esi
call   1030 <strchr@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x25(%rbp)
mov    -0x25(%rbp),%al
test   $0x1,%al
jne    1196 <rangeitem+0x66>
jmp    11a7 <rangeitem+0x77>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1144 <rangeitem+0x14>
cmpq   $0x0,-0x10(%rbp)
je     11c2 <rangeitem+0x92>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    11cf <rangeitem+0x9f>
movq   $0x0,-0x8(%rbp)
jmp    121a <rangeitem+0xea>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
lea    0xe21(%rip),%rsi
lea    -0x24(%rbp),%r8
call   1040 <sscanf@plt>
cmp    $0x2,%eax
jge    120b <rangeitem+0xdb>
mov    -0x10(%rbp),%rcx
mov    $0x1,%edi
xor    %esi,%esi
lea    0xe06(%rip),%rdx
call   1050 <error@plt>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rangeitem>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %rdi,%rdi
je     11c2 <rangeitem+0x92>
mov    %rdi,%rbx
mov    (%rdi),%al
test   %al,%al
je     11c2 <rangeitem+0x92>
mov    %rdx,%r14
mov    %rsi,%r15
lea    0xea9(%rip),%r12
nopw   0x0(%rax,%rax,1)
movsbl %al,%esi
mov    %r12,%rdi
call   1030 <strchr@plt>
test   %rax,%rax
je     117e <rangeitem+0x4e>
movzbl 0x1(%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1160 <rangeitem+0x30>
jmp    11c2 <rangeitem+0x92>
cmpb   $0x0,(%rbx)
je     11c2 <rangeitem+0x92>
lea    0xe79(%rip),%rsi
lea    0x4(%rsp),%r8
mov    %rbx,%rdi
mov    %r15,%rdx
mov    %r14,%rcx
call   1040 <sscanf@plt>
cmp    $0x1,%eax
jg     11b8 <rangeitem+0x88>
lea    0xe63(%rip),%rdx
mov    $0x1,%edi
xor    %esi,%esi
mov    %rbx,%rcx
call   1050 <error@plt>
movslq 0x4(%rsp),%rax
add    %rax,%rbx
jmp    11c4 <rangeitem+0x94>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c",;\00"
@.str.1 = [9 x i8] c"%u:%u%zn\00"
@.str.2 = [22 x i8] c"Invalid ID range '%s'\00"
define i8* @rangeitem(i8* %0, i32* %1, i32* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32
store i8* %0, i8** %5
store i32* %1, i32** %6
store i32* %2, i32** %7
br label %9
9: ; preds = %24, %3
%10 = load i8*, i8** %5
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %22
12: ; preds = %9
%13 = load i8*, i8** %5
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %22
17: ; preds = %12
%18 = load i8*, i8** %5
%19 = load i8, i8* %18
%20 = call i64 @strchr(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %19)
%21 = icmp ne i64 %20, 0
br label %22
22: ; preds = %17, %12, %9
%23 = phi i1 [ false, %12 ], [ false, %9 ], [ %21, %17 ]
br i1 %23, label %24, label %27
24: ; preds = %22
%25 = load i8*, i8** %5
%26 = getelementptr inbounds i8, i8* %25, i32 1
store i8* %26, i8** %5
br label %9
27: ; preds = %22
%28 = load i8*, i8** %5
%29 = icmp eq i8* %28, null
br i1 %29, label %35, label %30
30: ; preds = %27
%31 = load i8*, i8** %5
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %36
35: ; preds = %30, %27
store i8* null, i8** %4
br label %50
36: ; preds = %30
%37 = load i8*, i8** %5
%38 = load i32*, i32** %6
%39 = load i32*, i32** %7
%40 = call i32 @sscanf(i8* %37, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32* %38, i32* %39, i32* %8)
%41 = icmp slt i32 %40, 2
br i1 %41, label %42, label %45
42: ; preds = %36
%43 = load i8*, i8** %5
%44 = call i32 @error(i32 1, i32 0, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %43)
br label %45
45: ; preds = %42, %36
%46 = load i8*, i8** %5
%47 = load i32, i32* %8
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i8, i8* %46, i64 %48
store i8* %49, i8** %4
br label %50
50: ; preds = %45, %35
%51 = load i8*, i8** %4
ret i8* %51
}

LLVM IR (-O2):
@.str = [3 x i8] c",;\00"
@.str.1 = [9 x i8] c"%u:%u%zn\00"
@.str.2 = [22 x i8] c"Invalid ID range '%s'\00"
define i8* @rangeitem(i8* %0, i32* %1, i32* %2) {
%4 = alloca i32
%5 = bitcast i32* %4 to i8*
%6 = icmp eq i8* %0, null
br i1 %6, label %31, label %7
7: ; preds = %3
%8 = load i8, i8* %0
%9 = icmp eq i8 %8, 0
br i1 %9, label %31, label %10
10: ; preds = %7, %15
%11 = phi i8 [ %17, %15 ], [ %8, %7 ]
%12 = phi i8* [ %16, %15 ], [ %0, %7 ]
%13 = tail call i64 @strchr(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %11)
%14 = icmp eq i64 %13, 0
br i1 %14, label %19, label %15
15: ; preds = %10
%16 = getelementptr inbounds i8, i8* %12, i64 1
%17 = load i8, i8* %16
%18 = icmp eq i8 %17, 0
br i1 %18, label %31, label %10
19: ; preds = %10
%20 = load i8, i8* %12
%21 = icmp eq i8 %20, 0
br i1 %21, label %31, label %22
22: ; preds = %19
%23 = call i32 @sscanf(i8* %12, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32* %2, i32* %4)
%24 = icmp slt i32 %23, 2
br i1 %24, label %25, label %27
25: ; preds = %22
%26 = call i32 @error(i32 1, i32 0, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %12)
br label %27
27: ; preds = %25, %22
%28 = load i32, i32* %4
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %12, i64 %29
br label %31
31: ; preds = %15, %7, %3, %19, %27
%32 = phi i8* [ %30, %27 ], [ null, %19 ], [ null, %3 ], [ null, %7 ], [ null, %15 ]
ret i8* %32
}