#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 cpuset_getrange(char const *, int *, int *);
char *cpuset_nexttok(char const *);
bool cpu_in_cpuset(int cpu, const char *cpuset) {
  const char *c;
  for (c = cpuset; c; c = cpuset_nexttok(c)) {
    int a, b, ret;
    ret = cpuset_getrange(c, &a, &b);
    if (ret == 1 && cpu == a)
      return true;
    else if (ret == 2 && cpu >= a && cpu <= b)
      return true;
  }
  return false;
}


x86 assembly (clang, -O0):
<cpu_in_cpuset>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11c2 <cpu_in_cpuset+0xa2>
mov    -0x18(%rbp),%rdi
lea    -0x1c(%rbp),%rsi
lea    -0x20(%rbp),%rdx
call   1030 <cpuset_getrange@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x1,-0x24(%rbp)
jne    1178 <cpu_in_cpuset+0x58>
mov    -0x8(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jne    1178 <cpu_in_cpuset+0x58>
movl   $0x1,-0x4(%rbp)
jmp    11c9 <cpu_in_cpuset+0xa9>
cmpl   $0x2,-0x24(%rbp)
jne    11a6 <cpu_in_cpuset+0x86>
mov    -0x8(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jl     11a6 <cpu_in_cpuset+0x86>
mov    -0x8(%rbp),%eax
cmp    -0x20(%rbp),%eax
jg     11a6 <cpu_in_cpuset+0x86>
movl   $0x1,-0x4(%rbp)
jmp    11c9 <cpu_in_cpuset+0xa9>
jmp    11ab <cpu_in_cpuset+0x8b>
jmp    11b0 <cpu_in_cpuset+0x90>
mov    -0x18(%rbp),%rdi
call   1040 <cpuset_nexttok@plt>
mov    %rax,-0x18(%rbp)
jmp    1137 <cpu_in_cpuset+0x17>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cpu_in_cpuset>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
xor    %r14d,%r14d
test   %rsi,%rsi
je     1190 <cpu_in_cpuset+0x70>
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xc(%rsp),%r15
lea    0x8(%rsp),%r12
jmp    1160 <cpu_in_cpuset+0x40>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
call   1040 <cpuset_nexttok@plt>
mov    %rax,%rbx
test   %rax,%rax
je     1190 <cpu_in_cpuset+0x70>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1030 <cpuset_getrange@plt>
mov    0xc(%rsp),%ecx
cmp    $0x1,%eax
jne    117b <cpu_in_cpuset+0x5b>
cmp    %ebp,%ecx
je     118a <cpu_in_cpuset+0x6a>
cmp    $0x2,%eax
jne    1150 <cpu_in_cpuset+0x30>
cmp    %ebp,%ecx
jg     1150 <cpu_in_cpuset+0x30>
cmp    %ebp,0x8(%rsp)
jl     1150 <cpu_in_cpuset+0x30>
mov    $0x1,%r14d
mov    %r14d,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @cpu_in_cpuset(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %4
store i8* %1, i8** %5
%10 = load i8*, i8** %5
store i8* %10, i8** %6
br label %11
11: ; preds = %38, %2
%12 = load i8*, i8** %6
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %41
14: ; preds = %11
%15 = load i8*, i8** %6
%16 = call i32 @cpuset_getrange(i8* %15, i32* %7, i32* %8)
store i32 %16, i32* %9
%17 = load i32, i32* %9
%18 = icmp eq i32 %17, 1
br i1 %18, label %19, label %24
19: ; preds = %14
%20 = load i32, i32* %4
%21 = load i32, i32* %7
%22 = icmp eq i32 %20, %21
br i1 %22, label %23, label %24
23: ; preds = %19
store i32 1, i32* %3
br label %42
24: ; preds = %19, %14
%25 = load i32, i32* %9
%26 = icmp eq i32 %25, 2
br i1 %26, label %27, label %36
27: ; preds = %24
%28 = load i32, i32* %4
%29 = load i32, i32* %7
%30 = icmp sge i32 %28, %29
br i1 %30, label %31, label %36
31: ; preds = %27
%32 = load i32, i32* %4
%33 = load i32, i32* %8
%34 = icmp sle i32 %32, %33
br i1 %34, label %35, label %36
35: ; preds = %31
store i32 1, i32* %3
br label %42
36: ; preds = %31, %27, %24
br label %37
37: ; preds = %36
br label %38
38: ; preds = %37
%39 = load i8*, i8** %6
%40 = call i8* @cpuset_nexttok(i8* %39)
store i8* %40, i8** %6
br label %11
41: ; preds = %11
store i32 0, i32* %3
br label %42
42: ; preds = %41, %35, %23
%43 = load i32, i32* %3
ret i32 %43
}

LLVM IR (-O2):
define i32 @cpu_in_cpuset(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = icmp eq i8* %1, null
br i1 %5, label %27, label %6
6: ; preds = %2
%7 = bitcast i32* %3 to i8*
%8 = bitcast i32* %4 to i8*
br label %9
9: ; preds = %6, %24
%10 = phi i8* [ %1, %6 ], [ %25, %24 ]
%11 = call i32 @cpuset_getrange(i8* %10, i32* %3, i32* %4)
%12 = icmp eq i32 %11, 1
%13 = load i32, i32* %3
%14 = icmp eq i32 %13, %0
%15 = select i1 %12, i1 %14, i1 false
br i1 %15, label %23, label %16
16: ; preds = %9
%17 = icmp ne i32 %11, 2
%18 = icmp sgt i32 %13, %0
%19 = select i1 %17, i1 true, i1 %18
%20 = load i32, i32* %4
%21 = icmp slt i32 %20, %0
%22 = select i1 %19, i1 true, i1 %21
br i1 %22, label %24, label %23
23: ; preds = %16, %9
br label %27
24: ; preds = %16
%25 = call i8* @cpuset_nexttok(i8* %10)
%26 = icmp eq i8* %25, null
br i1 %26, label %27, label %9
27: ; preds = %24, %2, %23
%28 = phi i32 [ 1, %23 ], [ 0, %2 ], [ 0, %24 ]
ret i32 %28
}