#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_ANON;
void *MAP_FAILED;
int MAP_PRIVATE;
int PROT_EXEC;
int PROT_READ;
int PROT_WRITE;
int /*<<< orphan*/ assert(int);
void *mmap(int /*<<< orphan*/ *, int, int, int, int, int /*<<< orphan*/);
void *partial(void *function, void *first_arg) {
  void *wrapped = mmap(NULL, (64), PROT_READ | PROT_WRITE | PROT_EXEC,
                       MAP_PRIVATE | MAP_ANON, -1, 0);
  if (wrapped == MAP_FAILED) {
    return NULL;
  }
  assert(sizeof(uintptr_t) == 8);
  unsigned char *p = wrapped;
  *p++ = 0x41;
  *p++ = 0x51;
  *p++ = 0x4d;
  *p++ = 0x89;
  *p++ = 0xc1;
  *p++ = 0x49;
  *p++ = 0x89;
  *p++ = 0xc8;
  *p++ = 0x48;
  *p++ = 0x89;
  *p++ = 0xd1;
  *p++ = 0x48;
  *p++ = 0x89;
  *p++ = 0xf2;
  *p++ = 0x48;
  *p++ = 0x89;
  *p++ = 0xfe;
  *p++ = 0x48;
  *p++ = 0xbf;
  *(uintptr_t *)p = (uintptr_t)first_arg;
  p += sizeof(uintptr_t);
  *p++ = 0x48;
  *p++ = 0xb8;
  *(uintptr_t *)p = (uintptr_t)function;
  p += sizeof(uintptr_t);
  *p++ = 0xff;
  *p++ = 0xd0;
  *p++ = 0x41;
  *p++ = 0x59;
  *p++ = 0xc3;
  return wrapped;
}


x86 assembly (clang, -O0):
<partial>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    0x2ec1(%rip),%rax
mov    (%rax),%edx
mov    0x2e90(%rip),%rax
or     (%rax),%edx
mov    0x2e97(%rip),%rax
or     (%rax),%edx
mov    0x2e6e(%rip),%rax
mov    (%rax),%ecx
mov    0x2e6d(%rip),%rax
or     (%rax),%ecx
xor    %eax,%eax
mov    %eax,%edi
mov    $0x40,%esi
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1030 <mmap@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    0x2e35(%rip),%rcx
cmp    (%rcx),%rax
jne    1199 <partial+0x79>
movq   $0x0,-0x8(%rbp)
jmp    13b5 <partial+0x295>
mov    $0x1,%edi
call   1040 <assert@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x28(%rbp)
movb   $0x41,(%rax)
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x28(%rbp)
movb   $0x51,(%rax)
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x28(%rbp)
movb   $0x4d,(%rax)
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x28(%rbp)
movb   $0x89,(%rax)
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x28(%rbp)
movb   $0xc1,(%rax)
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x28(%rbp)
movb   $0x49,(%rax)
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x28(%rbp)
movb   $0x89,(%rax)
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x28(%rbp)
movb   $0xc8,(%rax)
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x28(%rbp)
movb   $0x48,(%rax)
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x28(%rbp)
movb   $0x89,(%rax)
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x28(%rbp)
movb   $0xd1,(%rax)
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x28(%rbp)
movb   $0x48,(%rax)
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x28(%rbp)
movb   $0x89,(%rax)
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x28(%rbp)
movb   $0xf2,(%rax)
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x28(%rbp)
movb   $0x48,(%rax)
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x28(%rbp)
movb   $0x89,(%rax)
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x28(%rbp)
movb   $0xfe,(%rax)
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x28(%rbp)
movb   $0x48,(%rax)
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x28(%rbp)
movb   $0xbf,(%rax)
mov    -0x18(%rbp),%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x28(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x28(%rbp)
movb   $0x48,(%rax)
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x28(%rbp)
movb   $0xb8,(%rax)
mov    -0x10(%rbp),%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x28(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x28(%rbp)
movb   $0xff,(%rax)
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x28(%rbp)
movb   $0xd0,(%rax)
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x28(%rbp)
movb   $0x41,(%rax)
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x28(%rbp)
movb   $0x59,(%rax)
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x28(%rbp)
movb   $0xc3,(%rax)
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<partial>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %rdi,%r14
mov    0x2ec3(%rip),%rax
mov    0x2e94(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    0x2e99(%rip),%rax
or     (%rax),%edx
mov    0x2e70(%rip),%rax
mov    0x2e71(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
xor    %r12d,%r12d
xor    %edi,%edi
mov    $0x40,%esi
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1030 <mmap@plt>
mov    %rax,%rbx
mov    0x2e3b(%rip),%rax
cmp    (%rax),%rbx
je     11bc <partial+0x9c>
mov    $0x1,%edi
call   1040 <assert@plt>
movaps 0xe6d(%rip),%xmm0
movups %xmm0,(%rbx)
movw   $0x48fe,0x10(%rbx)
movb   $0xbf,0x12(%rbx)
mov    %r15,0x13(%rbx)
movw   $0xb848,0x1b(%rbx)
mov    %r14,0x1d(%rbx)
movl   $0x5941d0ff,0x25(%rbx)
movb   $0xc3,0x29(%rbx)
mov    %rbx,%r12
mov    %r12,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@PROT_EXEC = global i32 0
@MAP_PRIVATE = global i32 0
@MAP_ANON = global i32 0
@MAP_FAILED = global i8* null
define i8* @partial(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%8 = load i32, i32* @PROT_READ
%9 = load i32, i32* @PROT_WRITE
%10 = or i32 %8, %9
%11 = load i32, i32* @PROT_EXEC
%12 = or i32 %10, %11
%13 = load i32, i32* @MAP_PRIVATE
%14 = load i32, i32* @MAP_ANON
%15 = or i32 %13, %14
%16 = call i8* @mmap(i32* null, i32 64, i32 %12, i32 %15, i32 -1, i32 0)
store i8* %16, i8** %6
%17 = load i8*, i8** %6
%18 = load i8*, i8** @MAP_FAILED
%19 = icmp eq i8* %17, %18
br i1 %19, label %20, label %21
20: ; preds = %2
store i8* null, i8** %3
br label %89
21: ; preds = %2
%22 = call i32 @assert(i32 1)
%23 = load i8*, i8** %6
store i8* %23, i8** %7
%24 = load i8*, i8** %7
%25 = getelementptr inbounds i8, i8* %24, i32 1
store i8* %25, i8** %7
store i8 65, i8* %24
%26 = load i8*, i8** %7
%27 = getelementptr inbounds i8, i8* %26, i32 1
store i8* %27, i8** %7
store i8 81, i8* %26
%28 = load i8*, i8** %7
%29 = getelementptr inbounds i8, i8* %28, i32 1
store i8* %29, i8** %7
store i8 77, i8* %28
%30 = load i8*, i8** %7
%31 = getelementptr inbounds i8, i8* %30, i32 1
store i8* %31, i8** %7
store i8 -119, i8* %30
%32 = load i8*, i8** %7
%33 = getelementptr inbounds i8, i8* %32, i32 1
store i8* %33, i8** %7
store i8 -63, i8* %32
%34 = load i8*, i8** %7
%35 = getelementptr inbounds i8, i8* %34, i32 1
store i8* %35, i8** %7
store i8 73, i8* %34
%36 = load i8*, i8** %7
%37 = getelementptr inbounds i8, i8* %36, i32 1
store i8* %37, i8** %7
store i8 -119, i8* %36
%38 = load i8*, i8** %7
%39 = getelementptr inbounds i8, i8* %38, i32 1
store i8* %39, i8** %7
store i8 -56, i8* %38
%40 = load i8*, i8** %7
%41 = getelementptr inbounds i8, i8* %40, i32 1
store i8* %41, i8** %7
store i8 72, i8* %40
%42 = load i8*, i8** %7
%43 = getelementptr inbounds i8, i8* %42, i32 1
store i8* %43, i8** %7
store i8 -119, i8* %42
%44 = load i8*, i8** %7
%45 = getelementptr inbounds i8, i8* %44, i32 1
store i8* %45, i8** %7
store i8 -47, i8* %44
%46 = load i8*, i8** %7
%47 = getelementptr inbounds i8, i8* %46, i32 1
store i8* %47, i8** %7
store i8 72, i8* %46
%48 = load i8*, i8** %7
%49 = getelementptr inbounds i8, i8* %48, i32 1
store i8* %49, i8** %7
store i8 -119, i8* %48
%50 = load i8*, i8** %7
%51 = getelementptr inbounds i8, i8* %50, i32 1
store i8* %51, i8** %7
store i8 -14, i8* %50
%52 = load i8*, i8** %7
%53 = getelementptr inbounds i8, i8* %52, i32 1
store i8* %53, i8** %7
store i8 72, i8* %52
%54 = load i8*, i8** %7
%55 = getelementptr inbounds i8, i8* %54, i32 1
store i8* %55, i8** %7
store i8 -119, i8* %54
%56 = load i8*, i8** %7
%57 = getelementptr inbounds i8, i8* %56, i32 1
store i8* %57, i8** %7
store i8 -2, i8* %56
%58 = load i8*, i8** %7
%59 = getelementptr inbounds i8, i8* %58, i32 1
store i8* %59, i8** %7
store i8 72, i8* %58
%60 = load i8*, i8** %7
%61 = getelementptr inbounds i8, i8* %60, i32 1
store i8* %61, i8** %7
store i8 -65, i8* %60
%62 = load i8*, i8** %5
%63 = ptrtoint i8* %62 to i64
%64 = load i8*, i8** %7
%65 = bitcast i8* %64 to i64*
store i64 %63, i64* %65
%66 = load i8*, i8** %7
%67 = getelementptr inbounds i8, i8* %66, i64 8
store i8* %67, i8** %7
%68 = load i8*, i8** %7
%69 = getelementptr inbounds i8, i8* %68, i32 1
store i8* %69, i8** %7
store i8 72, i8* %68
%70 = load i8*, i8** %7
%71 = getelementptr inbounds i8, i8* %70, i32 1
store i8* %71, i8** %7
store i8 -72, i8* %70
%72 = load i8*, i8** %4
%73 = ptrtoint i8* %72 to i64
%74 = load i8*, i8** %7
%75 = bitcast i8* %74 to i64*
store i64 %73, i64* %75
%76 = load i8*, i8** %7
%77 = getelementptr inbounds i8, i8* %76, i64 8
store i8* %77, i8** %7
%78 = load i8*, i8** %7
%79 = getelementptr inbounds i8, i8* %78, i32 1
store i8* %79, i8** %7
store i8 -1, i8* %78
%80 = load i8*, i8** %7
%81 = getelementptr inbounds i8, i8* %80, i32 1
store i8* %81, i8** %7
store i8 -48, i8* %80
%82 = load i8*, i8** %7
%83 = getelementptr inbounds i8, i8* %82, i32 1
store i8* %83, i8** %7
store i8 65, i8* %82
%84 = load i8*, i8** %7
%85 = getelementptr inbounds i8, i8* %84, i32 1
store i8* %85, i8** %7
store i8 89, i8* %84
%86 = load i8*, i8** %7
%87 = getelementptr inbounds i8, i8* %86, i32 1
store i8* %87, i8** %7
store i8 -61, i8* %86
%88 = load i8*, i8** %6
store i8* %88, i8** %3
br label %89
89: ; preds = %21, %20
%90 = load i8*, i8** %3
ret i8* %90
}

LLVM IR (-O2):
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@PROT_EXEC = global i32 0
@MAP_PRIVATE = global i32 0
@MAP_ANON = global i32 0
@MAP_FAILED = global i8* null
define i8* @partial(i8* %0, i8* %1) {
%3 = load i32, i32* @PROT_READ
%4 = load i32, i32* @PROT_WRITE
%5 = or i32 %4, %3
%6 = load i32, i32* @PROT_EXEC
%7 = or i32 %5, %6
%8 = load i32, i32* @MAP_PRIVATE
%9 = load i32, i32* @MAP_ANON
%10 = or i32 %9, %8
%11 = tail call i8* @mmap(i32* null, i32 64, i32 %7, i32 %10, i32 -1, i32 0)
%12 = load i8*, i8** @MAP_FAILED
%13 = icmp eq i8* %11, %12
br i1 %13, label %33, label %14
14: ; preds = %2
%15 = tail call i32 @assert(i32 1)
%16 = getelementptr inbounds i8, i8* %11, i64 16
%17 = bitcast i8* %11 to <16 x i8>*
store <16 x i8> <i8 65, i8 81, i8 77, i8 -119, i8 -63, i8 73, i8 -119, i8 -56, i8 72, i8 -119, i8 -47, i8 72, i8 -119, i8 -14, i8 72, i8 -119>, <16 x i8>* %17
%18 = getelementptr inbounds i8, i8* %11, i64 17
store i8 -2, i8* %16
%19 = getelementptr inbounds i8, i8* %11, i64 18
store i8 72, i8* %18
%20 = getelementptr inbounds i8, i8* %11, i64 19
store i8 -65, i8* %19
%21 = ptrtoint i8* %1 to i64
%22 = bitcast i8* %20 to i64*
store i64 %21, i64* %22
%23 = getelementptr inbounds i8, i8* %11, i64 27
%24 = getelementptr inbounds i8, i8* %11, i64 28
store i8 72, i8* %23
%25 = getelementptr inbounds i8, i8* %11, i64 29
store i8 -72, i8* %24
%26 = ptrtoint i8* %0 to i64
%27 = bitcast i8* %25 to i64*
store i64 %26, i64* %27
%28 = getelementptr inbounds i8, i8* %11, i64 37
%29 = getelementptr inbounds i8, i8* %11, i64 38
store i8 -1, i8* %28
%30 = getelementptr inbounds i8, i8* %11, i64 39
store i8 -48, i8* %29
%31 = getelementptr inbounds i8, i8* %11, i64 40
store i8 65, i8* %30
%32 = getelementptr inbounds i8, i8* %11, i64 41
store i8 89, i8* %31
store i8 -61, i8* %32
br label %33
33: ; preds = %2, %14
%34 = phi i8* [ %11, %14 ], [ null, %2 ]
ret i8* %34
}