#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__ 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,
           scalar_t__);
int /*<<< orphan*/ munmap(void *, unsigned long);
void rdc_reset(int fd) {
  int n;
  void *map_base, *virt_addr;
  off_t target;
  target = (off_t)0x020FC000;
  map_base = mmap(0, 4096UL, PROT_READ | PROT_WRITE, MAP_SHARED, fd, target);
  virt_addr = (unsigned char *)map_base + 0x808;
  *((unsigned long *)virt_addr) = 0xff;
  virt_addr = (unsigned char *)map_base + 0x80C;
  *((unsigned long *)virt_addr) = 0x0;
  for (n = 0; n < 110; n++) {
    virt_addr = (unsigned char *)map_base + 0x400 + (n * 0x4);
    *((unsigned long *)virt_addr) = 0xFF;
  }
  virt_addr = (unsigned char *)map_base + 0x204;
  *((unsigned long *)virt_addr) = 0x0;
  munmap(map_base, 4096UL);
}


x86 assembly (clang, -O0):
<rdc_reset>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movq   $0x20fc000,-0x20(%rbp)
02
mov    0x2ebe(%rip),%rax
mov    (%rax),%edx
mov    0x2e8d(%rip),%rax
or     (%rax),%edx
mov    0x2e9c(%rip),%rax
mov    (%rax),%ecx
mov    -0x4(%rbp),%r8d
mov    -0x20(%rbp),%r9
xor    %edi,%edi
mov    $0x1000,%esi
call   1030 <mmap@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0x808,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movq   $0xff,(%rax)
mov    -0x10(%rbp),%rax
add    $0x80c,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movq   $0x0,(%rax)
movl   $0x0,-0x8(%rbp)
cmpl   $0x6e,-0x8(%rbp)
jge    11dc <rdc_reset+0xbc>
mov    -0x10(%rbp),%rax
add    $0x400,%rax
mov    -0x8(%rbp),%ecx
shl    $0x2,%ecx
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movq   $0xff,(%rax)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    119f <rdc_reset+0x7f>
mov    -0x10(%rbp),%rax
add    $0x204,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
mov    $0x1000,%esi
call   1040 <munmap@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rdc_reset>:
push   %rax
mov    %edi,%r8d
mov    0x2ecd(%rip),%rax
mov    0x2e9e(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    0x2eab(%rip),%rax
mov    (%rax),%ecx
mov    $0x1000,%esi
mov    $0x20fc000,%r9d
xor    %edi,%edi
call   1030 <mmap@plt>
movq   $0xff,0x808(%rax)
movq   $0x0,0x80c(%rax)
mov    $0x104,%ecx
nopl   0x0(%rax)
movq   $0xff,-0x10(%rax,%rcx,4)
movq   $0xff,-0xc(%rax,%rcx,4)
movq   $0xff,-0x8(%rax,%rcx,4)
movq   $0xff,-0x4(%rax,%rcx,4)
movq   $0xff,(%rax,%rcx,4)
add    $0x5,%rcx
cmp    $0x172,%rcx
jne    1170 <rdc_reset+0x50>
movq   $0x0,0x204(%rax)
mov    $0x1000,%esi
mov    %rax,%rdi
pop    %rax
jmp    1040 <munmap@plt>

LLVM IR (-O0):
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
define void @rdc_reset(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
store i32 %0, i32* %2
store i64 34586624, i64* %6
%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* %2
%12 = load i64, i64* %6
%13 = call i8* @mmap(i32 0, i64 4096, i32 %9, i32 %10, i32 %11, i64 %12)
store i8* %13, i8** %4
%14 = load i8*, i8** %4
%15 = getelementptr inbounds i8, i8* %14, i64 2056
store i8* %15, i8** %5
%16 = load i8*, i8** %5
%17 = bitcast i8* %16 to i64*
store i64 255, i64* %17
%18 = load i8*, i8** %4
%19 = getelementptr inbounds i8, i8* %18, i64 2060
store i8* %19, i8** %5
%20 = load i8*, i8** %5
%21 = bitcast i8* %20 to i64*
store i64 0, i64* %21
store i32 0, i32* %3
br label %22
22: ; preds = %34, %1
%23 = load i32, i32* %3
%24 = icmp slt i32 %23, 110
br i1 %24, label %25, label %37
25: ; preds = %22
%26 = load i8*, i8** %4
%27 = getelementptr inbounds i8, i8* %26, i64 1024
%28 = load i32, i32* %3
%29 = mul nsw i32 %28, 4
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %27, i64 %30
store i8* %31, i8** %5
%32 = load i8*, i8** %5
%33 = bitcast i8* %32 to i64*
store i64 255, i64* %33
br label %34
34: ; preds = %25
%35 = load i32, i32* %3
%36 = add nsw i32 %35, 1
store i32 %36, i32* %3
br label %22
37: ; preds = %22
%38 = load i8*, i8** %4
%39 = getelementptr inbounds i8, i8* %38, i64 516
store i8* %39, i8** %5
%40 = load i8*, i8** %5
%41 = bitcast i8* %40 to i64*
store i64 0, i64* %41
%42 = load i8*, i8** %4
%43 = call i32 @munmap(i8* %42, i64 4096)
ret void
}

LLVM IR (-O2):
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
define void @rdc_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 4096, i32 %4, i32 %5, i32 %0, i64 34586624)
%7 = getelementptr inbounds i8, i8* %6, i64 2056
%8 = bitcast i8* %7 to i64*
store i64 255, i64* %8
%9 = getelementptr inbounds i8, i8* %6, i64 2060
%10 = bitcast i8* %9 to i64*
store i64 0, i64* %10
%11 = getelementptr inbounds i8, i8* %6, i64 1024
br label %12
12: ; preds = %12, %1
%13 = phi i64 [ 0, %1 ], [ %33, %12 ]
%14 = shl nuw nsw i64 %13, 2
%15 = getelementptr inbounds i8, i8* %11, i64 %14
%16 = bitcast i8* %15 to i64*
store i64 255, i64* %16
%17 = shl i64 %13, 2
%18 = add i64 %17, 4
%19 = getelementptr inbounds i8, i8* %11, i64 %18
%20 = bitcast i8* %19 to i64*
store i64 255, i64* %20
%21 = shl i64 %13, 2
%22 = add i64 %21, 8
%23 = getelementptr inbounds i8, i8* %11, i64 %22
%24 = bitcast i8* %23 to i64*
store i64 255, i64* %24
%25 = shl i64 %13, 2
%26 = add i64 %25, 12
%27 = getelementptr inbounds i8, i8* %11, i64 %26
%28 = bitcast i8* %27 to i64*
store i64 255, i64* %28
%29 = shl i64 %13, 2
%30 = add i64 %29, 16
%31 = getelementptr inbounds i8, i8* %11, i64 %30
%32 = bitcast i8* %31 to i64*
store i64 255, i64* %32
%33 = add nuw nsw i64 %13, 5
%34 = icmp eq i64 %33, 110
br i1 %34, label %35, label %12
35: ; preds = %12
%36 = getelementptr inbounds i8, i8* %6, i64 516
%37 = bitcast i8* %36 to i64*
store i64 0, i64* %37
%38 = tail call i32 @munmap(i8* %6, i64 4096)
ret void
}