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

/* Variables and functions */
scalar_t__ get_mempolicy(int *, int /*<<< orphan*/ *, int /*<<< orphan*/,
                         char *, int);
char *numa_alloc(int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, int);
int main(void) {
  int nd;
  char *man = numa_alloc(1000);
  *man = 1;
  if (get_mempolicy(&nd, NULL, 0, man, (1 << 0) | (1 << 1)) < 0)
    perror("get_mempolicy");
  else
    printf("my node %d\n", nd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x3e8,%edi
call   1060 <numa_alloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movb   $0x1,(%rax)
mov    -0x10(%rbp),%rcx
lea    -0x8(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
mov    $0x3,%r8d
call   1040 <get_mempolicy@plt>
cmp    $0x0,%rax
jge    1198 <main+0x58>
lea    0xe72(%rip),%rdi
call   1050 <perror@plt>
jmp    11a7 <main+0x67>
mov    -0x8(%rbp),%esi
lea    0xe6c(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    $0x3e8,%edi
call   1060 <numa_alloc@plt>
movb   $0x1,(%rax)
lea    0x4(%rsp),%rdi
xor    %esi,%esi
xor    %edx,%edx
mov    %rax,%rcx
mov    $0x3,%r8d
call   1040 <get_mempolicy@plt>
test   %rax,%rax
js     117e <main+0x3e>
mov    0x4(%rsp),%esi
lea    0xe99(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret
lea    0xe7b(%rip),%rdi
call   1050 <perror@plt>
jmp    117a <main+0x3a>

LLVM IR (-O0):
@.str = [14 x i8] c"get_mempolicy\00"
@.str.1 = [12 x i8] c"my node %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
store i32 0, i32* %1
%4 = call i8* @numa_alloc(i32 1000)
store i8* %4, i8** %3
%5 = load i8*, i8** %3
store i8 1, i8* %5
%6 = load i8*, i8** %3
%7 = call i64 @get_mempolicy(i32* %2, i32* null, i32 0, i8* %6, i32 3)
%8 = icmp slt i64 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %0
%10 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
br label %14
11: ; preds = %0
%12 = load i32, i32* %2
%13 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %12)
br label %14
14: ; preds = %11, %9
ret i32 0
}

LLVM IR (-O2):
@.str = [14 x i8] c"get_mempolicy\00"
@.str.1 = [12 x i8] c"my node %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i8* @numa_alloc(i32 1000)
store i8 1, i8* %3
%4 = call i64 @get_mempolicy(i32* %1, i32* null, i32 0, i8* %3, i32 3)
%5 = icmp slt i64 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %0
%7 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
br label %11
8: ; preds = %0
%9 = load i32, i32* %1
%10 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %9)
br label %11
11: ; preds = %8, %6
ret i32 0
}