#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 cat_perf_miss_val(int, int, char *);
int /*<<< orphan*/ cat_test_cleanup();
int /*<<< orphan*/ ksft_print_msg(char *);
int /*<<< orphan*/ ksft_test_result_fail(char *);
int /*<<< orphan*/ ksft_test_result_pass(char *);
int /*<<< orphan*/ ksft_test_result_skip(char *);
int /*<<< orphan*/ validate_resctrl_feature_request(char *);
void run_cat_test(int cpu_no, int no_of_bits) {
  int res;
  ksft_print_msg("Starting CAT test ...\n");
  if (!validate_resctrl_feature_request("cat")) {
    ksft_test_result_skip("Hardware does not support CAT or CAT is disabled\n");
    return;
  }
  res = cat_perf_miss_val(cpu_no, no_of_bits, "L3");
  do {
    if (!!(!res))
      ksft_test_result_pass("CAT: test\n");
    else
      ksft_test_result_fail("CAT: test\n");
  } while (0);
  cat_test_cleanup();
}


x86 assembly (clang, -O0):
<run_cat_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
lea    0xe7b(%rip),%rdi
call   1080 <ksft_print_msg@plt>
lea    0xe86(%rip),%rdi
call   1040 <validate_resctrl_feature_request@plt>
cmp    $0x0,%eax
jne    11b0 <run_cat_test+0x40>
lea    0xe75(%rip),%rdi
call   1060 <ksft_test_result_skip@plt>
jmp    11f8 <run_cat_test+0x88>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
lea    0xe90(%rip),%rdx
call   1070 <cat_perf_miss_val@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    11e0 <run_cat_test+0x70>
lea    0xe7a(%rip),%rdi
call   1030 <ksft_test_result_pass@plt>
jmp    11ec <run_cat_test+0x7c>
lea    0xe69(%rip),%rdi
call   1050 <ksft_test_result_fail@plt>
jmp    11f1 <run_cat_test+0x81>
mov    $0x0,%al
call   1090 <cat_test_cleanup@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<run_cat_test>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %edi,%ebp
lea    0xe82(%rip),%rdi
call   1080 <ksft_print_msg@plt>
lea    0xe8d(%rip),%rdi
call   1040 <validate_resctrl_feature_request@plt>
test   %eax,%eax
je     11b5 <run_cat_test+0x45>
lea    0xeb3(%rip),%rdx
mov    %ebp,%edi
mov    %ebx,%esi
call   1070 <cat_perf_miss_val@plt>
lea    0xea6(%rip),%rdi
test   %eax,%eax
je     11c7 <run_cat_test+0x57>
call   1050 <ksft_test_result_fail@plt>
jmp    11cc <run_cat_test+0x5c>
lea    0xe5f(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1060 <ksft_test_result_skip@plt>
call   1030 <ksft_test_result_pass@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1090 <cat_test_cleanup@plt>

LLVM IR (-O0):
@.str = [23 x i8] c"Starting CAT test ...\0A\00"
@.str.1 = [4 x i8] c"cat\00"
@.str.2 = [50 x i8] c"Hardware does not support CAT or CAT is disabled\0A\00"
@.str.3 = [3 x i8] c"L3\00"
@.str.4 = [11 x i8] c"CAT: test\0A\00"
define void @run_cat_test(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%6 = call i32 @ksft_print_msg(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @validate_resctrl_feature_request(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp ne i32 %7, 0
br i1 %8, label %11, label %9
9: ; preds = %2
%10 = call i32 @ksft_test_result_skip(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.2, i64 0, i64 0))
br label %25
11: ; preds = %2
%12 = load i32, i32* %3
%13 = load i32, i32* %4
%14 = call i32 @cat_perf_miss_val(i32 %12, i32 %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
store i32 %14, i32* %5
br label %15
15: ; preds = %11
%16 = load i32, i32* %5
%17 = icmp ne i32 %16, 0
br i1 %17, label %20, label %18
18: ; preds = %15
%19 = call i32 @ksft_test_result_pass(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
br label %22
20: ; preds = %15
%21 = call i32 @ksft_test_result_fail(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
br label %22
22: ; preds = %20, %18
br label %23
23: ; preds = %22
%24 = call i32 (...) @cat_test_cleanup()
br label %25
25: ; preds = %23, %9
ret void
}

LLVM IR (-O2):
@.str = [23 x i8] c"Starting CAT test ...\0A\00"
@.str.1 = [4 x i8] c"cat\00"
@.str.2 = [50 x i8] c"Hardware does not support CAT or CAT is disabled\0A\00"
@.str.3 = [3 x i8] c"L3\00"
@.str.4 = [11 x i8] c"CAT: test\0A\00"
define void @run_cat_test(i32 %0, i32 %1) {
%3 = tail call i32 @ksft_print_msg(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @validate_resctrl_feature_request(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 @ksft_test_result_skip(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.2, i64 0, i64 0))
br label %17
8: ; preds = %2
%9 = tail call i32 @cat_perf_miss_val(i32 %0, i32 %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = tail call i32 @ksft_test_result_pass(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
br label %15
13: ; preds = %8
%14 = tail call i32 @ksft_test_result_fail(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
br label %15
15: ; preds = %13, %11
%16 = tail call i32 (...) @cat_test_cleanup()
br label %17
17: ; preds = %15, %6
ret void
}