#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 */
scalar_t__ get_resource_id(int, int *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ set_cmt_path(char const *, char const *, int);
int /*<<< orphan*/ strncmp(char *, char *, int);
void initialize_llc_occu_resctrl(const char *ctrlgrp, const char *mongrp,
                                 int cpu_no, char *resctrl_val) {
  int resource_id;
  if (get_resource_id(cpu_no, &resource_id) < 0) {
    perror("# Unable to resource_id");
    return;
  }
  if (!strncmp(resctrl_val, "cmt", sizeof("cmt")))
    set_cmt_path(ctrlgrp, mongrp, resource_id);
}


x86 assembly (clang, -O0):
<initialize_llc_occu_resctrl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x24(%rbp),%rsi
call   1040 <get_resource_id@plt>
cmp    $0x0,%rax
jge    117e <initialize_llc_occu_resctrl+0x3e>
lea    0xe8c(%rip),%rdi
call   1050 <perror@plt>
jmp    11ac <initialize_llc_occu_resctrl+0x6c>
mov    -0x20(%rbp),%rdi
lea    0xe8f(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    11ac <initialize_llc_occu_resctrl+0x6c>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1060 <set_cmt_path@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<initialize_llc_occu_resctrl>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rcx,%rbx
mov    %rsi,%r14
mov    %rdi,%r15
lea    0xc(%rsp),%rsi
mov    %edx,%edi
call   1040 <get_resource_id@plt>
test   %rax,%rax
js     1194 <initialize_llc_occu_resctrl+0x54>
lea    0xeae(%rip),%rsi
mov    %rbx,%rdi
mov    $0x4,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
jne    118a <initialize_llc_occu_resctrl+0x4a>
mov    0xc(%rsp),%edx
mov    %r15,%rdi
mov    %r14,%rsi
call   1060 <set_cmt_path@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xe65(%rip),%rdi
call   1050 <perror@plt>
jmp    118a <initialize_llc_occu_resctrl+0x4a>

LLVM IR (-O0):
@.str = [24 x i8] c"# Unable to resource_id\00"
@.str.1 = [4 x i8] c"cmt\00"
define void @initialize_llc_occu_resctrl(i8* %0, i8* %1, i32 %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i8* %3, i8** %8
%10 = load i32, i32* %7
%11 = call i64 @get_resource_id(i32 %10, i32* %9)
%12 = icmp slt i64 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %4
%14 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
br label %24
15: ; preds = %4
%16 = load i8*, i8** %8
%17 = call i32 @strncmp(i8* %16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 4)
%18 = icmp ne i32 %17, 0
br i1 %18, label %24, label %19
19: ; preds = %15
%20 = load i8*, i8** %5
%21 = load i8*, i8** %6
%22 = load i32, i32* %9
%23 = call i32 @set_cmt_path(i8* %20, i8* %21, i32 %22)
br label %24
24: ; preds = %13, %19, %15
ret void
}

LLVM IR (-O2):
@.str = [24 x i8] c"# Unable to resource_id\00"
@.str.1 = [4 x i8] c"cmt\00"
define void @initialize_llc_occu_resctrl(i8* %0, i8* %1, i32 %2, i8* %3) {
%5 = alloca i32
%6 = bitcast i32* %5 to i8*
%7 = call i64 @get_resource_id(i32 %2, i32* %5)
%8 = icmp slt i64 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %4
%10 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
br label %17
11: ; preds = %4
%12 = call i32 @strncmp(i8* %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 4)
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %11
%15 = load i32, i32* %5
%16 = call i32 @set_cmt_path(i8* %0, i8* %1, i32 %15)
br label %17
17: ; preds = %11, %14, %9
ret void
}