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


x86 assembly (clang, -O0):
<muc_to_nocache>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    $0x80000000,%eax
cmp    %rax,-0x10(%rbp)
jb     114e <muc_to_nocache+0x4e>
mov    $0x80080000,%eax
cmp    %rax,-0x10(%rbp)
jae    114e <muc_to_nocache+0x4e>
mov    -0x10(%rbp),%rax
movabs $0x80000000,%rcx
sub    %rcx,%rax
add    $0x60000000,%rax
mov    %rax,-0x10(%rbp)
jmp    119f <muc_to_nocache+0x9f>
cmpq   $0x0,-0x10(%rbp)
jb     117e <muc_to_nocache+0x7e>
cmpq   $0x8000000,-0x10(%rbp)
08
jae    117e <muc_to_nocache+0x7e>
mov    -0x10(%rbp),%rax
sub    $0x0,%rax
add    $0x40000000,%rax
mov    %rax,-0x10(%rbp)
jmp    119a <muc_to_nocache+0x9a>
mov    $0xc0000000,%eax
cmp    %rax,-0x10(%rbp)
jae    1195 <muc_to_nocache+0x95>
movq   $0x0,-0x10(%rbp)
jmp    119a <muc_to_nocache+0x9a>
jmp    119f <muc_to_nocache+0x9f>
mov    -0x10(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<muc_to_nocache>:
mov    %rdi,%rax
mov    $0x80080000,%ecx
test   $0xffffffff80000000,%rdi
je     111d <muc_to_nocache+0x1d>
cmp    %rcx,%rax
jae    111d <muc_to_nocache+0x1d>
add    $0xffffffffe0000000,%rax
ret
cmp    $0x7ffffff,%rax
ja     112c <muc_to_nocache+0x2c>
add    $0x40000000,%rax
ret
add    $0x3ff80000,%rcx
xor    %edx,%edx
cmp    %rcx,%rax
cmovb  %rdx,%rax
ret

LLVM IR (-O0):
define weak i8* @muc_to_nocache(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, 2147483648
br i1 %7, label %8, label %15
8: ; preds = %1
%9 = load i64, i64* %3
%10 = icmp ult i64 %9, 2148007936
br i1 %10, label %11, label %15
11: ; preds = %8
%12 = load i64, i64* %3
%13 = sub i64 %12, 2147483648
%14 = add i64 %13, 1610612736
store i64 %14, i64* %3
br label %31
15: ; preds = %8, %1
%16 = load i64, i64* %3
%17 = icmp uge i64 %16, 0
br i1 %17, label %18, label %25
18: ; preds = %15
%19 = load i64, i64* %3
%20 = icmp ult i64 %19, 134217728
br i1 %20, label %21, label %25
21: ; preds = %18
%22 = load i64, i64* %3
%23 = sub i64 %22, 0
%24 = add i64 %23, 1073741824
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* @muc_to_nocache(i8* %0) {
%2 = ptrtoint i8* %0 to i64
%3 = icmp ugt i8* %0, inttoptr (i64 2147483647 to i8*)
%4 = icmp ult i8* %0, inttoptr (i64 2148007936 to i8*)
%5 = and i1 %3, %4
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = add i64 %2, -536870912
br label %15
8: ; preds = %1
%9 = icmp ult i8* %0, inttoptr (i64 134217728 to i8*)
br i1 %9, label %10, label %12
10: ; preds = %8
%11 = add i64 %2, 1073741824
br label %15
12: ; preds = %8
%13 = icmp ult i8* %0, inttoptr (i64 3221225472 to i8*)
%14 = select i1 %13, i64 0, i64 %2
br label %15
15: ; preds = %10, %12, %6
%16 = phi i64 [ %7, %6 ], [ %11, %10 ], [ %14, %12 ]
%17 = inttoptr i64 %16 to i8*
ret i8* %17
}