#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*/ printf(char *, char *);
int /*<<< orphan*/ usleep(int);
int /*<<< orphan*/ writeToFile(char *, char *);
int main(int argc, char **argv) {
  if (argc == 2 &&
      (argv[1][0] == '0' || argv[1][0] == '1' || argv[1][0] == '2')) {
    writeToFile("/sys/class/leds/led0/trigger", "none");
    if (argv[1][0] == '1') {
      writeToFile("/sys/class/leds/led0/brightness", "1");
    } else if (argv[1][0] == '0') {
      writeToFile("/sys/class/leds/led0/brightness", "0");
    } else if (argv[1][0] == '2') {
      for (int i = 0; i < 10; i++) {
        writeToFile("/sys/class/leds/led0/brightness",
                    (i % 2 == 0) ? "1" : "0");
        usleep(500 * 1000);
      }
    }
  } else {
    printf("Usage: %s [0|1|2]\n", argv[0]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    1274 <main+0x144>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl (%rax),%eax
cmp    $0x30,%eax
je     118c <main+0x5c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl (%rax),%eax
cmp    $0x31,%eax
je     118c <main+0x5c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl (%rax),%eax
cmp    $0x32,%eax
jne    1274 <main+0x144>
lea    0xe6d(%rip),%rdi
lea    0xe83(%rip),%rsi
call   1030 <writeToFile@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl (%rax),%eax
cmp    $0x31,%eax
jne    11cb <main+0x9b>
lea    0xe68(%rip),%rdi
lea    0xe81(%rip),%rsi
call   1030 <writeToFile@plt>
jmp    126f <main+0x13f>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl (%rax),%eax
cmp    $0x30,%eax
jne    11f7 <main+0xc7>
lea    0xe3c(%rip),%rdi
lea    0xe57(%rip),%rsi
call   1030 <writeToFile@plt>
jmp    126a <main+0x13a>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl (%rax),%eax
cmp    $0x32,%eax
jne    1265 <main+0x135>
movl   $0x0,-0x14(%rbp)
cmpl   $0xa,-0x14(%rbp)
jge    1260 <main+0x130>
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
lea    0xe16(%rip),%rsi
lea    0xe0d(%rip),%rax
cmp    $0x0,%edx
cmove  %rax,%rsi
lea    0xddf(%rip),%rdi
call   1030 <writeToFile@plt>
mov    $0x7a120,%edi
call   1050 <usleep@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1212 <main+0xe2>
jmp    1265 <main+0x135>
jmp    126a <main+0x13a>
jmp    126f <main+0x13f>
jmp    1287 <main+0x157>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xdc4(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%rbx
cmp    $0x2,%edi
jne    126b <main+0x13b>
mov    0x8(%rbx),%rax
mov    (%rax),%al
add    $0xd0,%al
cmp    $0x2,%al
ja     126b <main+0x13b>
lea    0xea8(%rip),%rdi
lea    0xebe(%rip),%rsi
call   1030 <writeToFile@plt>
mov    0x8(%rbx),%rax
mov    (%rax),%al
cmp    $0x30,%al
je     1282 <main+0x152>
cmp    $0x31,%al
je     1297 <main+0x167>
cmp    $0x32,%al
jne    127a <main+0x14a>
lea    0xe99(%rip),%rbx
lea    0xeb2(%rip),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <writeToFile@plt>
mov    $0x7a120,%edi
call   1050 <usleep@plt>
lea    0xe98(%rip),%r15
mov    %rbx,%rdi
mov    %r15,%rsi
call   1030 <writeToFile@plt>
mov    $0x7a120,%edi
call   1050 <usleep@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <writeToFile@plt>
mov    $0x7a120,%edi
call   1050 <usleep@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1030 <writeToFile@plt>
mov    $0x7a120,%edi
call   1050 <usleep@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <writeToFile@plt>
mov    $0x7a120,%edi
call   1050 <usleep@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1030 <writeToFile@plt>
mov    $0x7a120,%edi
call   1050 <usleep@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <writeToFile@plt>
mov    $0x7a120,%edi
call   1050 <usleep@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1030 <writeToFile@plt>
mov    $0x7a120,%edi
call   1050 <usleep@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <writeToFile@plt>
mov    $0x7a120,%edi
call   1050 <usleep@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1030 <writeToFile@plt>
mov    $0x7a120,%edi
call   1050 <usleep@plt>
jmp    127a <main+0x14a>
mov    (%rbx),%rsi
lea    0xdd1(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xd99(%rip),%rdi
lea    0xdb4(%rip),%rsi
call   1030 <writeToFile@plt>
jmp    127a <main+0x14a>
lea    0xd84(%rip),%rdi
lea    0xd9d(%rip),%rsi
call   1030 <writeToFile@plt>
jmp    127a <main+0x14a>

LLVM IR (-O0):
@.str = [29 x i8] c"/sys/class/leds/led0/trigger\00"
@.str.1 = [5 x i8] c"none\00"
@.str.2 = [32 x i8] c"/sys/class/leds/led0/brightness\00"
@.str.3 = [2 x i8] c"1\00"
@.str.4 = [2 x i8] c"0\00"
@.str.5 = [19 x i8] c"Usage: %s [0|1|2]\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp eq i32 %7, 2
br i1 %8, label %9, label %81
9: ; preds = %2
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
%13 = getelementptr inbounds i8, i8* %12, i64 0
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 48
br i1 %16, label %33, label %17
17: ; preds = %9
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = getelementptr inbounds i8, i8* %20, i64 0
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 49
br i1 %24, label %33, label %25
25: ; preds = %17
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
%29 = getelementptr inbounds i8, i8* %28, i64 0
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 50
br i1 %32, label %33, label %81
33: ; preds = %25, %17, %9
%34 = call i32 @writeToFile(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 1
%37 = load i8*, i8** %36
%38 = getelementptr inbounds i8, i8* %37, i64 0
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = icmp eq i32 %40, 49
br i1 %41, label %42, label %44
42: ; preds = %33
%43 = call i32 @writeToFile(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %80
44: ; preds = %33
%45 = load i8**, i8*** %5
%46 = getelementptr inbounds i8*, i8** %45, i64 1
%47 = load i8*, i8** %46
%48 = getelementptr inbounds i8, i8* %47, i64 0
%49 = load i8, i8* %48
%50 = sext i8 %49 to i32
%51 = icmp eq i32 %50, 48
br i1 %51, label %52, label %54
52: ; preds = %44
%53 = call i32 @writeToFile(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %79
54: ; preds = %44
%55 = load i8**, i8*** %5
%56 = getelementptr inbounds i8*, i8** %55, i64 1
%57 = load i8*, i8** %56
%58 = getelementptr inbounds i8, i8* %57, i64 0
%59 = load i8, i8* %58
%60 = sext i8 %59 to i32
%61 = icmp eq i32 %60, 50
br i1 %61, label %62, label %78
62: ; preds = %54
store i32 0, i32* %6
br label %63
63: ; preds = %74, %62
%64 = load i32, i32* %6
%65 = icmp slt i32 %64, 10
br i1 %65, label %66, label %77
66: ; preds = %63
%67 = load i32, i32* %6
%68 = srem i32 %67, 2
%69 = icmp eq i32 %68, 0
%70 = zext i1 %69 to i64
%71 = select i1 %69, 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)
%72 = call i32 @writeToFile(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i8* %71)
%73 = call i32 @usleep(i32 500000)
br label %74
74: ; preds = %66
%75 = load i32, i32* %6
%76 = add nsw i32 %75, 1
store i32 %76, i32* %6
br label %63
77: ; preds = %63
br label %78
78: ; preds = %77, %54
br label %79
79: ; preds = %78, %52
br label %80
80: ; preds = %79, %42
br label %86
81: ; preds = %25, %2
%82 = load i8**, i8*** %5
%83 = getelementptr inbounds i8*, i8** %82, i64 0
%84 = load i8*, i8** %83
%85 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i8* %84)
br label %86
86: ; preds = %81, %80
ret i32 0
}

LLVM IR (-O2):
@.str = [29 x i8] c"/sys/class/leds/led0/trigger\00"
@.str.1 = [5 x i8] c"none\00"
@.str.2 = [32 x i8] c"/sys/class/leds/led0/brightness\00"
@.str.3 = [2 x i8] c"1\00"
@.str.4 = [2 x i8] c"0\00"
@.str.5 = [19 x i8] c"Usage: %s [0|1|2]\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %4, label %39
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = load i8, i8* %6
%8 = add i8 %7, -48
%9 = icmp ult i8 %8, 3
br i1 %9, label %10, label %39
10: ; preds = %4
%11 = tail call i32 @writeToFile(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%12 = load i8*, i8** %5
%13 = load i8, i8* %12
switch i8 %13, label %42 [
i8 49, label %35
i8 48, label %37
i8 50, label %14
]
14: ; preds = %10
%15 = tail call i32 @writeToFile(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%16 = tail call i32 @usleep(i32 500000)
%17 = tail call i32 @writeToFile(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%18 = tail call i32 @usleep(i32 500000)
%19 = tail call i32 @writeToFile(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%20 = tail call i32 @usleep(i32 500000)
%21 = tail call i32 @writeToFile(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%22 = tail call i32 @usleep(i32 500000)
%23 = tail call i32 @writeToFile(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%24 = tail call i32 @usleep(i32 500000)
%25 = tail call i32 @writeToFile(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%26 = tail call i32 @usleep(i32 500000)
%27 = tail call i32 @writeToFile(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%28 = tail call i32 @usleep(i32 500000)
%29 = tail call i32 @writeToFile(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%30 = tail call i32 @usleep(i32 500000)
%31 = tail call i32 @writeToFile(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%32 = tail call i32 @usleep(i32 500000)
%33 = tail call i32 @writeToFile(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%34 = tail call i32 @usleep(i32 500000)
br label %42
35: ; preds = %10
%36 = tail call i32 @writeToFile(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %42
37: ; preds = %10
%38 = tail call i32 @writeToFile(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %42
39: ; preds = %4, %2
%40 = load i8*, i8** %1
%41 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i8* %40)
br label %42
42: ; preds = %14, %10, %35, %37, %39
ret i32 0
}