#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_FIXED;
int MAP_PRIVATE;
int /*<<< orphan*/ map_flags(int);
void *mmap(void *, unsigned long, int /*<<< orphan*/, int, int, unsigned long);
void *do_map_in(void *base, unsigned long length, int flags, int fd,
                unsigned long offset) {
  register int op = MAP_PRIVATE;
  if (base)
    op |= MAP_FIXED;
  return mmap(base, length, map_flags(flags), op, fd, offset);
}


x86 assembly (clang, -O0):
<do_map_in>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    0x2e9f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1160 <do_map_in+0x40>
mov    0x2e80(%rip),%rax
mov    (%rax),%eax
or     -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x14(%rbp),%edi
call   1040 <map_flags@plt>
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    %eax,%edx
mov    -0x24(%rbp),%ecx
mov    -0x18(%rbp),%r8d
mov    -0x20(%rbp),%r9
call   1030 <mmap@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_map_in>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %r8,%r14
mov    %ecx,%r15d
mov    %rsi,%r12
mov    %rdi,%rbp
mov    0x2ea5(%rip),%rax
xor    %ebx,%ebx
test   %rdi,%rdi
je     114b <do_map_in+0x2b>
mov    0x2e8f(%rip),%rcx
mov    (%rcx),%ebx
or     (%rax),%ebx
mov    %edx,%edi
call   1040 <map_flags@plt>
mov    %rbp,%rdi
mov    %r12,%rsi
mov    %eax,%edx
mov    %ebx,%ecx
mov    %r15d,%r8d
mov    %r14,%r9
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <mmap@plt>

LLVM IR (-O0):
@MAP_PRIVATE = global i32 0
@MAP_FIXED = global i32 0
define i8* @do_map_in(i8* %0, i64 %1, i32 %2, i32 %3, i64 %4) {
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i32
%9 = alloca i32
%10 = alloca i64
%11 = alloca i32
store i8* %0, i8** %6
store i64 %1, i64* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i64 %4, i64* %10
%12 = load i32, i32* @MAP_PRIVATE
store i32 %12, i32* %11
%13 = load i8*, i8** %6
%14 = icmp ne i8* %13, null
br i1 %14, label %15, label %19
15: ; preds = %5
%16 = load i32, i32* @MAP_FIXED
%17 = load i32, i32* %11
%18 = or i32 %17, %16
store i32 %18, i32* %11
br label %19
19: ; preds = %15, %5
%20 = load i8*, i8** %6
%21 = load i64, i64* %7
%22 = load i32, i32* %8
%23 = call i32 @map_flags(i32 %22)
%24 = load i32, i32* %11
%25 = load i32, i32* %9
%26 = load i64, i64* %10
%27 = call i8* @mmap(i8* %20, i64 %21, i32 %23, i32 %24, i32 %25, i64 %26)
ret i8* %27
}

LLVM IR (-O2):
@MAP_PRIVATE = global i32 0
@MAP_FIXED = global i32 0
define i8* @do_map_in(i8* %0, i64 %1, i32 %2, i32 %3, i64 %4) {
%6 = load i32, i32* @MAP_PRIVATE
%7 = icmp eq i8* %0, null
%8 = load i32, i32* @MAP_FIXED
%9 = select i1 %7, i32 0, i32 %8
%10 = or i32 %9, %6
%11 = tail call i32 @map_flags(i32 %2)
%12 = tail call i8* @mmap(i8* %0, i64 %1, i32 %11, i32 %10, i32 %3, i64 %4)
ret i8* %12
}