#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__ geteuid();
int /*<<< orphan*/ pr_inf(char *, char const *);
int system_write(char *, char *, int);
int stress_cpu_online_supported(const char *name) {
  int ret;
  if (geteuid() != 0) {
    pr_inf("%s stressor will be skipped, "
           "need to be running as root for this stressor\n",
           name);
    return -1;
  }
  ret = system_write("/sys/devices/system/cpu/cpu1/online", "1\n", 2);
  if (ret < 0) {
    pr_inf("%s stressor will be skipped, "
           "cannot write to cpu1 online sysfs control file\n",
           name);
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<stress_cpu_online_supported>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    $0x0,%al
call   1030 <geteuid@plt>
cmp    $0x0,%rax
je     1169 <stress_cpu_online_supported+0x39>
mov    -0x10(%rbp),%rsi
lea    0xea8(%rip),%rdi
call   1040 <pr_inf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b1 <stress_cpu_online_supported+0x81>
lea    0xedb(%rip),%rdi
lea    0xef8(%rip),%rsi
mov    $0x2,%edx
call   1050 <system_write@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    11aa <stress_cpu_online_supported+0x7a>
mov    -0x10(%rbp),%rsi
lea    0xed9(%rip),%rdi
call   1040 <pr_inf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b1 <stress_cpu_online_supported+0x81>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stress_cpu_online_supported>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
xor    %ebp,%ebp
xor    %eax,%eax
call   1030 <geteuid@plt>
test   %rax,%rax
je     115a <stress_cpu_online_supported+0x2a>
lea    0xeb5(%rip),%rdi
mov    %rbx,%rsi
call   1040 <pr_inf@plt>
mov    $0xffffffff,%ebp
jmp    1176 <stress_cpu_online_supported+0x46>
lea    0xeea(%rip),%rdi
lea    0xf07(%rip),%rsi
mov    $0x2,%edx
call   1050 <system_write@plt>
test   %eax,%eax
js     117f <stress_cpu_online_supported+0x4f>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xeec(%rip),%rdi
jmp    114b <stress_cpu_online_supported+0x1b>

LLVM IR (-O0):
@.str = [75 x i8] c"%s stressor will be skipped, need to be running as root for this stressor\0A\00"
@.str.1 = [36 x i8] c"/sys/devices/system/cpu/cpu1/online\00"
@.str.2 = [3 x i8] c"1\0A\00"
@.str.3 = [77 x i8] c"%s stressor will be skipped, cannot write to cpu1 online sysfs control file\0A\00"
define i32 @stress_cpu_online_supported(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
%5 = call i64 (...) @geteuid()
%6 = icmp ne i64 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %1
%8 = load i8*, i8** %3
%9 = call i32 @pr_inf(i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str, i64 0, i64 0), i8* %8)
store i32 -1, i32* %2
br label %18
10: ; preds = %1
%11 = call i32 @system_write(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 2)
store i32 %11, i32* %4
%12 = load i32, i32* %4
%13 = icmp slt i32 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %10
%15 = load i8*, i8** %3
%16 = call i32 @pr_inf(i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str.3, i64 0, i64 0), i8* %15)
store i32 -1, i32* %2
br label %18
17: ; preds = %10
store i32 0, i32* %2
br label %18
18: ; preds = %17, %14, %7
%19 = load i32, i32* %2
ret i32 %19
}

LLVM IR (-O2):
@.str = [75 x i8] c"%s stressor will be skipped, need to be running as root for this stressor\0A\00"
@.str.1 = [36 x i8] c"/sys/devices/system/cpu/cpu1/online\00"
@.str.2 = [3 x i8] c"1\0A\00"
@.str.3 = [77 x i8] c"%s stressor will be skipped, cannot write to cpu1 online sysfs control file\0A\00"
define i32 @stress_cpu_online_supported(i8* %0) {
%2 = tail call i64 (...) @geteuid()
%3 = icmp eq i64 %2, 0
br i1 %3, label %4, label %7
4: ; preds = %1
%5 = tail call i32 @system_write(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 2)
%6 = icmp slt i32 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %4, %1
%8 = phi i8* [ getelementptr inbounds ([75 x i8], [75 x i8]* @.str, i64 0, i64 0), %1 ], [ getelementptr inbounds ([77 x i8], [77 x i8]* @.str.3, i64 0, i64 0), %4 ]
%9 = tail call i32 @pr_inf(i8* %8, i8* %0)
br label %10
10: ; preds = %7, %4
%11 = phi i32 [ 0, %4 ], [ -1, %7 ]
ret i32 %11
}