#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*/ assert(int /*<<< orphan*/);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
scalar_t__ get_mempolicy(int *, unsigned long *, int, char *, int);
char *numa_alloc_onnode(int, int);
scalar_t__ numa_available();
int /*<<< orphan*/ numa_free(char *, int);
int numa_num_possible_nodes();
int numa_pagesize();
char *numa_realloc(char *, int, int);
int parse_int(char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  char *mem;
  int page_size = numa_pagesize();
  int node = 0;
  int nr_pages = 1024;
  if (numa_available() < 0) {
    fprintf(stderr, "numa is not available");
    exit(1);
  }
  if (argc > 1)
    node = parse_int(argv[1]);
  if (argc > 2)
    nr_pages = parse_int(argv[2]);
  mem = numa_alloc_onnode(page_size, node);
  unsigned long nodemask;
  int mode;
  int nr_nodes = numa_num_possible_nodes();
  if (get_mempolicy(&mode, &nodemask, nr_nodes, mem, (1 << 0) | (1 << 1)) < 0) {
    perror("get_mempolicy() failed");
    exit(1);
  }
  printf("Page size: %d\n", page_size);
  printf("Pages realloc'ed: %d\n", nr_pages);
  printf("Allocate data in node: %d\n", node);
  int i;
  int nr_inplace = 0;
  int nr_moved = 0;
  for (i = 0; i < nr_pages; i++) {
    char *new_mem = numa_realloc(mem, (i + 1) * page_size, (i + 2) * page_size);
    if (!new_mem) {
      perror("numa_realloc() failed");
      exit(1);
    }
    if (new_mem == mem)
      ++nr_inplace;
    else
      ++nr_moved;
    mem = new_mem;
    unsigned long realloc_nodemask;
    int realloc_mode;
    if (get_mempolicy(&realloc_mode, &realloc_nodemask, nr_nodes, mem,
                      (1 << 0) | (1 << 1)) < 0) {
      perror("get_mempolicy() failed");
      exit(1);
    }
    assert(realloc_nodemask == nodemask && realloc_mode == mode &&
           "policy changed");
  }
  mem = numa_realloc(mem, (nr_pages + 1) * page_size, page_size);
  if (!mem) {
    perror("numa_realloc() failed");
    exit(1);
  }
  numa_free(mem, page_size);
  printf("In-place reallocs: %d\n", nr_inplace);
  printf("Moved reallocs: %d\n", nr_moved);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1060 <numa_pagesize@plt>
mov    %eax,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x400,-0x24(%rbp)
mov    $0x0,%al
call   1090 <numa_available@plt>
cmp    $0x0,%rax
jge    122e <main+0x5e>
mov    0x2dca(%rip),%rax
mov    (%rax),%edi
lea    0xde1(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
cmpl   $0x1,-0x8(%rbp)
jle    1248 <main+0x78>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10c0 <parse_int@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x2,-0x8(%rbp)
jle    1262 <main+0x92>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10c0 <parse_int@plt>
mov    %eax,-0x24(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
call   10f0 <numa_alloc_onnode@plt>
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   10d0 <numa_num_possible_nodes@plt>
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%edx
mov    -0x18(%rbp),%rcx
lea    -0x34(%rbp),%rdi
lea    -0x30(%rbp),%rsi
mov    $0x3,%r8d
call   1070 <get_mempolicy@plt>
cmp    $0x0,%rax
jge    12b5 <main+0xe5>
lea    0xd70(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    -0x1c(%rbp),%esi
lea    0xd6e(%rip),%rdi
call   1030 <printf@plt>
mov    -0x24(%rbp),%esi
lea    0xd6e(%rip),%rdi
call   1030 <printf@plt>
mov    -0x20(%rbp),%esi
lea    0xd75(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x40(%rbp)
movl   $0x0,-0x44(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    13f5 <main+0x225>
mov    -0x18(%rbp),%rdi
mov    -0x3c(%rbp),%esi
add    $0x1,%esi
imul   -0x1c(%rbp),%esi
mov    -0x3c(%rbp),%edx
add    $0x2,%edx
imul   -0x1c(%rbp),%edx
call   1080 <numa_realloc@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
jne    1345 <main+0x175>
lea    0xd37(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    -0x50(%rbp),%rax
cmp    -0x18(%rbp),%rax
jne    1361 <main+0x191>
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    136a <main+0x19a>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
mov    -0x50(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x38(%rbp),%edx
mov    -0x18(%rbp),%rcx
lea    -0x5c(%rbp),%rdi
lea    -0x58(%rbp),%rsi
mov    $0x3,%r8d
call   1070 <get_mempolicy@plt>
cmp    $0x0,%rax
jge    13ac <main+0x1dc>
lea    0xc79(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    -0x58(%rbp),%rcx
xor    %eax,%eax
cmp    -0x30(%rbp),%rcx
mov    %al,-0x5d(%rbp)
jne    13da <main+0x20a>
mov    -0x5c(%rbp),%ecx
xor    %eax,%eax
cmp    -0x34(%rbp),%ecx
mov    %al,-0x5d(%rbp)
jne    13da <main+0x20a>
mov    $0x1,%al
mov    %al,-0x5d(%rbp)
jmp    13da <main+0x20a>
mov    -0x5d(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    12f7 <main+0x127>
mov    -0x18(%rbp),%rdi
mov    -0x24(%rbp),%esi
add    $0x1,%esi
imul   -0x1c(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1080 <numa_realloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1430 <main+0x260>
lea    0xc4c(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   10e0 <numa_free@plt>
mov    -0x40(%rbp),%esi
lea    0xc4c(%rip),%rdi
call   1030 <printf@plt>
mov    -0x44(%rbp),%esi
lea    0xc54(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rsi,%r14
mov    %edi,%ebp
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <numa_pagesize@plt>
mov    %eax,%r15d
xor    %eax,%eax
call   1090 <numa_available@plt>
test   %rax,%rax
js     13dc <main+0x20c>
mov    $0x400,%r13d
cmp    $0x2,%ebp
jl     1226 <main+0x56>
mov    0x8(%r14),%rdi
call   10c0 <parse_int@plt>
mov    %eax,%ebx
cmp    $0x2,%ebp
je     1226 <main+0x56>
mov    0x10(%r14),%rdi
call   10c0 <parse_int@plt>
mov    %eax,%r13d
mov    %r15d,%edi
mov    %ebx,%esi
call   10f0 <numa_alloc_onnode@plt>
mov    %rax,%rbp
xor    %eax,%eax
call   10d0 <numa_num_possible_nodes@plt>
lea    0x14(%rsp),%rdi
lea    0x30(%rsp),%rsi
mov    %eax,0xc(%rsp)
mov    %eax,%edx
mov    %rbp,0x18(%rsp)
mov    %rbp,%rcx
mov    $0x3,%r8d
call   1070 <get_mempolicy@plt>
test   %rax,%rax
js     13bd <main+0x1ed>
lea    0xdc0(%rip),%rdi
mov    %r15d,%esi
call   1030 <printf@plt>
lea    0xdc0(%rip),%rdi
mov    %r13d,%esi
call   1030 <printf@plt>
lea    0xdc7(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
test   %r13d,%r13d
mov    %r15,0x20(%rsp)
mov    %r13d,0x8(%rsp)
jle    1352 <main+0x182>
lea    (%r15,%r15,1),%r14d
xor    %r12d,%r12d
movl   $0x0,0x4(%rsp)
mov    0x18(%rsp),%rax
nopl   0x0(%rax)
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r15d,%esi
mov    %r14d,%edx
call   1080 <numa_realloc@plt>
test   %rax,%rax
je     13c6 <main+0x1f6>
mov    %rax,%rbp
lea    0x10(%rsp),%rdi
lea    0x28(%rsp),%rsi
mov    0xc(%rsp),%edx
mov    %rax,%rcx
mov    $0x3,%r8d
call   1070 <get_mempolicy@plt>
test   %rax,%rax
js     13bd <main+0x1ed>
xor    %eax,%eax
xor    %ecx,%ecx
cmp    %rbx,%rbp
sete   %al
setne  %cl
add    %ecx,%r12d
add    %eax,0x4(%rsp)
mov    0x28(%rsp),%rax
cmp    0x30(%rsp),%rax
sete   %al
mov    0x10(%rsp),%ecx
cmp    0x14(%rsp),%ecx
sete   %cl
and    %al,%cl
movzbl %cl,%edi
call   1040 <assert@plt>
mov    0x20(%rsp),%rax
add    %eax,%r14d
add    %eax,%r15d
mov    %rbp,%rax
add    $0xffffffff,%r13d
jne    12c0 <main+0xf0>
jmp    1362 <main+0x192>
movl   $0x0,0x4(%rsp)
xor    %r12d,%r12d
mov    0x18(%rsp),%rbp
mov    0x8(%rsp),%esi
add    $0x1,%esi
mov    0x20(%rsp),%r14
imul   %r14d,%esi
mov    %rbp,%rdi
mov    %r14d,%edx
call   1080 <numa_realloc@plt>
test   %rax,%rax
je     13c6 <main+0x1f6>
mov    %rax,%rdi
mov    %r14d,%esi
call   10e0 <numa_free@plt>
lea    0xcef(%rip),%rdi
mov    0x4(%rsp),%esi
call   1030 <printf@plt>
lea    0xcf6(%rip),%rdi
mov    %r12d,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc52(%rip),%rdi
jmp    13cd <main+0x1fd>
lea    0xca0(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    0x2bfd(%rip),%rax
mov    (%rax),%edi
lea    0xc14(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [22 x i8] c"numa is not available\00"
@.str.1 = [23 x i8] c"get_mempolicy() failed\00"
@.str.2 = [15 x i8] c"Page size: %d\0A\00"
@.str.3 = [22 x i8] c"Pages realloc'ed: %d\0A\00"
@.str.4 = [27 x i8] c"Allocate data in node: %d\0A\00"
@.str.5 = [22 x i8] c"numa_realloc() failed\00"
@.str.6 = [15 x i8] c"policy changed\00"
@.str.7 = [23 x i8] c"In-place reallocs: %d\0A\00"
@.str.8 = [20 x i8] c"Moved reallocs: %d\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
%10 = alloca i64
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i8*
%17 = alloca i64
%18 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%19 = call i32 (...) @numa_pagesize()
store i32 %19, i32* %7
store i32 0, i32* %8
store i32 1024, i32* %9
%20 = call i64 (...) @numa_available()
%21 = icmp slt i64 %20, 0
br i1 %21, label %22, label %26
22: ; preds = %2
%23 = load i32, i32* @stderr
%24 = call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%25 = call i32 @exit(i32 1)
unreachable
26: ; preds = %2
%27 = load i32, i32* %4
%28 = icmp sgt i32 %27, 1
br i1 %28, label %29, label %34
29: ; preds = %26
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 1
%32 = load i8*, i8** %31
%33 = call i32 @parse_int(i8* %32)
store i32 %33, i32* %8
br label %34
34: ; preds = %29, %26
%35 = load i32, i32* %4
%36 = icmp sgt i32 %35, 2
br i1 %36, label %37, label %42
37: ; preds = %34
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 2
%40 = load i8*, i8** %39
%41 = call i32 @parse_int(i8* %40)
store i32 %41, i32* %9
br label %42
42: ; preds = %37, %34
%43 = load i32, i32* %7
%44 = load i32, i32* %8
%45 = call i8* @numa_alloc_onnode(i32 %43, i32 %44)
store i8* %45, i8** %6
%46 = call i32 (...) @numa_num_possible_nodes()
store i32 %46, i32* %12
%47 = load i32, i32* %12
%48 = load i8*, i8** %6
%49 = call i64 @get_mempolicy(i32* %11, i64* %10, i32 %47, i8* %48, i32 3)
%50 = icmp slt i64 %49, 0
br i1 %50, label %51, label %54
51: ; preds = %42
%52 = call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%53 = call i32 @exit(i32 1)
unreachable
54: ; preds = %42
%55 = load i32, i32* %7
%56 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i32 %55)
%57 = load i32, i32* %9
%58 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 %57)
%59 = load i32, i32* %8
%60 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i32 %59)
store i32 0, i32* %14
store i32 0, i32* %15
store i32 0, i32* %13
br label %61
61: ; preds = %113, %54
%62 = load i32, i32* %13
%63 = load i32, i32* %9
%64 = icmp slt i32 %62, %63
br i1 %64, label %65, label %116
65: ; preds = %61
%66 = load i8*, i8** %6
%67 = load i32, i32* %13
%68 = add nsw i32 %67, 1
%69 = load i32, i32* %7
%70 = mul nsw i32 %68, %69
%71 = load i32, i32* %13
%72 = add nsw i32 %71, 2
%73 = load i32, i32* %7
%74 = mul nsw i32 %72, %73
%75 = call i8* @numa_realloc(i8* %66, i32 %70, i32 %74)
store i8* %75, i8** %16
%76 = load i8*, i8** %16
%77 = icmp ne i8* %76, null
br i1 %77, label %81, label %78
78: ; preds = %65
%79 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0))
%80 = call i32 @exit(i32 1)
unreachable
81: ; preds = %65
%82 = load i8*, i8** %16
%83 = load i8*, i8** %6
%84 = icmp eq i8* %82, %83
br i1 %84, label %85, label %88
85: ; preds = %81
%86 = load i32, i32* %14
%87 = add nsw i32 %86, 1
store i32 %87, i32* %14
br label %91
88: ; preds = %81
%89 = load i32, i32* %15
%90 = add nsw i32 %89, 1
store i32 %90, i32* %15
br label %91
91: ; preds = %88, %85
%92 = load i8*, i8** %16
store i8* %92, i8** %6
%93 = load i32, i32* %12
%94 = load i8*, i8** %6
%95 = call i64 @get_mempolicy(i32* %18, i64* %17, i32 %93, i8* %94, i32 3)
%96 = icmp slt i64 %95, 0
br i1 %96, label %97, label %100
97: ; preds = %91
%98 = call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%99 = call i32 @exit(i32 1)
unreachable
100: ; preds = %91
%101 = load i64, i64* %17
%102 = load i64, i64* %10
%103 = icmp eq i64 %101, %102
br i1 %103, label %104, label %109
104: ; preds = %100
%105 = load i32, i32* %18
%106 = load i32, i32* %11
%107 = icmp eq i32 %105, %106
br i1 %107, label %108, label %109
108: ; preds = %104
br label %109
109: ; preds = %108, %104, %100
%110 = phi i1 [ false, %104 ], [ false, %100 ], [ true, %108 ]
%111 = zext i1 %110 to i32
%112 = call i32 @assert(i32 %111)
br label %113
113: ; preds = %109
%114 = load i32, i32* %13
%115 = add nsw i32 %114, 1
store i32 %115, i32* %13
br label %61
116: ; preds = %61
%117 = load i8*, i8** %6
%118 = load i32, i32* %9
%119 = add nsw i32 %118, 1
%120 = load i32, i32* %7
%121 = mul nsw i32 %119, %120
%122 = load i32, i32* %7
%123 = call i8* @numa_realloc(i8* %117, i32 %121, i32 %122)
store i8* %123, i8** %6
%124 = load i8*, i8** %6
%125 = icmp ne i8* %124, null
br i1 %125, label %129, label %126
126: ; preds = %116
%127 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0))
%128 = call i32 @exit(i32 1)
unreachable
129: ; preds = %116
%130 = load i8*, i8** %6
%131 = load i32, i32* %7
%132 = call i32 @numa_free(i8* %130, i32 %131)
%133 = load i32, i32* %14
%134 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0), i32 %133)
%135 = load i32, i32* %15
%136 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0), i32 %135)
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [22 x i8] c"numa is not available\00"
@.str.1 = [23 x i8] c"get_mempolicy() failed\00"
@.str.2 = [15 x i8] c"Page size: %d\0A\00"
@.str.3 = [22 x i8] c"Pages realloc'ed: %d\0A\00"
@.str.4 = [27 x i8] c"Allocate data in node: %d\0A\00"
@.str.5 = [22 x i8] c"numa_realloc() failed\00"
@.str.7 = [23 x i8] c"In-place reallocs: %d\0A\00"
@.str.8 = [20 x i8] c"Moved reallocs: %d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i64
%4 = alloca i32
%5 = alloca i64
%6 = alloca i32
%7 = tail call i32 (...) @numa_pagesize()
%8 = tail call i64 (...) @numa_available()
%9 = icmp slt i64 %8, 0
br i1 %9, label %10, label %14
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%13 = tail call i32 @exit(i32 1)
unreachable
14: ; preds = %2
%15 = icmp sgt i32 %0, 1
br i1 %15, label %16, label %25
16: ; preds = %14
%17 = getelementptr inbounds i8*, i8** %1, i64 1
%18 = load i8*, i8** %17
%19 = tail call i32 @parse_int(i8* %18)
%20 = icmp eq i32 %0, 2
br i1 %20, label %25, label %21
21: ; preds = %16
%22 = getelementptr inbounds i8*, i8** %1, i64 2
%23 = load i8*, i8** %22
%24 = tail call i32 @parse_int(i8* %23)
br label %25
25: ; preds = %14, %21, %16
%26 = phi i32 [ %19, %21 ], [ %19, %16 ], [ 0, %14 ]
%27 = phi i32 [ %24, %21 ], [ 1024, %16 ], [ 1024, %14 ]
%28 = tail call i8* @numa_alloc_onnode(i32 %7, i32 %26)
%29 = bitcast i64* %3 to i8*
%30 = bitcast i32* %4 to i8*
%31 = tail call i32 (...) @numa_num_possible_nodes()
%32 = call i64 @get_mempolicy(i32* %4, i64* %3, i32 %31, i8* %28, i32 3)
%33 = icmp slt i64 %32, 0
br i1 %33, label %34, label %37
34: ; preds = %25
%35 = call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%36 = call i32 @exit(i32 1)
unreachable
37: ; preds = %25
%38 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i32 %7)
%39 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 %27)
%40 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i32 %26)
%41 = icmp sgt i32 %27, 0
br i1 %41, label %42, label %82
42: ; preds = %37
%43 = bitcast i64* %5 to i8*
%44 = bitcast i32* %6 to i8*
br label %45
45: ; preds = %42, %66
%46 = phi i8* [ %28, %42 ], [ %54, %66 ]
%47 = phi i32 [ 0, %42 ], [ %69, %66 ]
%48 = phi i32 [ 0, %42 ], [ %71, %66 ]
%49 = phi i32 [ 0, %42 ], [ %50, %66 ]
%50 = add nuw nsw i32 %49, 1
%51 = mul nsw i32 %50, %7
%52 = add nuw nsw i32 %49, 2
%53 = mul nsw i32 %52, %7
%54 = call i8* @numa_realloc(i8* %46, i32 %51, i32 %53)
%55 = icmp eq i8* %54, null
br i1 %55, label %56, label %59
56: ; preds = %45
%57 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0))
%58 = call i32 @exit(i32 1)
unreachable
59: ; preds = %45
%60 = icmp eq i8* %54, %46
%61 = call i64 @get_mempolicy(i32* %6, i64* %5, i32 %31, i8* %54, i32 3)
%62 = icmp slt i64 %61, 0
br i1 %62, label %63, label %66
63: ; preds = %59
%64 = call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%65 = call i32 @exit(i32 1)
unreachable
66: ; preds = %59
%67 = xor i1 %60, true
%68 = zext i1 %67 to i32
%69 = add nuw nsw i32 %47, %68
%70 = zext i1 %60 to i32
%71 = add nuw nsw i32 %48, %70
%72 = load i64, i64* %5
%73 = load i64, i64* %3
%74 = icmp eq i64 %72, %73
%75 = load i32, i32* %6
%76 = load i32, i32* %4
%77 = icmp eq i32 %75, %76
%78 = select i1 %74, i1 %77, i1 false
%79 = zext i1 %78 to i32
%80 = call i32 @assert(i32 %79)
%81 = icmp eq i32 %50, %27
br i1 %81, label %82, label %45
82: ; preds = %66, %37
%83 = phi i32 [ 0, %37 ], [ %71, %66 ]
%84 = phi i32 [ 0, %37 ], [ %69, %66 ]
%85 = phi i8* [ %28, %37 ], [ %54, %66 ]
%86 = add nsw i32 %27, 1
%87 = mul nsw i32 %86, %7
%88 = call i8* @numa_realloc(i8* %85, i32 %87, i32 %7)
%89 = icmp eq i8* %88, null
br i1 %89, label %90, label %93
90: ; preds = %82
%91 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0))
%92 = call i32 @exit(i32 1)
unreachable
93: ; preds = %82
%94 = call i32 @numa_free(i8* %88, i32 %7)
%95 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0), i32 %83)
%96 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0), i32 %84)
ret i32 0
}