#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*/ off_t;

/* Variables and functions */
int /*<<< orphan*/ MAP_SHARED;
int PROT_READ;
int PROT_WRITE;
void *mmap(int /*<<< orphan*/, unsigned long, int, int /*<<< orphan*/, int,
           int /*<<< orphan*/);
int /*<<< orphan*/ munmap(void *, unsigned long);
void srcscr_set_bit(int fd, unsigned int set_mask) {
  void *virt_addr;
  unsigned long read_result;
  virt_addr =
      mmap(0, 4UL, PROT_READ | PROT_WRITE, MAP_SHARED, fd, (off_t)0x020d8000);
  read_result = *((unsigned long *)virt_addr);
  *((unsigned long *)virt_addr) = read_result | set_mask;
  munmap(virt_addr, 4UL);
}


x86 assembly (clang, -O0):
<srcscr_set_bit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    0x2ec3(%rip),%rax
mov    (%rax),%edx
mov    0x2e92(%rip),%rax
or     (%rax),%edx
mov    0x2ea1(%rip),%rax
mov    (%rax),%ecx
mov    -0x4(%rbp),%r8d
xor    %edi,%edi
mov    $0x4,%esi
mov    $0x20d8000,%r9d
call   1030 <mmap@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rcx
mov    -0x8(%rbp),%eax
or     %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rdi
mov    $0x4,%esi
call   1040 <munmap@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<srcscr_set_bit>:
push   %rbx
mov    %esi,%ebx
mov    %edi,%r8d
mov    0x2ecb(%rip),%rax
mov    0x2e9c(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    0x2ea9(%rip),%rax
mov    (%rax),%ecx
mov    $0x4,%esi
xor    %edi,%edi
mov    $0x20d8000,%r9d
call   1030 <mmap@plt>
mov    %ebx,%ecx
or     %rcx,(%rax)
mov    $0x4,%esi
mov    %rax,%rdi
pop    %rbx
jmp    1040 <munmap@plt>

LLVM IR (-O0):
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
define void @srcscr_set_bit(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64
store i32 %0, i32* %3
store i32 %1, i32* %4
%7 = load i32, i32* @PROT_READ
%8 = load i32, i32* @PROT_WRITE
%9 = or i32 %7, %8
%10 = load i32, i32* @MAP_SHARED
%11 = load i32, i32* %3
%12 = call i8* @mmap(i32 0, i64 4, i32 %9, i32 %10, i32 %11, i32 34439168)
store i8* %12, i8** %5
%13 = load i8*, i8** %5
%14 = bitcast i8* %13 to i64*
%15 = load i64, i64* %14
store i64 %15, i64* %6
%16 = load i64, i64* %6
%17 = load i32, i32* %4
%18 = zext i32 %17 to i64
%19 = or i64 %16, %18
%20 = load i8*, i8** %5
%21 = bitcast i8* %20 to i64*
store i64 %19, i64* %21
%22 = load i8*, i8** %5
%23 = call i32 @munmap(i8* %22, i64 4)
ret void
}

LLVM IR (-O2):
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
define void @srcscr_set_bit(i32 %0, i32 %1) {
%3 = load i32, i32* @PROT_READ
%4 = load i32, i32* @PROT_WRITE
%5 = or i32 %4, %3
%6 = load i32, i32* @MAP_SHARED
%7 = tail call i8* @mmap(i32 0, i64 4, i32 %5, i32 %6, i32 %0, i32 34439168)
%8 = bitcast i8* %7 to i64*
%9 = load i64, i64* %8
%10 = zext i32 %1 to i64
%11 = or i64 %9, %10
store i64 %11, i64* %8
%12 = tail call i32 @munmap(i8* %7, i64 4)
ret void
}