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    $0x160,%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
mov    $0x0,%al
call   1030 <writeToFile@plt>
lea    -0x110(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xe9e(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
lea    -0x160(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    0xe94(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
lea    -0x110(%rbp),%rdi
lea    -0x160(%rbp),%rsi
mov    $0x0,%al
call   1030 <writeToFile@plt>
add    $0x160,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<switchLED>:
push   %rbp
push   %r14
push   %rbx
sub    $0x150,%rsp
mov    %esi,%r14d
mov    %rdi,%rbp
lea    0xec8(%rip),%rsi
lea    0x50(%rsp),%rbx
mov    %rbx,%rdi
mov    %rbp,%rdx
xor    %eax,%eax
call   1040 <sprintf@plt>
lea    0xeba(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <writeToFile@plt>
lea    0xeae(%rip),%rsi
mov    %rbx,%rdi
mov    %rbp,%rdx
xor    %eax,%eax
call   1040 <sprintf@plt>
lea    0xea8(%rip),%rsi
mov    %rsp,%rbp
mov    %rbp,%rdi
mov    %r14d,%edx
xor    %eax,%eax
call   1040 <sprintf@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1030 <writeToFile@plt>
add    $0x150,%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 (i8*, i8*, ...) bitcast (i32 (...)* @writeToFile to i32 (i8*, i8*, ...)*)(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 = bitcast i8** %15 to i8*
%17 = load i32, i32* %4
%18 = call i32 (i8*, i8*, ...) @sprintf(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %17)
%19 = getelementptr inbounds [255 x i8], [255 x i8]* %5, i64 0, i64 0
%20 = getelementptr inbounds [10 x i8*], [10 x i8*]* %6, i64 0, i64 0
%21 = call i32 (i8*, i8**, ...) bitcast (i32 (...)* @writeToFile to i32 (i8*, i8**, ...)*)(i8* %19, i8** %20)
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 = bitcast [10 x i8*]* %4 to i8*
%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 (i8*, i8*, ...) bitcast (i32 (...)* @writeToFile to i32 (i8*, i8*, ...)*)(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 = getelementptr inbounds [10 x i8*], [10 x i8*]* %4, i64 0, i64 0
%11 = 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)
%12 = call i32 (i8*, i8**, ...) bitcast (i32 (...)* @writeToFile to i32 (i8*, i8**, ...)*)(i8* %5, i8** %10)
ret void
}