#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_cpuset_t;

/* Variables and functions */
int /*<<< orphan*/ HWLOC_CPUBIND_PROCESS;
int /*<<< orphan*/ free(char *);
scalar_t__ getpid();
int /*<<< orphan*/ hwloc_bitmap_alloc();
int /*<<< orphan*/ hwloc_bitmap_asprintf(char **, int /*<<< orphan*/);
int /*<<< orphan*/ hwloc_bitmap_free(int /*<<< orphan*/);
int /*<<< orphan*/ hwloc_get_cpubind(int /*<<< orphan*/ const,
                                     int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int, char *);
void emit_binding(const hwloc_topology_t *t) {
  char *str = NULL;
  hwloc_cpuset_t cpu_set = hwloc_bitmap_alloc();
  hwloc_get_cpubind(*t, cpu_set, HWLOC_CPUBIND_PROCESS);
  hwloc_bitmap_asprintf(&str, cpu_set);
  printf("%d's cpubind bitmap is: %s\n", (int)getpid(), str);
  free(str);
  hwloc_bitmap_free(cpu_set);
}


x86 assembly (clang, -O0):
<emit_binding>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
mov    $0x0,%al
call   1030 <hwloc_bitmap_alloc@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%esi
mov    0x2e4a(%rip),%rax
mov    (%rax),%edx
call   1090 <hwloc_get_cpubind@plt>
mov    -0x14(%rbp),%esi
lea    -0x10(%rbp),%rdi
call   1060 <hwloc_bitmap_asprintf@plt>
mov    $0x0,%al
call   1070 <getpid@plt>
mov    %eax,%esi
mov    -0x10(%rbp),%rdx
lea    0xe3b(%rip),%rdi
call   1080 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <free@plt>
mov    -0x14(%rbp),%edi
call   1050 <hwloc_bitmap_free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<emit_binding>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
movq   $0x0,(%rsp)
xor    %eax,%eax
call   1030 <hwloc_bitmap_alloc@plt>
mov    %eax,%ebx
mov    (%r14),%edi
mov    0x2e56(%rip),%rax
mov    (%rax),%edx
mov    %ebx,%esi
call   1090 <hwloc_get_cpubind@plt>
mov    %rsp,%rdi
mov    %ebx,%esi
call   1060 <hwloc_bitmap_asprintf@plt>
xor    %eax,%eax
call   1070 <getpid@plt>
mov    (%rsp),%rdx
lea    0xe49(%rip),%rdi
mov    %eax,%esi
call   1080 <printf@plt>
mov    (%rsp),%rdi
call   1040 <free@plt>
mov    %ebx,%edi
call   1050 <hwloc_bitmap_free@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@HWLOC_CPUBIND_PROCESS = global i32 0
@.str = [28 x i8] c"%d's cpubind bitmap is: %s\0A\00"
define void @emit_binding(i32* %0) {
%2 = alloca i32*
%3 = alloca i8*
%4 = alloca i32
store i32* %0, i32** %2
store i8* null, i8** %3
%5 = call i32 (...) @hwloc_bitmap_alloc()
store i32 %5, i32* %4
%6 = load i32*, i32** %2
%7 = load i32, i32* %6
%8 = load i32, i32* %4
%9 = load i32, i32* @HWLOC_CPUBIND_PROCESS
%10 = call i32 @hwloc_get_cpubind(i32 %7, i32 %8, i32 %9)
%11 = load i32, i32* %4
%12 = call i32 @hwloc_bitmap_asprintf(i8** %3, i32 %11)
%13 = call i64 (...) @getpid()
%14 = trunc i64 %13 to i32
%15 = load i8*, i8** %3
%16 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 %14, i8* %15)
%17 = load i8*, i8** %3
%18 = call i32 @free(i8* %17)
%19 = load i32, i32* %4
%20 = call i32 @hwloc_bitmap_free(i32 %19)
ret void
}

LLVM IR (-O2):
@HWLOC_CPUBIND_PROCESS = global i32 0
@.str = [28 x i8] c"%d's cpubind bitmap is: %s\0A\00"
define void @emit_binding(i32* nocapture %0) {
%2 = alloca i8*
%3 = bitcast i8** %2 to i8*
store i8* null, i8** %2
%4 = tail call i32 (...) @hwloc_bitmap_alloc()
%5 = load i32, i32* %0
%6 = load i32, i32* @HWLOC_CPUBIND_PROCESS
%7 = tail call i32 @hwloc_get_cpubind(i32 %5, i32 %4, i32 %6)
%8 = call i32 @hwloc_bitmap_asprintf(i8** %2, i32 %4)
%9 = call i64 (...) @getpid()
%10 = trunc i64 %9 to i32
%11 = load i8*, i8** %2
%12 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 %10, i8* %11)
%13 = load i8*, i8** %2
%14 = call i32 @free(i8* %13)
%15 = call i32 @hwloc_bitmap_free(i32 %4)
ret void
}