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

/* Variables and functions */
int /*<<< orphan*/ assert(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, ...);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ hwloc_bitmap_alloc();
int /*<<< orphan*/ hwloc_bitmap_asprintf(char **, int /*<<< orphan*/);
int /*<<< orphan*/ hwloc_bitmap_free(int /*<<< orphan*/);
int /*<<< orphan*/ hwloc_bitmap_isequal(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ hwloc_bitmap_list_asprintf(char **, int /*<<< orphan*/);
int /*<<< orphan*/ hwloc_bitmap_list_sscanf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ hwloc_bitmap_sscanf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ hwloc_bitmap_taskset_asprintf(char **, int /*<<< orphan*/);
int /*<<< orphan*/ hwloc_bitmap_taskset_sscanf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char const *);
void check_cpuset(hwloc_bitmap_t set, const char *expected1,
                  const char *expected2, const char *expected3) {
  hwloc_bitmap_t set2 = hwloc_bitmap_alloc();
  char *string = NULL;
  hwloc_bitmap_asprintf(&string, set);
  fprintf(stderr, "exported to %s\n", string);
  if (expected1 && strcmp(string, expected1)) {
    fprintf(stderr, "got %s instead of %s\n", string, expected1);
    assert(0);
  }
  hwloc_bitmap_sscanf(set2, string);
  free(string);
  assert(hwloc_bitmap_isequal(set, set2));
  hwloc_bitmap_list_asprintf(&string, set);
  fprintf(stderr, "exported to list %s\n", string);
  if (expected2 && strcmp(string, expected2)) {
    fprintf(stderr, "got %s instead of %s\n", string, expected2);
    assert(0);
  }
  hwloc_bitmap_list_sscanf(set2, string);
  free(string);
  assert(hwloc_bitmap_isequal(set, set2));
  hwloc_bitmap_taskset_asprintf(&string, set);
  fprintf(stderr, "exported to taskset %s\n", string);
  if (expected3 && strcmp(string, expected3)) {
    fprintf(stderr, "got %s instead of %s\n", string, expected3);
    assert(0);
  }
  hwloc_bitmap_taskset_sscanf(set2, string);
  free(string);
  assert(hwloc_bitmap_isequal(set, set2));
  hwloc_bitmap_free(set2);
}


x86 assembly (clang, -O0):
<check_cpuset>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    $0x0,%al
call   1030 <hwloc_bitmap_alloc@plt>
mov    %eax,-0x24(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x4(%rbp),%esi
lea    -0x30(%rbp),%rdi
call   1060 <hwloc_bitmap_asprintf@plt>
mov    0x2dd4(%rip),%rax
mov    (%rax),%edi
mov    -0x30(%rbp),%rdx
lea    0xde7(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
cmpq   $0x0,-0x10(%rbp)
je     1268 <check_cpuset+0x98>
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
je     1268 <check_cpuset+0x98>
mov    0x2d97(%rip),%rax
mov    (%rax),%edi
mov    -0x30(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    0xdb6(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
xor    %edi,%edi
call   1090 <assert@plt>
mov    -0x24(%rbp),%edi
mov    -0x30(%rbp),%rsi
call   10d0 <hwloc_bitmap_sscanf@plt>
mov    -0x30(%rbp),%rdi
call   1040 <free@plt>
mov    -0x4(%rbp),%edi
mov    -0x24(%rbp),%esi
call   10c0 <hwloc_bitmap_isequal@plt>
mov    %eax,%edi
call   1090 <assert@plt>
mov    -0x4(%rbp),%esi
lea    -0x30(%rbp),%rdi
call   10e0 <hwloc_bitmap_list_asprintf@plt>
mov    0x2d3e(%rip),%rax
mov    (%rax),%edi
mov    -0x30(%rbp),%rdx
lea    0xd77(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
cmpq   $0x0,-0x18(%rbp)
je     12fe <check_cpuset+0x12e>
mov    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
je     12fe <check_cpuset+0x12e>
mov    0x2d01(%rip),%rax
mov    (%rax),%edi
mov    -0x30(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0xd20(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
xor    %edi,%edi
call   1090 <assert@plt>
mov    -0x24(%rbp),%edi
mov    -0x30(%rbp),%rsi
call   10f0 <hwloc_bitmap_list_sscanf@plt>
mov    -0x30(%rbp),%rdi
call   1040 <free@plt>
mov    -0x4(%rbp),%edi
mov    -0x24(%rbp),%esi
call   10c0 <hwloc_bitmap_isequal@plt>
mov    %eax,%edi
call   1090 <assert@plt>
mov    -0x4(%rbp),%esi
lea    -0x30(%rbp),%rdi
call   1070 <hwloc_bitmap_taskset_asprintf@plt>
mov    0x2ca8(%rip),%rax
mov    (%rax),%edi
mov    -0x30(%rbp),%rdx
lea    0xcf6(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
cmpq   $0x0,-0x20(%rbp)
je     1394 <check_cpuset+0x1c4>
mov    -0x30(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
je     1394 <check_cpuset+0x1c4>
mov    0x2c6b(%rip),%rax
mov    (%rax),%edi
mov    -0x30(%rbp),%rdx
mov    -0x20(%rbp),%rcx
lea    0xc8a(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
xor    %edi,%edi
call   1090 <assert@plt>
mov    -0x24(%rbp),%edi
mov    -0x30(%rbp),%rsi
call   10b0 <hwloc_bitmap_taskset_sscanf@plt>
mov    -0x30(%rbp),%rdi
call   1040 <free@plt>
mov    -0x4(%rbp),%edi
mov    -0x24(%rbp),%esi
call   10c0 <hwloc_bitmap_isequal@plt>
mov    %eax,%edi
call   1090 <assert@plt>
mov    -0x24(%rbp),%edi
call   1050 <hwloc_bitmap_free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_cpuset>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%rbp
mov    %edi,%r12d
xor    %eax,%eax
call   1030 <hwloc_bitmap_alloc@plt>
mov    %eax,%ebx
movq   $0x0,(%rsp)
mov    %rsp,%rdi
mov    %r12d,%esi
call   1060 <hwloc_bitmap_asprintf@plt>
mov    0x2dd6(%rip),%r13
mov    0x0(%r13),%edi
mov    (%rsp),%rdx
lea    0xde7(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
test   %rbp,%rbp
je     1256 <check_cpuset+0x86>
mov    (%rsp),%rdi
mov    %rbp,%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     1256 <check_cpuset+0x86>
mov    0x0(%r13),%edi
mov    (%rsp),%rdx
lea    0xdcb(%rip),%rsi
mov    %rbp,%rcx
xor    %eax,%eax
call   10a0 <fprintf@plt>
xor    %edi,%edi
call   1090 <assert@plt>
mov    (%rsp),%rsi
mov    %ebx,%edi
call   10d0 <hwloc_bitmap_sscanf@plt>
mov    (%rsp),%rdi
call   1040 <free@plt>
mov    %r12d,%edi
mov    %ebx,%esi
call   10c0 <hwloc_bitmap_isequal@plt>
mov    %eax,%edi
call   1090 <assert@plt>
mov    %rsp,%rdi
mov    %r12d,%esi
call   10e0 <hwloc_bitmap_list_asprintf@plt>
mov    0x0(%r13),%edi
mov    (%rsp),%rdx
lea    0xd91(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
test   %r15,%r15
je     12d2 <check_cpuset+0x102>
mov    (%rsp),%rdi
mov    %r15,%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     12d2 <check_cpuset+0x102>
mov    0x0(%r13),%edi
mov    (%rsp),%rdx
lea    0xd4f(%rip),%rsi
mov    %r15,%rcx
xor    %eax,%eax
call   10a0 <fprintf@plt>
xor    %edi,%edi
call   1090 <assert@plt>
mov    (%rsp),%rsi
mov    %ebx,%edi
call   10f0 <hwloc_bitmap_list_sscanf@plt>
mov    (%rsp),%rdi
call   1040 <free@plt>
mov    %r12d,%edi
mov    %ebx,%esi
call   10c0 <hwloc_bitmap_isequal@plt>
mov    %eax,%edi
call   1090 <assert@plt>
mov    %rsp,%rdi
mov    %r12d,%esi
call   1070 <hwloc_bitmap_taskset_asprintf@plt>
mov    0x0(%r13),%edi
mov    (%rsp),%rdx
lea    0xd2a(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
test   %r14,%r14
je     134e <check_cpuset+0x17e>
mov    (%rsp),%rdi
mov    %r14,%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     134e <check_cpuset+0x17e>
mov    0x0(%r13),%edi
mov    (%rsp),%rdx
lea    0xcd3(%rip),%rsi
mov    %r14,%rcx
xor    %eax,%eax
call   10a0 <fprintf@plt>
xor    %edi,%edi
call   1090 <assert@plt>
mov    (%rsp),%rsi
mov    %ebx,%edi
call   10b0 <hwloc_bitmap_taskset_sscanf@plt>
mov    (%rsp),%rdi
call   1040 <free@plt>
mov    %r12d,%edi
mov    %ebx,%esi
call   10c0 <hwloc_bitmap_isequal@plt>
mov    %eax,%edi
call   1090 <assert@plt>
mov    %ebx,%edi
call   1050 <hwloc_bitmap_free@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [16 x i8] c"exported to %s\0A\00"
@.str.1 = [22 x i8] c"got %s instead of %s\0A\00"
@.str.2 = [21 x i8] c"exported to list %s\0A\00"
@.str.3 = [24 x i8] c"exported to taskset %s\0A\00"
define void @check_cpuset(i32 %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i8*
store i32 %0, i32* %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i8* %3, i8** %8
%11 = call i32 (...) @hwloc_bitmap_alloc()
store i32 %11, i32* %9
store i8* null, i8** %10
%12 = load i32, i32* %5
%13 = call i32 @hwloc_bitmap_asprintf(i8** %10, i32 %12)
%14 = load i32, i32* @stderr
%15 = load i8*, i8** %10
%16 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = load i8*, i8** %6
%18 = icmp ne i8* %17, null
br i1 %18, label %19, label %30
19: ; preds = %4
%20 = load i8*, i8** %10
%21 = load i8*, i8** %6
%22 = call i64 @strcmp(i8* %20, i8* %21)
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %30
24: ; preds = %19
%25 = load i32, i32* @stderr
%26 = load i8*, i8** %10
%27 = load i8*, i8** %6
%28 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %26, i8* %27)
%29 = call i32 @assert(i32 0)
br label %30
30: ; preds = %24, %19, %4
%31 = load i32, i32* %9
%32 = load i8*, i8** %10
%33 = call i32 @hwloc_bitmap_sscanf(i32 %31, i8* %32)
%34 = load i8*, i8** %10
%35 = call i32 @free(i8* %34)
%36 = load i32, i32* %5
%37 = load i32, i32* %9
%38 = call i32 @hwloc_bitmap_isequal(i32 %36, i32 %37)
%39 = call i32 @assert(i32 %38)
%40 = load i32, i32* %5
%41 = call i32 @hwloc_bitmap_list_asprintf(i8** %10, i32 %40)
%42 = load i32, i32* @stderr
%43 = load i8*, i8** %10
%44 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %42, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %43)
%45 = load i8*, i8** %7
%46 = icmp ne i8* %45, null
br i1 %46, label %47, label %58
47: ; preds = %30
%48 = load i8*, i8** %10
%49 = load i8*, i8** %7
%50 = call i64 @strcmp(i8* %48, i8* %49)
%51 = icmp ne i64 %50, 0
br i1 %51, label %52, label %58
52: ; preds = %47
%53 = load i32, i32* @stderr
%54 = load i8*, i8** %10
%55 = load i8*, i8** %7
%56 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %53, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %54, i8* %55)
%57 = call i32 @assert(i32 0)
br label %58
58: ; preds = %52, %47, %30
%59 = load i32, i32* %9
%60 = load i8*, i8** %10
%61 = call i32 @hwloc_bitmap_list_sscanf(i32 %59, i8* %60)
%62 = load i8*, i8** %10
%63 = call i32 @free(i8* %62)
%64 = load i32, i32* %5
%65 = load i32, i32* %9
%66 = call i32 @hwloc_bitmap_isequal(i32 %64, i32 %65)
%67 = call i32 @assert(i32 %66)
%68 = load i32, i32* %5
%69 = call i32 @hwloc_bitmap_taskset_asprintf(i8** %10, i32 %68)
%70 = load i32, i32* @stderr
%71 = load i8*, i8** %10
%72 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %70, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i8* %71)
%73 = load i8*, i8** %8
%74 = icmp ne i8* %73, null
br i1 %74, label %75, label %86
75: ; preds = %58
%76 = load i8*, i8** %10
%77 = load i8*, i8** %8
%78 = call i64 @strcmp(i8* %76, i8* %77)
%79 = icmp ne i64 %78, 0
br i1 %79, label %80, label %86
80: ; preds = %75
%81 = load i32, i32* @stderr
%82 = load i8*, i8** %10
%83 = load i8*, i8** %8
%84 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %81, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %82, i8* %83)
%85 = call i32 @assert(i32 0)
br label %86
86: ; preds = %80, %75, %58
%87 = load i32, i32* %9
%88 = load i8*, i8** %10
%89 = call i32 @hwloc_bitmap_taskset_sscanf(i32 %87, i8* %88)
%90 = load i8*, i8** %10
%91 = call i32 @free(i8* %90)
%92 = load i32, i32* %5
%93 = load i32, i32* %9
%94 = call i32 @hwloc_bitmap_isequal(i32 %92, i32 %93)
%95 = call i32 @assert(i32 %94)
%96 = load i32, i32* %9
%97 = call i32 @hwloc_bitmap_free(i32 %96)
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [16 x i8] c"exported to %s\0A\00"
@.str.1 = [22 x i8] c"got %s instead of %s\0A\00"
@.str.2 = [21 x i8] c"exported to list %s\0A\00"
@.str.3 = [24 x i8] c"exported to taskset %s\0A\00"
define void @check_cpuset(i32 %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca i8*
%6 = tail call i32 (...) @hwloc_bitmap_alloc()
%7 = bitcast i8** %5 to i8*
store i8* null, i8** %5
%8 = call i32 @hwloc_bitmap_asprintf(i8** %5, i32 %0)
%9 = load i32, i32* @stderr
%10 = load i8*, i8** %5
%11 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = icmp eq i8* %1, null
br i1 %12, label %22, label %13
13: ; preds = %4
%14 = load i8*, i8** %5
%15 = call i64 @strcmp(i8* %14, i8* %1)
%16 = icmp eq i64 %15, 0
br i1 %16, label %22, label %17
17: ; preds = %13
%18 = load i32, i32* @stderr
%19 = load i8*, i8** %5
%20 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %19, i8* %1)
%21 = call i32 @assert(i32 0)
br label %22
22: ; preds = %17, %13, %4
%23 = load i8*, i8** %5
%24 = call i32 @hwloc_bitmap_sscanf(i32 %6, i8* %23)
%25 = load i8*, i8** %5
%26 = call i32 @free(i8* %25)
%27 = call i32 @hwloc_bitmap_isequal(i32 %0, i32 %6)
%28 = call i32 @assert(i32 %27)
%29 = call i32 @hwloc_bitmap_list_asprintf(i8** %5, i32 %0)
%30 = load i32, i32* @stderr
%31 = load i8*, i8** %5
%32 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %31)
%33 = icmp eq i8* %2, null
br i1 %33, label %43, label %34
34: ; preds = %22
%35 = load i8*, i8** %5
%36 = call i64 @strcmp(i8* %35, i8* %2)
%37 = icmp eq i64 %36, 0
br i1 %37, label %43, label %38
38: ; preds = %34
%39 = load i32, i32* @stderr
%40 = load i8*, i8** %5
%41 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %39, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %40, i8* %2)
%42 = call i32 @assert(i32 0)
br label %43
43: ; preds = %38, %34, %22
%44 = load i8*, i8** %5
%45 = call i32 @hwloc_bitmap_list_sscanf(i32 %6, i8* %44)
%46 = load i8*, i8** %5
%47 = call i32 @free(i8* %46)
%48 = call i32 @hwloc_bitmap_isequal(i32 %0, i32 %6)
%49 = call i32 @assert(i32 %48)
%50 = call i32 @hwloc_bitmap_taskset_asprintf(i8** %5, i32 %0)
%51 = load i32, i32* @stderr
%52 = load i8*, i8** %5
%53 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %51, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i8* %52)
%54 = icmp eq i8* %3, null
br i1 %54, label %64, label %55
55: ; preds = %43
%56 = load i8*, i8** %5
%57 = call i64 @strcmp(i8* %56, i8* %3)
%58 = icmp eq i64 %57, 0
br i1 %58, label %64, label %59
59: ; preds = %55
%60 = load i32, i32* @stderr
%61 = load i8*, i8** %5
%62 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %60, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %61, i8* %3)
%63 = call i32 @assert(i32 0)
br label %64
64: ; preds = %59, %55, %43
%65 = load i8*, i8** %5
%66 = call i32 @hwloc_bitmap_taskset_sscanf(i32 %6, i8* %65)
%67 = load i8*, i8** %5
%68 = call i32 @free(i8* %67)
%69 = call i32 @hwloc_bitmap_isequal(i32 %0, i32 %6)
%70 = call i32 @assert(i32 %69)
%71 = call i32 @hwloc_bitmap_free(i32 %6)
ret void
}