#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_cqm_path(char const *, char const *, int);
scalar_t__ strcmp(char *, char *);
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 (strcmp(resctrl_val, "cqm") == 0)
    set_cqm_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   1060 <perror@plt>
jmp    11a8 <initialize_llc_occu_resctrl+0x68>
mov    -0x20(%rbp),%rdi
lea    0xe8f(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11a8 <initialize_llc_occu_resctrl+0x68>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1030 <set_cqm_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     1190 <initialize_llc_occu_resctrl+0x50>
lea    0xeae(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
jne    1186 <initialize_llc_occu_resctrl+0x46>
mov    0xc(%rsp),%edx
mov    %r15,%rdi
mov    %r14,%rsi
call   1030 <set_cqm_path@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xe69(%rip),%rdi
call   1060 <perror@plt>
jmp    1186 <initialize_llc_occu_resctrl+0x46>

LLVM IR (-O0):
@.str = [24 x i8] c"# Unable to resource_id\00"
@.str.1 = [4 x i8] c"cqm\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 i64 @strcmp(i8* %16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %24
19: ; preds = %15
%20 = load i8*, i8** %5
%21 = load i8*, i8** %6
%22 = load i32, i32* %9
%23 = call i32 @set_cqm_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"cqm\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 i64 @strcmp(i8* %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %11
%15 = load i32, i32* %5
%16 = call i32 @set_cqm_path(i8* %0, i8* %1, i32 %15)
br label %17
17: ; preds = %11, %14, %9
ret void
}