#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int EXIT_FAILURE;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *);
int fscanf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ removeTrigger();
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int main(int argc, char *argv[]) {
  if (argc != 2) {
    printf("Usage: makeLed <command>\n");
    printf("commands: {on, off, flash, status}\n");
    printf("e.g., makeLed on\n");
    return EXIT_FAILURE;
  }
  FILE *ledFileP = NULL;
  char userCommand[10];
  strcpy(userCommand, argv[1]);
  printf("Starting the LED flash program\n");
  printf("The LED Path is: %s\n", "/sys/class/leds/beaglebone:green:usr0");
  if (strcmp(userCommand, "on") == 0) {
    removeTrigger();
    if ((ledFileP = fopen("/sys/class/leds/beaglebone:green:usr0"
                          "/brightness",
                          "w")) != NULL) {
      fprintf(ledFileP, "1");
      fclose(ledFileP);
    } else {
      printf("Unable to open LED:brightness file\n");
      return EXIT_FAILURE;
    }
  } else if (strcmp(userCommand, "off") == 0) {
    removeTrigger();
    if ((ledFileP = fopen("/sys/class/leds/beaglebone:green:usr0"
                          "/brightness",
                          "w")) != NULL) {
      fprintf(ledFileP, "0");
      fclose(ledFileP);
    } else {
      printf("Unable to open LED:brightness file\n");
      return EXIT_FAILURE;
    }
  } else if (strcmp(userCommand, "flash") == 0) {
    if ((ledFileP = fopen("/sys/class/leds/beaglebone:green:usr0"
                          "/trigger",
                          "w")) != NULL) {
      fprintf(ledFileP, "timer");
      fclose(ledFileP);
    } else {
      printf("Unable to open LED:trigger file\n");
      return EXIT_FAILURE;
    }
    if ((ledFileP = fopen("/sys/class/leds/beaglebone:green:usr0"
                          "/delay_on",
                          "w")) != NULL) {
      fprintf(ledFileP, "50");
      fclose(ledFileP);
    } else {
      printf("Unable to open LED:delay_on file\n");
      return EXIT_FAILURE;
    }
    if ((ledFileP = fopen("/sys/class/leds/beaglebone:green:usr0"
                          "/delay_off",
                          "w")) != NULL) {
      fprintf(ledFileP, "50");
      fclose(ledFileP);
    } else {
      printf("Unable to open LED:delay_off file\n");
      return EXIT_FAILURE;
    }
  } else if (strcmp(userCommand, "heartbeat") == 0) {
    if ((ledFileP = fopen("/sys/class/leds/beaglebone:green:usr0"
                          "/trigger",
                          "w")) != NULL) {
      fprintf(ledFileP, "heartbeat");
      fclose(ledFileP);
    } else {
      printf("Unable to open LED:trigger file\n");
      return EXIT_FAILURE;
    }
  } else if (strcmp(userCommand, "status") == 0) {
    if ((ledFileP = fopen("/sys/class/leds/beaglebone:green:usr0"
                          "/trigger",
                          "r")) != NULL) {
      char line[256];
      while (fscanf(ledFileP, "%s", line) == 1) {
        printf("%s ", line);
      }
      printf("\n");
      fclose(ledFileP);
    } else {
      printf("Unable to open LED:trigger file\n");
      return EXIT_FAILURE;
    }
  } else {
    printf("Invalid command\n");
  }
  printf("Finished the LED flash program\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11de <main+0x5e>
lea    0xe56(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe78(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2e0c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    15c9 <main+0x449>
movq   $0x0,-0x18(%rbp)
lea    -0x22(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1030 <strcpy@plt>
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe64(%rip),%rdi
lea    0xe72(%rip),%rsi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x22(%rbp),%rdi
lea    0xf66(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    129e <main+0x11e>
mov    $0x0,%al
call   10a0 <removeTrigger@plt>
lea    0xe69(%rip),%rdi
lea    0xe93(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     127a <main+0xfa>
mov    -0x18(%rbp),%rdi
lea    0xe77(%rip),%rsi
call   1080 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
jmp    1299 <main+0x119>
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2d51(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    15c9 <main+0x449>
jmp    15b4 <main+0x434>
lea    -0x22(%rbp),%rdi
lea    0xf36(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    1322 <main+0x1a2>
mov    $0x0,%al
call   10a0 <removeTrigger@plt>
lea    0xde5(%rip),%rdi
lea    0xe0f(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     12fe <main+0x17e>
mov    -0x18(%rbp),%rdi
lea    0xea4(%rip),%rsi
call   1080 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
jmp    131d <main+0x19d>
lea    0xddb(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2ccd(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    15c9 <main+0x449>
jmp    15af <main+0x42f>
lea    -0x22(%rbp),%rdi
lea    0xdd7(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    145b <main+0x2db>
lea    0xdc7(%rip),%rdi
lea    0xd92(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     137b <main+0x1fb>
mov    -0x18(%rbp),%rdi
lea    0xdd0(%rip),%rsi
call   1080 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
jmp    139a <main+0x21a>
lea    0xdbc(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2c50(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    15c9 <main+0x449>
lea    0xdbe(%rip),%rdi
lea    0xd34(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     13d9 <main+0x259>
mov    -0x18(%rbp),%rdi
lea    0xdc8(%rip),%rsi
call   1080 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
jmp    13f8 <main+0x278>
lea    0xdb1(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2bf2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    15c9 <main+0x449>
lea    0xdb4(%rip),%rdi
lea    0xcd6(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     1437 <main+0x2b7>
mov    -0x18(%rbp),%rdi
lea    0xd6a(%rip),%rsi
call   1080 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
jmp    1456 <main+0x2d6>
lea    0xda5(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2b94(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    15c9 <main+0x449>
jmp    15aa <main+0x42a>
lea    -0x22(%rbp),%rdi
lea    0xda0(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    14d8 <main+0x358>
lea    0xc8e(%rip),%rdi
lea    0xc59(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     14b4 <main+0x334>
mov    -0x18(%rbp),%rdi
lea    0xd65(%rip),%rsi
call   1080 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
jmp    14d3 <main+0x353>
lea    0xc83(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2b17(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    15c9 <main+0x449>
jmp    15a5 <main+0x425>
lea    -0x22(%rbp),%rdi
lea    0xd2d(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    1592 <main+0x412>
lea    0xc11(%rip),%rdi
lea    0xc36(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     156e <main+0x3ee>
jmp    1518 <main+0x398>
mov    -0x18(%rbp),%rdi
lea    -0x130(%rbp),%rdx
lea    0xced(%rip),%rsi
call   1060 <fscanf@plt>
cmp    $0x1,%eax
jne    1552 <main+0x3d2>
lea    -0x130(%rbp),%rsi
lea    0xcd4(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1518 <main+0x398>
lea    0xabf(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
jmp    158d <main+0x40d>
lea    0xbc9(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2a5d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    15c9 <main+0x449>
jmp    15a0 <main+0x420>
lea    0xc85(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    15a5 <main+0x425>
jmp    15aa <main+0x42a>
jmp    15af <main+0x42f>
jmp    15b4 <main+0x434>
lea    0xc74(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x118,%rsp
cmp    $0x2,%edi
jne    128a <main+0xda>
mov    0x8(%rsi),%rsi
lea    0x6(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <strcpy@plt>
lea    0xf43(%rip),%rdi
call   1050 <puts@plt>
lea    0xe15(%rip),%rdi
lea    0xe23(%rip),%rsi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0x1040(%rip),%rsi
mov    %rbx,%rdi
call   10a0 <strcmp@plt>
test   %rax,%rax
je     12b9 <main+0x109>
lea    0xeee(%rip),%rsi
lea    0x6(%rsp),%rdi
call   10a0 <strcmp@plt>
test   %rax,%rax
je     12e2 <main+0x132>
lea    0xe3c(%rip),%rsi
lea    0x6(%rsp),%rdi
call   10a0 <strcmp@plt>
test   %rax,%rax
je     1342 <main+0x192>
lea    0xebe(%rip),%rsi
lea    0x6(%rsp),%rdi
call   10a0 <strcmp@plt>
test   %rax,%rax
je     13ef <main+0x23f>
lea    0xeae(%rip),%rsi
lea    0x6(%rsp),%rdi
call   10a0 <strcmp@plt>
test   %rax,%rax
je     142c <main+0x27c>
lea    0xec1(%rip),%rdi
call   1050 <puts@plt>
jmp    1319 <main+0x169>
lea    0xf65(%rip),%rdi
call   1050 <puts@plt>
lea    0xf72(%rip),%rdi
call   1050 <puts@plt>
lea    0xf89(%rip),%rdi
call   1050 <puts@plt>
mov    0x2d2b(%rip),%rax
mov    (%rax),%eax
jmp    1327 <main+0x177>
xor    %eax,%eax
call   10d0 <removeTrigger@plt>
lea    0xd74(%rip),%rdi
lea    0xd9e(%rip),%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
je     1336 <main+0x186>
mov    %rax,%rbx
mov    $0x31,%edi
jmp    1309 <main+0x159>
xor    %eax,%eax
call   10d0 <removeTrigger@plt>
lea    0xd4b(%rip),%rdi
lea    0xd75(%rip),%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
je     1336 <main+0x186>
mov    %rax,%rbx
mov    $0x30,%edi
mov    %rbx,%rsi
call   1090 <fputc@plt>
mov    %rbx,%rdi
call   1060 <fclose@plt>
lea    0xe31(%rip),%rdi
call   1050 <puts@plt>
xor    %eax,%eax
add    $0x118,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
lea    0xe96(%rip),%rdi
jmp    12a9 <main+0xf9>
lea    0xd2b(%rip),%rdi
lea    0xd1c(%rip),%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
je     14b2 <main+0x302>
mov    %rax,%rbx
lea    0xd3a(%rip),%rdi
mov    $0x5,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   10c0 <fwrite@plt>
mov    %rbx,%rdi
call   1060 <fclose@plt>
lea    0xd1f(%rip),%rdi
lea    0xcdc(%rip),%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
je     14be <main+0x30e>
mov    %rax,%rbx
lea    0xd2f(%rip),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   10c0 <fwrite@plt>
mov    %rbx,%rdi
call   1060 <fclose@plt>
lea    0xd11(%rip),%rdi
lea    0xc9c(%rip),%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
je     14ca <main+0x31a>
mov    %rax,%rbx
lea    0xcef(%rip),%rdi
mov    $0x2,%esi
jmp    141a <main+0x26a>
lea    0xc7e(%rip),%rdi
lea    0xc6f(%rip),%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
je     14b2 <main+0x302>
mov    %rax,%rbx
lea    0xcf5(%rip),%rdi
mov    $0x9,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10c0 <fwrite@plt>
jmp    1311 <main+0x161>
lea    0xc41(%rip),%rdi
lea    0xc66(%rip),%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
je     14b2 <main+0x302>
mov    %rax,%r15
lea    0xccd(%rip),%rsi
lea    0x10(%rsp),%rdx
mov    %rax,%rdi
call   1080 <fscanf@plt>
cmp    $0x1,%eax
jne    14a0 <main+0x2f0>
lea    0xcb7(%rip),%r14
lea    0x10(%rsp),%rbx
lea    0xca8(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1080 <fscanf@plt>
cmp    $0x1,%eax
je     1480 <main+0x2d0>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r15,%rdi
jmp    1314 <main+0x164>
lea    0xcb7(%rip),%rdi
jmp    12a9 <main+0xf9>
lea    0xccb(%rip),%rdi
jmp    12a9 <main+0xf9>
lea    0xce0(%rip),%rdi
jmp    12a9 <main+0xf9>

LLVM IR (-O0):
@.str = [26 x i8] c"Usage: makeLed <command>\0A\00"
@.str.1 = [36 x i8] c"commands: {on, off, flash, status}\0A\00"
@.str.2 = [18 x i8] c"e.g., makeLed on\0A\00"
@EXIT_FAILURE = global i32 0
@.str.3 = [32 x i8] c"Starting the LED flash program\0A\00"
@.str.4 = [21 x i8] c"The LED Path is: %s\0A\00"
@.str.5 = [38 x i8] c"/sys/class/leds/beaglebone:green:usr0\00"
@.str.6 = [3 x i8] c"on\00"
@.str.7 = [49 x i8] c"/sys/class/leds/beaglebone:green:usr0/brightness\00"
@.str.8 = [2 x i8] c"w\00"
@.str.9 = [2 x i8] c"1\00"
@.str.10 = [36 x i8] c"Unable to open LED:brightness file\0A\00"
@.str.11 = [4 x i8] c"off\00"
@.str.12 = [2 x i8] c"0\00"
@.str.13 = [6 x i8] c"flash\00"
@.str.14 = [46 x i8] c"/sys/class/leds/beaglebone:green:usr0/trigger\00"
@.str.15 = [6 x i8] c"timer\00"
@.str.16 = [33 x i8] c"Unable to open LED:trigger file\0A\00"
@.str.17 = [47 x i8] c"/sys/class/leds/beaglebone:green:usr0/delay_on\00"
@.str.18 = [3 x i8] c"50\00"
@.str.19 = [34 x i8] c"Unable to open LED:delay_on file\0A\00"
@.str.20 = [48 x i8] c"/sys/class/leds/beaglebone:green:usr0/delay_off\00"
@.str.21 = [35 x i8] c"Unable to open LED:delay_off file\0A\00"
@.str.22 = [10 x i8] c"heartbeat\00"
@.str.23 = [7 x i8] c"status\00"
@.str.24 = [2 x i8] c"r\00"
@.str.25 = [3 x i8] c"%s\00"
@.str.26 = [4 x i8] c"%s \00"
@.str.27 = [2 x i8] c"\0A\00"
@.str.28 = [17 x i8] c"Invalid command\0A\00"
@.str.29 = [32 x i8] c"Finished the LED flash program\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca [10 x i8]
%8 = alloca [256 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 2
br i1 %10, label %11, label %16
11: ; preds = %2
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%15 = load i32, i32* @EXIT_FAILURE
store i32 %15, i32* %3
br label %143
16: ; preds = %2
store i32* null, i32** %6
%17 = getelementptr inbounds [10 x i8], [10 x i8]* %7, i64 0, i64 0
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i32 @strcpy(i8* %17, i8* %20)
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0))
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0))
%24 = getelementptr inbounds [10 x i8], [10 x i8]* %7, i64 0, i64 0
%25 = call i64 @strcmp(i8* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %40
27: ; preds = %16
%28 = call i32 (...) @removeTrigger()
%29 = call i32* @fopen(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
store i32* %29, i32** %6
%30 = icmp ne i32* %29, null
br i1 %30, label %31, label %36
31: ; preds = %27
%32 = load i32*, i32** %6
%33 = call i32 @fprintf(i32* %32, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
%34 = load i32*, i32** %6
%35 = call i32 @fclose(i32* %34)
br label %39
36: ; preds = %27
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.10, i64 0, i64 0))
%38 = load i32, i32* @EXIT_FAILURE
store i32 %38, i32* %3
br label %143
39: ; preds = %31
br label %141
40: ; preds = %16
%41 = getelementptr inbounds [10 x i8], [10 x i8]* %7, i64 0, i64 0
%42 = call i64 @strcmp(i8* %41, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0))
%43 = icmp eq i64 %42, 0
br i1 %43, label %44, label %57
44: ; preds = %40
%45 = call i32 (...) @removeTrigger()
%46 = call i32* @fopen(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
store i32* %46, i32** %6
%47 = icmp ne i32* %46, null
br i1 %47, label %48, label %53
48: ; preds = %44
%49 = load i32*, i32** %6
%50 = call i32 @fprintf(i32* %49, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i64 0, i64 0))
%51 = load i32*, i32** %6
%52 = call i32 @fclose(i32* %51)
br label %56
53: ; preds = %44
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.10, i64 0, i64 0))
%55 = load i32, i32* @EXIT_FAILURE
store i32 %55, i32* %3
br label %143
56: ; preds = %48
br label %140
57: ; preds = %40
%58 = getelementptr inbounds [10 x i8], [10 x i8]* %7, i64 0, i64 0
%59 = call i64 @strcmp(i8* %58, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.13, i64 0, i64 0))
%60 = icmp eq i64 %59, 0
br i1 %60, label %61, label %95
61: ; preds = %57
%62 = call i32* @fopen(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.14, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
store i32* %62, i32** %6
%63 = icmp ne i32* %62, null
br i1 %63, label %64, label %69
64: ; preds = %61
%65 = load i32*, i32** %6
%66 = call i32 @fprintf(i32* %65, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.15, i64 0, i64 0))
%67 = load i32*, i32** %6
%68 = call i32 @fclose(i32* %67)
br label %72
69: ; preds = %61
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.16, i64 0, i64 0))
%71 = load i32, i32* @EXIT_FAILURE
store i32 %71, i32* %3
br label %143
72: ; preds = %64
%73 = call i32* @fopen(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.17, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
store i32* %73, i32** %6
%74 = icmp ne i32* %73, null
br i1 %74, label %75, label %80
75: ; preds = %72
%76 = load i32*, i32** %6
%77 = call i32 @fprintf(i32* %76, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.18, i64 0, i64 0))
%78 = load i32*, i32** %6
%79 = call i32 @fclose(i32* %78)
br label %83
80: ; preds = %72
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.19, i64 0, i64 0))
%82 = load i32, i32* @EXIT_FAILURE
store i32 %82, i32* %3
br label %143
83: ; preds = %75
%84 = call i32* @fopen(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.20, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
store i32* %84, i32** %6
%85 = icmp ne i32* %84, null
br i1 %85, label %86, label %91
86: ; preds = %83
%87 = load i32*, i32** %6
%88 = call i32 @fprintf(i32* %87, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.18, i64 0, i64 0))
%89 = load i32*, i32** %6
%90 = call i32 @fclose(i32* %89)
br label %94
91: ; preds = %83
%92 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.21, i64 0, i64 0))
%93 = load i32, i32* @EXIT_FAILURE
store i32 %93, i32* %3
br label %143
94: ; preds = %86
br label %139
95: ; preds = %57
%96 = getelementptr inbounds [10 x i8], [10 x i8]* %7, i64 0, i64 0
%97 = call i64 @strcmp(i8* %96, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.22, i64 0, i64 0))
%98 = icmp eq i64 %97, 0
br i1 %98, label %99, label %111
99: ; preds = %95
%100 = call i32* @fopen(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.14, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
store i32* %100, i32** %6
%101 = icmp ne i32* %100, null
br i1 %101, label %102, label %107
102: ; preds = %99
%103 = load i32*, i32** %6
%104 = call i32 @fprintf(i32* %103, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.22, i64 0, i64 0))
%105 = load i32*, i32** %6
%106 = call i32 @fclose(i32* %105)
br label %110
107: ; preds = %99
%108 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.16, i64 0, i64 0))
%109 = load i32, i32* @EXIT_FAILURE
store i32 %109, i32* %3
br label %143
110: ; preds = %102
br label %138
111: ; preds = %95
%112 = getelementptr inbounds [10 x i8], [10 x i8]* %7, i64 0, i64 0
%113 = call i64 @strcmp(i8* %112, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.23, i64 0, i64 0))
%114 = icmp eq i64 %113, 0
br i1 %114, label %115, label %135
115: ; preds = %111
%116 = call i32* @fopen(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.14, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.24, i64 0, i64 0))
store i32* %116, i32** %6
%117 = icmp ne i32* %116, null
br i1 %117, label %118, label %131
118: ; preds = %115
br label %119
119: ; preds = %124, %118
%120 = load i32*, i32** %6
%121 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%122 = call i32 @fscanf(i32* %120, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.25, i64 0, i64 0), i8* %121)
%123 = icmp eq i32 %122, 1
br i1 %123, label %124, label %127
124: ; preds = %119
%125 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%126 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.26, i64 0, i64 0), i8* %125)
br label %119
127: ; preds = %119
%128 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.27, i64 0, i64 0))
%129 = load i32*, i32** %6
%130 = call i32 @fclose(i32* %129)
br label %134
131: ; preds = %115
%132 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.16, i64 0, i64 0))
%133 = load i32, i32* @EXIT_FAILURE
store i32 %133, i32* %3
br label %143
134: ; preds = %127
br label %137
135: ; preds = %111
%136 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.28, i64 0, i64 0))
br label %137
137: ; preds = %135, %134
br label %138
138: ; preds = %137, %110
br label %139
139: ; preds = %138, %94
br label %140
140: ; preds = %139, %56
br label %141
141: ; preds = %140, %39
%142 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.29, i64 0, i64 0))
store i32 0, i32* %3
br label %143
143: ; preds = %141, %131, %107, %91, %80, %69, %53, %36, %11
%144 = load i32, i32* %3
ret i32 %144
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
@.str.4 = [21 x i8] c"The LED Path is: %s\0A\00"
@.str.5 = [38 x i8] c"/sys/class/leds/beaglebone:green:usr0\00"
@.str.6 = [3 x i8] c"on\00"
@.str.7 = [49 x i8] c"/sys/class/leds/beaglebone:green:usr0/brightness\00"
@.str.8 = [2 x i8] c"w\00"
@.str.11 = [4 x i8] c"off\00"
@.str.13 = [6 x i8] c"flash\00"
@.str.14 = [46 x i8] c"/sys/class/leds/beaglebone:green:usr0/trigger\00"
@.str.15 = [6 x i8] c"timer\00"
@.str.17 = [47 x i8] c"/sys/class/leds/beaglebone:green:usr0/delay_on\00"
@.str.18 = [3 x i8] c"50\00"
@.str.20 = [48 x i8] c"/sys/class/leds/beaglebone:green:usr0/delay_off\00"
@.str.22 = [10 x i8] c"heartbeat\00"
@.str.23 = [7 x i8] c"status\00"
@.str.24 = [2 x i8] c"r\00"
@.str.25 = [3 x i8] c"%s\00"
@.str.26 = [4 x i8] c"%s \00"
@str = [31 x i8] c"Starting the LED flash program\00"
@str.30 = [16 x i8] c"Invalid command\00"
@str.31 = [31 x i8] c"Finished the LED flash program\00"
@str.34 = [32 x i8] c"Unable to open LED:trigger file\00"
@str.35 = [33 x i8] c"Unable to open LED:delay_on file\00"
@str.36 = [34 x i8] c"Unable to open LED:delay_off file\00"
@str.38 = [35 x i8] c"Unable to open LED:brightness file\00"
@str.39 = [25 x i8] c"Usage: makeLed <command>\00"
@str.40 = [35 x i8] c"commands: {on, off, flash, status}\00"
@str.41 = [17 x i8] c"e.g., makeLed on\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [10 x i8]
%4 = alloca [256 x i8]
%5 = icmp eq i32 %0, 2
br i1 %5, label %11, label %6
6: ; preds = %2
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.39, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.40, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.41, i64 0, i64 0))
%10 = load i32, i32* @EXIT_FAILURE
br label %109
11: ; preds = %2
%12 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = call i32 @strcpy(i8* %12, i8* %14)
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0))
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0))
%18 = call i64 @strcmp(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %30
20: ; preds = %11
%21 = call i32 (...) @removeTrigger()
%22 = call i32* @fopen(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%23 = icmp eq i32* %22, null
br i1 %23, label %27, label %24
24: ; preds = %20
%25 = call i32 @fputc(i32 49, i32* %22)
%26 = call i32 @fclose(i32* %22)
br label %105
27: ; preds = %20
%28 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.38, i64 0, i64 0))
%29 = load i32, i32* @EXIT_FAILURE
br label %107
30: ; preds = %11
%31 = call i64 @strcmp(i8* %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0))
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %43
33: ; preds = %30
%34 = call i32 (...) @removeTrigger()
%35 = call i32* @fopen(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%36 = icmp eq i32* %35, null
br i1 %36, label %40, label %37
37: ; preds = %33
%38 = call i32 @fputc(i32 48, i32* %35)
%39 = call i32 @fclose(i32* %35)
br label %105
40: ; preds = %33
%41 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.38, i64 0, i64 0))
%42 = load i32, i32* @EXIT_FAILURE
br label %107
43: ; preds = %30
%44 = call i64 @strcmp(i8* %12, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.13, i64 0, i64 0))
%45 = icmp eq i64 %44, 0
br i1 %45, label %46, label %71
46: ; preds = %43
%47 = call i32* @fopen(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.14, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%48 = icmp eq i32* %47, null
br i1 %48, label %54, label %49
49: ; preds = %46
%50 = call i64 @fwrite(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.15, i64 0, i64 0), i64 5, i64 1, i32* %47)
%51 = call i32 @fclose(i32* %47)
%52 = call i32* @fopen(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.17, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%53 = icmp eq i32* %52, null
br i1 %53, label %62, label %57
54: ; preds = %46
%55 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.34, i64 0, i64 0))
%56 = load i32, i32* @EXIT_FAILURE
br label %107
57: ; preds = %49
%58 = call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.18, i64 0, i64 0), i64 2, i64 1, i32* %52)
%59 = call i32 @fclose(i32* %52)
%60 = call i32* @fopen(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.20, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%61 = icmp eq i32* %60, null
br i1 %61, label %68, label %65
62: ; preds = %49
%63 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.35, i64 0, i64 0))
%64 = load i32, i32* @EXIT_FAILURE
br label %107
65: ; preds = %57
%66 = call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.18, i64 0, i64 0), i64 2, i64 1, i32* %60)
%67 = call i32 @fclose(i32* %60)
br label %105
68: ; preds = %57
%69 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.36, i64 0, i64 0))
%70 = load i32, i32* @EXIT_FAILURE
br label %107
71: ; preds = %43
%72 = call i64 @strcmp(i8* %12, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.22, i64 0, i64 0))
%73 = icmp eq i64 %72, 0
br i1 %73, label %74, label %83
74: ; preds = %71
%75 = call i32* @fopen(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.14, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%76 = icmp eq i32* %75, null
br i1 %76, label %80, label %77
77: ; preds = %74
%78 = call i64 @fwrite(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.22, i64 0, i64 0), i64 9, i64 1, i32* %75)
%79 = call i32 @fclose(i32* %75)
br label %105
80: ; preds = %74
%81 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.34, i64 0, i64 0))
%82 = load i32, i32* @EXIT_FAILURE
br label %107
83: ; preds = %71
%84 = call i64 @strcmp(i8* %12, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.23, i64 0, i64 0))
%85 = icmp eq i64 %84, 0
br i1 %85, label %86, label %103
86: ; preds = %83
%87 = call i32* @fopen(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.14, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.24, i64 0, i64 0))
%88 = icmp eq i32* %87, null
br i1 %88, label %100, label %89
89: ; preds = %86
%90 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%91 = call i32 @fscanf(i32* %87, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.25, i64 0, i64 0), i8* %90)
%92 = icmp eq i32 %91, 1
br i1 %92, label %93, label %97
93: ; preds = %89, %93
%94 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.26, i64 0, i64 0), i8* %90)
%95 = call i32 @fscanf(i32* %87, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.25, i64 0, i64 0), i8* %90)
%96 = icmp eq i32 %95, 1
br i1 %96, label %93, label %97
97: ; preds = %93, %89
%98 = call i32 @putchar(i32 10)
%99 = call i32 @fclose(i32* %87)
br label %105
100: ; preds = %86
%101 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.34, i64 0, i64 0))
%102 = load i32, i32* @EXIT_FAILURE
br label %107
103: ; preds = %83
%104 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.30, i64 0, i64 0))
br label %105
105: ; preds = %37, %77, %103, %97, %65, %24
%106 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.31, i64 0, i64 0))
br label %107
107: ; preds = %105, %100, %80, %68, %62, %54, %40, %27
%108 = phi i32 [ 0, %105 ], [ %29, %27 ], [ %42, %40 ], [ %70, %68 ], [ %64, %62 ], [ %56, %54 ], [ %82, %80 ], [ %102, %100 ]
br label %109
109: ; preds = %107, %6
%110 = phi i32 [ %10, %6 ], [ %108, %107 ]
ret i32 %110
}