#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_topology_t;
typedef int /*<<< orphan*/ hwloc_bitmap_t;

/* Variables and functions */
int /*<<< orphan*/ HWLOC_TOPOLOGY_FLAG_IS_THISSYSTEM;
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ hwloc_bitmap_dup(int /*<<< orphan*/);
int /*<<< orphan*/ hwloc_bitmap_free(int /*<<< orphan*/);
int /*<<< orphan*/ hwloc_bitmap_set(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ hwloc_bitmap_zero(int /*<<< orphan*/);
int hwloc_set_cpubind(int /*<<< orphan*/, int /*<<< orphan*/,
                      int /*<<< orphan*/);
int /*<<< orphan*/ hwloc_topology_destroy(int /*<<< orphan*/);
int /*<<< orphan*/ hwloc_topology_get_complete_cpuset(int /*<<< orphan*/);
int /*<<< orphan*/ hwloc_topology_init(int /*<<< orphan*/ *);
int hwloc_topology_is_thissystem(int /*<<< orphan*/);
int /*<<< orphan*/ hwloc_topology_load(int /*<<< orphan*/);
int /*<<< orphan*/ hwloc_topology_set_flags(int /*<<< orphan*/,
                                            int /*<<< orphan*/);
int /*<<< orphan*/ hwloc_topology_set_synthetic(int /*<<< orphan*/, char *);
int /*<<< orphan*/ result(char *, int);
int main(void) {
  hwloc_topology_t topology;
  hwloc_bitmap_t cpuset;
  int err;
  hwloc_topology_init(&topology);
  hwloc_topology_load(topology);
  assert(hwloc_topology_is_thissystem(topology));
  cpuset = hwloc_bitmap_dup(hwloc_topology_get_complete_cpuset(topology));
  result("Binding with OS backend", hwloc_set_cpubind(topology, cpuset, 0));
  hwloc_topology_destroy(topology);
  hwloc_bitmap_zero(cpuset);
  hwloc_bitmap_set(cpuset, 0);
  hwloc_topology_init(&topology);
  hwloc_topology_set_synthetic(topology, "1");
  hwloc_topology_load(topology);
  assert(!hwloc_topology_is_thissystem(topology));
  err = hwloc_set_cpubind(topology, cpuset, 0);
  result("Binding with synthetic backend", err);
  assert(!err);
  hwloc_topology_destroy(topology);
  hwloc_topology_init(&topology);
  hwloc_topology_set_flags(topology, HWLOC_TOPOLOGY_FLAG_IS_THISSYSTEM);
  hwloc_topology_set_synthetic(topology, "1");
  hwloc_topology_load(topology);
  assert(hwloc_topology_is_thissystem(topology));
  result("Binding with synthetic backend faking is_thissystem",
         hwloc_set_cpubind(topology, cpuset, 0));
  hwloc_topology_destroy(topology);
  hwloc_bitmap_free(cpuset);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x8(%rbp),%rdi
call   1040 <hwloc_topology_init@plt>
mov    -0x8(%rbp),%edi
call   1050 <hwloc_topology_load@plt>
mov    -0x8(%rbp),%edi
call   10d0 <hwloc_topology_is_thissystem@plt>
mov    %eax,%edi
call   1070 <assert@plt>
mov    -0x8(%rbp),%edi
call   1100 <hwloc_topology_get_complete_cpuset@plt>
mov    %eax,%edi
call   1080 <hwloc_bitmap_dup@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
xor    %edx,%edx
call   1090 <hwloc_set_cpubind@plt>
mov    %eax,%esi
lea    0xdc9(%rip),%rdi
call   10b0 <result@plt>
mov    -0x8(%rbp),%edi
call   10f0 <hwloc_topology_destroy@plt>
mov    -0xc(%rbp),%edi
call   10c0 <hwloc_bitmap_zero@plt>
mov    -0xc(%rbp),%edi
xor    %esi,%esi
call   1060 <hwloc_bitmap_set@plt>
lea    -0x8(%rbp),%rdi
call   1040 <hwloc_topology_init@plt>
mov    -0x8(%rbp),%edi
lea    0xdaf(%rip),%rsi
call   10e0 <hwloc_topology_set_synthetic@plt>
mov    -0x8(%rbp),%edi
call   1050 <hwloc_topology_load@plt>
mov    -0x8(%rbp),%edi
call   10d0 <hwloc_topology_is_thissystem@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
xor    %edx,%edx
call   1090 <hwloc_set_cpubind@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%esi
lea    0xd70(%rip),%rdi
call   10b0 <result@plt>
cmpl   $0x0,-0x10(%rbp)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
mov    -0x8(%rbp),%edi
call   10f0 <hwloc_topology_destroy@plt>
lea    -0x8(%rbp),%rdi
call   1040 <hwloc_topology_init@plt>
mov    -0x8(%rbp),%edi
mov    0x2d0b(%rip),%rax
mov    (%rax),%esi
call   10a0 <hwloc_topology_set_flags@plt>
mov    -0x8(%rbp),%edi
lea    0xd2a(%rip),%rsi
call   10e0 <hwloc_topology_set_synthetic@plt>
mov    -0x8(%rbp),%edi
call   1050 <hwloc_topology_load@plt>
mov    -0x8(%rbp),%edi
call   10d0 <hwloc_topology_is_thissystem@plt>
mov    %eax,%edi
call   1070 <assert@plt>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
xor    %edx,%edx
call   1090 <hwloc_set_cpubind@plt>
mov    %eax,%esi
lea    0xd19(%rip),%rdi
call   10b0 <result@plt>
mov    -0x8(%rbp),%edi
call   10f0 <hwloc_topology_destroy@plt>
mov    -0xc(%rbp),%edi
call   1030 <hwloc_bitmap_free@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0x4(%rsp),%r14
mov    %r14,%rdi
call   1040 <hwloc_topology_init@plt>
mov    0x4(%rsp),%edi
call   1050 <hwloc_topology_load@plt>
mov    0x4(%rsp),%edi
call   10d0 <hwloc_topology_is_thissystem@plt>
mov    %eax,%edi
call   1070 <assert@plt>
mov    0x4(%rsp),%edi
call   1100 <hwloc_topology_get_complete_cpuset@plt>
mov    %eax,%edi
call   1080 <hwloc_bitmap_dup@plt>
mov    %eax,%ebx
mov    0x4(%rsp),%edi
mov    %eax,%esi
xor    %edx,%edx
call   1090 <hwloc_set_cpubind@plt>
lea    0xdcd(%rip),%rdi
mov    %eax,%esi
call   10b0 <result@plt>
mov    0x4(%rsp),%edi
call   10f0 <hwloc_topology_destroy@plt>
mov    %ebx,%edi
call   10c0 <hwloc_bitmap_zero@plt>
mov    %ebx,%edi
xor    %esi,%esi
call   1060 <hwloc_bitmap_set@plt>
mov    %r14,%rdi
call   1040 <hwloc_topology_init@plt>
mov    0x4(%rsp),%edi
lea    0xdb2(%rip),%r15
mov    %r15,%rsi
call   10e0 <hwloc_topology_set_synthetic@plt>
mov    0x4(%rsp),%edi
call   1050 <hwloc_topology_load@plt>
mov    0x4(%rsp),%edi
call   10d0 <hwloc_topology_is_thissystem@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1070 <assert@plt>
mov    0x4(%rsp),%edi
mov    %ebx,%esi
xor    %edx,%edx
call   1090 <hwloc_set_cpubind@plt>
mov    %eax,%ebp
lea    0xd77(%rip),%rdi
mov    %eax,%esi
call   10b0 <result@plt>
xor    %edi,%edi
test   %ebp,%ebp
sete   %dil
call   1070 <assert@plt>
mov    0x4(%rsp),%edi
call   10f0 <hwloc_topology_destroy@plt>
mov    %r14,%rdi
call   1040 <hwloc_topology_init@plt>
mov    0x4(%rsp),%edi
mov    0x2d15(%rip),%rax
mov    (%rax),%esi
call   10a0 <hwloc_topology_set_flags@plt>
mov    0x4(%rsp),%edi
mov    %r15,%rsi
call   10e0 <hwloc_topology_set_synthetic@plt>
mov    0x4(%rsp),%edi
call   1050 <hwloc_topology_load@plt>
mov    0x4(%rsp),%edi
call   10d0 <hwloc_topology_is_thissystem@plt>
mov    %eax,%edi
call   1070 <assert@plt>
mov    0x4(%rsp),%edi
mov    %ebx,%esi
xor    %edx,%edx
call   1090 <hwloc_set_cpubind@plt>
lea    0xd26(%rip),%rdi
mov    %eax,%esi
call   10b0 <result@plt>
mov    0x4(%rsp),%edi
call   10f0 <hwloc_topology_destroy@plt>
mov    %ebx,%edi
call   1030 <hwloc_bitmap_free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [24 x i8] c"Binding with OS backend\00"
@.str.1 = [2 x i8] c"1\00"
@.str.2 = [31 x i8] c"Binding with synthetic backend\00"
@HWLOC_TOPOLOGY_FLAG_IS_THISSYSTEM = global i32 0
@.str.3 = [52 x i8] c"Binding with synthetic backend faking is_thissystem\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 @hwloc_topology_init(i32* %2)
%6 = load i32, i32* %2
%7 = call i32 @hwloc_topology_load(i32 %6)
%8 = load i32, i32* %2
%9 = call i32 @hwloc_topology_is_thissystem(i32 %8)
%10 = call i32 @assert(i32 %9)
%11 = load i32, i32* %2
%12 = call i32 @hwloc_topology_get_complete_cpuset(i32 %11)
%13 = call i32 @hwloc_bitmap_dup(i32 %12)
store i32 %13, i32* %3
%14 = load i32, i32* %2
%15 = load i32, i32* %3
%16 = call i32 @hwloc_set_cpubind(i32 %14, i32 %15, i32 0)
%17 = call i32 @result(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %16)
%18 = load i32, i32* %2
%19 = call i32 @hwloc_topology_destroy(i32 %18)
%20 = load i32, i32* %3
%21 = call i32 @hwloc_bitmap_zero(i32 %20)
%22 = load i32, i32* %3
%23 = call i32 @hwloc_bitmap_set(i32 %22, i32 0)
%24 = call i32 @hwloc_topology_init(i32* %2)
%25 = load i32, i32* %2
%26 = call i32 @hwloc_topology_set_synthetic(i32 %25, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%27 = load i32, i32* %2
%28 = call i32 @hwloc_topology_load(i32 %27)
%29 = load i32, i32* %2
%30 = call i32 @hwloc_topology_is_thissystem(i32 %29)
%31 = icmp ne i32 %30, 0
%32 = xor i1 %31, true
%33 = zext i1 %32 to i32
%34 = call i32 @assert(i32 %33)
%35 = load i32, i32* %2
%36 = load i32, i32* %3
%37 = call i32 @hwloc_set_cpubind(i32 %35, i32 %36, i32 0)
store i32 %37, i32* %4
%38 = load i32, i32* %4
%39 = call i32 @result(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i32 %38)
%40 = load i32, i32* %4
%41 = icmp ne i32 %40, 0
%42 = xor i1 %41, true
%43 = zext i1 %42 to i32
%44 = call i32 @assert(i32 %43)
%45 = load i32, i32* %2
%46 = call i32 @hwloc_topology_destroy(i32 %45)
%47 = call i32 @hwloc_topology_init(i32* %2)
%48 = load i32, i32* %2
%49 = load i32, i32* @HWLOC_TOPOLOGY_FLAG_IS_THISSYSTEM
%50 = call i32 @hwloc_topology_set_flags(i32 %48, i32 %49)
%51 = load i32, i32* %2
%52 = call i32 @hwloc_topology_set_synthetic(i32 %51, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%53 = load i32, i32* %2
%54 = call i32 @hwloc_topology_load(i32 %53)
%55 = load i32, i32* %2
%56 = call i32 @hwloc_topology_is_thissystem(i32 %55)
%57 = call i32 @assert(i32 %56)
%58 = load i32, i32* %2
%59 = load i32, i32* %3
%60 = call i32 @hwloc_set_cpubind(i32 %58, i32 %59, i32 0)
%61 = call i32 @result(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.3, i64 0, i64 0), i32 %60)
%62 = load i32, i32* %2
%63 = call i32 @hwloc_topology_destroy(i32 %62)
%64 = load i32, i32* %3
%65 = call i32 @hwloc_bitmap_free(i32 %64)
ret i32 0
}

LLVM IR (-O2):
@.str = [24 x i8] c"Binding with OS backend\00"
@.str.1 = [2 x i8] c"1\00"
@.str.2 = [31 x i8] c"Binding with synthetic backend\00"
@HWLOC_TOPOLOGY_FLAG_IS_THISSYSTEM = global i32 0
@.str.3 = [52 x i8] c"Binding with synthetic backend faking is_thissystem\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @hwloc_topology_init(i32* %1)
%4 = load i32, i32* %1
%5 = call i32 @hwloc_topology_load(i32 %4)
%6 = load i32, i32* %1
%7 = call i32 @hwloc_topology_is_thissystem(i32 %6)
%8 = call i32 @assert(i32 %7)
%9 = load i32, i32* %1
%10 = call i32 @hwloc_topology_get_complete_cpuset(i32 %9)
%11 = call i32 @hwloc_bitmap_dup(i32 %10)
%12 = load i32, i32* %1
%13 = call i32 @hwloc_set_cpubind(i32 %12, i32 %11, i32 0)
%14 = call i32 @result(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = load i32, i32* %1
%16 = call i32 @hwloc_topology_destroy(i32 %15)
%17 = call i32 @hwloc_bitmap_zero(i32 %11)
%18 = call i32 @hwloc_bitmap_set(i32 %11, i32 0)
%19 = call i32 @hwloc_topology_init(i32* %1)
%20 = load i32, i32* %1
%21 = call i32 @hwloc_topology_set_synthetic(i32 %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%22 = load i32, i32* %1
%23 = call i32 @hwloc_topology_load(i32 %22)
%24 = load i32, i32* %1
%25 = call i32 @hwloc_topology_is_thissystem(i32 %24)
%26 = icmp eq i32 %25, 0
%27 = zext i1 %26 to i32
%28 = call i32 @assert(i32 %27)
%29 = load i32, i32* %1
%30 = call i32 @hwloc_set_cpubind(i32 %29, i32 %11, i32 0)
%31 = call i32 @result(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i32 %30)
%32 = icmp eq i32 %30, 0
%33 = zext i1 %32 to i32
%34 = call i32 @assert(i32 %33)
%35 = load i32, i32* %1
%36 = call i32 @hwloc_topology_destroy(i32 %35)
%37 = call i32 @hwloc_topology_init(i32* %1)
%38 = load i32, i32* %1
%39 = load i32, i32* @HWLOC_TOPOLOGY_FLAG_IS_THISSYSTEM
%40 = call i32 @hwloc_topology_set_flags(i32 %38, i32 %39)
%41 = load i32, i32* %1
%42 = call i32 @hwloc_topology_set_synthetic(i32 %41, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%43 = load i32, i32* %1
%44 = call i32 @hwloc_topology_load(i32 %43)
%45 = load i32, i32* %1
%46 = call i32 @hwloc_topology_is_thissystem(i32 %45)
%47 = call i32 @assert(i32 %46)
%48 = load i32, i32* %1
%49 = call i32 @hwloc_set_cpubind(i32 %48, i32 %11, i32 0)
%50 = call i32 @result(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.3, i64 0, i64 0), i32 %49)
%51 = load i32, i32* %1
%52 = call i32 @hwloc_topology_destroy(i32 %51)
%53 = call i32 @hwloc_bitmap_free(i32 %11)
ret i32 0
}