__attribute__((weak)) void *nocache_to_muc(const void *addr) {
  unsigned long ret = (unsigned long)addr;
  if ((((ret) >= (0x60000000)) &&
       ((ret) < (0x60000000) + ((8 * (64 * 1024)))))) {
    ret = ret - 0x60000000 + 0x80000000;
  } else if ((((ret) >= (0x40000000)) &&
              ((ret) < (0x40000000) + ((128 * 1024 * 1024))))) {
    ret = ret - 0x40000000 + 0x0;
  } else if (ret < 0xC0000000) {
    ret = (unsigned long)((void *)((unsigned long)0));
  }
  return (void *)ret;
}


x86 assembly (clang, -O0):
<nocache_to_muc>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
cmpq   $0x60000000,-0x10(%rbp)
60
jb     114c <nocache_to_muc+0x4c>
cmpq   $0x60080000,-0x10(%rbp)
60
jae    114c <nocache_to_muc+0x4c>
mov    -0x10(%rbp),%rax
sub    $0x60000000,%rax
movabs $0x80000000,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
jmp    11a0 <nocache_to_muc+0xa0>
cmpq   $0x40000000,-0x10(%rbp)
40
jb     117f <nocache_to_muc+0x7f>
cmpq   $0x48000000,-0x10(%rbp)
48
jae    117f <nocache_to_muc+0x7f>
mov    -0x10(%rbp),%rax
sub    $0x40000000,%rax
add    $0x0,%rax
mov    %rax,-0x10(%rbp)
jmp    119b <nocache_to_muc+0x9b>
mov    $0xc0000000,%eax
cmp    %rax,-0x10(%rbp)
jae    1196 <nocache_to_muc+0x96>
movq   $0x0,-0x10(%rbp)
jmp    119b <nocache_to_muc+0x9b>
jmp    11a0 <nocache_to_muc+0xa0>
mov    -0x10(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<nocache_to_muc>:
cmp    $0x60000000,%rdi
jb     111d <nocache_to_muc+0x1d>
cmp    $0x6007ffff,%rdi
ja     111d <nocache_to_muc+0x1d>
add    $0x20000000,%rdi
mov    %rdi,%rax
ret
cmp    $0x40000000,%rdi
jb     113a <nocache_to_muc+0x3a>
cmp    $0x47ffffff,%rdi
ja     113a <nocache_to_muc+0x3a>
add    $0xffffffffc0000000,%rdi
mov    %rdi,%rax
ret
mov    %rdi,%rcx
shr    $0x1e,%rcx
xor    %eax,%eax
cmp    $0x3,%rcx
cmovae %rdi,%rax
ret

LLVM IR (-O0):
define weak i8* @nocache_to_muc(i8* %0) {
%2 = alloca i8*
%3 = alloca i64
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = ptrtoint i8* %4 to i64
store i64 %5, i64* %3
%6 = load i64, i64* %3
%7 = icmp uge i64 %6, 1610612736
br i1 %7, label %8, label %15
8: ; preds = %1
%9 = load i64, i64* %3
%10 = icmp ult i64 %9, 1611137024
br i1 %10, label %11, label %15
11: ; preds = %8
%12 = load i64, i64* %3
%13 = sub i64 %12, 1610612736
%14 = add i64 %13, 2147483648
store i64 %14, i64* %3
br label %31
15: ; preds = %8, %1
%16 = load i64, i64* %3
%17 = icmp uge i64 %16, 1073741824
br i1 %17, label %18, label %25
18: ; preds = %15
%19 = load i64, i64* %3
%20 = icmp ult i64 %19, 1207959552
br i1 %20, label %21, label %25
21: ; preds = %18
%22 = load i64, i64* %3
%23 = sub i64 %22, 1073741824
%24 = add i64 %23, 0
store i64 %24, i64* %3
br label %30
25: ; preds = %18, %15
%26 = load i64, i64* %3
%27 = icmp ult i64 %26, 3221225472
br i1 %27, label %28, label %29
28: ; preds = %25
store i64 0, i64* %3
br label %29
29: ; preds = %28, %25
br label %30
30: ; preds = %29, %21
br label %31
31: ; preds = %30, %11
%32 = load i64, i64* %3
%33 = inttoptr i64 %32 to i8*
ret i8* %33
}

LLVM IR (-O2):
define weak i8* @nocache_to_muc(i8* %0) {
%2 = ptrtoint i8* %0 to i64
%3 = icmp ugt i8* %0, inttoptr (i64 1610612735 to i8*)
%4 = icmp ult i8* %0, inttoptr (i64 1611137024 to i8*)
%5 = and i1 %3, %4
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = add i64 %2, 536870912
br label %17
8: ; preds = %1
%9 = icmp ugt i8* %0, inttoptr (i64 1073741823 to i8*)
%10 = icmp ult i8* %0, inttoptr (i64 1207959552 to i8*)
%11 = and i1 %9, %10
br i1 %11, label %12, label %14
12: ; preds = %8
%13 = add i64 %2, -1073741824
br label %17
14: ; preds = %8
%15 = icmp ult i8* %0, inttoptr (i64 3221225472 to i8*)
%16 = select i1 %15, i64 0, i64 %2
br label %17
17: ; preds = %12, %14, %6
%18 = phi i64 [ %7, %6 ], [ %13, %12 ], [ %16, %14 ]
%19 = inttoptr i64 %18 to i8*
ret i8* %19
}