#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*/ perror(char *);
int set_system_attribute(char *, char *, int);
int /*<<< orphan*/ sysattr_is_writeable(char *);
int set_smt_snooze_delay(int delay) {
  if (!sysattr_is_writeable("smt_snooze_delay")) {
    perror("Cannot set smt snooze delay");
    return -2;
  }
  return set_system_attribute("smt_snooze_delay", "%d", delay);
}


x86 assembly (clang, -O0):
<set_smt_snooze_delay>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
lea    0xebe(%rip),%rdi
call   1050 <sysattr_is_writeable@plt>
cmp    $0x0,%eax
jne    1168 <set_smt_snooze_delay+0x38>
lea    0xeba(%rip),%rdi
call   1040 <perror@plt>
movl   $0xfffffffe,-0x4(%rbp)
jmp    1181 <set_smt_snooze_delay+0x51>
mov    -0x8(%rbp),%edx
lea    0xe8e(%rip),%rdi
lea    0xeb4(%rip),%rsi
call   1030 <set_system_attribute@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_smt_snooze_delay>:
push   %rbx
mov    %edi,%ebx
lea    0xec6(%rip),%rdi
call   1050 <sysattr_is_writeable@plt>
test   %eax,%eax
je     1159 <set_smt_snooze_delay+0x29>
lea    0xeb6(%rip),%rdi
lea    0xedc(%rip),%rsi
mov    %ebx,%edx
pop    %rbx
jmp    1030 <set_system_attribute@plt>
lea    0xeb1(%rip),%rdi
call   1040 <perror@plt>
mov    $0xfffffffe,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [17 x i8] c"smt_snooze_delay\00"
@.str.1 = [28 x i8] c"Cannot set smt snooze delay\00"
@.str.2 = [3 x i8] c"%d\00"
define i32 @set_smt_snooze_delay(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = call i32 @sysattr_is_writeable(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%5 = icmp ne i32 %4, 0
br i1 %5, label %8, label %6
6: ; preds = %1
%7 = call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
store i32 -2, i32* %2
br label %11
8: ; preds = %1
%9 = load i32, i32* %3
%10 = call i32 @set_system_attribute(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %9)
store i32 %10, i32* %2
br label %11
11: ; preds = %8, %6
%12 = load i32, i32* %2
ret i32 %12
}

LLVM IR (-O2):
@.str = [17 x i8] c"smt_snooze_delay\00"
@.str.1 = [28 x i8] c"Cannot set smt snooze delay\00"
@.str.2 = [3 x i8] c"%d\00"
define i32 @set_smt_snooze_delay(i32 %0) {
%2 = tail call i32 @sysattr_is_writeable(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i32 %2, 0
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = tail call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
br label %8
6: ; preds = %1
%7 = tail call i32 @set_system_attribute(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %0)
br label %8
8: ; preds = %6, %4
%9 = phi i32 [ %7, %6 ], [ -2, %4 ]
ret i32 %9
}