#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 aips123_reset(int fd) {
  void *virt_addr;
  unsigned long read_result;
  virt_addr =
      mmap(0, 4UL, PROT_READ | PROT_WRITE, MAP_SHARED, fd, (off_t)0x0207C000);
  read_result = *((unsigned long *)virt_addr);
  *((unsigned long *)virt_addr) = 0x77777777;
  munmap(virt_addr, 4UL);
  virt_addr =
      mmap(0, 4UL, PROT_READ | PROT_WRITE, MAP_SHARED, fd, (off_t)0x0217C000);
  read_result = *((unsigned long *)virt_addr);
  *((unsigned long *)virt_addr) = 0x77777777;
  munmap(virt_addr, 4UL);
  virt_addr =
      mmap(0, 4UL, PROT_READ | PROT_WRITE, MAP_SHARED, fd, (off_t)0x0227C000);
  read_result = *((unsigned long *)virt_addr);
  *((unsigned long *)virt_addr) = 0x77777777;
  munmap(virt_addr, 4UL);
}


x86 assembly (clang, -O0):
<aips123_reset>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    0x2ec6(%rip),%rax
mov    (%rax),%edx
mov    0x2e95(%rip),%rax
or     (%rax),%edx
mov    0x2ea4(%rip),%rax
mov    (%rax),%ecx
mov    -0x4(%rbp),%r8d
xor    %edi,%edi
mov    $0x4,%esi
mov    $0x207c000,%r9d
call   1030 <mmap@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movq   $0x77777777,(%rax)
mov    -0x10(%rbp),%rdi
mov    $0x4,%esi
call   1040 <munmap@plt>
mov    0x2e6d(%rip),%rax
mov    (%rax),%edx
mov    0x2e3c(%rip),%rax
or     (%rax),%edx
mov    0x2e4b(%rip),%rax
mov    (%rax),%ecx
mov    -0x4(%rbp),%r8d
xor    %edi,%edi
mov    $0x4,%esi
mov    $0x217c000,%r9d
call   1030 <mmap@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movq   $0x77777777,(%rax)
mov    -0x10(%rbp),%rdi
mov    $0x4,%esi
call   1040 <munmap@plt>
mov    0x2e14(%rip),%rax
mov    (%rax),%edx
mov    0x2de3(%rip),%rax
or     (%rax),%edx
mov    0x2df2(%rip),%rax
mov    (%rax),%ecx
mov    -0x4(%rbp),%r8d
xor    %edi,%edi
mov    $0x4,%esi
mov    $0x227c000,%r9d
call   1030 <mmap@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movq   $0x77777777,(%rax)
mov    -0x10(%rbp),%rdi
mov    $0x4,%esi
call   1040 <munmap@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<aips123_reset>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %edi,%ebx
mov    0x2ec7(%rip),%r14
mov    0x2e98(%rip),%r15
mov    (%r15),%edx
or     (%r14),%edx
mov    0x2ea3(%rip),%r12
mov    (%r12),%ecx
mov    $0x4,%esi
xor    %edi,%edi
mov    %ebx,%r8d
mov    $0x207c000,%r9d
call   1030 <mmap@plt>
movq   $0x77777777,(%rax)
mov    $0x4,%esi
mov    %rax,%rdi
call   1040 <munmap@plt>
mov    (%r15),%edx
or     (%r14),%edx
mov    (%r12),%ecx
mov    $0x4,%esi
xor    %edi,%edi
mov    %ebx,%r8d
mov    $0x217c000,%r9d
call   1030 <mmap@plt>
movq   $0x77777777,(%rax)
mov    $0x4,%esi
mov    %rax,%rdi
call   1040 <munmap@plt>
mov    (%r15),%edx
or     (%r14),%edx
mov    (%r12),%ecx
mov    $0x4,%esi
xor    %edi,%edi
mov    %ebx,%r8d
mov    $0x227c000,%r9d
call   1030 <mmap@plt>
movq   $0x77777777,(%rax)
mov    $0x4,%esi
mov    %rax,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1040 <munmap@plt>

LLVM IR (-O0):
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
define void @aips123_reset(i32 %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i64
store i32 %0, i32* %2
%5 = load i32, i32* @PROT_READ
%6 = load i32, i32* @PROT_WRITE
%7 = or i32 %5, %6
%8 = load i32, i32* @MAP_SHARED
%9 = load i32, i32* %2
%10 = call i8* @mmap(i32 0, i64 4, i32 %7, i32 %8, i32 %9, i32 34062336)
store i8* %10, i8** %3
%11 = load i8*, i8** %3
%12 = bitcast i8* %11 to i64*
%13 = load i64, i64* %12
store i64 %13, i64* %4
%14 = load i8*, i8** %3
%15 = bitcast i8* %14 to i64*
store i64 2004318071, i64* %15
%16 = load i8*, i8** %3
%17 = call i32 @munmap(i8* %16, i64 4)
%18 = load i32, i32* @PROT_READ
%19 = load i32, i32* @PROT_WRITE
%20 = or i32 %18, %19
%21 = load i32, i32* @MAP_SHARED
%22 = load i32, i32* %2
%23 = call i8* @mmap(i32 0, i64 4, i32 %20, i32 %21, i32 %22, i32 35110912)
store i8* %23, i8** %3
%24 = load i8*, i8** %3
%25 = bitcast i8* %24 to i64*
%26 = load i64, i64* %25
store i64 %26, i64* %4
%27 = load i8*, i8** %3
%28 = bitcast i8* %27 to i64*
store i64 2004318071, i64* %28
%29 = load i8*, i8** %3
%30 = call i32 @munmap(i8* %29, i64 4)
%31 = load i32, i32* @PROT_READ
%32 = load i32, i32* @PROT_WRITE
%33 = or i32 %31, %32
%34 = load i32, i32* @MAP_SHARED
%35 = load i32, i32* %2
%36 = call i8* @mmap(i32 0, i64 4, i32 %33, i32 %34, i32 %35, i32 36159488)
store i8* %36, i8** %3
%37 = load i8*, i8** %3
%38 = bitcast i8* %37 to i64*
%39 = load i64, i64* %38
store i64 %39, i64* %4
%40 = load i8*, i8** %3
%41 = bitcast i8* %40 to i64*
store i64 2004318071, i64* %41
%42 = load i8*, i8** %3
%43 = call i32 @munmap(i8* %42, i64 4)
ret void
}

LLVM IR (-O2):
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
define void @aips123_reset(i32 %0) {
%2 = load i32, i32* @PROT_READ
%3 = load i32, i32* @PROT_WRITE
%4 = or i32 %3, %2
%5 = load i32, i32* @MAP_SHARED
%6 = tail call i8* @mmap(i32 0, i64 4, i32 %4, i32 %5, i32 %0, i32 34062336)
%7 = bitcast i8* %6 to i64*
store i64 2004318071, i64* %7
%8 = tail call i32 @munmap(i8* %6, i64 4)
%9 = load i32, i32* @PROT_READ
%10 = load i32, i32* @PROT_WRITE
%11 = or i32 %10, %9
%12 = load i32, i32* @MAP_SHARED
%13 = tail call i8* @mmap(i32 0, i64 4, i32 %11, i32 %12, i32 %0, i32 35110912)
%14 = bitcast i8* %13 to i64*
store i64 2004318071, i64* %14
%15 = tail call i32 @munmap(i8* %13, i64 4)
%16 = load i32, i32* @PROT_READ
%17 = load i32, i32* @PROT_WRITE
%18 = or i32 %17, %16
%19 = load i32, i32* @MAP_SHARED
%20 = tail call i8* @mmap(i32 0, i64 4, i32 %18, i32 %19, i32 %0, i32 36159488)
%21 = bitcast i8* %20 to i64*
store i64 2004318071, i64* %21
%22 = tail call i32 @munmap(i8* %20, i64 4)
ret void
}