#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 */

/* Variables and functions */
int /*<<< orphan*/ shim_cacheflush(void *, int, int);
void stress_cache_flush(void *addr, void *bad_addr, int size) {
  (void)shim_cacheflush(addr, size, 0);
  (void)shim_cacheflush(addr, size, ~0);
  (void)shim_cacheflush(addr, 0, (1 << 1));
  (void)shim_cacheflush(addr, 1, (1 << 1));
  (void)shim_cacheflush(addr, -1, (1 << 1));
  (void)shim_cacheflush(bad_addr, size, (1 << 0));
  (void)shim_cacheflush(bad_addr, size, (1 << 1));
  (void)shim_cacheflush(bad_addr, size, (1 << 0) | (1 << 1));
}


x86 assembly (clang, -O0):
<stress_cache_flush>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
xor    %edx,%edx
call   1030 <shim_cacheflush@plt>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    $0xffffffff,%edx
call   1030 <shim_cacheflush@plt>
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
mov    $0x2,%edx
call   1030 <shim_cacheflush@plt>
mov    -0x8(%rbp),%rdi
mov    $0x1,%esi
mov    $0x2,%edx
call   1030 <shim_cacheflush@plt>
mov    -0x8(%rbp),%rdi
mov    $0xffffffff,%esi
mov    $0x2,%edx
call   1030 <shim_cacheflush@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    $0x1,%edx
call   1030 <shim_cacheflush@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    $0x2,%edx
call   1030 <shim_cacheflush@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    $0x3,%edx
call   1030 <shim_cacheflush@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stress_cache_flush>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%ebp
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %edx,%esi
xor    %edx,%edx
call   1030 <shim_cacheflush@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0xffffffff,%edx
call   1030 <shim_cacheflush@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x2,%edx
call   1030 <shim_cacheflush@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x2,%edx
call   1030 <shim_cacheflush@plt>
mov    %rbx,%rdi
mov    $0xffffffff,%esi
mov    $0x2,%edx
call   1030 <shim_cacheflush@plt>
mov    %r14,%rdi
mov    %ebp,%esi
mov    $0x1,%edx
call   1030 <shim_cacheflush@plt>
mov    %r14,%rdi
mov    %ebp,%esi
mov    $0x2,%edx
call   1030 <shim_cacheflush@plt>
mov    %r14,%rdi
mov    %ebp,%esi
mov    $0x3,%edx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <shim_cacheflush@plt>

LLVM IR (-O0):
define void @stress_cache_flush(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%7 = load i8*, i8** %4
%8 = load i32, i32* %6
%9 = call i32 @shim_cacheflush(i8* %7, i32 %8, i32 0)
%10 = load i8*, i8** %4
%11 = load i32, i32* %6
%12 = call i32 @shim_cacheflush(i8* %10, i32 %11, i32 -1)
%13 = load i8*, i8** %4
%14 = call i32 @shim_cacheflush(i8* %13, i32 0, i32 2)
%15 = load i8*, i8** %4
%16 = call i32 @shim_cacheflush(i8* %15, i32 1, i32 2)
%17 = load i8*, i8** %4
%18 = call i32 @shim_cacheflush(i8* %17, i32 -1, i32 2)
%19 = load i8*, i8** %5
%20 = load i32, i32* %6
%21 = call i32 @shim_cacheflush(i8* %19, i32 %20, i32 1)
%22 = load i8*, i8** %5
%23 = load i32, i32* %6
%24 = call i32 @shim_cacheflush(i8* %22, i32 %23, i32 2)
%25 = load i8*, i8** %5
%26 = load i32, i32* %6
%27 = call i32 @shim_cacheflush(i8* %25, i32 %26, i32 3)
ret void
}

LLVM IR (-O2):
define void @stress_cache_flush(i8* %0, i8* %1, i32 %2) {
%4 = tail call i32 @shim_cacheflush(i8* %0, i32 %2, i32 0)
%5 = tail call i32 @shim_cacheflush(i8* %0, i32 %2, i32 -1)
%6 = tail call i32 @shim_cacheflush(i8* %0, i32 0, i32 2)
%7 = tail call i32 @shim_cacheflush(i8* %0, i32 1, i32 2)
%8 = tail call i32 @shim_cacheflush(i8* %0, i32 -1, i32 2)
%9 = tail call i32 @shim_cacheflush(i8* %1, i32 %2, i32 1)
%10 = tail call i32 @shim_cacheflush(i8* %1, i32 %2, i32 2)
%11 = tail call i32 @shim_cacheflush(i8* %1, i32 %2, i32 3)
ret void
}