#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 */
int /*<<< orphan*/ abort();
int atoi(char *);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
void fprintf(int /*<<< orphan*/, char *, ...);
char *getenv(char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ memcpy(int *, int *, int);
int /*<<< orphan*/ stderr;
char *strtok(char *, char *);
int Get_Affinity_Map(int **list, int total_cores) {
  char *data, *str;
  int list_size;
  int buf[4096], *my_list;
  int cnt, i;
  if ((data = getenv("O64_OMP_AFFINITY_MAP")) == NULL)
    return 0;
  cnt = 0;
  str = strtok(data, ", ");
  while (str && cnt < 4096) {
    int core_id = atoi(str);
    if (core_id == 0 && str[0] != '0')
      fprintf(stderr, "O64_OMP_AFFINITY_MAP: ignored invalid core_id=%s.\n",
              str);
    else if (core_id < 0 || core_id >= total_cores)
      fprintf(stderr, "O64_OMP_AFFINITY_MAP: ignored invalid core_id=%d.\n",
              core_id);
    else
      buf[cnt++] = atoi(str);
    str = strtok(NULL, ", \n");
  }
  if (cnt == 0)
    return 0;
  if (cnt == 4096)
    fprintf(stderr,
            "O64_OMP_AFFINITY_MAP: map is too big, ignore items after %dth.\n",
            4096);
  my_list = (int *)malloc(sizeof(int) * cnt);
  (my_list != NULL
       ? (void)1
       : (fprintf(stderr, "Assertion Failed at %s:%d ",
                  "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                  "outputs/2022-01-22/02-19-57/repos/pumpkin83/OpenUH-OpenACC/"
                  "refs/heads/master/osprey/libopenmp-pcl/omp_util.c",
                  171),
          fprintf(stderr, ("Can't allocate list in Get_Affinity_Map")),
          fprintf(stderr, "\n"), fflush(stderr), abort(), (void)0));
  memcpy(my_list, buf, sizeof(int) * cnt);
  *list = my_list;
  return cnt;
}


x86 assembly (clang, -O0):
<Get_Affinity_Map>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4050,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
lea    0xe67(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    11b8 <Get_Affinity_Map+0x38>
movl   $0x0,-0x4(%rbp)
jmp    13ea <Get_Affinity_Map+0x26a>
movl   $0x0,-0x403c(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xe48(%rip),%rsi
call   1090 <strtok@plt>
mov    %rax,-0x28(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x28(%rbp)
mov    %al,-0x4045(%rbp)
je     11fc <Get_Affinity_Map+0x7c>
cmpl   $0x1000,-0x403c(%rbp)
setl   %al
mov    %al,-0x4045(%rbp)
mov    -0x4045(%rbp),%al
test   $0x1,%al
jne    120f <Get_Affinity_Map+0x8f>
jmp    12dc <Get_Affinity_Map+0x15c>
mov    -0x28(%rbp),%rdi
call   10a0 <atoi@plt>
mov    %eax,-0x4044(%rbp)
cmpl   $0x0,-0x4044(%rbp)
jne    125b <Get_Affinity_Map+0xdb>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x30,%eax
je     125b <Get_Affinity_Map+0xdb>
mov    0x2d9e(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%rdx
lea    0xdc9(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    12c3 <Get_Affinity_Map+0x143>
cmpl   $0x0,-0x4044(%rbp)
jl     1277 <Get_Affinity_Map+0xf7>
mov    -0x4044(%rbp),%eax
cmp    -0x14(%rbp),%eax
jl     1299 <Get_Affinity_Map+0x119>
mov    0x2d62(%rip),%rax
mov    (%rax),%edi
mov    -0x4044(%rbp),%edx
lea    0xdbe(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    12be <Get_Affinity_Map+0x13e>
mov    -0x28(%rbp),%rdi
call   10a0 <atoi@plt>
mov    %eax,%ecx
mov    -0x403c(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x403c(%rbp)
cltq
mov    %ecx,-0x4030(%rbp,%rax,4)
jmp    12c3 <Get_Affinity_Map+0x143>
xor    %eax,%eax
mov    %eax,%edi
lea    0xdb0(%rip),%rsi
call   1090 <strtok@plt>
mov    %rax,-0x28(%rbp)
jmp    11d6 <Get_Affinity_Map+0x56>
cmpl   $0x0,-0x403c(%rbp)
jne    12f5 <Get_Affinity_Map+0x175>
movl   $0x0,-0x4(%rbp)
jmp    13ea <Get_Affinity_Map+0x26a>
cmpl   $0x1000,-0x403c(%rbp)
jne    1321 <Get_Affinity_Map+0x1a1>
mov    0x2cd4(%rip),%rax
mov    (%rax),%edi
lea    0xd6d(%rip),%rsi
mov    $0x1000,%edx
mov    $0x0,%al
call   1050 <fprintf@plt>
movslq -0x403c(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x4038(%rbp)
cmpq   $0x0,-0x4038(%rbp)
je     134d <Get_Affinity_Map+0x1cd>
jmp    13b3 <Get_Affinity_Map+0x233>
mov    0x2c8c(%rip),%rax
mov    (%rax),%edi
lea    0xd65(%rip),%rsi
lea    0xd79(%rip),%rdx
mov    $0xab,%ecx
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2c69(%rip),%rax
mov    (%rax),%edi
lea    0xe02(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2c52(%rip),%rax
mov    (%rax),%edi
lea    0xce9(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2c3b(%rip),%rax
mov    (%rax),%edi
call   1080 <fflush@plt>
mov    $0x0,%al
call   1040 <abort@plt>
mov    -0x4038(%rbp),%rdi
lea    -0x4030(%rbp),%rsi
movslq -0x403c(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edx
call   1060 <memcpy@plt>
mov    -0x4038(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x403c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x4050,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Get_Affinity_Map>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x4018,%rsp
mov    %esi,%ebp
mov    %rdi,%r15
lea    0xe63(%rip),%rdi
call   1030 <getenv@plt>
xor    %ebx,%ebx
test   %rax,%rax
je     12bc <Get_Affinity_Map+0x13c>
lea    0xe61(%rip),%rsi
mov    %rax,%rdi
call   1090 <strtok@plt>
test   %rax,%rax
je     12bc <Get_Affinity_Map+0x13c>
mov    %rax,%r14
mov    %r15,0x8(%rsp)
mov    0x2e0c(%rip),%r15
lea    0xe70(%rip),%r12
lea    0xe9c(%rip),%r13
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
call   10a0 <atoi@plt>
test   %eax,%eax
jne    1202 <Get_Affinity_Map+0x82>
cmpb   $0x30,(%r14)
jne    1231 <Get_Affinity_Map+0xb1>
test   %eax,%eax
js     1220 <Get_Affinity_Map+0xa0>
cmp    %ebp,%eax
jge    1220 <Get_Affinity_Map+0xa0>
movslq %ebx,%rcx
add    $0x1,%ebx
mov    %eax,0x10(%rsp,%rcx,4)
jmp    1250 <Get_Affinity_Map+0xd0>
cs nopw 0x0(%rax,%rax,1)
mov    (%r15),%edi
mov    %r12,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
jmp    1250 <Get_Affinity_Map+0xd0>
mov    (%r15),%edi
lea    0xddd(%rip),%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
cs nopw 0x0(%rax,%rax,1)
nop
xor    %edi,%edi
mov    %r13,%rsi
call   1090 <strtok@plt>
test   %rax,%rax
je     126a <Get_Affinity_Map+0xea>
mov    %rax,%r14
cmp    $0x1000,%ebx
jl     11f0 <Get_Affinity_Map+0x70>
test   %ebx,%ebx
je     12bc <Get_Affinity_Map+0x13c>
cmp    $0x1000,%ebx
jne    128c <Get_Affinity_Map+0x10c>
mov    (%r15),%edi
lea    0xe02(%rip),%rsi
mov    $0x1000,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
lea    0x0(,%rbx,4),%r14d
mov    %r14d,%edi
call   1070 <malloc@plt>
test   %rax,%rax
je     12d0 <Get_Affinity_Map+0x150>
mov    %rax,%rbp
lea    0x10(%rsp),%rsi
mov    %rax,%rdi
mov    %r14d,%edx
call   1060 <memcpy@plt>
mov    0x8(%rsp),%rax
mov    %rbp,(%rax)
mov    %ebx,%eax
add    $0x4018,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    (%r15),%edi
lea    0xde8(%rip),%rsi
lea    0xdfc(%rip),%rdx
mov    $0xab,%ecx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    (%r15),%edi
lea    0xe8b(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    (%r15),%edi
lea    0xd78(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    (%r15),%edi
call   1080 <fflush@plt>
xor    %eax,%eax
call   1040 <abort@plt>

LLVM IR (-O0):
@.str = [21 x i8] c"O64_OMP_AFFINITY_MAP\00"
@.str.1 = [3 x i8] c", \00"
@stderr = global i32 0
@.str.2 = [51 x i8] c"O64_OMP_AFFINITY_MAP: ignored invalid core_id=%s.\0A\00"
@.str.3 = [51 x i8] c"O64_OMP_AFFINITY_MAP: ignored invalid core_id=%d.\0A\00"
@.str.4 = [4 x i8] c", \0A\00"
@.str.5 = [64 x i8] c"O64_OMP_AFFINITY_MAP: map is too big, ignore items after %dth.\0A\00"
@.str.6 = [27 x i8] c"Assertion Failed at %s:%d \00"
@.str.7 = [165 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/pumpkin83/OpenUH-OpenACC/refs/heads/master/osprey/libopenmp-pcl/omp_util.c\00"
@.str.8 = [40 x i8] c"Can't allocate list in Get_Affinity_Map\00"
@.str.9 = [2 x i8] c"\0A\00"
define i32 @Get_Affinity_Map(i32** %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32**
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca [4096 x i32]
%10 = alloca i32*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i32** %0, i32*** %4
store i32 %1, i32* %5
%14 = call i8* @getenv(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
store i8* %14, i8** %6
%15 = icmp eq i8* %14, null
br i1 %15, label %16, label %17
16: ; preds = %2
store i32 0, i32* %3
br label %100
17: ; preds = %2
store i32 0, i32* %11
%18 = load i8*, i8** %6
%19 = call i8* @strtok(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i8* %19, i8** %7
br label %20
20: ; preds = %60, %17
%21 = load i8*, i8** %7
%22 = icmp ne i8* %21, null
br i1 %22, label %23, label %26
23: ; preds = %20
%24 = load i32, i32* %11
%25 = icmp slt i32 %24, 4096
br label %26
26: ; preds = %23, %20
%27 = phi i1 [ false, %20 ], [ %25, %23 ]
br i1 %27, label %28, label %62
28: ; preds = %26
%29 = load i8*, i8** %7
%30 = call i32 @atoi(i8* %29)
store i32 %30, i32* %13
%31 = load i32, i32* %13
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %42
33: ; preds = %28
%34 = load i8*, i8** %7
%35 = getelementptr inbounds i8, i8* %34, i64 0
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = icmp ne i32 %37, 48
br i1 %38, label %39, label %42
39: ; preds = %33
%40 = load i32, i32* @stderr
%41 = load i8*, i8** %7
br label %60
42: ; preds = %33, %28
%43 = load i32, i32* %13
%44 = icmp slt i32 %43, 0
br i1 %44, label %49, label %45
45: ; preds = %42
%46 = load i32, i32* %13
%47 = load i32, i32* %5
%48 = icmp sge i32 %46, %47
br i1 %48, label %49, label %52
49: ; preds = %45, %42
%50 = load i32, i32* @stderr
%51 = load i32, i32* %13
br label %59
52: ; preds = %45
%53 = load i8*, i8** %7
%54 = call i32 @atoi(i8* %53)
%55 = load i32, i32* %11
%56 = add nsw i32 %55, 1
store i32 %56, i32* %11
%57 = sext i32 %55 to i64
%58 = getelementptr inbounds [4096 x i32], [4096 x i32]* %9, i64 0, i64 %57
store i32 %54, i32* %58
br label %59
59: ; preds = %52, %49
br label %60
60: ; preds = %59, %39
%61 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
store i8* %61, i8** %7
br label %20
62: ; preds = %26
%63 = load i32, i32* %11
%64 = icmp eq i32 %63, 0
br i1 %64, label %65, label %66
65: ; preds = %62
store i32 0, i32* %3
br label %100
66: ; preds = %62
%67 = load i32, i32* %11
%68 = icmp eq i32 %67, 4096
br i1 %68, label %69, label %71
69: ; preds = %66
%70 = load i32, i32* @stderr
br label %71
71: ; preds = %69, %66
%72 = load i32, i32* %11
%73 = sext i32 %72 to i64
%74 = mul i64 4, %73
%75 = trunc i64 %74 to i32
%76 = call i64 @malloc(i32 %75)
%77 = inttoptr i64 %76 to i32*
store i32* %77, i32** %10
%78 = load i32*, i32** %10
%79 = icmp ne i32* %78, null
br i1 %79, label %80, label %81
80: ; preds = %71
br label %89
81: ; preds = %71
%82 = load i32, i32* @stderr
%83 = load i32, i32* @stderr
%84 = load i32, i32* @stderr
%85 = load i32, i32* @stderr
%86 = call i32 @fflush(i32 %85)
%87 = call i32 (...) @abort()
unreachable
88: ; No predecessors!
br label %89
89: ; preds = %88, %80
%90 = load i32*, i32** %10
%91 = getelementptr inbounds [4096 x i32], [4096 x i32]* %9, i64 0, i64 0
%92 = load i32, i32* %11
%93 = sext i32 %92 to i64
%94 = mul i64 4, %93
%95 = trunc i64 %94 to i32
%96 = call i32 @memcpy(i32* %90, i32* %91, i32 %95)
%97 = load i32*, i32** %10
%98 = load i32**, i32*** %4
store i32* %97, i32** %98
%99 = load i32, i32* %11
store i32 %99, i32* %3
br label %100
100: ; preds = %89, %65, %16
%101 = load i32, i32* %3
ret i32 %101
}

LLVM IR (-O2):
@.str = [21 x i8] c"O64_OMP_AFFINITY_MAP\00"
@.str.1 = [3 x i8] c", \00"
@stderr = global i32 0
@.str.2 = [51 x i8] c"O64_OMP_AFFINITY_MAP: ignored invalid core_id=%s.\0A\00"
@.str.3 = [51 x i8] c"O64_OMP_AFFINITY_MAP: ignored invalid core_id=%d.\0A\00"
@.str.4 = [4 x i8] c", \0A\00"
@.str.5 = [64 x i8] c"O64_OMP_AFFINITY_MAP: map is too big, ignore items after %dth.\0A\00"
@.str.6 = [27 x i8] c"Assertion Failed at %s:%d \00"
@.str.7 = [165 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/pumpkin83/OpenUH-OpenACC/refs/heads/master/osprey/libopenmp-pcl/omp_util.c\00"
@.str.8 = [40 x i8] c"Can't allocate list in Get_Affinity_Map\00"
@.str.9 = [2 x i8] c"\0A\00"
define i32 @Get_Affinity_Map(i32** nocapture writeonly %0, i32 %1) {
%3 = alloca [4096 x i32]
%4 = bitcast [4096 x i32]* %3 to i8*
%5 = tail call i8* @getenv(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i8* %5, null
br i1 %6, label %54, label %7
7: ; preds = %2
%8 = tail call i8* @strtok(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%9 = icmp eq i8* %8, null
br i1 %9, label %54, label %10
10: ; preds = %7, %30
%11 = phi i8* [ %32, %30 ], [ %8, %7 ]
%12 = phi i32 [ %31, %30 ], [ 0, %7 ]
%13 = tail call i32 @atoi(i8* %11)
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %20
15: ; preds = %10
%16 = load i8, i8* %11
%17 = icmp eq i8 %16, 48
br i1 %17, label %20, label %18
18: ; preds = %15
%19 = load i32, i32* @stderr
tail call void (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.2, i64 0, i64 0), i8* %11)
br label %30
20: ; preds = %15, %10
%21 = icmp sgt i32 %13, -1
%22 = icmp slt i32 %13, %1
%23 = and i1 %21, %22
br i1 %23, label %26, label %24
24: ; preds = %20
%25 = load i32, i32* @stderr
tail call void (i32, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.3, i64 0, i64 0), i32 %13)
br label %30
26: ; preds = %20
%27 = add nsw i32 %12, 1
%28 = sext i32 %12 to i64
%29 = getelementptr inbounds [4096 x i32], [4096 x i32]* %3, i64 0, i64 %28
store i32 %13, i32* %29
br label %30
30: ; preds = %24, %26, %18
%31 = phi i32 [ %12, %18 ], [ %12, %24 ], [ %27, %26 ]
%32 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%33 = icmp ne i8* %32, null
%34 = icmp slt i32 %31, 4096
%35 = select i1 %33, i1 %34, i1 false
br i1 %35, label %10, label %36
36: ; preds = %30
switch i32 %31, label %39 [
i32 0, label %54
i32 4096, label %37
]
37: ; preds = %36
%38 = load i32, i32* @stderr
tail call void (i32, i8*, ...) @fprintf(i32 %38, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.5, i64 0, i64 0), i32 4096)
br label %39
39: ; preds = %36, %37
%40 = shl i32 %31, 2
%41 = tail call i64 @malloc(i32 %40)
%42 = inttoptr i64 %41 to i32*
%43 = icmp eq i64 %41, 0
br i1 %43, label %44, label %51
44: ; preds = %39
%45 = load i32, i32* @stderr
tail call void (i32, i8*, ...) @fprintf(i32 %45, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([165 x i8], [165 x i8]* @.str.7, i64 0, i64 0), i32 171)
%46 = load i32, i32* @stderr
tail call void (i32, i8*, ...) @fprintf(i32 %46, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.8, i64 0, i64 0))
%47 = load i32, i32* @stderr
tail call void (i32, i8*, ...) @fprintf(i32 %47, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
%48 = load i32, i32* @stderr
%49 = tail call i32 @fflush(i32 %48)
%50 = tail call i32 (...) @abort()
unreachable
51: ; preds = %39
%52 = getelementptr inbounds [4096 x i32], [4096 x i32]* %3, i64 0, i64 0
%53 = call i32 @memcpy(i32* %42, i32* %52, i32 %40)
store i32* %42, i32** %0
br label %54
54: ; preds = %7, %36, %2, %51
%55 = phi i32 [ %31, %51 ], [ 0, %2 ], [ %31, %36 ], [ 0, %7 ]
ret i32 %55
}