#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 uint32_t;

/* Variables and functions */
int /*<<< orphan*/ __L1C_MaintainDCacheSetWay(int, int);
int __get_CLIDR();
void __L1C_CleanInvalidateCache(uint32_t op) {
  register volatile uint32_t clidr;
  uint32_t cache_type;
  clidr = __get_CLIDR();
  for (uint32_t i = 0; i < 7; i++) {
    cache_type = (clidr >> i * 3) & 0x7UL;
    if ((cache_type >= 2) && (cache_type <= 4)) {
      __L1C_MaintainDCacheSetWay(i, op);
    }
  }
}


x86 assembly (clang, -O0):
<__L1C_CleanInvalidateCache>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x0,%al
call   1030 <__get_CLIDR@plt>
mov    %eax,-0x8(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x7,-0x10(%rbp)
jge    118a <__L1C_CleanInvalidateCache+0x6a>
mov    -0x8(%rbp),%eax
imul   $0x3,-0x10(%rbp),%ecx
sar    %cl,%eax
cltq
and    $0x7,%rax
mov    %eax,-0xc(%rbp)
cmpl   $0x2,-0xc(%rbp)
jl     1177 <__L1C_CleanInvalidateCache+0x57>
cmpl   $0x4,-0xc(%rbp)
jg     1177 <__L1C_CleanInvalidateCache+0x57>
mov    -0x10(%rbp),%edi
mov    -0x4(%rbp),%esi
call   1040 <__L1C_MaintainDCacheSetWay@plt>
jmp    117c <__L1C_CleanInvalidateCache+0x5c>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    113c <__L1C_CleanInvalidateCache+0x1c>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__L1C_CleanInvalidateCache>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
xor    %eax,%eax
call   1030 <__get_CLIDR@plt>
mov    %eax,0xc(%rsp)
mov    0xc(%rsp),%eax
and    $0x7,%eax
add    $0xfffffffe,%eax
cmp    $0x2,%eax
ja     114a <__L1C_CleanInvalidateCache+0x2a>
xor    %edi,%edi
mov    %ebx,%esi
call   1040 <__L1C_MaintainDCacheSetWay@plt>
mov    0xc(%rsp),%eax
shr    $0x3,%eax
and    $0x7,%eax
add    $0xfffffffe,%eax
cmp    $0x2,%eax
ja     1168 <__L1C_CleanInvalidateCache+0x48>
mov    $0x1,%edi
mov    %ebx,%esi
call   1040 <__L1C_MaintainDCacheSetWay@plt>
mov    0xc(%rsp),%eax
shr    $0x6,%eax
and    $0x7,%eax
add    $0xfffffffe,%eax
cmp    $0x2,%eax
ja     1186 <__L1C_CleanInvalidateCache+0x66>
mov    $0x2,%edi
mov    %ebx,%esi
call   1040 <__L1C_MaintainDCacheSetWay@plt>
mov    0xc(%rsp),%eax
shr    $0x9,%eax
and    $0x7,%eax
add    $0xfffffffe,%eax
cmp    $0x2,%eax
ja     11a4 <__L1C_CleanInvalidateCache+0x84>
mov    $0x3,%edi
mov    %ebx,%esi
call   1040 <__L1C_MaintainDCacheSetWay@plt>
mov    0xc(%rsp),%eax
shr    $0xc,%eax
and    $0x7,%eax
add    $0xfffffffe,%eax
cmp    $0x2,%eax
ja     11c2 <__L1C_CleanInvalidateCache+0xa2>
mov    $0x4,%edi
mov    %ebx,%esi
call   1040 <__L1C_MaintainDCacheSetWay@plt>
mov    0xc(%rsp),%eax
shr    $0xf,%eax
and    $0x7,%eax
add    $0xfffffffe,%eax
cmp    $0x2,%eax
ja     11e0 <__L1C_CleanInvalidateCache+0xc0>
mov    $0x5,%edi
mov    %ebx,%esi
call   1040 <__L1C_MaintainDCacheSetWay@plt>
mov    0xc(%rsp),%eax
shr    $0x12,%eax
and    $0x7,%eax
add    $0xfffffffe,%eax
cmp    $0x2,%eax
ja     1203 <__L1C_CleanInvalidateCache+0xe3>
mov    $0x6,%edi
mov    %ebx,%esi
add    $0x10,%rsp
pop    %rbx
jmp    1040 <__L1C_MaintainDCacheSetWay@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define void @__L1C_CleanInvalidateCache(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %2
%6 = call i32 (...) @__get_CLIDR()
store volatile i32 %6, i32* %3
store i32 0, i32* %5
br label %7
7: ; preds = %28, %1
%8 = load i32, i32* %5
%9 = icmp slt i32 %8, 7
br i1 %9, label %10, label %31
10: ; preds = %7
%11 = load volatile i32, i32* %3
%12 = load i32, i32* %5
%13 = mul nsw i32 %12, 3
%14 = ashr i32 %11, %13
%15 = sext i32 %14 to i64
%16 = and i64 %15, 7
%17 = trunc i64 %16 to i32
store i32 %17, i32* %4
%18 = load i32, i32* %4
%19 = icmp sge i32 %18, 2
br i1 %19, label %20, label %27
20: ; preds = %10
%21 = load i32, i32* %4
%22 = icmp sle i32 %21, 4
br i1 %22, label %23, label %27
23: ; preds = %20
%24 = load i32, i32* %5
%25 = load i32, i32* %2
%26 = call i32 @__L1C_MaintainDCacheSetWay(i32 %24, i32 %25)
br label %27
27: ; preds = %23, %20, %10
br label %28
28: ; preds = %27
%29 = load i32, i32* %5
%30 = add nsw i32 %29, 1
store i32 %30, i32* %5
br label %7
31: ; preds = %7
ret void
}

LLVM IR (-O2):
define void @__L1C_CleanInvalidateCache(i32 %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = tail call i32 (...) @__get_CLIDR()
store volatile i32 %4, i32* %2
%5 = load volatile i32, i32* %2
%6 = and i32 %5, 7
%7 = add nsw i32 %6, -2
%8 = icmp ult i32 %7, 3
br i1 %8, label %9, label %11
9: ; preds = %1
%10 = tail call i32 @__L1C_MaintainDCacheSetWay(i32 0, i32 %0)
br label %11
11: ; preds = %1, %9
%12 = load volatile i32, i32* %2
%13 = lshr i32 %12, 3
%14 = and i32 %13, 7
%15 = add nsw i32 %14, -2
%16 = icmp ult i32 %15, 3
br i1 %16, label %17, label %19
17: ; preds = %11
%18 = tail call i32 @__L1C_MaintainDCacheSetWay(i32 1, i32 %0)
br label %19
19: ; preds = %17, %11
%20 = load volatile i32, i32* %2
%21 = lshr i32 %20, 6
%22 = and i32 %21, 7
%23 = add nsw i32 %22, -2
%24 = icmp ult i32 %23, 3
br i1 %24, label %25, label %27
25: ; preds = %19
%26 = tail call i32 @__L1C_MaintainDCacheSetWay(i32 2, i32 %0)
br label %27
27: ; preds = %25, %19
%28 = load volatile i32, i32* %2
%29 = lshr i32 %28, 9
%30 = and i32 %29, 7
%31 = add nsw i32 %30, -2
%32 = icmp ult i32 %31, 3
br i1 %32, label %33, label %35
33: ; preds = %27
%34 = tail call i32 @__L1C_MaintainDCacheSetWay(i32 3, i32 %0)
br label %35
35: ; preds = %33, %27
%36 = load volatile i32, i32* %2
%37 = lshr i32 %36, 12
%38 = and i32 %37, 7
%39 = add nsw i32 %38, -2
%40 = icmp ult i32 %39, 3
br i1 %40, label %41, label %43
41: ; preds = %35
%42 = tail call i32 @__L1C_MaintainDCacheSetWay(i32 4, i32 %0)
br label %43
43: ; preds = %41, %35
%44 = load volatile i32, i32* %2
%45 = lshr i32 %44, 15
%46 = and i32 %45, 7
%47 = add nsw i32 %46, -2
%48 = icmp ult i32 %47, 3
br i1 %48, label %49, label %51
49: ; preds = %43
%50 = tail call i32 @__L1C_MaintainDCacheSetWay(i32 5, i32 %0)
br label %51
51: ; preds = %49, %43
%52 = load volatile i32, i32* %2
%53 = lshr i32 %52, 18
%54 = and i32 %53, 7
%55 = add nsw i32 %54, -2
%56 = icmp ult i32 %55, 3
br i1 %56, label %57, label %59
57: ; preds = %51
%58 = tail call i32 @__L1C_MaintainDCacheSetWay(i32 6, i32 %0)
br label %59
59: ; preds = %57, %51
ret void
}