#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*/ MAP_SHARED;
int /*<<< orphan*/ POSIX_FADV_DONTNEED;
int PROT_READ;
int PROT_WRITE;
char *mmap(int /*<<< orphan*/ *, int, int, int /*<<< orphan*/, int,
           int /*<<< orphan*/);
int /*<<< orphan*/ munmap(char *, int);
int /*<<< orphan*/ posix_fadvise(int, int /*<<< orphan*/, int,
                                 int /*<<< orphan*/);
char *remap(int fd, char *mapping) {
  if (mapping) {
    munmap(mapping, (((100 << 20) / (1460)) * (1460)));
    posix_fadvise(fd, 0, (((100 << 20) / (1460)) * (1460)),
                  POSIX_FADV_DONTNEED);
  }
  return mmap(NULL, (((100 << 20) / (1460)) * (1460)), PROT_READ | PROT_WRITE,
              MAP_SHARED, fd, 0);
}


x86 assembly (clang, -O0):
<remap>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1170 <remap+0x40>
mov    -0x10(%rbp),%rdi
mov    $0x63ffe70,%esi
call   1050 <munmap@plt>
mov    -0x4(%rbp),%edi
mov    0x2e86(%rip),%rax
mov    (%rax),%ecx
xor    %esi,%esi
mov    $0x63ffe70,%edx
call   1040 <posix_fadvise@plt>
mov    0x2e81(%rip),%rax
mov    (%rax),%edx
mov    0x2e48(%rip),%rax
or     (%rax),%edx
mov    0x2e57(%rip),%rax
mov    (%rax),%ecx
mov    -0x4(%rbp),%r8d
xor    %eax,%eax
mov    %eax,%edi
mov    $0x63ffe70,%esi
xor    %r9d,%r9d
call   1030 <mmap@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<remap>:
push   %rbx
mov    %edi,%ebx
test   %rsi,%rsi
je     115c <remap+0x2c>
mov    %rsi,%rdi
mov    $0x63ffe70,%esi
call   1050 <munmap@plt>
mov    0x2e9c(%rip),%rax
mov    (%rax),%ecx
mov    %ebx,%edi
xor    %esi,%esi
mov    $0x63ffe70,%edx
call   1040 <posix_fadvise@plt>
mov    0x2e95(%rip),%rax
mov    0x2e5e(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    0x2e6b(%rip),%rax
mov    (%rax),%ecx
xor    %edi,%edi
mov    $0x63ffe70,%esi
mov    %ebx,%r8d
xor    %r9d,%r9d
pop    %rbx
jmp    1030 <mmap@plt>

LLVM IR (-O0):
@POSIX_FADV_DONTNEED = global i32 0
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
define i8* @remap(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
store i32 %0, i32* %3
store i8* %1, i8** %4
%5 = load i8*, i8** %4
%6 = icmp ne i8* %5, null
br i1 %6, label %7, label %13
7: ; preds = %2
%8 = load i8*, i8** %4
%9 = call i32 @munmap(i8* %8, i32 104857200)
%10 = load i32, i32* %3
%11 = load i32, i32* @POSIX_FADV_DONTNEED
%12 = call i32 @posix_fadvise(i32 %10, i32 0, i32 104857200, i32 %11)
br label %13
13: ; preds = %7, %2
%14 = load i32, i32* @PROT_READ
%15 = load i32, i32* @PROT_WRITE
%16 = or i32 %14, %15
%17 = load i32, i32* @MAP_SHARED
%18 = load i32, i32* %3
%19 = call i8* @mmap(i32* null, i32 104857200, i32 %16, i32 %17, i32 %18, i32 0)
ret i8* %19
}

LLVM IR (-O2):
@POSIX_FADV_DONTNEED = global i32 0
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
define i8* @remap(i32 %0, i8* %1) {
%3 = icmp eq i8* %1, null
br i1 %3, label %8, label %4
4: ; preds = %2
%5 = tail call i32 @munmap(i8* %1, i32 104857200)
%6 = load i32, i32* @POSIX_FADV_DONTNEED
%7 = tail call i32 @posix_fadvise(i32 %0, i32 0, i32 104857200, i32 %6)
br label %8
8: ; preds = %4, %2
%9 = load i32, i32* @PROT_READ
%10 = load i32, i32* @PROT_WRITE
%11 = or i32 %10, %9
%12 = load i32, i32* @MAP_SHARED
%13 = tail call i8* @mmap(i32* null, i32 104857200, i32 %11, i32 %12, i32 %0, i32 0)
ret i8* %13
}