#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 */
typedef int /*<<< orphan*/ uint64_t;
typedef int /*<<< orphan*/ pid_t;
typedef scalar_t__ off_t;

/* Variables and functions */
int /*<<< orphan*/ SYS_mmap;
scalar_t__ remote_syscall(int /*<<< orphan*/, int /*<<< orphan*/,
                          int /*<<< orphan*/, int /*<<< orphan*/,
                          int /*<<< orphan*/, int /*<<< orphan*/,
                          int /*<<< orphan*/, int /*<<< orphan*/);
void *remote_mmap(pid_t pid, void *addr, size_t len, int prot, int flags,
                  int fd, off_t offset) {
  return (void *)remote_syscall(pid, SYS_mmap, (uint64_t)addr, (uint64_t)len,
                                (uint64_t)prot, (uint64_t)flags, (uint64_t)fd,
                                (uint64_t)offset);
}


x86 assembly (clang, -O0):
<remote_mmap>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x10(%rbp),%rax
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    %r9d,-0x24(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2ea4(%rip),%rax
mov    (%rax),%esi
mov    -0x10(%rbp),%rax
mov    %eax,%edx
mov    -0x18(%rbp),%rax
mov    %eax,%ecx
mov    -0x1c(%rbp),%r8d
mov    -0x20(%rbp),%r9d
mov    -0x24(%rbp),%r10d
mov    0x10(%rbp),%rax
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
call   1030 <remote_syscall@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<remote_mmap>:
push   %rax
mov    %r9d,%eax
mov    %r8d,%r9d
mov    %ecx,%r8d
mov    %rdx,%rcx
mov    %rsi,%rdx
mov    0x10(%rsp),%r10d
mov    0x2eb4(%rip),%rsi
mov    (%rsi),%esi
push   %r10
push   %rax
call   1030 <remote_syscall@plt>
add    $0x10,%rsp
pop    %rcx
ret

LLVM IR (-O0):
@SYS_mmap = global i32 0
define i8* @remote_mmap(i32 %0, i8* %1, i64 %2, i32 %3, i32 %4, i32 %5, i64 %6) {
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i64
store i32 %0, i32* %8
store i8* %1, i8** %9
store i64 %2, i64* %10
store i32 %3, i32* %11
store i32 %4, i32* %12
store i32 %5, i32* %13
store i64 %6, i64* %14
%15 = load i32, i32* %8
%16 = load i32, i32* @SYS_mmap
%17 = load i8*, i8** %9
%18 = ptrtoint i8* %17 to i32
%19 = load i64, i64* %10
%20 = trunc i64 %19 to i32
%21 = load i32, i32* %11
%22 = load i32, i32* %12
%23 = load i32, i32* %13
%24 = load i64, i64* %14
%25 = trunc i64 %24 to i32
%26 = call i64 @remote_syscall(i32 %15, i32 %16, i32 %18, i32 %20, i32 %21, i32 %22, i32 %23, i32 %25)
%27 = inttoptr i64 %26 to i8*
ret i8* %27
}

LLVM IR (-O2):
@SYS_mmap = global i32 0
define i8* @remote_mmap(i32 %0, i8* %1, i64 %2, i32 %3, i32 %4, i32 %5, i64 %6) {
%8 = load i32, i32* @SYS_mmap
%9 = ptrtoint i8* %1 to i64
%10 = trunc i64 %9 to i32
%11 = trunc i64 %2 to i32
%12 = trunc i64 %6 to i32
%13 = tail call i64 @remote_syscall(i32 %0, i32 %8, i32 %10, i32 %11, i32 %3, i32 %4, i32 %5, i32 %12)
%14 = inttoptr i64 %13 to i8*
ret i8* %14
}