#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*/ sprintf(char *, char *, ...);
int /*<<< orphan*/ writeToFile(char *, char *);
void switchLED(char *led, int value) {
  char filename[255];
  char valueStr[10];
  sprintf(filename, "%s/trigger", led);
  writeToFile(filename, "none");
  sprintf(filename, "%s/brightness", led);
  sprintf(valueStr, "%i", value);
  writeToFile(filename, valueStr);
}


x86 assembly (clang, -O0):
<switchLED>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    -0x110(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xebc(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
lea    -0x110(%rbp),%rdi
lea    0xeb2(%rip),%rsi
call   1030 <writeToFile@plt>
lea    -0x110(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xea0(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
lea    -0x11a(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    0xe96(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
lea    -0x110(%rbp),%rdi
lea    -0x11a(%rbp),%rsi
call   1030 <writeToFile@plt>
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<switchLED>:
push   %rbp
push   %r14
push   %rbx
sub    $0x110,%rsp
mov    %esi,%r14d
mov    %rdi,%rbp
lea    0xec8(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    %rbp,%rdx
xor    %eax,%eax
call   1040 <sprintf@plt>
lea    0xeba(%rip),%rsi
mov    %rbx,%rdi
call   1030 <writeToFile@plt>
lea    0xeb0(%rip),%rsi
mov    %rbx,%rdi
mov    %rbp,%rdx
xor    %eax,%eax
call   1040 <sprintf@plt>
lea    0xeaa(%rip),%rsi
lea    0x6(%rsp),%rbp
mov    %rbp,%rdi
mov    %r14d,%edx
xor    %eax,%eax
call   1040 <sprintf@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1030 <writeToFile@plt>
add    $0x110,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"%s/trigger\00"
@.str.1 = [5 x i8] c"none\00"
@.str.2 = [14 x i8] c"%s/brightness\00"
@.str.3 = [3 x i8] c"%i\00"
define void @switchLED(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca [255 x i8]
%6 = alloca [10 x i8]
store i8* %0, i8** %3
store i32 %1, i32* %4
%7 = getelementptr inbounds [255 x i8], [255 x i8]* %5, i64 0, i64 0
%8 = load i8*, i8** %3
%9 = call i32 (i8*, i8*, ...) @sprintf(i8* %7, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = getelementptr inbounds [255 x i8], [255 x i8]* %5, i64 0, i64 0
%11 = call i32 @writeToFile(i8* %10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%12 = getelementptr inbounds [255 x i8], [255 x i8]* %5, i64 0, i64 0
%13 = load i8*, i8** %3
%14 = call i32 (i8*, i8*, ...) @sprintf(i8* %12, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %13)
%15 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 0
%16 = load i32, i32* %4
%17 = call i32 (i8*, i8*, ...) @sprintf(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %16)
%18 = getelementptr inbounds [255 x i8], [255 x i8]* %5, i64 0, i64 0
%19 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 0
%20 = call i32 @writeToFile(i8* %18, i8* %19)
ret void
}

LLVM IR (-O2):
@.str = [11 x i8] c"%s/trigger\00"
@.str.1 = [5 x i8] c"none\00"
@.str.2 = [14 x i8] c"%s/brightness\00"
@.str.3 = [3 x i8] c"%i\00"
define void @switchLED(i8* %0, i32 %1) {
%3 = alloca [255 x i8]
%4 = alloca [10 x i8]
%5 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 0
%7 = call i32 (i8*, i8*, ...) @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %0)
%8 = call i32 @writeToFile(i8* %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 (i8*, i8*, ...) @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %0)
%10 = call i32 (i8*, i8*, ...) @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %1)
%11 = call i32 @writeToFile(i8* %5, i8* %6)
ret void
}