#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 */
struct bitmask {
  int dummy;
};

/* Variables and functions */
struct bitmask *numa_allocate_nodemask();
int /*<<< orphan*/ numa_bitmask_free(struct bitmask *);
int /*<<< orphan*/ numa_bitmask_setbit(struct bitmask *, int);
int /*<<< orphan*/ setpol(int, struct bitmask *);
void numa_set_preferred(int node) {
  struct bitmask *bmp;
  bmp = numa_allocate_nodemask();
  if (node >= 0) {
    numa_bitmask_setbit(bmp, node);
    setpol(1, bmp);
  } else
    setpol(0, bmp);
  numa_bitmask_free(bmp);
}


x86 assembly (clang, -O0):
<numa_set_preferred>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x0,%al
call   1050 <numa_allocate_nodemask@plt>
mov    %rax,-0x10(%rbp)
cmpl   $0x0,-0x4(%rbp)
jl     117f <numa_set_preferred+0x3f>
mov    -0x10(%rbp),%rdi
mov    -0x4(%rbp),%esi
call   1030 <numa_bitmask_setbit@plt>
mov    -0x10(%rbp),%rsi
mov    $0x1,%edi
call   1040 <setpol@plt>
jmp    118a <numa_set_preferred+0x4a>
mov    -0x10(%rbp),%rsi
xor    %edi,%edi
call   1040 <setpol@plt>
mov    -0x10(%rbp),%rdi
call   1060 <numa_bitmask_free@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<numa_set_preferred>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%r14d
xor    %ebp,%ebp
xor    %eax,%eax
call   1050 <numa_allocate_nodemask@plt>
mov    %rax,%rbx
test   %r14d,%r14d
js     1168 <numa_set_preferred+0x28>
mov    %rbx,%rdi
mov    %r14d,%esi
call   1030 <numa_bitmask_setbit@plt>
mov    $0x1,%ebp
mov    %ebp,%edi
mov    %rbx,%rsi
call   1040 <setpol@plt>
mov    %rbx,%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1060 <numa_bitmask_free@plt>

LLVM IR (-O0):
%struct.bitmask = type { i32 }
define void @numa_set_preferred(i32 %0) {
%2 = alloca i32
%3 = alloca %struct.bitmask*
store i32 %0, i32* %2
%4 = call %struct.bitmask* (...) @numa_allocate_nodemask()
store %struct.bitmask* %4, %struct.bitmask** %3
%5 = load i32, i32* %2
%6 = icmp sge i32 %5, 0
br i1 %6, label %7, label %13
7: ; preds = %1
%8 = load %struct.bitmask*, %struct.bitmask** %3
%9 = load i32, i32* %2
%10 = call i32 @numa_bitmask_setbit(%struct.bitmask* %8, i32 %9)
%11 = load %struct.bitmask*, %struct.bitmask** %3
%12 = call i32 @setpol(i32 1, %struct.bitmask* %11)
br label %16
13: ; preds = %1
%14 = load %struct.bitmask*, %struct.bitmask** %3
%15 = call i32 @setpol(i32 0, %struct.bitmask* %14)
br label %16
16: ; preds = %13, %7
%17 = load %struct.bitmask*, %struct.bitmask** %3
%18 = call i32 @numa_bitmask_free(%struct.bitmask* %17)
ret void
}

LLVM IR (-O2):
%struct.bitmask = type { i32 }
define void @numa_set_preferred(i32 %0) {
%2 = tail call %struct.bitmask* (...) @numa_allocate_nodemask()
%3 = icmp sgt i32 %0, -1
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = tail call i32 @numa_bitmask_setbit(%struct.bitmask* %2, i32 %0)
br label %6
6: ; preds = %1, %4
%7 = phi i32 [ 1, %4 ], [ 0, %1 ]
%8 = tail call i32 @setpol(i32 %7, %struct.bitmask* %2)
%9 = tail call i32 @numa_bitmask_free(%struct.bitmask* %2)
ret void
}