#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 MAP_ANONYMOUS;
char *MAP_FAILED;
int MAP_LOCKED;
int MAP_PRIVATE;
int PROT_READ;
int PROT_WRITE;
int /*<<< orphan*/ exit(int);
int getpagesize();
char *mmap(int /*<<< orphan*/ *, int, int, int, int /*<<< orphan*/,
           int /*<<< orphan*/);
void sigusr_handler(int __attribute__((unused)) signo) {
  char *p;
  int size = getpagesize() * 2;
  p = mmap(NULL, size, PROT_READ | PROT_WRITE,
           MAP_PRIVATE | MAP_ANONYMOUS | MAP_LOCKED, 0, 0);
  if (p == MAP_FAILED)
    exit(1);
}


x86 assembly (clang, -O0):
<sigusr_handler>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x0,%al
call   1040 <getpagesize@plt>
shl    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
mov    0x2ea6(%rip),%rax
mov    (%rax),%edx
mov    0x2e6d(%rip),%rax
or     (%rax),%edx
mov    0x2e5c(%rip),%rax
mov    (%rax),%ecx
mov    0x2e73(%rip),%rax
or     (%rax),%ecx
mov    0x2e5a(%rip),%rax
or     (%rax),%ecx
xor    %eax,%eax
mov    %eax,%edi
xor    %r9d,%r9d
mov    %r9d,%r8d
call   1030 <mmap@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x2e22(%rip),%rcx
cmp    (%rcx),%rax
jne    11a9 <sigusr_handler+0x79>
mov    $0x1,%edi
call   1050 <exit@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sigusr_handler>:
push   %rax
xor    %eax,%eax
call   1040 <getpagesize@plt>
mov    0x2eb9(%rip),%rcx
mov    0x2e82(%rip),%rdx
mov    (%rdx),%edx
or     (%rcx),%edx
mov    0x2e6f(%rip),%rsi
mov    0x2e88(%rip),%rcx
mov    (%rcx),%ecx
or     (%rsi),%ecx
lea    (%rax,%rax,1),%esi
mov    0x2e6a(%rip),%rax
or     (%rax),%ecx
xor    %edi,%edi
xor    %r8d,%r8d
xor    %r9d,%r9d
call   1030 <mmap@plt>
mov    0x2e3c(%rip),%rcx
cmp    (%rcx),%rax
je     1183 <sigusr_handler+0x53>
pop    %rax
ret
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_PRIVATE = global i32 0
@MAP_ANONYMOUS = global i32 0
@MAP_LOCKED = global i32 0
@MAP_FAILED = global i8* null
define void @sigusr_handler(i32 %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i32 %0, i32* %2
%5 = call i32 (...) @getpagesize()
%6 = mul nsw i32 %5, 2
store i32 %6, i32* %4
%7 = load i32, i32* %4
%8 = load i32, i32* @PROT_READ
%9 = load i32, i32* @PROT_WRITE
%10 = or i32 %8, %9
%11 = load i32, i32* @MAP_PRIVATE
%12 = load i32, i32* @MAP_ANONYMOUS
%13 = or i32 %11, %12
%14 = load i32, i32* @MAP_LOCKED
%15 = or i32 %13, %14
%16 = call i8* @mmap(i32* null, i32 %7, i32 %10, i32 %15, i32 0, i32 0)
store i8* %16, i8** %3
%17 = load i8*, i8** %3
%18 = load i8*, i8** @MAP_FAILED
%19 = icmp eq i8* %17, %18
br i1 %19, label %20, label %22
20: ; preds = %1
%21 = call i32 @exit(i32 1)
unreachable
22: ; preds = %1
ret void
}

LLVM IR (-O2):
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_PRIVATE = global i32 0
@MAP_ANONYMOUS = global i32 0
@MAP_LOCKED = global i32 0
@MAP_FAILED = global i8* null
define void @sigusr_handler(i32 %0) {
%2 = tail call i32 (...) @getpagesize()
%3 = shl nsw i32 %2, 1
%4 = load i32, i32* @PROT_READ
%5 = load i32, i32* @PROT_WRITE
%6 = or i32 %5, %4
%7 = load i32, i32* @MAP_PRIVATE
%8 = load i32, i32* @MAP_ANONYMOUS
%9 = or i32 %8, %7
%10 = load i32, i32* @MAP_LOCKED
%11 = or i32 %9, %10
%12 = tail call i8* @mmap(i32* null, i32 %3, i32 %6, i32 %11, i32 0, i32 0)
%13 = load i8*, i8** @MAP_FAILED
%14 = icmp eq i8* %12, %13
br i1 %14, label %15, label %17
15: ; preds = %1
%16 = tail call i32 @exit(i32 1)
unreachable
17: ; preds = %1
ret void
}