#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_cpu(unsigned int);
int /*<<< orphan*/ die(char *);
char *skip_space_and_test_digit(char const *, char const *);
unsigned int strtoul(char const *, char **, int);
void parse_cpulist(const char *cpu_str) {
  unsigned a, b;
  const char *s = cpu_str;
  do {
    s = skip_space_and_test_digit(s, cpu_str);
    b = a = strtoul(s, (char **)&s, 10);
    if (*s == '-') {
      s = skip_space_and_test_digit(s + 1, cpu_str);
      b = strtoul(s, (char **)&s, 10);
    }
    if (!(a <= b))
      die("range of cpu numbers must be lower to greater");
    while (a <= b) {
      __add_cpu(a);
      a++;
    }
    if (*s == ',' || *s == ':')
      s++;
  } while (*s != '\0');
}


x86 assembly (clang, -O0):
<parse_cpulist>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1040 <skip_space_and_test_digit@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    -0x18(%rbp),%rsi
mov    $0xa,%edx
call   1060 <strtoul@plt>
mov    %eax,-0xc(%rbp)
mov    %eax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    11b7 <parse_cpulist+0x77>
mov    -0x18(%rbp),%rdi
add    $0x1,%rdi
mov    -0x8(%rbp),%rsi
call   1040 <skip_space_and_test_digit@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    -0x18(%rbp),%rsi
mov    $0xa,%edx
call   1060 <strtoul@plt>
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jbe    11cf <parse_cpulist+0x8f>
lea    0xe36(%rip),%rdi
call   1050 <die@plt>
jmp    11d4 <parse_cpulist+0x94>
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
ja     11f6 <parse_cpulist+0xb6>
mov    -0xc(%rbp),%edi
call   1030 <__add_cpu@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11d4 <parse_cpulist+0x94>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2c,%eax
je     1216 <parse_cpulist+0xd6>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3a,%eax
jne    1222 <parse_cpulist+0xe2>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1227 <parse_cpulist+0xe7>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1154 <parse_cpulist+0x14>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_cpulist>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%r12
lea    0x8(%rsp),%r14
lea    0xea5(%rip),%r15
jmp    1178 <parse_cpulist+0x38>
nopl   (%rax)
lea    0x1(%rdi),%rcx
mov    %rcx,0x8(%rsp)
movzbl 0x1(%rdi),%eax
mov    %rcx,%rdi
test   %al,%al
je     120b <parse_cpulist+0xcb>
mov    %r12,%rsi
call   1040 <skip_space_and_test_digit@plt>
mov    %rax,0x8(%rsp)
mov    %rax,%rdi
mov    %r14,%rsi
mov    $0xa,%edx
call   1060 <strtoul@plt>
mov    %eax,%ebp
mov    0x8(%rsp),%rdi
cmpb   $0x2d,(%rdi)
mov    %eax,%ebx
jne    11e0 <parse_cpulist+0xa0>
add    $0x1,%rdi
mov    %r12,%rsi
call   1040 <skip_space_and_test_digit@plt>
mov    %rax,0x8(%rsp)
mov    %rax,%rdi
mov    %r14,%rsi
mov    $0xa,%edx
call   1060 <strtoul@plt>
mov    %eax,%ebx
cmp    %eax,%ebp
jbe    11ea <parse_cpulist+0xaa>
mov    %r15,%rdi
call   1050 <die@plt>
jmp    11ea <parse_cpulist+0xaa>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %ebp,%edi
call   1030 <__add_cpu@plt>
add    $0x1,%ebp
cmp    %ebx,%ebp
jbe    11e0 <parse_cpulist+0xa0>
mov    0x8(%rsp),%rdi
movzbl (%rdi),%eax
cmp    $0x3a,%al
je     1160 <parse_cpulist+0x20>
cmp    $0x2c,%al
je     1160 <parse_cpulist+0x20>
jmp    1170 <parse_cpulist+0x30>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [46 x i8] c"range of cpu numbers must be lower to greater\00"
define void @parse_cpulist(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
store i8* %0, i8** %2
%6 = load i8*, i8** %2
store i8* %6, i8** %5
br label %7
7: ; preds = %54, %1
%8 = load i8*, i8** %5
%9 = load i8*, i8** %2
%10 = call i8* @skip_space_and_test_digit(i8* %8, i8* %9)
store i8* %10, i8** %5
%11 = load i8*, i8** %5
%12 = call i32 @strtoul(i8* %11, i8** %5, i32 10)
store i32 %12, i32* %3
store i32 %12, i32* %4
%13 = load i8*, i8** %5
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 45
br i1 %16, label %17, label %24
17: ; preds = %7
%18 = load i8*, i8** %5
%19 = getelementptr inbounds i8, i8* %18, i64 1
%20 = load i8*, i8** %2
%21 = call i8* @skip_space_and_test_digit(i8* %19, i8* %20)
store i8* %21, i8** %5
%22 = load i8*, i8** %5
%23 = call i32 @strtoul(i8* %22, i8** %5, i32 10)
store i32 %23, i32* %4
br label %24
24: ; preds = %17, %7
%25 = load i32, i32* %3
%26 = load i32, i32* %4
%27 = icmp ule i32 %25, %26
br i1 %27, label %30, label %28
28: ; preds = %24
%29 = call i32 @die(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
br label %30
30: ; preds = %28, %24
br label %31
31: ; preds = %35, %30
%32 = load i32, i32* %3
%33 = load i32, i32* %4
%34 = icmp ule i32 %32, %33
br i1 %34, label %35, label %40
35: ; preds = %31
%36 = load i32, i32* %3
%37 = call i32 @__add_cpu(i32 %36)
%38 = load i32, i32* %3
%39 = add i32 %38, 1
store i32 %39, i32* %3
br label %31
40: ; preds = %31
%41 = load i8*, i8** %5
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = icmp eq i32 %43, 44
br i1 %44, label %50, label %45
45: ; preds = %40
%46 = load i8*, i8** %5
%47 = load i8, i8* %46
%48 = sext i8 %47 to i32
%49 = icmp eq i32 %48, 58
br i1 %49, label %50, label %53
50: ; preds = %45, %40
%51 = load i8*, i8** %5
%52 = getelementptr inbounds i8, i8* %51, i32 1
store i8* %52, i8** %5
br label %53
53: ; preds = %50, %45
br label %54
54: ; preds = %53
%55 = load i8*, i8** %5
%56 = load i8, i8* %55
%57 = sext i8 %56 to i32
%58 = icmp ne i32 %57, 0
br i1 %58, label %7, label %59
59: ; preds = %54
ret void
}

LLVM IR (-O2):
@.str = [46 x i8] c"range of cpu numbers must be lower to greater\00"
define void @parse_cpulist(i8* %0) {
%2 = alloca i8*
%3 = bitcast i8** %2 to i8*
br label %4
4: ; preds = %33, %1
%5 = phi i8* [ %35, %33 ], [ %0, %1 ]
%6 = tail call i8* @skip_space_and_test_digit(i8* %5, i8* %0)
store i8* %6, i8** %2
%7 = call i32 @strtoul(i8* %6, i8** %2, i32 10)
%8 = load i8*, i8** %2
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 45
br i1 %10, label %11, label %20
11: ; preds = %4
%12 = getelementptr inbounds i8, i8* %8, i64 1
%13 = tail call i8* @skip_space_and_test_digit(i8* %12, i8* %0)
store i8* %13, i8** %2
%14 = call i32 @strtoul(i8* %13, i8** %2, i32 10)
%15 = icmp ugt i32 %7, %14
br i1 %15, label %16, label %18
16: ; preds = %11
%17 = tail call i32 @die(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
br label %18
18: ; preds = %16, %11
%19 = icmp ugt i32 %7, %14
br i1 %19, label %27, label %20
20: ; preds = %4, %18
%21 = phi i32 [ %14, %18 ], [ %7, %4 ]
br label %22
22: ; preds = %20, %22
%23 = phi i32 [ %25, %22 ], [ %7, %20 ]
%24 = tail call i32 @__add_cpu(i32 %23)
%25 = add i32 %23, 1
%26 = icmp ugt i32 %25, %21
br i1 %26, label %27, label %22
27: ; preds = %22, %18
%28 = load i8*, i8** %2
%29 = load i8, i8* %28
switch i8 %29, label %33 [
i8 44, label %30
i8 58, label %30
]
30: ; preds = %27, %27
%31 = getelementptr inbounds i8, i8* %28, i64 1
store i8* %31, i8** %2
%32 = load i8, i8* %31
br label %33
33: ; preds = %27, %30
%34 = phi i8 [ %29, %27 ], [ %32, %30 ]
%35 = phi i8* [ %28, %27 ], [ %31, %30 ]
%36 = icmp eq i8 %34, 0
br i1 %36, label %37, label %4
37: ; preds = %33
ret void
}