#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");
    }
    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");
    }
    usleep(100000);
  }
}


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    118e <main+0x4e>
lea    0xe8f(%rip),%rdi
call   1040 <system@plt>
lea    0xeb8(%rip),%rdi
call   1040 <system@plt>
lea    0xee0(%rip),%rdi
call   1040 <system@plt>
mov    $0x0,%al
call   1050 <check_dec_button@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x1,-0x14(%rbp)
jne    11c6 <main+0x86>
lea    0xef3(%rip),%rdi
call   1040 <system@plt>
lea    0xe80(%rip),%rdi
call   1040 <system@plt>
lea    0xf0e(%rip),%rdi
call   1040 <system@plt>
mov    $0x186a0,%edi
call   1060 <usleep@plt>
jmp    1156 <main+0x16>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
lea    0xeb0(%rip),%r14
lea    0xede(%rip),%rbx
lea    0xf0b(%rip),%r15
lea    0xf37(%rip),%r12
lea    0xf63(%rip),%r13
jmp    117a <main+0x3a>
xchg   %ax,%ax
mov    $0x186a0,%edi
call   1060 <usleep@plt>
xor    %eax,%eax
call   1030 <check_reset_button@plt>
cmp    $0x1,%eax
jne    119e <main+0x5e>
mov    %r14,%rdi
call   1040 <system@plt>
mov    %rbx,%rdi
call   1040 <system@plt>
mov    %r15,%rdi
call   1040 <system@plt>
xor    %eax,%eax
call   1050 <check_dec_button@plt>
cmp    $0x1,%eax
jne    1170 <main+0x30>
mov    %r12,%rdi
call   1040 <system@plt>
mov    %rbx,%rdi
call   1040 <system@plt>
mov    %r13,%rdi
call   1040 <system@plt>
jmp    1170 <main+0x30>

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