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

/* Variables and functions */
int /*<<< orphan*/ hwloc_bitmap_alloc();
int /*<<< orphan*/ hwloc_bitmap_free(int /*<<< orphan*/);
int /*<<< orphan*/ hwloc_bitmap_set(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ hwloc_topology_check(int /*<<< orphan*/);
int /*<<< orphan*/ hwloc_topology_destroy(int /*<<< orphan*/);
int /*<<< orphan*/ hwloc_topology_init(int /*<<< orphan*/ *);
int /*<<< orphan*/
hwloc_topology_insert_misc_object_by_cpuset(int /*<<< orphan*/,
                                            int /*<<< orphan*/, char *);
int /*<<< orphan*/
hwloc_topology_insert_misc_object_by_parent(int /*<<< orphan*/,
                                            int /*<<< orphan*/, char *);
int /*<<< orphan*/ hwloc_topology_load(int /*<<< orphan*/);
int main(void) {
  hwloc_topology_t topology;
  hwloc_bitmap_t cpuset;
  hwloc_obj_t obj;
  hwloc_topology_init(&topology);
  hwloc_topology_load(topology);
  hwloc_topology_check(topology);
  cpuset = hwloc_bitmap_alloc();
  hwloc_bitmap_set(cpuset, 0);
  obj = hwloc_topology_insert_misc_object_by_cpuset(topology, cpuset, "test");
  hwloc_bitmap_free(cpuset);
  hwloc_topology_insert_misc_object_by_parent(topology, obj, "test2");
  hwloc_topology_check(topology);
  hwloc_topology_destroy(topology);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x8(%rbp),%rdi
call   1060 <hwloc_topology_init@plt>
mov    -0x8(%rbp),%edi
call   1070 <hwloc_topology_load@plt>
mov    -0x8(%rbp),%edi
call   1050 <hwloc_topology_check@plt>
mov    $0x0,%al
call   1030 <hwloc_bitmap_alloc@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
xor    %esi,%esi
call   1080 <hwloc_bitmap_set@plt>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
lea    0xe27(%rip),%rdx
call   10b0 <hwloc_topology_insert_misc_object_by_cpuset@plt>
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%edi
call   1040 <hwloc_bitmap_free@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%esi
lea    0xe0f(%rip),%rdx
call   1090 <hwloc_topology_insert_misc_object_by_parent@plt>
mov    -0x8(%rbp),%edi
call   1050 <hwloc_topology_check@plt>
mov    -0x8(%rbp),%edi
call   10a0 <hwloc_topology_destroy@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0x4(%rsp),%rdi
call   1060 <hwloc_topology_init@plt>
mov    0x4(%rsp),%edi
call   1070 <hwloc_topology_load@plt>
mov    0x4(%rsp),%edi
call   1050 <hwloc_topology_check@plt>
xor    %eax,%eax
call   1030 <hwloc_bitmap_alloc@plt>
mov    %eax,%ebx
mov    %eax,%edi
xor    %esi,%esi
call   1080 <hwloc_bitmap_set@plt>
mov    0x4(%rsp),%edi
lea    0xe34(%rip),%rdx
mov    %ebx,%esi
call   10b0 <hwloc_topology_insert_misc_object_by_cpuset@plt>
mov    %eax,%ebp
mov    %ebx,%edi
call   1040 <hwloc_bitmap_free@plt>
mov    0x4(%rsp),%edi
lea    0xe1e(%rip),%rdx
mov    %ebp,%esi
call   1090 <hwloc_topology_insert_misc_object_by_parent@plt>
mov    0x4(%rsp),%edi
call   1050 <hwloc_topology_check@plt>
mov    0x4(%rsp),%edi
call   10a0 <hwloc_topology_destroy@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"test\00"
@.str.1 = [6 x i8] c"test2\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_check(i32 %8)
%10 = call i32 (...) @hwloc_bitmap_alloc()
store i32 %10, i32* %3
%11 = load i32, i32* %3
%12 = call i32 @hwloc_bitmap_set(i32 %11, i32 0)
%13 = load i32, i32* %2
%14 = load i32, i32* %3
%15 = call i32 @hwloc_topology_insert_misc_object_by_cpuset(i32 %13, i32 %14, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i32 %15, i32* %4
%16 = load i32, i32* %3
%17 = call i32 @hwloc_bitmap_free(i32 %16)
%18 = load i32, i32* %2
%19 = load i32, i32* %4
%20 = call i32 @hwloc_topology_insert_misc_object_by_parent(i32 %18, i32 %19, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%21 = load i32, i32* %2
%22 = call i32 @hwloc_topology_check(i32 %21)
%23 = load i32, i32* %2
%24 = call i32 @hwloc_topology_destroy(i32 %23)
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"test\00"
@.str.1 = [6 x i8] c"test2\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_check(i32 %6)
%8 = call i32 (...) @hwloc_bitmap_alloc()
%9 = call i32 @hwloc_bitmap_set(i32 %8, i32 0)
%10 = load i32, i32* %1
%11 = call i32 @hwloc_topology_insert_misc_object_by_cpuset(i32 %10, i32 %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @hwloc_bitmap_free(i32 %8)
%13 = load i32, i32* %1
%14 = call i32 @hwloc_topology_insert_misc_object_by_parent(i32 %13, i32 %11, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%15 = load i32, i32* %1
%16 = call i32 @hwloc_topology_check(i32 %15)
%17 = load i32, i32* %1
%18 = call i32 @hwloc_topology_destroy(i32 %17)
ret i32 0
}