#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 /*<<< orphan*/ cpu_set_t;

/* Variables and functions */
scalar_t__ CPU_ISSET_S(int, int, int /*<<< orphan*/ const *);
int /*<<< orphan*/ printf(char *, char const *, int, ...);
void print_cpu_list(const cpu_set_t *cpuset, int cpuset_size,
                    int cpus_in_system) {
  int core;
  const char *comma = "";
  for (core = 0; core < cpus_in_system; core++) {
    int begin = core;
    if (CPU_ISSET_S(core, cpuset_size, cpuset)) {
      while (CPU_ISSET_S(core + 1, cpuset_size, cpuset))
        core++;
      if (core > begin)
        printf("%s%d-%d", comma, begin, core);
      else
        printf("%s%d", comma, core);
      comma = ",";
    }
  }
}


x86 assembly (clang, -O0):
<print_cpu_list>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
lea    0xed5(%rip),%rax
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11fa <print_cpu_list+0xda>
mov    -0x14(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x14(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x8(%rbp),%rdx
call   1040 <CPU_ISSET_S@plt>
cmp    $0x0,%rax
je     11e7 <print_cpu_list+0xc7>
jmp    1174 <print_cpu_list+0x54>
mov    -0x14(%rbp),%edi
add    $0x1,%edi
mov    -0xc(%rbp),%esi
mov    -0x8(%rbp),%rdx
call   1040 <CPU_ISSET_S@plt>
cmp    $0x0,%rax
je     119e <print_cpu_list+0x7e>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1174 <print_cpu_list+0x54>
mov    -0x14(%rbp),%eax
cmp    -0x24(%rbp),%eax
jle    11c7 <print_cpu_list+0xa7>
mov    -0x20(%rbp),%rsi
mov    -0x24(%rbp),%edx
mov    -0x14(%rbp),%ecx
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11dc <print_cpu_list+0xbc>
mov    -0x20(%rbp),%rsi
mov    -0x14(%rbp),%edx
lea    0xe33(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe2a(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    11ec <print_cpu_list+0xcc>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1144 <print_cpu_list+0x24>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_cpu_list>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %edx,%edx
jle    11df <print_cpu_list+0xbf>
mov    %edx,%r14d
mov    %esi,%ebp
mov    %rdi,%rbx
lea    0xecc(%rip),%r13
xor    %r12d,%r12d
jmp    1163 <print_cpu_list+0x43>
nopw   0x0(%rax,%rax,1)
add    $0x1,%r12d
mov    %r12d,%r15d
mov    %r15d,%r12d
cmp    %r14d,%r15d
jge    11df <print_cpu_list+0xbf>
mov    %r12d,%edi
mov    %ebp,%esi
mov    %rbx,%rdx
call   1040 <CPU_ISSET_S@plt>
mov    %r12d,%r15d
test   %rax,%rax
je     1150 <print_cpu_list+0x30>
nopl   0x0(%rax,%rax,1)
add    $0x1,%r15d
mov    %r15d,%edi
mov    %ebp,%esi
mov    %rbx,%rdx
call   1040 <CPU_ISSET_S@plt>
test   %rax,%rax
jne    1180 <print_cpu_list+0x60>
lea    -0x1(%r15),%ecx
cmp    %r12d,%ecx
jle    11c0 <print_cpu_list+0xa0>
lea    0xe5a(%rip),%rdi
mov    %r13,%rsi
mov    %r12d,%edx
xor    %eax,%eax
call   1030 <printf@plt>
jmp    11d3 <print_cpu_list+0xb3>
cs nopw 0x0(%rax,%rax,1)
nop
lea    0xe41(%rip),%rdi
mov    %r13,%rsi
mov    %ecx,%edx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe33(%rip),%r13
jmp    1157 <print_cpu_list+0x37>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@.str.1 = [8 x i8] c"%s%d-%d\00"
@.str.2 = [5 x i8] c"%s%d\00"
@.str.3 = [2 x i8] c",\00"
define void @print_cpu_list(i32* %0, i32 %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %8
store i32 0, i32* %7
br label %10
10: ; preds = %47, %3
%11 = load i32, i32* %7
%12 = load i32, i32* %6
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %50
14: ; preds = %10
%15 = load i32, i32* %7
store i32 %15, i32* %9
%16 = load i32, i32* %7
%17 = load i32, i32* %5
%18 = load i32*, i32** %4
%19 = call i64 @CPU_ISSET_S(i32 %16, i32 %17, i32* %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %46
21: ; preds = %14
br label %22
22: ; preds = %29, %21
%23 = load i32, i32* %7
%24 = add nsw i32 %23, 1
%25 = load i32, i32* %5
%26 = load i32*, i32** %4
%27 = call i64 @CPU_ISSET_S(i32 %24, i32 %25, i32* %26)
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %22
%30 = load i32, i32* %7
%31 = add nsw i32 %30, 1
store i32 %31, i32* %7
br label %22
32: ; preds = %22
%33 = load i32, i32* %7
%34 = load i32, i32* %9
%35 = icmp sgt i32 %33, %34
br i1 %35, label %36, label %41
36: ; preds = %32
%37 = load i8*, i8** %8
%38 = load i32, i32* %9
%39 = load i32, i32* %7
%40 = call i32 (i8*, i8*, i32, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %37, i32 %38, i32 %39)
br label %45
41: ; preds = %32
%42 = load i8*, i8** %8
%43 = load i32, i32* %7
%44 = call i32 (i8*, i8*, i32, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %42, i32 %43)
br label %45
45: ; preds = %41, %36
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8** %8
br label %46
46: ; preds = %45, %14
br label %47
47: ; preds = %46
%48 = load i32, i32* %7
%49 = add nsw i32 %48, 1
store i32 %49, i32* %7
br label %10
50: ; preds = %10
ret void
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@.str.1 = [8 x i8] c"%s%d-%d\00"
@.str.2 = [5 x i8] c"%s%d\00"
@.str.3 = [2 x i8] c",\00"
define void @print_cpu_list(i32* %0, i32 %1, i32 %2) {
%4 = icmp sgt i32 %2, 0
br i1 %4, label %5, label %27
5: ; preds = %3, %23
%6 = phi i32 [ %24, %23 ], [ 0, %3 ]
%7 = phi i8* [ %25, %23 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), %3 ]
%8 = tail call i64 @CPU_ISSET_S(i32 %6, i32 %1, i32* %0)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %5
%11 = add nsw i32 %6, 1
br label %23
12: ; preds = %5, %12
%13 = phi i32 [ %14, %12 ], [ %6, %5 ]
%14 = add nsw i32 %13, 1
%15 = tail call i64 @CPU_ISSET_S(i32 %14, i32 %1, i32* %0)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %12
17: ; preds = %12
%18 = icmp sgt i32 %13, %6
br i1 %18, label %19, label %21
19: ; preds = %17
%20 = tail call i32 (i8*, i8*, i32, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %7, i32 %6, i32 %13)
br label %23
21: ; preds = %17
%22 = tail call i32 (i8*, i8*, i32, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %7, i32 %13)
br label %23
23: ; preds = %10, %19, %21
%24 = phi i32 [ %11, %10 ], [ %14, %19 ], [ %14, %21 ]
%25 = phi i8* [ %7, %10 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), %19 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), %21 ]
%26 = icmp slt i32 %24, %2
br i1 %26, label %5, label %27
27: ; preds = %23, %3
ret void
}