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

/* Variables and functions */
int PROT_EXEC;
int PROT_READ;
int PROT_WRITE;
int /*<<< orphan*/ SYS_mprotect;
int /*<<< orphan*/ assert(int);
scalar_t__ inject_syscall(int /*<<< orphan*/, int, int /*<<< orphan*/, char *,
                          size_t, unsigned long long);
void unprotect_i(pid_t pid, char *start, size_t size) {
  ;
  register_t ret =
      inject_syscall(pid, 3, SYS_mprotect, start, size,
                     (long long unsigned)(PROT_READ | PROT_WRITE | PROT_EXEC));
  assert(ret == 0);
}


x86 assembly (clang, -O0):
<unprotect_i>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2eab(%rip),%rax
mov    (%rax),%edx
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%r8
mov    0x2eaa(%rip),%rax
mov    (%rax),%eax
mov    0x2e71(%rip),%rsi
or     (%rsi),%eax
mov    0x2e78(%rip),%rsi
or     (%rsi),%eax
movslq %eax,%r9
mov    $0x3,%esi
call   1040 <inject_syscall@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<unprotect_i>:
push   %rax
mov    %rdx,%r8
mov    %rsi,%rcx
mov    0x2eba(%rip),%rax
mov    (%rax),%edx
mov    0x2ec1(%rip),%rax
mov    0x2e8a(%rip),%rsi
mov    (%rsi),%esi
or     (%rax),%esi
movslq %esi,%rax
mov    0x2e8c(%rip),%rsi
movslq (%rsi),%r9
or     %rax,%r9
mov    $0x3,%esi
call   1040 <inject_syscall@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
pop    %rax
jmp    1030 <assert@plt>

LLVM IR (-O0):
@SYS_mprotect = global i32 0
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@PROT_EXEC = global i32 0
define void @unprotect_i(i32 %0, i8* %1, i64 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i64
store i32 %0, i32* %4
store i8* %1, i8** %5
store i64 %2, i64* %6
%8 = load i32, i32* %4
%9 = load i32, i32* @SYS_mprotect
%10 = load i8*, i8** %5
%11 = load i64, i64* %6
%12 = load i32, i32* @PROT_READ
%13 = load i32, i32* @PROT_WRITE
%14 = or i32 %12, %13
%15 = load i32, i32* @PROT_EXEC
%16 = or i32 %14, %15
%17 = sext i32 %16 to i64
%18 = call i64 @inject_syscall(i32 %8, i32 3, i32 %9, i8* %10, i64 %11, i64 %17)
store i64 %18, i64* %7
%19 = load i64, i64* %7
%20 = icmp eq i64 %19, 0
%21 = zext i1 %20 to i32
%22 = call i32 @assert(i32 %21)
ret void
}

LLVM IR (-O2):
@SYS_mprotect = global i32 0
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@PROT_EXEC = global i32 0
define void @unprotect_i(i32 %0, i8* %1, i64 %2) {
%4 = load i32, i32* @SYS_mprotect
%5 = load i32, i32* @PROT_READ
%6 = load i32, i32* @PROT_WRITE
%7 = or i32 %6, %5
%8 = load i32, i32* @PROT_EXEC
%9 = or i32 %7, %8
%10 = sext i32 %9 to i64
%11 = tail call i64 @inject_syscall(i32 %0, i32 3, i32 %4, i8* %1, i64 %2, i64 %10)
%12 = icmp eq i64 %11, 0
%13 = zext i1 %12 to i32
%14 = tail call i32 @assert(i32 %13)
ret void
}