#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*/ buffer;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strstr(char *, char *);
void displaymap(void) {
  FILE *f = fopen("/proc/self/numa_maps", "r");
  if (!f) {
    printf("/proc/self/numa_maps not accessible.\n");
    exit(1);
  }
  while (!feof(f)) {
    char buffer[2000];
    if (!fgets(buffer, sizeof(buffer), f))
      break;
    if (!strstr(buffer, "bind"))
      continue;
    printf("%s", buffer);
  }
  fclose(f);
}


x86 assembly (clang, -O0):
<displaymap>:
push   %rbp
mov    %rsp,%rbp
sub    $0x7e0,%rsp
lea    0xe7e(%rip),%rdi
lea    0xe8c(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    11b5 <displaymap+0x45>
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
jmp    11ba <displaymap+0x4a>
mov    -0x8(%rbp),%rdi
call   1060 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11d8 <displaymap+0x68>
jmp    1236 <displaymap+0xc6>
lea    -0x7e0(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x7d0,%esi
call   1050 <fgets@plt>
cmp    $0x0,%eax
jne    11fb <displaymap+0x8b>
jmp    1236 <displaymap+0xc6>
lea    -0x7e0(%rbp),%rdi
lea    0xe34(%rip),%rsi
call   1090 <strstr@plt>
cmp    $0x0,%eax
jne    121c <displaymap+0xac>
jmp    11ba <displaymap+0x4a>
lea    -0x7e0(%rbp),%rsi
lea    0xe18(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11ba <displaymap+0x4a>
mov    -0x8(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x7e0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<displaymap>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x7d8,%rsp
lea    0xe6b(%rip),%rdi
lea    0xe79(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     121e <displaymap+0x9e>
mov    %rax,%rbx
mov    %rax,%rdi
call   1070 <feof@plt>
test   %eax,%eax
je     11cc <displaymap+0x4c>
mov    %rbx,%rdi
call   1040 <fclose@plt>
add    $0x7d8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
mov    %rsp,%r14
lea    0xe41(%rip),%r15
lea    0xe3f(%rip),%r12
jmp    11ec <displaymap+0x6c>
nop
mov    %rbx,%rdi
call   1070 <feof@plt>
test   %eax,%eax
jne    11b5 <displaymap+0x35>
mov    %r14,%rdi
mov    $0x7d0,%esi
mov    %rbx,%rdx
call   1060 <fgets@plt>
test   %eax,%eax
je     11b5 <displaymap+0x35>
mov    %r14,%rdi
mov    %r15,%rsi
call   10a0 <strstr@plt>
test   %eax,%eax
je     11e0 <displaymap+0x60>
mov    %r12,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11e0 <displaymap+0x60>
lea    0xdfa(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [21 x i8] c"/proc/self/numa_maps\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [38 x i8] c"/proc/self/numa_maps not accessible.\0A\00"
@.str.3 = [5 x i8] c"bind\00"
@.str.4 = [3 x i8] c"%s\00"
define void @displaymap() {
%1 = alloca i32*
%2 = alloca [2000 x i8]
%3 = call i32* @fopen(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %3, i32** %1
%4 = load i32*, i32** %1
%5 = icmp ne i32* %4, null
br i1 %5, label %9, label %6
6: ; preds = %0
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 @exit(i32 1)
unreachable
9: ; preds = %0
br label %10
10: ; preds = %26, %25, %9
%11 = load i32*, i32** %1
%12 = call i32 @feof(i32* %11)
%13 = icmp ne i32 %12, 0
%14 = xor i1 %13, true
br i1 %14, label %15, label %29
15: ; preds = %10
%16 = getelementptr inbounds [2000 x i8], [2000 x i8]* %2, i64 0, i64 0
%17 = load i32*, i32** %1
%18 = call i32 @fgets(i8* %16, i32 2000, i32* %17)
%19 = icmp ne i32 %18, 0
br i1 %19, label %21, label %20
20: ; preds = %15
br label %29
21: ; preds = %15
%22 = getelementptr inbounds [2000 x i8], [2000 x i8]* %2, i64 0, i64 0
%23 = call i32 @strstr(i8* %22, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%24 = icmp ne i32 %23, 0
br i1 %24, label %26, label %25
25: ; preds = %21
br label %10
26: ; preds = %21
%27 = getelementptr inbounds [2000 x i8], [2000 x i8]* %2, i64 0, i64 0
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %27)
br label %10
29: ; preds = %20, %10
%30 = load i32*, i32** %1
%31 = call i32 @fclose(i32* %30)
ret void
}

LLVM IR (-O2):
@.str = [21 x i8] c"/proc/self/numa_maps\00"
@.str.1 = [2 x i8] c"r\00"
@.str.3 = [5 x i8] c"bind\00"
@.str.4 = [3 x i8] c"%s\00"
@str = [37 x i8] c"/proc/self/numa_maps not accessible.\00"
define void @displaymap() {
%1 = alloca [2000 x i8]
%2 = tail call i32* @fopen(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%3 = icmp eq i32* %2, null
br i1 %3, label %9, label %4
4: ; preds = %0
%5 = call i32 @feof(i32* %2)
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %24
7: ; preds = %4
%8 = getelementptr inbounds [2000 x i8], [2000 x i8]* %1, i64 0, i64 0
br label %12
9: ; preds = %0
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0))
%11 = tail call i32 @exit(i32 1)
unreachable
12: ; preds = %7, %21
%13 = call i32 @fgets(i8* %8, i32 2000, i32* %2)
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %12
br label %24
16: ; preds = %12
%17 = call i32 @strstr(i8* %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%18 = icmp eq i32 %17, 0
br i1 %18, label %21, label %19
19: ; preds = %16
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %8)
br label %21
21: ; preds = %16, %19
%22 = call i32 @feof(i32* %2)
%23 = icmp eq i32 %22, 0
br i1 %23, label %12, label %24
24: ; preds = %21, %4, %15
%25 = call i32 @fclose(i32* %2)
ret void
}