#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 check_dec_button();
int check_reset_button();
int /*<<< orphan*/ system(char *);
int /*<<< orphan*/ usleep(int);
int main(int argc, char **argv) {
  int button_status;
  while (1) {
    button_status = check_reset_button();
    if (button_status == 1) {
      system("echo 1 > /sys/class/leds/system\:led\:green/brightness");
      system("echo 0 > /sys/class/leds/system\:led\:blue/brightness");
      system("echo 0 > /sys/class/leds/system\:led\:red/brightness");
      system("echo timer > /sys/class/leds/system\:led\:green/trigger");
    }
    button_status = check_dec_button();
    if (button_status == 1) {
      system("echo 1 > /sys/class/leds/system\:led\:red/brightness");
      system("echo 0 > /sys/class/leds/system\:led\:blue/brightness");
      system("echo 0 > /sys/class/leds/system\:led\:green/brightness");
      system("echo timer > /sys/class/leds/system\:led\:red/trigger");
    }
    usleep(50000);
  }
}


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)
mov    $0x0,%al
call   1030 <check_reset_button@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x1,-0x14(%rbp)
jne    119a <main+0x5a>
lea    0xe8f(%rip),%rdi
call   1040 <system@plt>
lea    0xeb8(%rip),%rdi
call   1040 <system@plt>
lea    0xee0(%rip),%rdi
call   1040 <system@plt>
lea    0xf07(%rip),%rdi
call   1040 <system@plt>
mov    $0x0,%al
call   1050 <check_dec_button@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x1,-0x14(%rbp)
jne    11de <main+0x9e>
lea    0xf1d(%rip),%rdi
call   1040 <system@plt>
lea    0xe74(%rip),%rdi
call   1040 <system@plt>
lea    0xf38(%rip),%rdi
call   1040 <system@plt>
lea    0xf61(%rip),%rdi
call   1040 <system@plt>
mov    $0xc350,%edi
call   1060 <usleep@plt>
jmp    1156 <main+0x16>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xee3(%rip),%rbx
lea    0xf10(%rip),%r15
lea    0xf3c(%rip),%r12
lea    0xf6b(%rip),%r13
lea    0xf97(%rip),%rbp
lea    0xfc5(%rip),%r14
jmp    118a <main+0x4a>
nopw   0x0(%rax,%rax,1)
mov    $0xc350,%edi
call   1060 <usleep@plt>
xor    %eax,%eax
call   1030 <check_reset_button@plt>
cmp    $0x1,%eax
jne    11ba <main+0x7a>
lea    0xe63(%rip),%rdi
call   1040 <system@plt>
mov    %rbx,%rdi
call   1040 <system@plt>
mov    %r15,%rdi
call   1040 <system@plt>
mov    %r12,%rdi
call   1040 <system@plt>
xor    %eax,%eax
call   1050 <check_dec_button@plt>
cmp    $0x1,%eax
jne    1180 <main+0x40>
mov    %r13,%rdi
call   1040 <system@plt>
mov    %rbx,%rdi
call   1040 <system@plt>
mov    %rbp,%rdi
call   1040 <system@plt>
mov    %r14,%rdi
call   1040 <system@plt>
jmp    1180 <main+0x40>

LLVM IR (-O0):
@.str = [53 x i8] c"echo 1 > /sys/class/leds/system:led:green/brightness\00"
@.str.1 = [52 x i8] c"echo 0 > /sys/class/leds/system:led:blue/brightness\00"
@.str.2 = [51 x i8] c"echo 0 > /sys/class/leds/system:led:red/brightness\00"
@.str.3 = [54 x i8] c"echo timer > /sys/class/leds/system:led:green/trigger\00"
@.str.4 = [51 x i8] c"echo 1 > /sys/class/leds/system:led:red/brightness\00"
@.str.5 = [53 x i8] c"echo 0 > /sys/class/leds/system:led:green/brightness\00"
@.str.6 = [52 x i8] c"echo timer > /sys/class/leds/system:led:red/trigger\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
br label %7
7: ; preds = %2, %25
%8 = call i32 (...) @check_reset_button()
store i32 %8, i32* %6
%9 = load i32, i32* %6
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %16
11: ; preds = %7
%12 = call i32 @system(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @system(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.1, i64 0, i64 0))
%14 = call i32 @system(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.2, i64 0, i64 0))
%15 = call i32 @system(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.3, i64 0, i64 0))
br label %16
16: ; preds = %11, %7
%17 = call i32 (...) @check_dec_button()
store i32 %17, i32* %6
%18 = load i32, i32* %6
%19 = icmp eq i32 %18, 1
br i1 %19, label %20, label %25
20: ; preds = %16
%21 = call i32 @system(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.4, i64 0, i64 0))
%22 = call i32 @system(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.1, i64 0, i64 0))
%23 = call i32 @system(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.5, i64 0, i64 0))
%24 = call i32 @system(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.6, i64 0, i64 0))
br label %25
25: ; preds = %20, %16
%26 = call i32 @usleep(i32 50000)
br label %7
}

LLVM IR (-O2):
@.str = [53 x i8] c"echo 1 > /sys/class/leds/system:led:green/brightness\00"
@.str.1 = [52 x i8] c"echo 0 > /sys/class/leds/system:led:blue/brightness\00"
@.str.2 = [51 x i8] c"echo 0 > /sys/class/leds/system:led:red/brightness\00"
@.str.3 = [54 x i8] c"echo timer > /sys/class/leds/system:led:green/trigger\00"
@.str.4 = [51 x i8] c"echo 1 > /sys/class/leds/system:led:red/brightness\00"
@.str.5 = [53 x i8] c"echo 0 > /sys/class/leds/system:led:green/brightness\00"
@.str.6 = [52 x i8] c"echo timer > /sys/class/leds/system:led:red/trigger\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
br label %3
3: ; preds = %19, %2
%4 = tail call i32 (...) @check_reset_button()
%5 = icmp eq i32 %4, 1
br i1 %5, label %6, label %11
6: ; preds = %3
%7 = tail call i32 @system(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0))
%8 = tail call i32 @system(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.1, i64 0, i64 0))
%9 = tail call i32 @system(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.2, i64 0, i64 0))
%10 = tail call i32 @system(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.3, i64 0, i64 0))
br label %11
11: ; preds = %6, %3
%12 = tail call i32 (...) @check_dec_button()
%13 = icmp eq i32 %12, 1
br i1 %13, label %14, label %19
14: ; preds = %11
%15 = tail call i32 @system(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.4, i64 0, i64 0))
%16 = tail call i32 @system(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.1, i64 0, i64 0))
%17 = tail call i32 @system(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.5, i64 0, i64 0))
%18 = tail call i32 @system(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.6, i64 0, i64 0))
br label %19
19: ; preds = %14, %11
%20 = tail call i32 @usleep(i32 50000)
br label %3
}