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

/* Variables and functions */
int /*<<< orphan*/ _load_cpu_mask(int /*<<< orphan*/ *);
int /*<<< orphan*/ _load_mem_mask(int /*<<< orphan*/ *);
int /*<<< orphan*/ _mask_to_int(int /*<<< orphan*/ *);
int atoi(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
char *getenv(char *);
scalar_t__ numa_available();
int /*<<< orphan*/ printf(char *, int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  char *task_str;
  nodemask_t cpu_mask;
  nodemask_t mem_mask;
  int task_id;
  if (numa_available() < 0) {
    fprintf(stderr, "ERROR: numa support not available\n");
    exit(0);
  }
  if (((task_str = getenv("SLURM_PROCID")) == NULL) &&
      ((task_str = getenv("MP_CHILD")) == NULL)) {
    fprintf(stderr, "ERROR: getenv(SLURM_PROCID) failed\n");
    exit(1);
  }
  task_id = atoi(task_str);
  _load_cpu_mask(&cpu_mask);
  _load_mem_mask(&mem_mask);
  printf("TASK_ID:%d,CPU_MASK:%lu,MEM_MASK:%lu\n", task_id,
         _mask_to_int(&cpu_mask), _mask_to_int(&mem_mask));
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1090 <numa_available@plt>
cmp    $0x0,%rax
jge    11d3 <main+0x43>
mov    0x2e22(%rip),%rax
mov    (%rax),%edi
lea    0xe39(%rip),%rsi
call   1070 <fprintf@plt>
xor    %edi,%edi
call   10b0 <exit@plt>
lea    0xe49(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1226 <main+0x96>
lea    0xe3c(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1226 <main+0x96>
mov    0x2dd2(%rip),%rax
mov    (%rax),%edi
lea    0xe22(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    -0x18(%rbp),%rdi
call   10a0 <atoi@plt>
mov    %eax,-0x24(%rbp)
lea    -0x1c(%rbp),%rdi
call   1080 <_load_cpu_mask@plt>
lea    -0x20(%rbp),%rdi
call   1040 <_load_mem_mask@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x2c(%rbp)
lea    -0x1c(%rbp),%rdi
call   1050 <_mask_to_int@plt>
mov    %eax,-0x28(%rbp)
lea    -0x20(%rbp),%rdi
call   1050 <_mask_to_int@plt>
mov    -0x2c(%rbp),%esi
mov    -0x28(%rbp),%edx
mov    %eax,%ecx
lea    0xdef(%rip),%rdi
call   1060 <printf@plt>
xor    %edi,%edi
call   10b0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
xor    %eax,%eax
call   1090 <numa_available@plt>
test   %rax,%rax
jns    11c0 <main+0x30>
mov    0x2e35(%rip),%rax
mov    (%rax),%edi
lea    0xe4c(%rip),%rsi
call   1070 <fprintf@plt>
xor    %edi,%edi
call   10b0 <exit@plt>
lea    0xe5c(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
jne    1201 <main+0x71>
lea    0xe58(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
jne    1201 <main+0x71>
mov    0x2df7(%rip),%rax
mov    (%rax),%edi
lea    0xe47(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    %rax,%rdi
call   10a0 <atoi@plt>
mov    %eax,%r14d
lea    0xc(%rsp),%rbx
mov    %rbx,%rdi
call   1080 <_load_cpu_mask@plt>
lea    0x8(%rsp),%rbp
mov    %rbp,%rdi
call   1040 <_load_mem_mask@plt>
mov    %rbx,%rdi
call   1050 <_mask_to_int@plt>
mov    %eax,%ebx
mov    %rbp,%rdi
call   1050 <_mask_to_int@plt>
lea    0xe1e(%rip),%rdi
mov    %r14d,%esi
mov    %ebx,%edx
mov    %eax,%ecx
call   1060 <printf@plt>
xor    %edi,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [35 x i8] c"ERROR: numa support not available\0A\00"
@.str.1 = [13 x i8] c"SLURM_PROCID\00"
@.str.2 = [9 x i8] c"MP_CHILD\00"
@.str.3 = [36 x i8] c"ERROR: getenv(SLURM_PROCID) failed\0A\00"
@.str.4 = [38 x i8] c"TASK_ID:%d,CPU_MASK:%lu,MEM_MASK:%lu\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = call i64 (...) @numa_available()
%11 = icmp slt i64 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%15 = call i32 @exit(i32 0)
unreachable
16: ; preds = %2
%17 = call i8* @getenv(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
store i8* %17, i8** %6
%18 = icmp eq i8* %17, null
br i1 %18, label %19, label %26
19: ; preds = %16
%20 = call i8* @getenv(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
store i8* %20, i8** %6
%21 = icmp eq i8* %20, null
br i1 %21, label %22, label %26
22: ; preds = %19
%23 = load i32, i32* @stderr
%24 = call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0))
%25 = call i32 @exit(i32 1)
unreachable
26: ; preds = %19, %16
%27 = load i8*, i8** %6
%28 = call i32 @atoi(i8* %27)
store i32 %28, i32* %9
%29 = call i32 @_load_cpu_mask(i32* %7)
%30 = call i32 @_load_mem_mask(i32* %8)
%31 = load i32, i32* %9
%32 = call i32 @_mask_to_int(i32* %7)
%33 = call i32 @_mask_to_int(i32* %8)
%34 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0), i32 %31, i32 %32, i32 %33)
%35 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [35 x i8] c"ERROR: numa support not available\0A\00"
@.str.1 = [13 x i8] c"SLURM_PROCID\00"
@.str.2 = [9 x i8] c"MP_CHILD\00"
@.str.3 = [36 x i8] c"ERROR: getenv(SLURM_PROCID) failed\0A\00"
@.str.4 = [38 x i8] c"TASK_ID:%d,CPU_MASK:%lu,MEM_MASK:%lu\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %3 to i8*
%6 = bitcast i32* %4 to i8*
%7 = tail call i64 (...) @numa_available()
%8 = icmp slt i64 %7, 0
br i1 %8, label %9, label %13
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%12 = tail call i32 @exit(i32 0)
unreachable
13: ; preds = %2
%14 = tail call i8* @getenv(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i8* %14, null
br i1 %15, label %16, label %23
16: ; preds = %13
%17 = tail call i8* @getenv(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%18 = icmp eq i8* %17, null
br i1 %18, label %19, label %23
19: ; preds = %16
%20 = load i32, i32* @stderr
%21 = tail call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0))
%22 = tail call i32 @exit(i32 1)
unreachable
23: ; preds = %16, %13
%24 = phi i8* [ %17, %16 ], [ %14, %13 ]
%25 = tail call i32 @atoi(i8* %24)
%26 = call i32 @_load_cpu_mask(i32* %3)
%27 = call i32 @_load_mem_mask(i32* %4)
%28 = call i32 @_mask_to_int(i32* %3)
%29 = call i32 @_mask_to_int(i32* %4)
%30 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0), i32 %25, i32 %28, i32 %29)
%31 = call i32 @exit(i32 0)
unreachable
}