#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_PRIVATE;
int PROT_READ;
int PROT_WRITE;
int /*<<< orphan*/ err(int, char *);
int /*<<< orphan*/ memset(char *, char, int);
char *mmap(int /*<<< orphan*/ *, int, int, int, int /*<<< orphan*/,
           int /*<<< orphan*/);
void sigusr_handler(int __attribute__((unused)) signo) {
  char *p;
  p = mmap(NULL, (1024 * 1024 * 100), PROT_READ | PROT_WRITE,
           MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
  if (p == MAP_FAILED) {
    err(1, "failed to allocate memory!");
  }
  memset(p, 'z', (1024 * 1024 * 100));
}


x86 assembly (clang, -O0):
<sigusr_handler>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    0x2eb6(%rip),%rax
mov    (%rax),%edx
mov    0x2e85(%rip),%rax
or     (%rax),%edx
mov    0x2e74(%rip),%rax
mov    (%rax),%ecx
mov    0x2e83(%rip),%rax
or     (%rax),%ecx
xor    %eax,%eax
mov    %eax,%edi
mov    $0x6400000,%esi
xor    %r9d,%r9d
mov    %r9d,%r8d
call   1030 <mmap@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x2e3e(%rip),%rcx
cmp    (%rcx),%rax
jne    119c <sigusr_handler+0x6c>
mov    $0x1,%edi
lea    0xe69(%rip),%rsi
call   1050 <err@plt>
mov    -0x10(%rbp),%rdi
mov    $0x7a,%esi
mov    $0x6400000,%edx
call   1040 <memset@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sigusr_handler>:
push   %rbx
mov    0x2ec0(%rip),%rax
mov    0x2e91(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    0x2e7e(%rip),%rax
mov    0x2e8f(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
xor    %edi,%edi
mov    $0x6400000,%esi
xor    %r8d,%r8d
xor    %r9d,%r9d
call   1030 <mmap@plt>
mov    %rax,%rbx
mov    0x2e4f(%rip),%rax
cmp    (%rax),%rbx
jne    1187 <sigusr_handler+0x57>
lea    0xe83(%rip),%rsi
mov    $0x1,%edi
call   1050 <err@plt>
mov    %rbx,%rdi
mov    $0x7a,%esi
mov    $0x6400000,%edx
pop    %rbx
jmp    1040 <memset@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_FAILED = global i8* null
@.str = [27 x i8] c"failed to allocate memory!\00"
define void @sigusr_handler(i32 %0) {
%2 = alloca i32
%3 = alloca i8*
store i32 %0, i32* %2
%4 = load i32, i32* @PROT_READ
%5 = load i32, i32* @PROT_WRITE
%6 = or i32 %4, %5
%7 = load i32, i32* @MAP_PRIVATE
%8 = load i32, i32* @MAP_ANONYMOUS
%9 = or i32 %7, %8
%10 = call i8* @mmap(i32* null, i32 104857600, i32 %6, i32 %9, i32 0, i32 0)
store i8* %10, i8** %3
%11 = load i8*, i8** %3
%12 = load i8*, i8** @MAP_FAILED
%13 = icmp eq i8* %11, %12
br i1 %13, label %14, label %16
14: ; preds = %1
%15 = call i32 @err(i32 1, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
br label %16
16: ; preds = %14, %1
%17 = load i8*, i8** %3
%18 = call i32 @memset(i8* %17, i8 signext 122, i32 104857600)
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_FAILED = global i8* null
@.str = [27 x i8] c"failed to allocate memory!\00"
define void @sigusr_handler(i32 %0) {
%2 = load i32, i32* @PROT_READ
%3 = load i32, i32* @PROT_WRITE
%4 = or i32 %3, %2
%5 = load i32, i32* @MAP_PRIVATE
%6 = load i32, i32* @MAP_ANONYMOUS
%7 = or i32 %6, %5
%8 = tail call i8* @mmap(i32* null, i32 104857600, i32 %4, i32 %7, i32 0, i32 0)
%9 = load i8*, i8** @MAP_FAILED
%10 = icmp eq i8* %8, %9
br i1 %10, label %11, label %13
11: ; preds = %1
%12 = tail call i32 @err(i32 1, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; preds = %11, %1
%14 = tail call i32 @memset(i8* %8, i8 signext 122, i32 104857600)
ret void
}