#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 O_RDWR;
int O_SYNC;
int O_WRONLY;
int PATH_MAX;
int close(int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ error(int, int /*<<< orphan*/, char *, ...);
int open(char *, int);
int read(int, char *, int);
int snprintf(char *, int, char *, char const *);
int usleep(int);
int write(int, char *, int);
int main(void) {
  int i;
  const char *leds_array[] = {"fpga_led0", "fpga_led1", "fpga_led2",
                              "fpga_led3", "fpga_led4", "fpga_led5",
                              "fpga_led6", "fpga_led7"};
  int leds_array_count = (sizeof leds_array) / (sizeof *leds_array);
  int led_fd;
  char path[PATH_MAX];
  int path_length;
  int result;
  char brightness;
  for (i = 0; i < leds_array_count; i++) {
    path_length =
        snprintf(path, PATH_MAX, "/sys/class/leds/%s/trigger", leds_array[i]);
    if (path_length < 0)
      error(1, 0, "path output error");
    if (path_length >= PATH_MAX)
      error(1, 0, "path length overflow");
    led_fd = open(path, O_WRONLY | O_SYNC);
    if (led_fd < 0)
      error(1, errno, "could not open file '%s'", path);
    result = write(led_fd, "none", 4);
    if (result < 0)
      error(1, errno, "writing 'none' to '%s'", path);
    if (result != 4)
      error(1, 0, "did not write 4 bytes to '%s'", path);
    result = close(led_fd);
    if (result < 0)
      error(1, errno, "could not close file '%s'", path);
    path_length = snprintf(path, PATH_MAX, "/sys/class/leds/%s/brightness",
                           leds_array[i]);
    if (path_length < 0)
      error(1, 0, "path output error");
    if (path_length >= PATH_MAX)
      error(1, 0, "path length overflow");
    led_fd = open(path, O_WRONLY | O_SYNC);
    if (led_fd < 0)
      error(1, errno, "could not open file '%s'", path);
    result = write(led_fd, "0", 1);
    if (result < 0)
      error(1, errno, "writing 'none' to '%s'", path);
    if (result != 1)
      led_fd = open(path, O_WRONLY | O_SYNC);
    if (led_fd < 0)
      error(1, errno, "could not open file '%s'", path);
    result = write(led_fd, "0", 1);
    if (result < 0)
      error(1, errno, "writing '0' to '%s'", path);
    if (result != 1)
      error(1, 0, "did not write 1 byte to '%s'", path);
    result = close(led_fd);
    if (result < 0)
      error(1, errno, "could not close file '%s'", path);
  }
  for (i = 0; i < (leds_array_count * 2); i++) {
    path_length = snprintf(path, PATH_MAX, "/sys/class/leds/%s/brightness",
                           leds_array[i % leds_array_count]);
    if (path_length < 0)
      error(1, 0, "path output error");
    if (path_length >= PATH_MAX)
      error(1, 0, "path length overflow");
    led_fd = open(path, O_RDWR | O_SYNC);
    if (led_fd < 0)
      error(1, errno, "could not open file '%s'", path);
    result = read(led_fd, &brightness, 1);
    if (result < 0)
      error(1, errno, "reading 1 byte from '%s'", path);
    if (result != 1)
      error(1, 0, "did not read 1 byte from '%s'", path);
    if (brightness == '0')
      brightness = '1';
    else if (brightness == '1')
      brightness = '0';
    else
      error(1, 0, "unexpected value for brightness");
    result = write(led_fd, &brightness, 1);
    if (result < 0)
      error(1, errno, "writing brightness to '%s'", path);
    if (result != 1)
      error(1, 0, "did not write 1 byte to '%s'", path);
    result = close(led_fd);
    if (result < 0)
      error(1, errno, "could not close file '%s'", path);
    result = usleep(125000);
    if (result < 0)
      error(1, errno, "usleep error");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
movaps 0x2c57(%rip),%xmm0
movaps %xmm0,-0x20(%rbp)
movaps 0x2c3c(%rip),%xmm0
movaps %xmm0,-0x30(%rbp)
movaps 0x2c21(%rip),%xmm0
movaps %xmm0,-0x40(%rbp)
movaps 0x2c06(%rip),%xmm0
movaps %xmm0,-0x50(%rbp)
movl   $0x8,-0x54(%rbp)
mov    0x2e2c(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x60(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x80(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x68(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x54(%rbp),%eax
jge    1532 <main+0x3c2>
mov    -0x80(%rbp),%rdi
mov    0x2de9(%rip),%rax
mov    (%rax),%esi
movslq -0x8(%rbp),%rax
mov    -0x50(%rbp,%rax,8),%rcx
lea    0xe3f(%rip),%rdx
call   1040 <snprintf@plt>
mov    %eax,-0x6c(%rbp)
cmpl   $0x0,-0x6c(%rbp)
jge    1238 <main+0xc8>
mov    $0x1,%edi
xor    %esi,%esi
lea    0xe3a(%rip),%rdx
mov    $0x0,%al
call   1070 <error@plt>
mov    -0x6c(%rbp),%eax
mov    0x2da6(%rip),%rcx
cmp    (%rcx),%eax
jl     125f <main+0xef>
mov    $0x1,%edi
xor    %esi,%esi
lea    0xe25(%rip),%rdx
mov    $0x0,%al
call   1070 <error@plt>
mov    -0x80(%rbp),%rdi
mov    0x2d46(%rip),%rax
mov    (%rax),%esi
mov    0x2d5d(%rip),%rax
or     (%rax),%esi
call   1080 <open@plt>
mov    %eax,-0x58(%rbp)
cmpl   $0x0,-0x58(%rbp)
jge    12a7 <main+0x137>
mov    -0x80(%rbp),%rcx
mov    0x2d2e(%rip),%rax
mov    (%rax),%esi
mov    $0x1,%edi
lea    0xdf2(%rip),%rdx
mov    $0x0,%al
call   1070 <error@plt>
mov    -0x58(%rbp),%edi
lea    0xdfa(%rip),%rsi
mov    $0x4,%edx
call   1030 <write@plt>
mov    %eax,-0x70(%rbp)
cmpl   $0x0,-0x70(%rbp)
jge    12e8 <main+0x178>
mov    -0x80(%rbp),%rcx
mov    0x2ced(%rip),%rax
mov    (%rax),%esi
mov    $0x1,%edi
lea    0xdcf(%rip),%rdx
mov    $0x0,%al
call   1070 <error@plt>
cmpl   $0x4,-0x70(%rbp)
je     130b <main+0x19b>
mov    -0x80(%rbp),%rcx
mov    $0x1,%edi
xor    %esi,%esi
lea    0xdc3(%rip),%rdx
mov    $0x0,%al
call   1070 <error@plt>
mov    -0x58(%rbp),%edi
call   1050 <close@plt>
mov    %eax,-0x70(%rbp)
cmpl   $0x0,-0x70(%rbp)
jge    1340 <main+0x1d0>
mov    -0x80(%rbp),%rcx
mov    0x2c95(%rip),%rax
mov    (%rax),%esi
mov    $0x1,%edi
lea    0xdac(%rip),%rdx
mov    $0x0,%al
call   1070 <error@plt>
mov    -0x80(%rbp),%rdi
mov    0x2c9d(%rip),%rax
mov    (%rax),%esi
movslq -0x8(%rbp),%rax
mov    -0x50(%rbp,%rax,8),%rcx
lea    0xda2(%rip),%rdx
call   1040 <snprintf@plt>
mov    %eax,-0x6c(%rbp)
cmpl   $0x0,-0x6c(%rbp)
jge    1384 <main+0x214>
mov    $0x1,%edi
xor    %esi,%esi
lea    0xcee(%rip),%rdx
mov    $0x0,%al
call   1070 <error@plt>
mov    -0x6c(%rbp),%eax
mov    0x2c5a(%rip),%rcx
cmp    (%rcx),%eax
jl     13ab <main+0x23b>
mov    $0x1,%edi
xor    %esi,%esi
lea    0xcd9(%rip),%rdx
mov    $0x0,%al
call   1070 <error@plt>
mov    -0x80(%rbp),%rdi
mov    0x2bfa(%rip),%rax
mov    (%rax),%esi
mov    0x2c11(%rip),%rax
or     (%rax),%esi
call   1080 <open@plt>
mov    %eax,-0x58(%rbp)
cmpl   $0x0,-0x58(%rbp)
jge    13f3 <main+0x283>
mov    -0x80(%rbp),%rcx
mov    0x2be2(%rip),%rax
mov    (%rax),%esi
mov    $0x1,%edi
lea    0xca6(%rip),%rdx
mov    $0x0,%al
call   1070 <error@plt>
mov    -0x58(%rbp),%edi
lea    0xc0b(%rip),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    %eax,-0x70(%rbp)
cmpl   $0x0,-0x70(%rbp)
jge    1434 <main+0x2c4>
mov    -0x80(%rbp),%rcx
mov    0x2ba1(%rip),%rax
mov    (%rax),%esi
mov    $0x1,%edi
lea    0xc83(%rip),%rdx
mov    $0x0,%al
call   1070 <error@plt>
cmpl   $0x1,-0x70(%rbp)
je     145c <main+0x2ec>
mov    -0x80(%rbp),%rdi
mov    0x2b67(%rip),%rax
mov    (%rax),%esi
mov    0x2b7e(%rip),%rax
or     (%rax),%esi
call   1080 <open@plt>
mov    %eax,-0x58(%rbp)
cmpl   $0x0,-0x58(%rbp)
jge    1486 <main+0x316>
mov    -0x80(%rbp),%rcx
mov    0x2b4f(%rip),%rax
mov    (%rax),%esi
mov    $0x1,%edi
lea    0xc13(%rip),%rdx
mov    $0x0,%al
call   1070 <error@plt>
mov    -0x58(%rbp),%edi
lea    0xb78(%rip),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    %eax,-0x70(%rbp)
cmpl   $0x0,-0x70(%rbp)
jge    14c7 <main+0x357>
mov    -0x80(%rbp),%rcx
mov    0x2b0e(%rip),%rax
mov    (%rax),%esi
mov    $0x1,%edi
lea    0xc5d(%rip),%rdx
mov    $0x0,%al
call   1070 <error@plt>
cmpl   $0x1,-0x70(%rbp)
je     14ea <main+0x37a>
mov    -0x80(%rbp),%rcx
mov    $0x1,%edi
xor    %esi,%esi
lea    0xc4e(%rip),%rdx
mov    $0x0,%al
call   1070 <error@plt>
mov    -0x58(%rbp),%edi
call   1050 <close@plt>
mov    %eax,-0x70(%rbp)
cmpl   $0x0,-0x70(%rbp)
jge    151f <main+0x3af>
mov    -0x80(%rbp),%rcx
mov    0x2ab6(%rip),%rax
mov    (%rax),%esi
mov    $0x1,%edi
lea    0xbcd(%rip),%rdx
mov    $0x0,%al
call   1070 <error@plt>
jmp    1524 <main+0x3b4>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11e8 <main+0x78>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    -0x54(%rbp),%ecx
shl    $0x1,%ecx
cmp    %ecx,%eax
jge    1786 <main+0x616>
mov    -0x80(%rbp),%rdi
mov    0x2a93(%rip),%rax
mov    (%rax),%esi
mov    -0x8(%rbp),%eax
cltd
idivl  -0x54(%rbp)
movslq %edx,%rax
mov    -0x50(%rbp,%rax,8),%rcx
lea    0xb92(%rip),%rdx
call   1040 <snprintf@plt>
mov    %eax,-0x6c(%rbp)
cmpl   $0x0,-0x6c(%rbp)
jge    1594 <main+0x424>
mov    $0x1,%edi
xor    %esi,%esi
lea    0xade(%rip),%rdx
mov    $0x0,%al
call   1070 <error@plt>
mov    -0x6c(%rbp),%eax
mov    0x2a4a(%rip),%rcx
cmp    (%rcx),%eax
jl     15bb <main+0x44b>
mov    $0x1,%edi
xor    %esi,%esi
lea    0xac9(%rip),%rdx
mov    $0x0,%al
call   1070 <error@plt>
mov    -0x80(%rbp),%rdi
mov    0x2a12(%rip),%rax
mov    (%rax),%esi
mov    0x2a01(%rip),%rax
or     (%rax),%esi
call   1080 <open@plt>
mov    %eax,-0x58(%rbp)
cmpl   $0x0,-0x58(%rbp)
jge    1603 <main+0x493>
mov    -0x80(%rbp),%rcx
mov    0x29d2(%rip),%rax
mov    (%rax),%esi
mov    $0x1,%edi
lea    0xa96(%rip),%rdx
mov    $0x0,%al
call   1070 <error@plt>
mov    -0x58(%rbp),%edi
lea    -0x71(%rbp),%rsi
mov    $0x1,%edx
call   1060 <read@plt>
mov    %eax,-0x70(%rbp)
cmpl   $0x0,-0x70(%rbp)
jge    1641 <main+0x4d1>
mov    -0x80(%rbp),%rcx
mov    0x2994(%rip),%rax
mov    (%rax),%esi
mov    $0x1,%edi
lea    0xb14(%rip),%rdx
mov    $0x0,%al
call   1070 <error@plt>
cmpl   $0x1,-0x70(%rbp)
je     1664 <main+0x4f4>
mov    -0x80(%rbp),%rcx
mov    $0x1,%edi
xor    %esi,%esi
lea    0xb0a(%rip),%rdx
mov    $0x0,%al
call   1070 <error@plt>
movsbl -0x71(%rbp),%eax
cmp    $0x30,%eax
jne    167a <main+0x50a>
movb   $0x31,-0x71(%rbp)
jmp    16aa <main+0x53a>
movsbl -0x71(%rbp),%eax
cmp    $0x31,%eax
jne    1690 <main+0x520>
movb   $0x30,-0x71(%rbp)
jmp    16a5 <main+0x535>
mov    $0x1,%edi
xor    %esi,%esi
lea    0xae7(%rip),%rdx
mov    $0x0,%al
call   1070 <error@plt>
jmp    16aa <main+0x53a>
mov    -0x58(%rbp),%edi
lea    -0x71(%rbp),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    %eax,-0x70(%rbp)
cmpl   $0x0,-0x70(%rbp)
jge    16e8 <main+0x578>
mov    -0x80(%rbp),%rcx
mov    0x28ed(%rip),%rax
mov    (%rax),%esi
mov    $0x1,%edi
lea    0xac4(%rip),%rdx
mov    $0x0,%al
call   1070 <error@plt>
cmpl   $0x1,-0x70(%rbp)
je     170b <main+0x59b>
mov    -0x80(%rbp),%rcx
mov    $0x1,%edi
xor    %esi,%esi
lea    0xa2d(%rip),%rdx
mov    $0x0,%al
call   1070 <error@plt>
mov    -0x58(%rbp),%edi
call   1050 <close@plt>
mov    %eax,-0x70(%rbp)
cmpl   $0x0,-0x70(%rbp)
jge    1740 <main+0x5d0>
mov    -0x80(%rbp),%rcx
mov    0x2895(%rip),%rax
mov    (%rax),%esi
mov    $0x1,%edi
lea    0x9ac(%rip),%rdx
mov    $0x0,%al
call   1070 <error@plt>
mov    $0x1e848,%edi
call   1090 <usleep@plt>
mov    %eax,-0x70(%rbp)
cmpl   $0x0,-0x70(%rbp)
jge    1773 <main+0x603>
mov    0x2862(%rip),%rax
mov    (%rax),%esi
mov    $0x1,%edi
lea    0xa54(%rip),%rdx
mov    $0x0,%al
call   1070 <error@plt>
jmp    1778 <main+0x608>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1539 <main+0x3c9>
movl   $0x0,-0x4(%rbp)
mov    -0x60(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    0x2e63(%rip),%r13
mov    0x0(%r13),%esi
mov    %rsp,%r14
mov    %rsi,%rax
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r14
mov    %r14,%rsp
xor    %r12d,%r12d
lea    0x2c09(%rip),%rax
mov    (%r12,%rax,1),%r15
mov    %r14,%rdi
lea    0xe9b(%rip),%rdx
mov    %r15,%rcx
call   1040 <snprintf@plt>
mov    %eax,%ebx
test   %eax,%eax
js     1240 <main+0xd0>
cmp    0x0(%r13),%ebx
jl     11de <main+0x6e>
mov    $0x1,%edi
xor    %esi,%esi
lea    0xea6(%rip),%rdx
xor    %eax,%eax
call   1070 <error@plt>
mov    0x2deb(%rip),%rax
mov    (%rax),%esi
mov    0x2dc2(%rip),%rax
or     (%rax),%esi
mov    %r14,%rdi
call   1080 <open@plt>
mov    %eax,%ebx
test   %eax,%eax
jns    121d <main+0xad>
mov    0x2dbb(%rip),%rax
mov    (%rax),%esi
mov    $0x1,%edi
lea    0xe7f(%rip),%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1070 <error@plt>
mov    %ebx,%edi
lea    0xe85(%rip),%rsi
mov    $0x4,%edx
call   1030 <write@plt>
test   %eax,%eax
js     1270 <main+0x100>
cmp    $0x4,%eax
jne    128f <main+0x11f>
jmp    12a7 <main+0x137>
nopl   0x0(%rax,%rax,1)
mov    $0x1,%edi
xor    %esi,%esi
lea    0xe1d(%rip),%rdx
xor    %eax,%eax
call   1070 <error@plt>
cmp    0x0(%r13),%ebx
jge    11c9 <main+0x59>
jmp    11de <main+0x6e>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x2d49(%rip),%rax
mov    (%rax),%esi
mov    $0x1,%edi
lea    0xe2b(%rip),%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1070 <error@plt>
mov    $0x1,%edi
xor    %esi,%esi
lea    0xe2a(%rip),%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1070 <error@plt>
mov    %ebx,%edi
call   1050 <close@plt>
test   %eax,%eax
jns    12d1 <main+0x161>
mov    0x2d07(%rip),%rax
mov    (%rax),%esi
mov    $0x1,%edi
lea    0xe1e(%rip),%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1070 <error@plt>
mov    0x0(%r13),%esi
mov    %r14,%rdi
lea    0xe20(%rip),%rdx
mov    %r15,%rcx
call   1040 <snprintf@plt>
mov    %eax,%ebx
test   %eax,%eax
jns    1302 <main+0x192>
mov    $0x1,%edi
xor    %esi,%esi
lea    0xd70(%rip),%rdx
xor    %eax,%eax
call   1070 <error@plt>
cmp    0x0(%r13),%ebx
lea    0xcfb(%rip),%r15
jl     1324 <main+0x1b4>
mov    $0x1,%edi
xor    %esi,%esi
lea    0xd60(%rip),%rdx
xor    %eax,%eax
call   1070 <error@plt>
mov    0x2ca5(%rip),%rax
mov    (%rax),%esi
mov    0x2c7c(%rip),%rax
or     (%rax),%esi
mov    %r14,%rdi
call   1080 <open@plt>
mov    %eax,%ebx
test   %eax,%eax
jns    1363 <main+0x1f3>
mov    0x2c75(%rip),%rax
mov    (%rax),%esi
mov    $0x1,%edi
lea    0xd39(%rip),%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1070 <error@plt>
mov    %ebx,%edi
mov    %r15,%rsi
mov    $0x1,%edx
call   1030 <write@plt>
test   %eax,%eax
js     13a0 <main+0x230>
cmp    $0x1,%eax
jne    13bf <main+0x24f>
test   %ebx,%ebx
js     13df <main+0x26f>
mov    %ebx,%edi
mov    %r15,%rsi
mov    $0x1,%edx
call   1030 <write@plt>
test   %eax,%eax
js     1410 <main+0x2a0>
cmp    $0x1,%eax
jne    142f <main+0x2bf>
jmp    1447 <main+0x2d7>
mov    0x2c19(%rip),%rax
mov    (%rax),%esi
mov    $0x1,%edi
lea    0xcfb(%rip),%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1070 <error@plt>
mov    0x2c0a(%rip),%rax
mov    (%rax),%esi
mov    0x2be1(%rip),%rax
or     (%rax),%esi
mov    %r14,%rdi
call   1080 <open@plt>
mov    %eax,%ebx
test   %ebx,%ebx
jns    137f <main+0x20f>
mov    0x2bda(%rip),%rax
mov    (%rax),%esi
mov    $0x1,%edi
lea    0xc9e(%rip),%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1070 <error@plt>
jmp    137f <main+0x20f>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x2ba9(%rip),%rax
mov    (%rax),%esi
mov    $0x1,%edi
lea    0xcf8(%rip),%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1070 <error@plt>
mov    $0x1,%edi
xor    %esi,%esi
lea    0xcf4(%rip),%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1070 <error@plt>
mov    %ebx,%edi
call   1050 <close@plt>
test   %eax,%eax
jns    1471 <main+0x301>
mov    0x2b67(%rip),%rax
mov    (%rax),%esi
mov    $0x1,%edi
lea    0xc7e(%rip),%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1070 <error@plt>
cmp    $0x38,%r12
je     1484 <main+0x314>
mov    0x0(%r13),%esi
add    $0x8,%r12
jmp    11a0 <main+0x30>
lea    -0x29(%rbp),%r13
xor    %r15d,%r15d
jmp    149e <main+0x32e>
nopl   (%rax)
add    $0x1,%r15d
cmp    $0x10,%r15d
je     16a5 <main+0x535>
mov    0x2b43(%rip),%r12
mov    (%r12),%esi
mov    %r15d,%eax
and    $0x7,%eax
lea    0x28fa(%rip),%rcx
mov    (%rcx,%rax,8),%rcx
mov    %r14,%rdi
lea    0xc3b(%rip),%rdx
call   1040 <snprintf@plt>
mov    %eax,%ebx
test   %eax,%eax
js     1550 <main+0x3e0>
cmp    (%r12),%ebx
jl     14ee <main+0x37e>
mov    $0x1,%edi
xor    %esi,%esi
lea    0xb96(%rip),%rdx
xor    %eax,%eax
call   1070 <error@plt>
mov    0x2adb(%rip),%rax
mov    (%rax),%esi
mov    0x2ada(%rip),%rax
or     (%rax),%esi
mov    %r14,%rdi
call   1080 <open@plt>
mov    %eax,%r12d
test   %eax,%eax
jns    152e <main+0x3be>
mov    0x2aaa(%rip),%rax
mov    (%rax),%esi
mov    $0x1,%edi
lea    0xb6e(%rip),%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1070 <error@plt>
mov    %r12d,%edi
mov    %r13,%rsi
mov    $0x1,%edx
call   1060 <read@plt>
test   %eax,%eax
js     1580 <main+0x410>
cmp    $0x1,%eax
jne    159f <main+0x42f>
jmp    15b7 <main+0x447>
nopl   0x0(%rax)
mov    $0x1,%edi
xor    %esi,%esi
lea    0xb0d(%rip),%rdx
xor    %eax,%eax
call   1070 <error@plt>
cmp    (%r12),%ebx
jge    14d9 <main+0x369>
jmp    14ee <main+0x37e>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x2a39(%rip),%rax
mov    (%rax),%esi
mov    $0x1,%edi
lea    0xbb9(%rip),%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1070 <error@plt>
mov    $0x1,%edi
xor    %esi,%esi
lea    0xbba(%rip),%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1070 <error@plt>
movzbl -0x29(%rbp),%eax
cmp    $0x31,%al
je     15d0 <main+0x460>
cmp    $0x30,%al
jne    15e0 <main+0x470>
movb   $0x31,-0x29(%rbp)
jmp    15f5 <main+0x485>
nopl   0x0(%rax)
movb   $0x30,-0x29(%rbp)
jmp    15f5 <main+0x485>
cs nopw 0x0(%rax,%rax,1)
mov    $0x1,%edi
xor    %esi,%esi
lea    0xb97(%rip),%rdx
xor    %eax,%eax
call   1070 <error@plt>
mov    %r12d,%edi
mov    %r13,%rsi
mov    $0x1,%edx
call   1030 <write@plt>
test   %eax,%eax
js     1610 <main+0x4a0>
cmp    $0x1,%eax
jne    162f <main+0x4bf>
jmp    1647 <main+0x4d7>
mov    0x29a9(%rip),%rax
mov    (%rax),%esi
mov    $0x1,%edi
lea    0xb80(%rip),%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1070 <error@plt>
mov    $0x1,%edi
xor    %esi,%esi
lea    0xaf4(%rip),%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1070 <error@plt>
mov    %r12d,%edi
call   1050 <close@plt>
test   %eax,%eax
jns    1672 <main+0x502>
mov    0x2966(%rip),%rax
mov    (%rax),%esi
mov    $0x1,%edi
lea    0xa7d(%rip),%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1070 <error@plt>
mov    $0x1e848,%edi
call   1090 <usleep@plt>
test   %eax,%eax
jns    1490 <main+0x320>
mov    0x2935(%rip),%rax
mov    (%rax),%esi
mov    $0x1,%edi
lea    0xb27(%rip),%rdx
xor    %eax,%eax
call   1070 <error@plt>
jmp    1490 <main+0x320>
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"fpga_led0\00"
@.str.1 = [10 x i8] c"fpga_led1\00"
@.str.2 = [10 x i8] c"fpga_led2\00"
@.str.3 = [10 x i8] c"fpga_led3\00"
@.str.4 = [10 x i8] c"fpga_led4\00"
@.str.5 = [10 x i8] c"fpga_led5\00"
@.str.6 = [10 x i8] c"fpga_led6\00"
@.str.7 = [10 x i8] c"fpga_led7\00"
@__const.main.leds_array = [8 x i8*] [i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i32 0, i32 0)]
@PATH_MAX = global i32 0
@.str.8 = [27 x i8] c"/sys/class/leds/%s/trigger\00"
@.str.9 = [18 x i8] c"path output error\00"
@.str.10 = [21 x i8] c"path length overflow\00"
@O_WRONLY = global i32 0
@O_SYNC = global i32 0
@errno = global i32 0
@.str.11 = [25 x i8] c"could not open file '%s'\00"
@.str.12 = [5 x i8] c"none\00"
@.str.13 = [23 x i8] c"writing 'none' to '%s'\00"
@.str.14 = [30 x i8] c"did not write 4 bytes to '%s'\00"
@.str.15 = [26 x i8] c"could not close file '%s'\00"
@.str.16 = [30 x i8] c"/sys/class/leds/%s/brightness\00"
@.str.17 = [2 x i8] c"0\00"
@.str.18 = [20 x i8] c"writing '0' to '%s'\00"
@.str.19 = [29 x i8] c"did not write 1 byte to '%s'\00"
@O_RDWR = global i32 0
@.str.20 = [25 x i8] c"reading 1 byte from '%s'\00"
@.str.21 = [30 x i8] c"did not read 1 byte from '%s'\00"
@.str.22 = [32 x i8] c"unexpected value for brightness\00"
@.str.23 = [27 x i8] c"writing brightness to '%s'\00"
@.str.24 = [13 x i8] c"usleep error\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [8 x i8*]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8
store i32 0, i32* %1
%11 = bitcast [8 x i8*]* %3 to i8*
store i32 8, i32* %4
%12 = load i32, i32* @PATH_MAX
%13 = zext i32 %12 to i64
%14 = call i8* @llvm.stacksave()
store i8* %14, i8** %6
%15 = alloca i8, i64 %13
store i64 %13, i64* %7
store i32 0, i32* %2
br label %16
16: ; preds = %139, %0
%17 = load i32, i32* %2
%18 = load i32, i32* %4
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %142
20: ; preds = %16
%21 = load i32, i32* @PATH_MAX
%22 = load i32, i32* %2
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [8 x i8*], [8 x i8*]* %3, i64 0, i64 %23
%25 = load i8*, i8** %24
%26 = call i32 @snprintf(i8* %15, i32 %21, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.8, i64 0, i64 0), i8* %25)
store i32 %26, i32* %8
%27 = load i32, i32* %8
%28 = icmp slt i32 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %20
%30 = call i32 (i32, i32, i8*, ...) @error(i32 1, i32 0, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0))
br label %31
31: ; preds = %29, %20
%32 = load i32, i32* %8
%33 = load i32, i32* @PATH_MAX
%34 = icmp sge i32 %32, %33
br i1 %34, label %35, label %37
35: ; preds = %31
%36 = call i32 (i32, i32, i8*, ...) @error(i32 1, i32 0, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.10, i64 0, i64 0))
br label %37
37: ; preds = %35, %31
%38 = load i32, i32* @O_WRONLY
%39 = load i32, i32* @O_SYNC
%40 = or i32 %38, %39
%41 = call i32 @open(i8* %15, i32 %40)
store i32 %41, i32* %5
%42 = load i32, i32* %5
%43 = icmp slt i32 %42, 0
br i1 %43, label %44, label %47
44: ; preds = %37
%45 = load i32, i32* @errno
%46 = call i32 (i32, i32, i8*, ...) @error(i32 1, i32 %45, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.11, i64 0, i64 0), i8* %15)
br label %47
47: ; preds = %44, %37
%48 = load i32, i32* %5
%49 = call i32 @write(i32 %48, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i32 4)
store i32 %49, i32* %9
%50 = load i32, i32* %9
%51 = icmp slt i32 %50, 0
br i1 %51, label %52, label %55
52: ; preds = %47
%53 = load i32, i32* @errno
%54 = call i32 (i32, i32, i8*, ...) @error(i32 1, i32 %53, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.13, i64 0, i64 0), i8* %15)
br label %55
55: ; preds = %52, %47
%56 = load i32, i32* %9
%57 = icmp ne i32 %56, 4
br i1 %57, label %58, label %60
58: ; preds = %55
%59 = call i32 (i32, i32, i8*, ...) @error(i32 1, i32 0, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.14, i64 0, i64 0), i8* %15)
br label %60
60: ; preds = %58, %55
%61 = load i32, i32* %5
%62 = call i32 @close(i32 %61)
store i32 %62, i32* %9
%63 = load i32, i32* %9
%64 = icmp slt i32 %63, 0
br i1 %64, label %65, label %68
65: ; preds = %60
%66 = load i32, i32* @errno
%67 = call i32 (i32, i32, i8*, ...) @error(i32 1, i32 %66, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.15, i64 0, i64 0), i8* %15)
br label %68
68: ; preds = %65, %60
%69 = load i32, i32* @PATH_MAX
%70 = load i32, i32* %2
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds [8 x i8*], [8 x i8*]* %3, i64 0, i64 %71
%73 = load i8*, i8** %72
%74 = call i32 @snprintf(i8* %15, i32 %69, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.16, i64 0, i64 0), i8* %73)
store i32 %74, i32* %8
%75 = load i32, i32* %8
%76 = icmp slt i32 %75, 0
br i1 %76, label %77, label %79
77: ; preds = %68
%78 = call i32 (i32, i32, i8*, ...) @error(i32 1, i32 0, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0))
br label %79
79: ; preds = %77, %68
%80 = load i32, i32* %8
%81 = load i32, i32* @PATH_MAX
%82 = icmp sge i32 %80, %81
br i1 %82, label %83, label %85
83: ; preds = %79
%84 = call i32 (i32, i32, i8*, ...) @error(i32 1, i32 0, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.10, i64 0, i64 0))
br label %85
85: ; preds = %83, %79
%86 = load i32, i32* @O_WRONLY
%87 = load i32, i32* @O_SYNC
%88 = or i32 %86, %87
%89 = call i32 @open(i8* %15, i32 %88)
store i32 %89, i32* %5
%90 = load i32, i32* %5
%91 = icmp slt i32 %90, 0
br i1 %91, label %92, label %95
92: ; preds = %85
%93 = load i32, i32* @errno
%94 = call i32 (i32, i32, i8*, ...) @error(i32 1, i32 %93, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.11, i64 0, i64 0), i8* %15)
br label %95
95: ; preds = %92, %85
%96 = load i32, i32* %5
%97 = call i32 @write(i32 %96, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.17, i64 0, i64 0), i32 1)
store i32 %97, i32* %9
%98 = load i32, i32* %9
%99 = icmp slt i32 %98, 0
br i1 %99, label %100, label %103
100: ; preds = %95
%101 = load i32, i32* @errno
%102 = call i32 (i32, i32, i8*, ...) @error(i32 1, i32 %101, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.13, i64 0, i64 0), i8* %15)
br label %103
103: ; preds = %100, %95
%104 = load i32, i32* %9
%105 = icmp ne i32 %104, 1
br i1 %105, label %106, label %111
106: ; preds = %103
%107 = load i32, i32* @O_WRONLY
%108 = load i32, i32* @O_SYNC
%109 = or i32 %107, %108
%110 = call i32 @open(i8* %15, i32 %109)
store i32 %110, i32* %5
br label %111
111: ; preds = %106, %103
%112 = load i32, i32* %5
%113 = icmp slt i32 %112, 0
br i1 %113, label %114, label %117
114: ; preds = %111
%115 = load i32, i32* @errno
%116 = call i32 (i32, i32, i8*, ...) @error(i32 1, i32 %115, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.11, i64 0, i64 0), i8* %15)
br label %117
117: ; preds = %114, %111
%118 = load i32, i32* %5
%119 = call i32 @write(i32 %118, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.17, i64 0, i64 0), i32 1)
store i32 %119, i32* %9
%120 = load i32, i32* %9
%121 = icmp slt i32 %120, 0
br i1 %121, label %122, label %125
122: ; preds = %117
%123 = load i32, i32* @errno
%124 = call i32 (i32, i32, i8*, ...) @error(i32 1, i32 %123, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.18, i64 0, i64 0), i8* %15)
br label %125
125: ; preds = %122, %117
%126 = load i32, i32* %9
%127 = icmp ne i32 %126, 1
br i1 %127, label %128, label %130
128: ; preds = %125
%129 = call i32 (i32, i32, i8*, ...) @error(i32 1, i32 0, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.19, i64 0, i64 0), i8* %15)
br label %130
130: ; preds = %128, %125
%131 = load i32, i32* %5
%132 = call i32 @close(i32 %131)
store i32 %132, i32* %9
%133 = load i32, i32* %9
%134 = icmp slt i32 %133, 0
br i1 %134, label %135, label %138
135: ; preds = %130
%136 = load i32, i32* @errno
%137 = call i32 (i32, i32, i8*, ...) @error(i32 1, i32 %136, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.15, i64 0, i64 0), i8* %15)
br label %138
138: ; preds = %135, %130
br label %139
139: ; preds = %138
%140 = load i32, i32* %2
%141 = add nsw i32 %140, 1
store i32 %141, i32* %2
br label %16
142: ; preds = %16
store i32 0, i32* %2
br label %143
143: ; preds = %232, %142
%144 = load i32, i32* %2
%145 = load i32, i32* %4
%146 = mul nsw i32 %145, 2
%147 = icmp slt i32 %144, %146
br i1 %147, label %148, label %235
148: ; preds = %143
%149 = load i32, i32* @PATH_MAX
%150 = load i32, i32* %2
%151 = load i32, i32* %4
%152 = srem i32 %150, %151
%153 = sext i32 %152 to i64
%154 = getelementptr inbounds [8 x i8*], [8 x i8*]* %3, i64 0, i64 %153
%155 = load i8*, i8** %154
%156 = call i32 @snprintf(i8* %15, i32 %149, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.16, i64 0, i64 0), i8* %155)
store i32 %156, i32* %8
%157 = load i32, i32* %8
%158 = icmp slt i32 %157, 0
br i1 %158, label %159, label %161
159: ; preds = %148
%160 = call i32 (i32, i32, i8*, ...) @error(i32 1, i32 0, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0))
br label %161
161: ; preds = %159, %148
%162 = load i32, i32* %8
%163 = load i32, i32* @PATH_MAX
%164 = icmp sge i32 %162, %163
br i1 %164, label %165, label %167
165: ; preds = %161
%166 = call i32 (i32, i32, i8*, ...) @error(i32 1, i32 0, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.10, i64 0, i64 0))
br label %167
167: ; preds = %165, %161
%168 = load i32, i32* @O_RDWR
%169 = load i32, i32* @O_SYNC
%170 = or i32 %168, %169
%171 = call i32 @open(i8* %15, i32 %170)
store i32 %171, i32* %5
%172 = load i32, i32* %5
%173 = icmp slt i32 %172, 0
br i1 %173, label %174, label %177
174: ; preds = %167
%175 = load i32, i32* @errno
%176 = call i32 (i32, i32, i8*, ...) @error(i32 1, i32 %175, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.11, i64 0, i64 0), i8* %15)
br label %177
177: ; preds = %174, %167
%178 = load i32, i32* %5
%179 = call i32 @read(i32 %178, i8* %10, i32 1)
store i32 %179, i32* %9
%180 = load i32, i32* %9
%181 = icmp slt i32 %180, 0
br i1 %181, label %182, label %185
182: ; preds = %177
%183 = load i32, i32* @errno
%184 = call i32 (i32, i32, i8*, ...) @error(i32 1, i32 %183, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.20, i64 0, i64 0), i8* %15)
br label %185
185: ; preds = %182, %177
%186 = load i32, i32* %9
%187 = icmp ne i32 %186, 1
br i1 %187, label %188, label %190
188: ; preds = %185
%189 = call i32 (i32, i32, i8*, ...) @error(i32 1, i32 0, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.21, i64 0, i64 0), i8* %15)
br label %190
190: ; preds = %188, %185
%191 = load i8, i8* %10
%192 = sext i8 %191 to i32
%193 = icmp eq i32 %192, 48
br i1 %193, label %194, label %195
194: ; preds = %190
store i8 49, i8* %10
br label %203
195: ; preds = %190
%196 = load i8, i8* %10
%197 = sext i8 %196 to i32
%198 = icmp eq i32 %197, 49
br i1 %198, label %199, label %200
199: ; preds = %195
store i8 48, i8* %10
br label %202
200: ; preds = %195
%201 = call i32 (i32, i32, i8*, ...) @error(i32 1, i32 0, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.22, i64 0, i64 0))
br label %202
202: ; preds = %200, %199
br label %203
203: ; preds = %202, %194
%204 = load i32, i32* %5
%205 = call i32 @write(i32 %204, i8* %10, i32 1)
store i32 %205, i32* %9
%206 = load i32, i32* %9
%207 = icmp slt i32 %206, 0
br i1 %207, label %208, label %211
208: ; preds = %203
%209 = load i32, i32* @errno
%210 = call i32 (i32, i32, i8*, ...) @error(i32 1, i32 %209, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.23, i64 0, i64 0), i8* %15)
br label %211
211: ; preds = %208, %203
%212 = load i32, i32* %9
%213 = icmp ne i32 %212, 1
br i1 %213, label %214, label %216
214: ; preds = %211
%215 = call i32 (i32, i32, i8*, ...) @error(i32 1, i32 0, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.19, i64 0, i64 0), i8* %15)
br label %216
216: ; preds = %214, %211
%217 = load i32, i32* %5
%218 = call i32 @close(i32 %217)
store i32 %218, i32* %9
%219 = load i32, i32* %9
%220 = icmp slt i32 %219, 0
br i1 %220, label %221, label %224
221: ; preds = %216
%222 = load i32, i32* @errno
%223 = call i32 (i32, i32, i8*, ...) @error(i32 1, i32 %222, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.15, i64 0, i64 0), i8* %15)
br label %224
224: ; preds = %221, %216
%225 = call i32 @usleep(i32 125000)
store i32 %225, i32* %9
%226 = load i32, i32* %9
%227 = icmp slt i32 %226, 0
br i1 %227, label %228, label %231
228: ; preds = %224
%229 = load i32, i32* @errno
%230 = call i32 (i32, i32, i8*, ...) @error(i32 1, i32 %229, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.24, i64 0, i64 0))
br label %231
231: ; preds = %228, %224
br label %232
232: ; preds = %231
%233 = load i32, i32* %2
%234 = add nsw i32 %233, 1
store i32 %234, i32* %2
br label %143
235: ; preds = %143
store i32 0, i32* %1
%236 = load i8*, i8** %6
%237 = load i32, i32* %1
ret i32 %237
}

LLVM IR (-O2):
@.str = [10 x i8] c"fpga_led0\00"
@.str.1 = [10 x i8] c"fpga_led1\00"
@.str.2 = [10 x i8] c"fpga_led2\00"
@.str.3 = [10 x i8] c"fpga_led3\00"
@.str.4 = [10 x i8] c"fpga_led4\00"
@.str.5 = [10 x i8] c"fpga_led5\00"
@.str.6 = [10 x i8] c"fpga_led6\00"
@.str.7 = [10 x i8] c"fpga_led7\00"
@__const.main.leds_array = [8 x i8*] [i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i32 0, i32 0)]
@PATH_MAX = global i32 0
@.str.8 = [27 x i8] c"/sys/class/leds/%s/trigger\00"
@.str.9 = [18 x i8] c"path output error\00"
@.str.10 = [21 x i8] c"path length overflow\00"
@O_WRONLY = global i32 0
@O_SYNC = global i32 0
@errno = global i32 0
@.str.11 = [25 x i8] c"could not open file '%s'\00"
@.str.12 = [5 x i8] c"none\00"
@.str.13 = [23 x i8] c"writing 'none' to '%s'\00"
@.str.14 = [30 x i8] c"did not write 4 bytes to '%s'\00"
@.str.15 = [26 x i8] c"could not close file '%s'\00"
@.str.16 = [30 x i8] c"/sys/class/leds/%s/brightness\00"
@.str.17 = [2 x i8] c"0\00"
@.str.18 = [20 x i8] c"writing '0' to '%s'\00"
@.str.19 = [29 x i8] c"did not write 1 byte to '%s'\00"
@O_RDWR = global i32 0
@.str.20 = [25 x i8] c"reading 1 byte from '%s'\00"
@.str.21 = [30 x i8] c"did not read 1 byte from '%s'\00"
@.str.22 = [32 x i8] c"unexpected value for brightness\00"
@.str.23 = [27 x i8] c"writing brightness to '%s'\00"
@.str.24 = [13 x i8] c"usleep error\00"
define i32 @main() {
%1 = alloca i8
%2 = load i32, i32* @PATH_MAX
%3 = zext i32 %2 to i64
%4 = alloca i8, i64 %3
br label %5
5: ; preds = %102, %0
%6 = phi i32 [ %2, %0 ], [ %103, %102 ]
%7 = phi i64 [ 0, %0 ], [ %100, %102 ]
%8 = getelementptr inbounds [8 x i8*], [8 x i8*]* @__const.main.leds_array, i64 0, i64 %7
%9 = load i8*, i8** %8
%10 = call i32 @snprintf(i8* %4, i32 %6, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.8, i64 0, i64 0), i8* %9)
%11 = icmp slt i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %5
%13 = call i32 (i32, i32, i8*, ...) @error(i32 1, i32 0, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0))
br label %14
14: ; preds = %12, %5
%15 = load i32, i32* @PATH_MAX
%16 = icmp slt i32 %10, %15
br i1 %16, label %19, label %17
17: ; preds = %14
%18 = call i32 (i32, i32, i8*, ...) @error(i32 1, i32 0, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.10, i64 0, i64 0))
br label %19
19: ; preds = %17, %14
%20 = load i32, i32* @O_WRONLY
%21 = load i32, i32* @O_SYNC
%22 = or i32 %21, %20
%23 = call i32 @open(i8* %4, i32 %22)
%24 = icmp slt i32 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %19
%26 = load i32, i32* @errno
%27 = call i32 (i32, i32, i8*, ...) @error(i32 1, i32 %26, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.11, i64 0, i64 0), i8* %4)
br label %28
28: ; preds = %25, %19
%29 = call i32 @write(i32 %23, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i32 4)
%30 = icmp slt i32 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %28
%32 = load i32, i32* @errno
%33 = call i32 (i32, i32, i8*, ...) @error(i32 1, i32 %32, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.13, i64 0, i64 0), i8* %4)
br label %36
34: ; preds = %28
%35 = icmp eq i32 %29, 4
br i1 %35, label %38, label %36
36: ; preds = %31, %34
%37 = call i32 (i32, i32, i8*, ...) @error(i32 1, i32 0, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.14, i64 0, i64 0), i8* %4)
br label %38
38: ; preds = %36, %34
%39 = call i32 @close(i32 %23)
%40 = icmp slt i32 %39, 0
br i1 %40, label %41, label %44
41: ; preds = %38
%42 = load i32, i32* @errno
%43 = call i32 (i32, i32, i8*, ...) @error(i32 1, i32 %42, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.15, i64 0, i64 0), i8* %4)
br label %44
44: ; preds = %41, %38
%45 = load i32, i32* @PATH_MAX
%46 = call i32 @snprintf(i8* %4, i32 %45, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.16, i64 0, i64 0), i8* %9)
%47 = icmp slt i32 %46, 0
br i1 %47, label %48, label %50
48: ; preds = %44
%49 = call i32 (i32, i32, i8*, ...) @error(i32 1, i32 0, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0))
br label %50
50: ; preds = %48, %44
%51 = load i32, i32* @PATH_MAX
%52 = icmp slt i32 %46, %51
br i1 %52, label %55, label %53
53: ; preds = %50
%54 = call i32 (i32, i32, i8*, ...) @error(i32 1, i32 0, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.10, i64 0, i64 0))
br label %55
55: ; preds = %53, %50
%56 = load i32, i32* @O_WRONLY
%57 = load i32, i32* @O_SYNC
%58 = or i32 %57, %56
%59 = call i32 @open(i8* %4, i32 %58)
%60 = icmp slt i32 %59, 0
br i1 %60, label %61, label %64
61: ; preds = %55
%62 = load i32, i32* @errno
%63 = call i32 (i32, i32, i8*, ...) @error(i32 1, i32 %62, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.11, i64 0, i64 0), i8* %4)
br label %64
64: ; preds = %61, %55
%65 = call i32 @write(i32 %59, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.17, i64 0, i64 0), i32 1)
%66 = icmp slt i32 %65, 0
br i1 %66, label %67, label %70
67: ; preds = %64
%68 = load i32, i32* @errno
%69 = call i32 (i32, i32, i8*, ...) @error(i32 1, i32 %68, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.13, i64 0, i64 0), i8* %4)
br label %72
70: ; preds = %64
%71 = icmp eq i32 %65, 1
br i1 %71, label %77, label %72
72: ; preds = %67, %70
%73 = load i32, i32* @O_WRONLY
%74 = load i32, i32* @O_SYNC
%75 = or i32 %74, %73
%76 = call i32 @open(i8* %4, i32 %75)
br label %77
77: ; preds = %72, %70
%78 = phi i32 [ %76, %72 ], [ %59, %70 ]
%79 = icmp slt i32 %78, 0
br i1 %79, label %80, label %83
80: ; preds = %77
%81 = load i32, i32* @errno
%82 = call i32 (i32, i32, i8*, ...) @error(i32 1, i32 %81, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.11, i64 0, i64 0), i8* %4)
br label %83
83: ; preds = %80, %77
%84 = call i32 @write(i32 %78, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.17, i64 0, i64 0), i32 1)
%85 = icmp slt i32 %84, 0
br i1 %85, label %86, label %89
86: ; preds = %83
%87 = load i32, i32* @errno
%88 = call i32 (i32, i32, i8*, ...) @error(i32 1, i32 %87, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.18, i64 0, i64 0), i8* %4)
br label %91
89: ; preds = %83
%90 = icmp eq i32 %84, 1
br i1 %90, label %93, label %91
91: ; preds = %86, %89
%92 = call i32 (i32, i32, i8*, ...) @error(i32 1, i32 0, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.19, i64 0, i64 0), i8* %4)
br label %93
93: ; preds = %91, %89
%94 = call i32 @close(i32 %78)
%95 = icmp slt i32 %94, 0
br i1 %95, label %96, label %99
96: ; preds = %93
%97 = load i32, i32* @errno
%98 = call i32 (i32, i32, i8*, ...) @error(i32 1, i32 %97, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.15, i64 0, i64 0), i8* %4)
br label %99
99: ; preds = %93, %96
%100 = add nuw nsw i64 %7, 1
%101 = icmp eq i64 %100, 8
br i1 %101, label %104, label %102
102: ; preds = %99
%103 = load i32, i32* @PATH_MAX
br label %5
104: ; preds = %99, %167
%105 = phi i32 [ %168, %167 ], [ 0, %99 ]
%106 = load i32, i32* @PATH_MAX
%107 = and i32 %105, 7
%108 = zext i32 %107 to i64
%109 = getelementptr inbounds [8 x i8*], [8 x i8*]* @__const.main.leds_array, i64 0, i64 %108
%110 = load i8*, i8** %109
%111 = call i32 @snprintf(i8* %4, i32 %106, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.16, i64 0, i64 0), i8* %110)
%112 = icmp slt i32 %111, 0
br i1 %112, label %113, label %115
113: ; preds = %104
%114 = call i32 (i32, i32, i8*, ...) @error(i32 1, i32 0, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0))
br label %115
115: ; preds = %113, %104
%116 = load i32, i32* @PATH_MAX
%117 = icmp slt i32 %111, %116
br i1 %117, label %120, label %118
118: ; preds = %115
%119 = call i32 (i32, i32, i8*, ...) @error(i32 1, i32 0, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.10, i64 0, i64 0))
br label %120
120: ; preds = %118, %115
%121 = load i32, i32* @O_RDWR
%122 = load i32, i32* @O_SYNC
%123 = or i32 %122, %121
%124 = call i32 @open(i8* %4, i32 %123)
%125 = icmp slt i32 %124, 0
br i1 %125, label %126, label %129
126: ; preds = %120
%127 = load i32, i32* @errno
%128 = call i32 (i32, i32, i8*, ...) @error(i32 1, i32 %127, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.11, i64 0, i64 0), i8* %4)
br label %129
129: ; preds = %126, %120
%130 = call i32 @read(i32 %124, i8* %1, i32 1)
%131 = icmp slt i32 %130, 0
br i1 %131, label %132, label %135
132: ; preds = %129
%133 = load i32, i32* @errno
%134 = call i32 (i32, i32, i8*, ...) @error(i32 1, i32 %133, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.20, i64 0, i64 0), i8* %4)
br label %137
135: ; preds = %129
%136 = icmp eq i32 %130, 1
br i1 %136, label %139, label %137
137: ; preds = %132, %135
%138 = call i32 (i32, i32, i8*, ...) @error(i32 1, i32 0, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.21, i64 0, i64 0), i8* %4)
br label %139
139: ; preds = %137, %135
%140 = load i8, i8* %1
switch i8 %140, label %143 [
i8 48, label %141
i8 49, label %142
]
141: ; preds = %139
store i8 49, i8* %1
br label %145
142: ; preds = %139
store i8 48, i8* %1
br label %145
143: ; preds = %139
%144 = call i32 (i32, i32, i8*, ...) @error(i32 1, i32 0, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.22, i64 0, i64 0))
br label %145
145: ; preds = %142, %143, %141
%146 = call i32 @write(i32 %124, i8* %1, i32 1)
%147 = icmp slt i32 %146, 0
br i1 %147, label %148, label %151
148: ; preds = %145
%149 = load i32, i32* @errno
%150 = call i32 (i32, i32, i8*, ...) @error(i32 1, i32 %149, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.23, i64 0, i64 0), i8* %4)
br label %153
151: ; preds = %145
%152 = icmp eq i32 %146, 1
br i1 %152, label %155, label %153
153: ; preds = %148, %151
%154 = call i32 (i32, i32, i8*, ...) @error(i32 1, i32 0, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.19, i64 0, i64 0), i8* %4)
br label %155
155: ; preds = %153, %151
%156 = call i32 @close(i32 %124)
%157 = icmp slt i32 %156, 0
br i1 %157, label %158, label %161
158: ; preds = %155
%159 = load i32, i32* @errno
%160 = call i32 (i32, i32, i8*, ...) @error(i32 1, i32 %159, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.15, i64 0, i64 0), i8* %4)
br label %161
161: ; preds = %158, %155
%162 = call i32 @usleep(i32 125000)
%163 = icmp slt i32 %162, 0
br i1 %163, label %164, label %167
164: ; preds = %161
%165 = load i32, i32* @errno
%166 = call i32 (i32, i32, i8*, ...) @error(i32 1, i32 %165, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.24, i64 0, i64 0))
br label %167
167: ; preds = %161, %164
%168 = add nuw nsw i32 %105, 1
%169 = icmp eq i32 %168, 16
br i1 %169, label %170, label %104
170: ; preds = %167
ret i32 0
}