#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 MADV_DOFORK;
int MADV_DONTFORK;
int MADV_DONTNEED;
int MADV_NORMAL;
int MADV_RANDOM;
int MADV_REMOVE;
int MADV_SEQUENTIAL;
int MADV_WILLNEED;
int /*<<< orphan*/ MAP_SHARED;
int O_CREAT;
int O_RDWR;
int PATH_MAX;
int /*<<< orphan*/ PROT_READ;
int /*<<< orphan*/ close(int);
int getpid();
int /*<<< orphan*/ madvise(void *, size_t, int);
void *mmap(int /*<<< orphan*/ *, size_t, int /*<<< orphan*/, int /*<<< orphan*/,
           int, int /*<<< orphan*/);
int /*<<< orphan*/ munmap(void *, size_t);
int open(char *, int, int);
int /*<<< orphan*/ sprintf(char *, char *, char *, int);
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ unlink(char *);
int /*<<< orphan*/ write(int, char *, int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  char *str_for_file = "abcdefghijklmnopqrstuvwxyz12345\n";
  char filename[PATH_MAX];
  int i, fd;
  void *file;
  size_t size = 40960;
  sprintf(filename, "%s-out.%d", *argv, getpid());
  fd = open(filename, O_RDWR | O_CREAT, 0664);
  for (i = 0; i < 1280; i++)
    write(fd, str_for_file, strlen(str_for_file));
  file = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0);
  madvise((void *)-1, size, MADV_NORMAL);
  madvise(file, (size_t)-1, MADV_NORMAL);
  madvise(file, size, -1);
  madvise(file, size, MADV_NORMAL);
  madvise(file, size, MADV_RANDOM);
  madvise(file, size, MADV_SEQUENTIAL);
  madvise(file, size, MADV_WILLNEED);
  madvise(file, size, MADV_DONTNEED);
  madvise(file, size, MADV_REMOVE);
  madvise(file, size, MADV_DONTFORK);
  madvise(file, size, MADV_DOFORK);
  munmap(file, size);
  close(fd);
  unlink(filename);
  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)
lea    0xe43(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0x2e18(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x48(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
movq   $0xa000,-0x40(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x50(%rbp)
mov    $0x0,%al
call   1050 <getpid@plt>
mov    -0x50(%rbp),%rdx
mov    -0x48(%rbp),%rdi
mov    %eax,%ecx
lea    0xe09(%rip),%rsi
call   10c0 <sprintf@plt>
mov    -0x48(%rbp),%rdi
mov    0x2da0(%rip),%rax
mov    (%rax),%esi
mov    0x2dc7(%rip),%rax
or     (%rax),%esi
mov    $0x1b4,%edx
call   10b0 <open@plt>
mov    %eax,-0x30(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpl   $0x500,-0x2c(%rbp)
jge    1287 <main+0xe7>
mov    -0x30(%rbp),%eax
mov    %eax,-0x5c(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x5c(%rbp),%edi
mov    -0x58(%rbp),%rsi
mov    %eax,%edx
call   1040 <write@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1247 <main+0xa7>
mov    -0x40(%rbp),%rsi
mov    0x2d5e(%rip),%rax
mov    (%rax),%edx
mov    0x2d3d(%rip),%rax
mov    (%rax),%ecx
mov    -0x30(%rbp),%r8d
xor    %eax,%eax
mov    %eax,%edi
xor    %r9d,%r9d
call   1070 <mmap@plt>
mov    %rax,-0x38(%rbp)
mov    -0x40(%rbp),%rsi
mov    0x2d04(%rip),%rax
mov    (%rax),%edx
mov    $0xffffffffffffffff,%rdi
call   10a0 <madvise@plt>
mov    -0x38(%rbp),%rdi
mov    0x2ceb(%rip),%rax
mov    (%rax),%edx
mov    $0xffffffffffffffff,%rsi
call   10a0 <madvise@plt>
mov    -0x38(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    $0xffffffff,%edx
call   10a0 <madvise@plt>
mov    -0x38(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    0x2cbc(%rip),%rax
mov    (%rax),%edx
call   10a0 <madvise@plt>
mov    -0x38(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    0x2c7e(%rip),%rax
mov    (%rax),%edx
call   10a0 <madvise@plt>
mov    -0x38(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    0x2c50(%rip),%rax
mov    (%rax),%edx
call   10a0 <madvise@plt>
mov    -0x38(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    0x2c4a(%rip),%rax
mov    (%rax),%edx
call   10a0 <madvise@plt>
mov    -0x38(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    0x2c4c(%rip),%rax
mov    (%rax),%edx
call   10a0 <madvise@plt>
mov    -0x38(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    0x2c46(%rip),%rax
mov    (%rax),%edx
call   10a0 <madvise@plt>
mov    -0x38(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    0x2c18(%rip),%rax
mov    (%rax),%edx
call   10a0 <madvise@plt>
mov    -0x38(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    0x2bda(%rip),%rax
mov    (%rax),%edx
call   10a0 <madvise@plt>
mov    -0x38(%rbp),%rdi
mov    -0x40(%rbp),%rsi
call   1090 <munmap@plt>
mov    -0x30(%rbp),%edi
call   1080 <close@plt>
mov    -0x48(%rbp),%rdi
call   1030 <unlink@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    0x2e2e(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%r14
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r14
mov    %r14,%rsp
mov    (%rsi),%rbx
xor    %eax,%eax
call   1050 <getpid@plt>
lea    0xe4b(%rip),%rsi
mov    %r14,%rdi
mov    %rbx,%rdx
mov    %eax,%ecx
call   10c0 <sprintf@plt>
mov    0x2dde(%rip),%rax
mov    0x2e07(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    %r14,%rdi
mov    $0x1b4,%edx
call   10b0 <open@plt>
mov    %eax,%r12d
mov    $0x500,%ebx
lea    0xdef(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
call   1060 <strlen@plt>
mov    %r12d,%edi
mov    %r15,%rsi
mov    %eax,%edx
call   1040 <write@plt>
add    $0xffffffff,%ebx
jne    1220 <main+0x80>
mov    0x2daf(%rip),%rax
mov    (%rax),%edx
mov    0x2d8e(%rip),%rax
mov    (%rax),%ecx
mov    $0xa000,%esi
xor    %edi,%edi
mov    %r12d,%r8d
xor    %r9d,%r9d
call   1070 <mmap@plt>
mov    %rax,%r15
mov    0x2d58(%rip),%rbx
mov    (%rbx),%edx
mov    $0xa000,%esi
mov    $0xffffffffffffffff,%rdi
call   10a0 <madvise@plt>
mov    (%rbx),%edx
mov    %r15,%rdi
mov    $0xffffffffffffffff,%rsi
call   10a0 <madvise@plt>
mov    $0xa000,%esi
mov    %r15,%rdi
mov    $0xffffffff,%edx
call   10a0 <madvise@plt>
mov    (%rbx),%edx
mov    $0xa000,%esi
mov    %r15,%rdi
call   10a0 <madvise@plt>
mov    0x2ce4(%rip),%rax
mov    (%rax),%edx
mov    $0xa000,%esi
mov    %r15,%rdi
call   10a0 <madvise@plt>
mov    0x2cb6(%rip),%rax
mov    (%rax),%edx
mov    $0xa000,%esi
mov    %r15,%rdi
call   10a0 <madvise@plt>
mov    0x2cb0(%rip),%rax
mov    (%rax),%edx
mov    $0xa000,%esi
mov    %r15,%rdi
call   10a0 <madvise@plt>
mov    0x2cb2(%rip),%rax
mov    (%rax),%edx
mov    $0xa000,%esi
mov    %r15,%rdi
call   10a0 <madvise@plt>
mov    0x2cac(%rip),%rax
mov    (%rax),%edx
mov    $0xa000,%esi
mov    %r15,%rdi
call   10a0 <madvise@plt>
mov    0x2c7e(%rip),%rax
mov    (%rax),%edx
mov    $0xa000,%esi
mov    %r15,%rdi
call   10a0 <madvise@plt>
mov    0x2c40(%rip),%rax
mov    (%rax),%edx
mov    $0xa000,%esi
mov    %r15,%rdi
call   10a0 <madvise@plt>
mov    $0xa000,%esi
mov    %r15,%rdi
call   1090 <munmap@plt>
mov    %r12d,%edi
call   1080 <close@plt>
mov    %r14,%rdi
call   1030 <unlink@plt>
xor    %eax,%eax
lea    -0x20(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [33 x i8] c"abcdefghijklmnopqrstuvwxyz12345\0A\00"
@PATH_MAX = global i32 0
@.str.1 = [10 x i8] c"%s-out.%d\00"
@O_RDWR = global i32 0
@O_CREAT = global i32 0
@PROT_READ = global i32 0
@MAP_SHARED = global i32 0
@MADV_NORMAL = global i32 0
@MADV_RANDOM = global i32 0
@MADV_SEQUENTIAL = global i32 0
@MADV_WILLNEED = global i32 0
@MADV_DONTNEED = global i32 0
@MADV_REMOVE = global i32 0
@MADV_DONTFORK = global i32 0
@MADV_DOFORK = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8** %6
%13 = load i32, i32* @PATH_MAX
%14 = zext i32 %13 to i64
%15 = call i8* @llvm.stacksave()
store i8* %15, i8** %7
%16 = alloca i8, i64 %14
store i64 %14, i64* %8
store i64 40960, i64* %12
%17 = load i8**, i8*** %5
%18 = load i8*, i8** %17
%19 = call i32 (...) @getpid()
%20 = call i32 @sprintf(i8* %16, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %18, i32 %19)
%21 = load i32, i32* @O_RDWR
%22 = load i32, i32* @O_CREAT
%23 = or i32 %21, %22
%24 = call i32 @open(i8* %16, i32 %23, i32 436)
store i32 %24, i32* %10
store i32 0, i32* %9
br label %25
25: ; preds = %34, %2
%26 = load i32, i32* %9
%27 = icmp slt i32 %26, 1280
br i1 %27, label %28, label %37
28: ; preds = %25
%29 = load i32, i32* %10
%30 = load i8*, i8** %6
%31 = load i8*, i8** %6
%32 = call i32 @strlen(i8* %31)
%33 = call i32 @write(i32 %29, i8* %30, i32 %32)
br label %34
34: ; preds = %28
%35 = load i32, i32* %9
%36 = add nsw i32 %35, 1
store i32 %36, i32* %9
br label %25
37: ; preds = %25
%38 = load i64, i64* %12
%39 = load i32, i32* @PROT_READ
%40 = load i32, i32* @MAP_SHARED
%41 = load i32, i32* %10
%42 = call i8* @mmap(i32* null, i64 %38, i32 %39, i32 %40, i32 %41, i32 0)
store i8* %42, i8** %11
%43 = load i64, i64* %12
%44 = load i32, i32* @MADV_NORMAL
%45 = call i32 @madvise(i8* inttoptr (i64 -1 to i8*), i64 %43, i32 %44)
%46 = load i8*, i8** %11
%47 = load i32, i32* @MADV_NORMAL
%48 = call i32 @madvise(i8* %46, i64 -1, i32 %47)
%49 = load i8*, i8** %11
%50 = load i64, i64* %12
%51 = call i32 @madvise(i8* %49, i64 %50, i32 -1)
%52 = load i8*, i8** %11
%53 = load i64, i64* %12
%54 = load i32, i32* @MADV_NORMAL
%55 = call i32 @madvise(i8* %52, i64 %53, i32 %54)
%56 = load i8*, i8** %11
%57 = load i64, i64* %12
%58 = load i32, i32* @MADV_RANDOM
%59 = call i32 @madvise(i8* %56, i64 %57, i32 %58)
%60 = load i8*, i8** %11
%61 = load i64, i64* %12
%62 = load i32, i32* @MADV_SEQUENTIAL
%63 = call i32 @madvise(i8* %60, i64 %61, i32 %62)
%64 = load i8*, i8** %11
%65 = load i64, i64* %12
%66 = load i32, i32* @MADV_WILLNEED
%67 = call i32 @madvise(i8* %64, i64 %65, i32 %66)
%68 = load i8*, i8** %11
%69 = load i64, i64* %12
%70 = load i32, i32* @MADV_DONTNEED
%71 = call i32 @madvise(i8* %68, i64 %69, i32 %70)
%72 = load i8*, i8** %11
%73 = load i64, i64* %12
%74 = load i32, i32* @MADV_REMOVE
%75 = call i32 @madvise(i8* %72, i64 %73, i32 %74)
%76 = load i8*, i8** %11
%77 = load i64, i64* %12
%78 = load i32, i32* @MADV_DONTFORK
%79 = call i32 @madvise(i8* %76, i64 %77, i32 %78)
%80 = load i8*, i8** %11
%81 = load i64, i64* %12
%82 = load i32, i32* @MADV_DOFORK
%83 = call i32 @madvise(i8* %80, i64 %81, i32 %82)
%84 = load i8*, i8** %11
%85 = load i64, i64* %12
%86 = call i32 @munmap(i8* %84, i64 %85)
%87 = load i32, i32* %10
%88 = call i32 @close(i32 %87)
%89 = call i32 @unlink(i8* %16)
store i32 0, i32* %3
%90 = load i8*, i8** %7
%91 = load i32, i32* %3
ret i32 %91
}

LLVM IR (-O2):
@.str = [33 x i8] c"abcdefghijklmnopqrstuvwxyz12345\0A\00"
@PATH_MAX = global i32 0
@.str.1 = [10 x i8] c"%s-out.%d\00"
@O_RDWR = global i32 0
@O_CREAT = global i32 0
@PROT_READ = global i32 0
@MAP_SHARED = global i32 0
@MADV_NORMAL = global i32 0
@MADV_RANDOM = global i32 0
@MADV_SEQUENTIAL = global i32 0
@MADV_WILLNEED = global i32 0
@MADV_DONTNEED = global i32 0
@MADV_REMOVE = global i32 0
@MADV_DONTFORK = global i32 0
@MADV_DOFORK = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = load i32, i32* @PATH_MAX
%4 = zext i32 %3 to i64
%5 = alloca i8, i64 %4
%6 = load i8*, i8** %1
%7 = tail call i32 (...) @getpid()
%8 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %6, i32 %7)
%9 = load i32, i32* @O_RDWR
%10 = load i32, i32* @O_CREAT
%11 = or i32 %10, %9
%12 = call i32 @open(i8* %5, i32 %11, i32 436)
br label %13
13: ; preds = %2, %13
%14 = phi i32 [ 0, %2 ], [ %17, %13 ]
%15 = tail call i32 @strlen(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%16 = tail call i32 @write(i32 %12, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = add nuw nsw i32 %14, 1
%18 = icmp eq i32 %17, 1280
br i1 %18, label %19, label %13
19: ; preds = %13
%20 = load i32, i32* @PROT_READ
%21 = load i32, i32* @MAP_SHARED
%22 = tail call i8* @mmap(i32* null, i64 40960, i32 %20, i32 %21, i32 %12, i32 0)
%23 = load i32, i32* @MADV_NORMAL
%24 = tail call i32 @madvise(i8* inttoptr (i64 -1 to i8*), i64 40960, i32 %23)
%25 = load i32, i32* @MADV_NORMAL
%26 = tail call i32 @madvise(i8* %22, i64 -1, i32 %25)
%27 = tail call i32 @madvise(i8* %22, i64 40960, i32 -1)
%28 = load i32, i32* @MADV_NORMAL
%29 = tail call i32 @madvise(i8* %22, i64 40960, i32 %28)
%30 = load i32, i32* @MADV_RANDOM
%31 = tail call i32 @madvise(i8* %22, i64 40960, i32 %30)
%32 = load i32, i32* @MADV_SEQUENTIAL
%33 = tail call i32 @madvise(i8* %22, i64 40960, i32 %32)
%34 = load i32, i32* @MADV_WILLNEED
%35 = tail call i32 @madvise(i8* %22, i64 40960, i32 %34)
%36 = load i32, i32* @MADV_DONTNEED
%37 = tail call i32 @madvise(i8* %22, i64 40960, i32 %36)
%38 = load i32, i32* @MADV_REMOVE
%39 = tail call i32 @madvise(i8* %22, i64 40960, i32 %38)
%40 = load i32, i32* @MADV_DONTFORK
%41 = tail call i32 @madvise(i8* %22, i64 40960, i32 %40)
%42 = load i32, i32* @MADV_DOFORK
%43 = tail call i32 @madvise(i8* %22, i64 40960, i32 %42)
%44 = tail call i32 @munmap(i8* %22, i64 40960)
%45 = tail call i32 @close(i32 %12)
%46 = call i32 @unlink(i8* %5)
ret i32 0
}