#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 __set_attribute(int, char *, char *);
int led_set_state(int id, int state) {
  if (__set_attribute(id, "trigger", "none") == -1)
    return -1;
  return __set_attribute(id, "brightness", state == 0 ? "1" : "0");
}


x86 assembly (clang, -O0):
<led_set_state>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%edi
lea    0xed8(%rip),%rsi
lea    0xed9(%rip),%rdx
call   1030 <__set_attribute@plt>
cmp    $0xffffffff,%eax
jne    1149 <led_set_state+0x39>
movl   $0xffffffff,-0x4(%rbp)
jmp    1173 <led_set_state+0x63>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%ecx
lea    0xec4(%rip),%rdx
lea    0xebb(%rip),%rax
cmp    $0x0,%ecx
cmove  %rax,%rdx
lea    0xea2(%rip),%rsi
call   1030 <__set_attribute@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<led_set_state>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %edi,%ebx
lea    0xee2(%rip),%rsi
lea    0xee3(%rip),%rdx
call   1030 <__set_attribute@plt>
cmp    $0xffffffff,%eax
je     1157 <led_set_state+0x47>
test   %ebp,%ebp
lea    0xee0(%rip),%rax
lea    0xedb(%rip),%rdx
cmove  %rax,%rdx
lea    0xec3(%rip),%rsi
mov    %ebx,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <__set_attribute@plt>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"trigger\00"
@.str.1 = [5 x i8] c"none\00"
@.str.2 = [11 x i8] c"brightness\00"
@.str.3 = [2 x i8] c"1\00"
@.str.4 = [2 x i8] c"0\00"
define i32 @led_set_state(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%6 = load i32, i32* %4
%7 = call i32 @__set_attribute(i32 %6, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %10
9: ; preds = %2
store i32 -1, i32* %3
br label %17
10: ; preds = %2
%11 = load i32, i32* %4
%12 = load i32, i32* %5
%13 = icmp eq i32 %12, 0
%14 = zext i1 %13 to i64
%15 = select i1 %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0)
%16 = call i32 @__set_attribute(i32 %11, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* %15)
store i32 %16, i32* %3
br label %17
17: ; preds = %10, %9
%18 = load i32, i32* %3
ret i32 %18
}

LLVM IR (-O2):
@.str = [8 x i8] c"trigger\00"
@.str.1 = [5 x i8] c"none\00"
@.str.2 = [11 x i8] c"brightness\00"
@.str.3 = [2 x i8] c"1\00"
@.str.4 = [2 x i8] c"0\00"
define i32 @led_set_state(i32 %0, i32 %1) {
%3 = tail call i32 @__set_attribute(i32 %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%4 = icmp eq i32 %3, -1
br i1 %4, label %9, label %5
5: ; preds = %2
%6 = icmp eq i32 %1, 0
%7 = select i1 %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0)
%8 = tail call i32 @__set_attribute(i32 %0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* %7)
br label %9
9: ; preds = %2, %5
%10 = phi i32 [ %8, %5 ], [ -1, %2 ]
ret i32 %10
}