#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 */
struct dirent {
  char *d_name;
};
typedef int /*<<< orphan*/ DIR;

/* Variables and functions */
int O_RDONLY;
int O_SYNC;
int O_WRONLY;
int PATH_MAX;
int close(int);
scalar_t__ errno;
int /*<<< orphan*/ error(int, scalar_t__, char *, ...);
int /*<<< orphan*/ memset(char *, char, int);
int open(char *, int);
int /*<<< orphan*/ *opendir(char const *);
int /*<<< orphan*/ printf(char *, char *);
int read(int, char *, int);
struct dirent *readdir(int /*<<< orphan*/ *);
int snprintf(char *, int, char *, char const *, ...);
char *strchr(char *, char);
size_t strlen(char const *);
int strncmp(char *, char const *, size_t);
char *strstr(char *, char const *);
int write(int, char *, size_t);
int main(void) {
  DIR *gpio_dir;
  const char *gpio_dir_path = "/sys/class/gpio";
  const char *gpiochip_str = "gpiochip";
  const char *gpio_label = "gpio@0x100005000";
  size_t gpiochip_str_len = strlen(gpiochip_str);
  int result;
  struct dirent *dir_entry;
  char path[PATH_MAX];
  int path_length;
  int file_fd;
  char buffer[PATH_MAX];
  char gpio_number_buffer[PATH_MAX];
  char *str_result = NULL;
  char *newline_ptr;
  gpio_dir = opendir(gpio_dir_path);
  if (gpio_dir == NULL)
    error(1, errno, "could not open directory '%s'", gpio_dir_path);
  while (1) {
    errno = 0;
    dir_entry = readdir(gpio_dir);
    if (dir_entry == NULL) {
      if (errno != 0)
        error(1, errno, "reading directory '%s'", gpio_dir_path);
      else
        break;
    }
    result = strncmp(dir_entry->d_name, gpiochip_str, gpiochip_str_len);
    if (result != 0)
      continue;
    path_length = snprintf(path, PATH_MAX, "%s/%s/label", gpio_dir_path,
                           dir_entry->d_name);
    if (path_length < 0)
      error(1, 0, "path output error");
    if (path_length >= PATH_MAX)
      error(1, 0, "path length overflow");
    file_fd = open(path, O_RDONLY | O_SYNC);
    if (file_fd < 0)
      error(1, errno, "could not open file '%s'", path);
    result = read(file_fd, buffer, PATH_MAX);
    if (result < 0)
      error(1, errno, "reading from '%s'", path);
    if (result == PATH_MAX)
      error(1, errno, "buffer overflow reading '%s'", path);
    result = close(file_fd);
    if (result < 0)
      error(1, errno, "could not close file '%s'", path);
    str_result = strstr(buffer, gpio_label);
    if (str_result != NULL)
      break;
  }
  if (str_result == NULL)
    error(1, 0, "unable to locate gpio controller");
  path_length =
      snprintf(path, PATH_MAX, "%s/%s/base", gpio_dir_path, dir_entry->d_name);
  if (path_length < 0)
    error(1, 0, "path output error");
  if (path_length >= PATH_MAX)
    error(1, 0, "path length overflow");
  file_fd = open(path, O_RDONLY | O_SYNC);
  if (file_fd < 0)
    error(1, errno, "could not open file '%s'", path);
  result = read(file_fd, gpio_number_buffer, PATH_MAX);
  if (result < 0)
    error(1, errno, "reading from '%s'", path);
  if (result == PATH_MAX)
    error(1, errno, "buffer overflow reading '%s'", path);
  result = close(file_fd);
  if (result < 0)
    error(1, errno, "could not close file '%s'", path);
  newline_ptr = strchr(gpio_number_buffer, '\n');
  if (newline_ptr != NULL)
    memset(newline_ptr, '\0', 1);
  path_length = snprintf(path, PATH_MAX, "%s/export", gpio_dir_path);
  if (path_length < 0)
    error(1, 0, "path output error");
  if (path_length >= PATH_MAX)
    error(1, 0, "path length overflow");
  file_fd = open(path, O_WRONLY | O_SYNC);
  if (file_fd < 0)
    error(1, errno, "could not open file '%s'", path);
  result = write(file_fd, gpio_number_buffer, strlen(gpio_number_buffer));
  result = close(file_fd);
  if (result < 0)
    error(1, errno, "could not close file '%s'", path);
  path_length = snprintf(path, PATH_MAX, "%s/gpio%s/value", gpio_dir_path,
                         gpio_number_buffer);
  if (path_length < 0)
    error(1, 0, "path output error");
  if (path_length >= PATH_MAX)
    error(1, 0, "path length overflow");
  file_fd = open(path, O_RDONLY | O_SYNC);
  if (file_fd < 0)
    error(1, errno, "could not open file '%s'", path);
  result = read(file_fd, buffer, PATH_MAX);
  if (result < 0)
    error(1, errno, "reading from '%s'", path);
  if (result == PATH_MAX)
    error(1, errno, "buffer overflow reading '%s'", path);
  result = close(file_fd);
  if (result < 0)
    error(1, errno, "could not close file '%s'", path);
  newline_ptr = strchr(buffer, '\n');
  if (newline_ptr != NULL)
    memset(newline_ptr, '\0', 1);
  printf("KEY0 push button is at state '%s'\n", buffer);
  path_length = snprintf(path, PATH_MAX, "%s/unexport", gpio_dir_path);
  if (path_length < 0)
    error(1, 0, "path output error");
  if (path_length >= PATH_MAX)
    error(1, 0, "path length overflow");
  file_fd = open(path, O_WRONLY | O_SYNC);
  if (file_fd < 0)
    error(1, errno, "could not open file '%s'", path);
  result = write(file_fd, gpio_number_buffer, strlen(gpio_number_buffer));
  if (result < 0)
    error(1, errno, "writing to '%s'", path);
  if ((size_t)(result) != strlen(gpio_number_buffer))
    error(1, errno, "buffer underflow writing '%s'", path);
  result = close(file_fd);
  if (result < 0)
    error(1, errno, "could not close file '%s'", path);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe07(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    0xe0c(%rip),%rax
mov    %rax,-0x20(%rbp)
lea    0xe0a(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1060 <strlen@plt>
mov    %rax,-0x30(%rbp)
mov    0x2dc9(%rip),%rax
mov    (%rax),%ecx
mov    %rsp,%rdx
mov    %rdx,-0x48(%rbp)
mov    %rcx,%rsi
add    $0xf,%rsi
and    $0xfffffffffffffff0,%rsi
mov    %rsp,%rdx
sub    %rsi,%rdx
mov    %rdx,-0x90(%rbp)
mov    %rdx,%rsp
mov    %rcx,-0x50(%rbp)
mov    (%rax),%ecx
mov    %rcx,%rsi
add    $0xf,%rsi
and    $0xfffffffffffffff0,%rsi
mov    %rsp,%rdx
sub    %rsi,%rdx
mov    %rdx,-0x88(%rbp)
mov    %rdx,%rsp
mov    %rcx,-0x60(%rbp)
mov    (%rax),%eax
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)
movq   $0x0,-0x70(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <opendir@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    12cf <main+0xef>
mov    0x2d13(%rip),%rax
mov    (%rax),%rsi
mov    -0x18(%rbp),%rcx
mov    $0x1,%edi
lea    0xd62(%rip),%rdx
mov    $0x0,%al
call   10e0 <error@plt>
jmp    12d4 <main+0xf4>
jmp    12d9 <main+0xf9>
mov    0x2ce8(%rip),%rax
movq   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
call   10d0 <readdir@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    1340 <main+0x160>
mov    0x2cc2(%rip),%rax
cmpq   $0x0,(%rax)
je     1336 <main+0x156>
mov    0x2cb1(%rip),%rax
mov    (%rax),%rsi
mov    -0x18(%rbp),%rcx
mov    $0x1,%edi
lea    0xd1e(%rip),%rdx
mov    $0x0,%al
call   10e0 <error@plt>
jmp    133b <main+0x15b>
jmp    150c <main+0x32c>
jmp    1340 <main+0x160>
mov    -0x40(%rbp),%rax
mov    (%rax),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x30(%rbp),%rdx
call   1030 <strncmp@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
je     1366 <main+0x186>
jmp    12d4 <main+0xf4>
mov    -0x90(%rbp),%rdi
mov    0x2c7c(%rip),%rax
mov    (%rax),%esi
mov    -0x18(%rbp),%rcx
mov    -0x40(%rbp),%rax
mov    (%rax),%r8
lea    0xcd7(%rip),%rdx
mov    $0x0,%al
call   1090 <snprintf@plt>
mov    %eax,-0x54(%rbp)
cmpl   $0x0,-0x54(%rbp)
jge    13b3 <main+0x1d3>
mov    $0x1,%edi
xor    %eax,%eax
mov    %eax,%esi
lea    0xcbf(%rip),%rdx
mov    $0x0,%al
call   10e0 <error@plt>
mov    -0x54(%rbp),%eax
mov    0x2c33(%rip),%rcx
cmp    (%rcx),%eax
jl     13dc <main+0x1fc>
mov    $0x1,%edi
xor    %eax,%eax
mov    %eax,%esi
lea    0xca8(%rip),%rdx
mov    $0x0,%al
call   10e0 <error@plt>
mov    -0x90(%rbp),%rdi
mov    0x2bee(%rip),%rax
mov    (%rax),%esi
mov    0x2bed(%rip),%rax
or     (%rax),%esi
call   10f0 <open@plt>
mov    %eax,-0x58(%rbp)
cmpl   $0x0,-0x58(%rbp)
jge    142b <main+0x24b>
mov    -0x90(%rbp),%rcx
mov    0x2bb3(%rip),%rax
mov    (%rax),%rsi
mov    $0x1,%edi
lea    0xc6e(%rip),%rdx
mov    $0x0,%al
call   10e0 <error@plt>
mov    -0x88(%rbp),%rsi
mov    -0x58(%rbp),%edi
mov    0x2bb4(%rip),%rax
mov    (%rax),%edx
call   10c0 <read@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jge    1474 <main+0x294>
mov    -0x90(%rbp),%rcx
mov    0x2b6a(%rip),%rax
mov    (%rax),%rsi
mov    $0x1,%edi
lea    0xc3e(%rip),%rdx
mov    $0x0,%al
call   10e0 <error@plt>
mov    -0x34(%rbp),%eax
mov    0x2b72(%rip),%rcx
cmp    (%rcx),%eax
jne    14aa <main+0x2ca>
mov    -0x90(%rbp),%rcx
mov    0x2b34(%rip),%rax
mov    (%rax),%rsi
mov    $0x1,%edi
lea    0xc1a(%rip),%rdx
mov    $0x0,%al
call   10e0 <error@plt>
mov    -0x58(%rbp),%edi
call   10b0 <close@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jge    14e3 <main+0x303>
mov    -0x90(%rbp),%rcx
mov    0x2afb(%rip),%rax
mov    (%rax),%rsi
mov    $0x1,%edi
lea    0xbfe(%rip),%rdx
mov    $0x0,%al
call   10e0 <error@plt>
mov    -0x88(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1100 <strstr@plt>
mov    %rax,-0x70(%rbp)
cmpq   $0x0,-0x70(%rbp)
je     1507 <main+0x327>
jmp    150c <main+0x32c>
jmp    12d4 <main+0xf4>
cmpq   $0x0,-0x70(%rbp)
jne    152e <main+0x34e>
mov    $0x1,%edi
xor    %eax,%eax
mov    %eax,%esi
lea    0xbcd(%rip),%rdx
mov    $0x0,%al
call   10e0 <error@plt>
mov    -0x90(%rbp),%rdi
mov    0x2ab4(%rip),%rax
mov    (%rax),%esi
mov    -0x18(%rbp),%rcx
mov    -0x40(%rbp),%rax
mov    (%rax),%r8
lea    0xbc5(%rip),%rdx
mov    $0x0,%al
call   1090 <snprintf@plt>
mov    %eax,-0x54(%rbp)
cmpl   $0x0,-0x54(%rbp)
jge    157b <main+0x39b>
mov    $0x1,%edi
xor    %eax,%eax
mov    %eax,%esi
lea    0xaf7(%rip),%rdx
mov    $0x0,%al
call   10e0 <error@plt>
mov    -0x54(%rbp),%eax
mov    0x2a6b(%rip),%rcx
cmp    (%rcx),%eax
jl     15a4 <main+0x3c4>
mov    $0x1,%edi
xor    %eax,%eax
mov    %eax,%esi
lea    0xae0(%rip),%rdx
mov    $0x0,%al
call   10e0 <error@plt>
mov    -0x90(%rbp),%rdi
mov    0x2a26(%rip),%rax
mov    (%rax),%esi
mov    0x2a25(%rip),%rax
or     (%rax),%esi
call   10f0 <open@plt>
mov    %eax,-0x58(%rbp)
cmpl   $0x0,-0x58(%rbp)
jge    15f3 <main+0x413>
mov    -0x90(%rbp),%rcx
mov    0x29eb(%rip),%rax
mov    (%rax),%rsi
mov    $0x1,%edi
lea    0xaa6(%rip),%rdx
mov    $0x0,%al
call   10e0 <error@plt>
mov    -0x80(%rbp),%rsi
mov    -0x58(%rbp),%edi
mov    0x29ef(%rip),%rax
mov    (%rax),%edx
call   10c0 <read@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jge    1639 <main+0x459>
mov    -0x90(%rbp),%rcx
mov    0x29a5(%rip),%rax
mov    (%rax),%rsi
mov    $0x1,%edi
lea    0xa79(%rip),%rdx
mov    $0x0,%al
call   10e0 <error@plt>
mov    -0x34(%rbp),%eax
mov    0x29ad(%rip),%rcx
cmp    (%rcx),%eax
jne    166f <main+0x48f>
mov    -0x90(%rbp),%rcx
mov    0x296f(%rip),%rax
mov    (%rax),%rsi
mov    $0x1,%edi
lea    0xa55(%rip),%rdx
mov    $0x0,%al
call   10e0 <error@plt>
mov    -0x58(%rbp),%edi
call   10b0 <close@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jge    16a8 <main+0x4c8>
mov    -0x90(%rbp),%rcx
mov    0x2936(%rip),%rax
mov    (%rax),%rsi
mov    $0x1,%edi
lea    0xa39(%rip),%rdx
mov    $0x0,%al
call   10e0 <error@plt>
mov    -0x80(%rbp),%rdi
mov    $0xa,%esi
call   1070 <strchr@plt>
mov    %rax,-0x78(%rbp)
cmpq   $0x0,-0x78(%rbp)
je     16d5 <main+0x4f5>
mov    -0x78(%rbp),%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   10a0 <memset@plt>
mov    -0x90(%rbp),%rdi
mov    0x290d(%rip),%rax
mov    (%rax),%esi
mov    -0x18(%rbp),%rcx
lea    0xa30(%rip),%rdx
mov    $0x0,%al
call   1090 <snprintf@plt>
mov    %eax,-0x54(%rbp)
cmpl   $0x0,-0x54(%rbp)
jge    171b <main+0x53b>
mov    $0x1,%edi
xor    %eax,%eax
mov    %eax,%esi
lea    0x957(%rip),%rdx
mov    $0x0,%al
call   10e0 <error@plt>
mov    -0x54(%rbp),%eax
mov    0x28cb(%rip),%rcx
cmp    (%rcx),%eax
jl     1744 <main+0x564>
mov    $0x1,%edi
xor    %eax,%eax
mov    %eax,%esi
lea    0x940(%rip),%rdx
mov    $0x0,%al
call   10e0 <error@plt>
mov    -0x90(%rbp),%rdi
mov    0x2866(%rip),%rax
mov    (%rax),%esi
mov    0x2885(%rip),%rax
or     (%rax),%esi
call   10f0 <open@plt>
mov    %eax,-0x58(%rbp)
cmpl   $0x0,-0x58(%rbp)
jge    1793 <main+0x5b3>
mov    -0x90(%rbp),%rcx
mov    0x284b(%rip),%rax
mov    (%rax),%rsi
mov    $0x1,%edi
lea    0x906(%rip),%rdx
mov    $0x0,%al
call   10e0 <error@plt>
mov    -0x80(%rbp),%rdi
mov    -0x58(%rbp),%eax
mov    %eax,-0x94(%rbp)
call   1060 <strlen@plt>
mov    -0x94(%rbp),%edi
mov    -0x80(%rbp),%rsi
mov    %rax,%rdx
call   1040 <write@plt>
mov    %eax,-0x34(%rbp)
mov    -0x58(%rbp),%edi
call   10b0 <close@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jge    17f3 <main+0x613>
mov    -0x90(%rbp),%rcx
mov    0x27eb(%rip),%rax
mov    (%rax),%rsi
mov    $0x1,%edi
lea    0x8ee(%rip),%rdx
mov    $0x0,%al
call   10e0 <error@plt>
mov    -0x80(%rbp),%r8
mov    -0x90(%rbp),%rdi
mov    0x27eb(%rip),%rax
mov    (%rax),%esi
mov    -0x18(%rbp),%rcx
lea    0x918(%rip),%rdx
mov    $0x0,%al
call   1090 <snprintf@plt>
mov    %eax,-0x54(%rbp)
cmpl   $0x0,-0x54(%rbp)
jge    183d <main+0x65d>
mov    $0x1,%edi
xor    %eax,%eax
mov    %eax,%esi
lea    0x835(%rip),%rdx
mov    $0x0,%al
call   10e0 <error@plt>
mov    -0x54(%rbp),%eax
mov    0x27a9(%rip),%rcx
cmp    (%rcx),%eax
jl     1866 <main+0x686>
mov    $0x1,%edi
xor    %eax,%eax
mov    %eax,%esi
lea    0x81e(%rip),%rdx
mov    $0x0,%al
call   10e0 <error@plt>
mov    -0x90(%rbp),%rdi
mov    0x2764(%rip),%rax
mov    (%rax),%esi
mov    0x2763(%rip),%rax
or     (%rax),%esi
call   10f0 <open@plt>
mov    %eax,-0x58(%rbp)
cmpl   $0x0,-0x58(%rbp)
jge    18b5 <main+0x6d5>
mov    -0x90(%rbp),%rcx
mov    0x2729(%rip),%rax
mov    (%rax),%rsi
mov    $0x1,%edi
lea    0x7e4(%rip),%rdx
mov    $0x0,%al
call   10e0 <error@plt>
mov    -0x88(%rbp),%rsi
mov    -0x58(%rbp),%edi
mov    0x272a(%rip),%rax
mov    (%rax),%edx
call   10c0 <read@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jge    18fe <main+0x71e>
mov    -0x90(%rbp),%rcx
mov    0x26e0(%rip),%rax
mov    (%rax),%rsi
mov    $0x1,%edi
lea    0x7b4(%rip),%rdx
mov    $0x0,%al
call   10e0 <error@plt>
mov    -0x34(%rbp),%eax
mov    0x26e8(%rip),%rcx
cmp    (%rcx),%eax
jne    1934 <main+0x754>
mov    -0x90(%rbp),%rcx
mov    0x26aa(%rip),%rax
mov    (%rax),%rsi
mov    $0x1,%edi
lea    0x790(%rip),%rdx
mov    $0x0,%al
call   10e0 <error@plt>
mov    -0x58(%rbp),%edi
call   10b0 <close@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jge    196d <main+0x78d>
mov    -0x90(%rbp),%rcx
mov    0x2671(%rip),%rax
mov    (%rax),%rsi
mov    $0x1,%edi
lea    0x774(%rip),%rdx
mov    $0x0,%al
call   10e0 <error@plt>
mov    -0x88(%rbp),%rdi
mov    $0xa,%esi
call   1070 <strchr@plt>
mov    %rax,-0x78(%rbp)
cmpq   $0x0,-0x78(%rbp)
je     199d <main+0x7bd>
mov    -0x78(%rbp),%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   10a0 <memset@plt>
mov    -0x88(%rbp),%rsi
lea    0x78f(%rip),%rdi
call   1080 <printf@plt>
mov    -0x90(%rbp),%rdi
mov    0x2632(%rip),%rax
mov    (%rax),%esi
mov    -0x18(%rbp),%rcx
lea    0x792(%rip),%rdx
mov    $0x0,%al
call   1090 <snprintf@plt>
mov    %eax,-0x54(%rbp)
cmpl   $0x0,-0x54(%rbp)
jge    19f6 <main+0x816>
mov    $0x1,%edi
xor    %eax,%eax
mov    %eax,%esi
lea    0x67c(%rip),%rdx
mov    $0x0,%al
call   10e0 <error@plt>
mov    -0x54(%rbp),%eax
mov    0x25f0(%rip),%rcx
cmp    (%rcx),%eax
jl     1a1f <main+0x83f>
mov    $0x1,%edi
xor    %eax,%eax
mov    %eax,%esi
lea    0x665(%rip),%rdx
mov    $0x0,%al
call   10e0 <error@plt>
mov    -0x90(%rbp),%rdi
mov    0x258b(%rip),%rax
mov    (%rax),%esi
mov    0x25aa(%rip),%rax
or     (%rax),%esi
call   10f0 <open@plt>
mov    %eax,-0x58(%rbp)
cmpl   $0x0,-0x58(%rbp)
jge    1a6e <main+0x88e>
mov    -0x90(%rbp),%rcx
mov    0x2570(%rip),%rax
mov    (%rax),%rsi
mov    $0x1,%edi
lea    0x62b(%rip),%rdx
mov    $0x0,%al
call   10e0 <error@plt>
mov    -0x80(%rbp),%rdi
mov    -0x58(%rbp),%eax
mov    %eax,-0x98(%rbp)
call   1060 <strlen@plt>
mov    -0x98(%rbp),%edi
mov    -0x80(%rbp),%rsi
mov    %rax,%rdx
call   1040 <write@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jge    1ac3 <main+0x8e3>
mov    -0x90(%rbp),%rcx
mov    0x251b(%rip),%rax
mov    (%rax),%rsi
mov    $0x1,%edi
lea    0x6ad(%rip),%rdx
mov    $0x0,%al
call   10e0 <error@plt>
mov    -0x80(%rbp),%rdi
movslq -0x34(%rbp),%rax
mov    %rax,-0xa0(%rbp)
call   1060 <strlen@plt>
mov    %rax,%rcx
mov    -0xa0(%rbp),%rax
cmp    %rcx,%rax
je     1b0e <main+0x92e>
mov    -0x90(%rbp),%rcx
mov    0x24d0(%rip),%rax
mov    (%rax),%rsi
mov    $0x1,%edi
lea    0x672(%rip),%rdx
mov    $0x0,%al
call   10e0 <error@plt>
mov    -0x58(%rbp),%edi
call   10b0 <close@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jge    1b47 <main+0x967>
mov    -0x90(%rbp),%rcx
mov    0x2497(%rip),%rax
mov    (%rax),%rsi
mov    $0x1,%edi
lea    0x59a(%rip),%rdx
mov    $0x0,%al
call   10e0 <error@plt>
mov    -0x48(%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
sub    $0x18,%rsp
mov    0x2df8(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rcx,%rsp
mov    %rsp,%r13
sub    %rax,%r13
mov    %r13,%rsp
mov    %rsp,%rcx
sub    %rax,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rcx,%rsp
lea    0xdd4(%rip),%rdi
call   1050 <opendir@plt>
mov    %rax,%r12
test   %rax,%rax
jne    125d <main+0x7d>
mov    0x2d88(%rip),%rax
mov    (%rax),%rsi
lea    0xde0(%rip),%rdx
lea    0xdaf(%rip),%rcx
mov    $0x1,%edi
xor    %eax,%eax
call   10e0 <error@plt>
mov    0x2d64(%rip),%r14
mov    %r13,-0x38(%rbp)
jmp    12a3 <main+0xc3>
nopw   0x0(%rax,%rax,1)
mov    %r14d,%edi
call   10b0 <close@plt>
test   %eax,%eax
mov    0x2d47(%rip),%r14
mov    -0x38(%rbp),%r13
js     13be <main+0x1de>
mov    %r13,%rdi
lea    0xd84(%rip),%rsi
call   1100 <strstr@plt>
test   %rax,%rax
jne    1443 <main+0x263>
movq   $0x0,(%r14)
mov    %r12,%rdi
call   10d0 <readdir@plt>
mov    %rax,%r15
test   %rax,%rax
jne    12e0 <main+0x100>
mov    (%r14),%rsi
test   %rsi,%rsi
je     142e <main+0x24e>
mov    $0x1,%edi
lea    0xd76(%rip),%rdx
lea    0xd27(%rip),%rcx
xor    %eax,%eax
call   10e0 <error@plt>
mov    (%r15),%rbx
mov    $0x8,%edx
mov    %rbx,%rdi
lea    0xd1e(%rip),%rsi
call   1030 <strncmp@plt>
test   %eax,%eax
jne    12a3 <main+0xc3>
mov    0x2cee(%rip),%r14
mov    (%r14),%esi
mov    -0x30(%rbp),%rdi
lea    0xd4f(%rip),%rdx
lea    0xce9(%rip),%rcx
mov    %rbx,%r8
xor    %eax,%eax
call   1090 <snprintf@plt>
mov    %eax,%ebx
test   %eax,%eax
jns    133c <main+0x15c>
mov    $0x1,%edi
xor    %esi,%esi
lea    0xd36(%rip),%rdx
xor    %eax,%eax
call   10e0 <error@plt>
cmp    (%r14),%ebx
mov    %r14,%rbx
jl     1359 <main+0x179>
mov    $0x1,%edi
xor    %esi,%esi
lea    0xd2b(%rip),%rdx
xor    %eax,%eax
call   10e0 <error@plt>
mov    0x2c80(%rip),%rax
mov    (%rax),%esi
mov    0x2c6f(%rip),%rax
or     (%rax),%esi
mov    -0x30(%rbp),%rdi
call   10f0 <open@plt>
mov    %eax,%r14d
test   %eax,%eax
jns    139c <main+0x1bc>
mov    0x2c46(%rip),%rax
mov    (%rax),%rsi
mov    $0x1,%edi
lea    0xd01(%rip),%rdx
mov    -0x30(%rbp),%rcx
xor    %eax,%eax
call   10e0 <error@plt>
mov    (%rbx),%edx
mov    %r14d,%edi
mov    %r13,%rsi
call   10c0 <read@plt>
mov    %rbx,%r13
mov    %eax,%ebx
test   %eax,%eax
js     13dd <main+0x1fd>
cmp    0x0(%r13),%ebx
jne    1270 <main+0x90>
jmp    1408 <main+0x228>
mov    (%r14),%rsi
mov    $0x1,%edi
lea    0xd0d(%rip),%rdx
mov    -0x30(%rbp),%rcx
xor    %eax,%eax
call   10e0 <error@plt>
jmp    128b <main+0xab>
mov    0x2be4(%rip),%rax
mov    (%rax),%rsi
mov    $0x1,%edi
lea    0xcb8(%rip),%rdx
mov    -0x30(%rbp),%rcx
xor    %eax,%eax
call   10e0 <error@plt>
cmp    0x0(%r13),%ebx
jne    1270 <main+0x90>
mov    0x2bb9(%rip),%rax
mov    (%rax),%rsi
mov    $0x1,%edi
lea    0xc9f(%rip),%rdx
mov    -0x30(%rbp),%rcx
xor    %eax,%eax
call   10e0 <error@plt>
jmp    1270 <main+0x90>
lea    0xcbf(%rip),%rdx
mov    $0x1,%edi
xor    %esi,%esi
xor    %eax,%eax
call   10e0 <error@plt>
mov    0x2ba6(%rip),%r14
mov    (%r14),%esi
mov    (%r15),%r8
lea    0xcbe(%rip),%rdx
lea    0xba2(%rip),%rcx
mov    -0x30(%rbp),%rdi
xor    %eax,%eax
call   1090 <snprintf@plt>
mov    %eax,%ebx
test   %eax,%eax
jns    1484 <main+0x2a4>
lea    0xbf5(%rip),%rdx
mov    $0x1,%edi
xor    %esi,%esi
xor    %eax,%eax
call   10e0 <error@plt>
cmp    (%r14),%ebx
mov    -0x40(%rbp),%r12
mov    %r14,%rbx
jl     14a5 <main+0x2c5>
lea    0xbe6(%rip),%rdx
mov    $0x1,%edi
xor    %esi,%esi
xor    %eax,%eax
call   10e0 <error@plt>
mov    0x2b34(%rip),%rax
mov    (%rax),%esi
mov    0x2b23(%rip),%rax
or     (%rax),%esi
mov    -0x30(%rbp),%rdi
call   10f0 <open@plt>
mov    %eax,%r14d
test   %eax,%eax
jns    14e8 <main+0x308>
mov    0x2afa(%rip),%rax
mov    (%rax),%rsi
lea    0xbba(%rip),%rdx
mov    $0x1,%edi
mov    -0x30(%rbp),%rcx
xor    %eax,%eax
call   10e0 <error@plt>
mov    (%rbx),%edx
mov    %r14d,%edi
mov    %r12,%rsi
call   10c0 <read@plt>
mov    %rbx,%r15
mov    %eax,%ebx
test   %eax,%eax
jns    151f <main+0x33f>
mov    0x2ac3(%rip),%rax
mov    (%rax),%rsi
lea    0xb9c(%rip),%rdx
mov    $0x1,%edi
mov    -0x30(%rbp),%rcx
xor    %eax,%eax
call   10e0 <error@plt>
cmp    (%r15),%ebx
mov    %r15,%rbx
jne    1548 <main+0x368>
mov    0x2a9a(%rip),%rax
mov    (%rax),%rsi
lea    0xb85(%rip),%rdx
mov    $0x1,%edi
mov    -0x30(%rbp),%rcx
xor    %eax,%eax
call   10e0 <error@plt>
mov    %r14d,%edi
call   10b0 <close@plt>
test   %eax,%eax
mov    0x2a6f(%rip),%r14
jns    1575 <main+0x395>
mov    (%r14),%rsi
lea    0xb75(%rip),%rdx
mov    $0x1,%edi
mov    -0x30(%rbp),%rcx
xor    %eax,%eax
call   10e0 <error@plt>
mov    %r12,%rdi
mov    $0xa,%esi
call   1070 <strchr@plt>
test   %rax,%rax
je     1596 <main+0x3b6>
mov    %rax,%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   10a0 <memset@plt>
mov    (%rbx),%esi
lea    0xb81(%rip),%rdx
lea    0xa5a(%rip),%rcx
mov    -0x30(%rbp),%rdi
xor    %eax,%eax
call   1090 <snprintf@plt>
mov    %rbx,%r15
mov    %eax,%ebx
test   %eax,%eax
js     18be <main+0x6de>
cmp    (%r15),%ebx
jl     15d8 <main+0x3f8>
lea    0xab3(%rip),%rdx
mov    $0x1,%edi
xor    %esi,%esi
xor    %eax,%eax
call   10e0 <error@plt>
mov    0x29d9(%rip),%r15
mov    0x29fa(%rip),%rax
mov    (%rax),%esi
or     (%r15),%esi
mov    -0x30(%rbp),%rdi
call   10f0 <open@plt>
mov    %eax,%ebx
test   %eax,%eax
jns    1614 <main+0x434>
mov    (%r14),%rsi
lea    0xa8e(%rip),%rdx
mov    $0x1,%edi
mov    -0x30(%rbp),%rcx
xor    %eax,%eax
call   10e0 <error@plt>
mov    %r12,%rdi
call   1060 <strlen@plt>
mov    %ebx,%edi
mov    %r12,%rsi
mov    %rax,%rdx
call   1040 <write@plt>
mov    %ebx,%edi
call   10b0 <close@plt>
test   %eax,%eax
jns    164e <main+0x46e>
mov    (%r14),%rsi
lea    0xa9c(%rip),%rdx
mov    $0x1,%edi
mov    -0x30(%rbp),%rcx
xor    %eax,%eax
call   10e0 <error@plt>
mov    0x299b(%rip),%r14
mov    (%r14),%esi
lea    0xacb(%rip),%rdx
lea    0x99a(%rip),%rcx
mov    -0x30(%rbp),%rdi
mov    %r12,%r8
xor    %eax,%eax
call   1090 <snprintf@plt>
mov    %eax,%ebx
test   %eax,%eax
jns    168f <main+0x4af>
lea    0x9ea(%rip),%rdx
mov    $0x1,%edi
xor    %esi,%esi
xor    %eax,%eax
call   10e0 <error@plt>
cmp    (%r14),%ebx
mov    %r14,%rbx
jl     16ac <main+0x4cc>
lea    0x9df(%rip),%rdx
mov    $0x1,%edi
xor    %esi,%esi
xor    %eax,%eax
call   10e0 <error@plt>
mov    0x292d(%rip),%rax
mov    (%rax),%esi
mov    0x291c(%rip),%rax
or     (%rax),%esi
mov    -0x30(%rbp),%rdi
call   10f0 <open@plt>
mov    %eax,%r14d
test   %eax,%eax
jns    16ef <main+0x50f>
mov    0x28f3(%rip),%rax
mov    (%rax),%rsi
lea    0x9b3(%rip),%rdx
mov    $0x1,%edi
mov    -0x30(%rbp),%rcx
xor    %eax,%eax
call   10e0 <error@plt>
mov    (%rbx),%edx
mov    %r14d,%edi
mov    %r13,%rsi
call   10c0 <read@plt>
mov    %rbx,%r13
mov    %eax,%ebx
test   %eax,%eax
js     18e1 <main+0x701>
cmp    0x0(%r13),%ebx
jne    1730 <main+0x550>
mov    0x28b2(%rip),%rax
mov    (%rax),%rsi
lea    0x99d(%rip),%rdx
mov    $0x1,%edi
mov    -0x30(%rbp),%rcx
xor    %eax,%eax
call   10e0 <error@plt>
mov    %r14d,%edi
call   10b0 <close@plt>
test   %eax,%eax
mov    0x2887(%rip),%rax
mov    -0x38(%rbp),%rbx
jns    1761 <main+0x581>
mov    (%rax),%rsi
lea    0x989(%rip),%rdx
mov    $0x1,%edi
mov    -0x30(%rbp),%rcx
xor    %eax,%eax
call   10e0 <error@plt>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1070 <strchr@plt>
test   %rax,%rax
je     1782 <main+0x5a2>
mov    %rax,%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   10a0 <memset@plt>
lea    0x9b1(%rip),%rdi
mov    %rbx,%rsi
call   1080 <printf@plt>
mov    0x0(%r13),%esi
lea    0x9c1(%rip),%rdx
lea    0x85d(%rip),%rcx
mov    -0x30(%rbp),%rdi
xor    %eax,%eax
call   1090 <snprintf@plt>
mov    %r13,%r14
mov    %eax,%ebx
test   %eax,%eax
js     1911 <main+0x731>
cmp    (%r14),%ebx
jl     17d5 <main+0x5f5>
lea    0x8b6(%rip),%rdx
mov    $0x1,%edi
xor    %esi,%esi
xor    %eax,%eax
call   10e0 <error@plt>
mov    0x2804(%rip),%rax
mov    (%rax),%esi
or     (%r15),%esi
mov    -0x30(%rbp),%rdi
call   10f0 <open@plt>
mov    %eax,%r14d
test   %eax,%eax
jns    1812 <main+0x632>
mov    0x27d0(%rip),%rax
mov    (%rax),%rsi
lea    0x890(%rip),%rdx
mov    $0x1,%edi
mov    -0x30(%rbp),%rcx
xor    %eax,%eax
call   10e0 <error@plt>
mov    %r12,%rdi
call   1060 <strlen@plt>
mov    %r14d,%edi
mov    %r12,%rsi
mov    %rax,%rdx
call   1040 <write@plt>
mov    %eax,%ebx
test   %eax,%eax
jns    184f <main+0x66f>
mov    0x2793(%rip),%rax
mov    (%rax),%rsi
lea    0x92a(%rip),%rdx
mov    $0x1,%edi
mov    -0x30(%rbp),%rcx
xor    %eax,%eax
call   10e0 <error@plt>
movslq %ebx,%rbx
mov    %r12,%rdi
call   1060 <strlen@plt>
cmp    %rbx,%rax
je     1880 <main+0x6a0>
mov    0x2762(%rip),%rax
mov    (%rax),%rsi
lea    0x909(%rip),%rdx
mov    $0x1,%edi
mov    -0x30(%rbp),%rcx
xor    %eax,%eax
call   10e0 <error@plt>
mov    %r14d,%edi
call   10b0 <close@plt>
test   %eax,%eax
jns    18ad <main+0x6cd>
mov    0x2735(%rip),%rax
mov    (%rax),%rsi
lea    0x83d(%rip),%rdx
mov    $0x1,%edi
mov    -0x30(%rbp),%rcx
xor    %eax,%eax
call   10e0 <error@plt>
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x7a6(%rip),%rdx
mov    $0x1,%edi
xor    %esi,%esi
xor    %eax,%eax
call   10e0 <error@plt>
cmp    (%r15),%ebx
jge    15c3 <main+0x3e3>
jmp    15d8 <main+0x3f8>
mov    0x26e0(%rip),%rax
mov    (%rax),%rsi
lea    0x7b9(%rip),%rdx
mov    $0x1,%edi
mov    -0x30(%rbp),%rcx
xor    %eax,%eax
call   10e0 <error@plt>
cmp    0x0(%r13),%ebx
je     170f <main+0x52f>
jmp    1730 <main+0x550>
lea    0x753(%rip),%rdx
mov    $0x1,%edi
xor    %esi,%esi
xor    %eax,%eax
call   10e0 <error@plt>
cmp    (%r14),%ebx
jge    17c0 <main+0x5e0>
jmp    17d5 <main+0x5f5>

LLVM IR (-O0):
%struct.dirent = type { i8* }
@.str = [16 x i8] c"/sys/class/gpio\00"
@.str.1 = [9 x i8] c"gpiochip\00"
@.str.2 = [17 x i8] c"gpio@0x100005000\00"
@PATH_MAX = global i32 0
@errno = global i64 0
@.str.3 = [30 x i8] c"could not open directory '%s'\00"
@.str.4 = [23 x i8] c"reading directory '%s'\00"
@.str.5 = [12 x i8] c"%s/%s/label\00"
@.str.6 = [18 x i8] c"path output error\00"
@.str.7 = [21 x i8] c"path length overflow\00"
@O_RDONLY = global i32 0
@O_SYNC = global i32 0
@.str.8 = [25 x i8] c"could not open file '%s'\00"
@.str.9 = [18 x i8] c"reading from '%s'\00"
@.str.10 = [29 x i8] c"buffer overflow reading '%s'\00"
@.str.11 = [26 x i8] c"could not close file '%s'\00"
@.str.12 = [33 x i8] c"unable to locate gpio controller\00"
@.str.13 = [11 x i8] c"%s/%s/base\00"
@.str.14 = [10 x i8] c"%s/export\00"
@O_WRONLY = global i32 0
@.str.15 = [16 x i8] c"%s/gpio%s/value\00"
@.str.16 = [35 x i8] c"KEY0 push button is at state '%s'\0A\00"
@.str.17 = [12 x i8] c"%s/unexport\00"
@.str.18 = [16 x i8] c"writing to '%s'\00"
@.str.19 = [30 x i8] c"buffer underflow writing '%s'\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i32
%8 = alloca %struct.dirent*
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i32
%12 = alloca i32
%13 = alloca i64
%14 = alloca i64
%15 = alloca i8*
%16 = alloca i8*
store i32 0, i32* %1
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8** %3
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8** %4
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8** %5
%17 = load i8*, i8** %4
%18 = call i64 @strlen(i8* %17)
store i64 %18, i64* %6
%19 = load i32, i32* @PATH_MAX
%20 = zext i32 %19 to i64
%21 = call i8* @llvm.stacksave()
store i8* %21, i8** %9
%22 = alloca i8, i64 %20
store i64 %20, i64* %10
%23 = load i32, i32* @PATH_MAX
%24 = zext i32 %23 to i64
%25 = alloca i8, i64 %24
store i64 %24, i64* %13
%26 = load i32, i32* @PATH_MAX
%27 = zext i32 %26 to i64
%28 = alloca i8, i64 %27
store i64 %27, i64* %14
store i8* null, i8** %15
%29 = load i8*, i8** %3
%30 = call i32* @opendir(i8* %29)
store i32* %30, i32** %2
%31 = load i32*, i32** %2
%32 = icmp eq i32* %31, null
br i1 %32, label %33, label %37
33: ; preds = %0
%34 = load i64, i64* @errno
%35 = load i8*, i8** %3
%36 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %34, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i8* %35)
br label %37
37: ; preds = %33, %0
br label %38
38: ; preds = %120, %62, %37
br label %39
39: ; preds = %38
store i64 0, i64* @errno
%40 = load i32*, i32** %2
%41 = call %struct.dirent* @readdir(i32* %40)
store %struct.dirent* %41, %struct.dirent** %8
%42 = load %struct.dirent*, %struct.dirent** %8
%43 = icmp eq %struct.dirent* %42, null
br i1 %43, label %44, label %53
44: ; preds = %39
%45 = load i64, i64* @errno
%46 = icmp ne i64 %45, 0
br i1 %46, label %47, label %51
47: ; preds = %44
%48 = load i64, i64* @errno
%49 = load i8*, i8** %3
%50 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %48, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i8* %49)
br label %52
51: ; preds = %44
br label %121
52: ; preds = %47
br label %53
53: ; preds = %52, %39
%54 = load %struct.dirent*, %struct.dirent** %8
%55 = getelementptr inbounds %struct.dirent, %struct.dirent* %54, i32 0, i32 0
%56 = load i8*, i8** %55
%57 = load i8*, i8** %4
%58 = load i64, i64* %6
%59 = call i32 @strncmp(i8* %56, i8* %57, i64 %58)
store i32 %59, i32* %7
%60 = load i32, i32* %7
%61 = icmp ne i32 %60, 0
br i1 %61, label %62, label %63
62: ; preds = %53
br label %38
63: ; preds = %53
%64 = load i32, i32* @PATH_MAX
%65 = load i8*, i8** %3
%66 = load %struct.dirent*, %struct.dirent** %8
%67 = getelementptr inbounds %struct.dirent, %struct.dirent* %66, i32 0, i32 0
%68 = load i8*, i8** %67
%69 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %22, i32 %64, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i8* %65, i8* %68)
store i32 %69, i32* %11
%70 = load i32, i32* %11
%71 = icmp slt i32 %70, 0
br i1 %71, label %72, label %74
72: ; preds = %63
%73 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 0, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0))
br label %74
74: ; preds = %72, %63
%75 = load i32, i32* %11
%76 = load i32, i32* @PATH_MAX
%77 = icmp sge i32 %75, %76
br i1 %77, label %78, label %80
78: ; preds = %74
%79 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 0, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0))
br label %80
80: ; preds = %78, %74
%81 = load i32, i32* @O_RDONLY
%82 = load i32, i32* @O_SYNC
%83 = or i32 %81, %82
%84 = call i32 @open(i8* %22, i32 %83)
store i32 %84, i32* %12
%85 = load i32, i32* %12
%86 = icmp slt i32 %85, 0
br i1 %86, label %87, label %90
87: ; preds = %80
%88 = load i64, i64* @errno
%89 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %88, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0), i8* %22)
br label %90
90: ; preds = %87, %80
%91 = load i32, i32* %12
%92 = load i32, i32* @PATH_MAX
%93 = call i32 @read(i32 %91, i8* %25, i32 %92)
store i32 %93, i32* %7
%94 = load i32, i32* %7
%95 = icmp slt i32 %94, 0
br i1 %95, label %96, label %99
96: ; preds = %90
%97 = load i64, i64* @errno
%98 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %97, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0), i8* %22)
br label %99
99: ; preds = %96, %90
%100 = load i32, i32* %7
%101 = load i32, i32* @PATH_MAX
%102 = icmp eq i32 %100, %101
br i1 %102, label %103, label %106
103: ; preds = %99
%104 = load i64, i64* @errno
%105 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %104, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.10, i64 0, i64 0), i8* %22)
br label %106
106: ; preds = %103, %99
%107 = load i32, i32* %12
%108 = call i32 @close(i32 %107)
store i32 %108, i32* %7
%109 = load i32, i32* %7
%110 = icmp slt i32 %109, 0
br i1 %110, label %111, label %114
111: ; preds = %106
%112 = load i64, i64* @errno
%113 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %112, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.11, i64 0, i64 0), i8* %22)
br label %114
114: ; preds = %111, %106
%115 = load i8*, i8** %5
%116 = call i8* @strstr(i8* %25, i8* %115)
store i8* %116, i8** %15
%117 = load i8*, i8** %15
%118 = icmp ne i8* %117, null
br i1 %118, label %119, label %120
119: ; preds = %114
br label %121
120: ; preds = %114
br label %38
121: ; preds = %119, %51
%122 = load i8*, i8** %15
%123 = icmp eq i8* %122, null
br i1 %123, label %124, label %126
124: ; preds = %121
%125 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 0, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.12, i64 0, i64 0))
br label %126
126: ; preds = %124, %121
%127 = load i32, i32* @PATH_MAX
%128 = load i8*, i8** %3
%129 = load %struct.dirent*, %struct.dirent** %8
%130 = getelementptr inbounds %struct.dirent, %struct.dirent* %129, i32 0, i32 0
%131 = load i8*, i8** %130
%132 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %22, i32 %127, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.13, i64 0, i64 0), i8* %128, i8* %131)
store i32 %132, i32* %11
%133 = load i32, i32* %11
%134 = icmp slt i32 %133, 0
br i1 %134, label %135, label %137
135: ; preds = %126
%136 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 0, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0))
br label %137
137: ; preds = %135, %126
%138 = load i32, i32* %11
%139 = load i32, i32* @PATH_MAX
%140 = icmp sge i32 %138, %139
br i1 %140, label %141, label %143
141: ; preds = %137
%142 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 0, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0))
br label %143
143: ; preds = %141, %137
%144 = load i32, i32* @O_RDONLY
%145 = load i32, i32* @O_SYNC
%146 = or i32 %144, %145
%147 = call i32 @open(i8* %22, i32 %146)
store i32 %147, i32* %12
%148 = load i32, i32* %12
%149 = icmp slt i32 %148, 0
br i1 %149, label %150, label %153
150: ; preds = %143
%151 = load i64, i64* @errno
%152 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %151, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0), i8* %22)
br label %153
153: ; preds = %150, %143
%154 = load i32, i32* %12
%155 = load i32, i32* @PATH_MAX
%156 = call i32 @read(i32 %154, i8* %28, i32 %155)
store i32 %156, i32* %7
%157 = load i32, i32* %7
%158 = icmp slt i32 %157, 0
br i1 %158, label %159, label %162
159: ; preds = %153
%160 = load i64, i64* @errno
%161 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %160, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0), i8* %22)
br label %162
162: ; preds = %159, %153
%163 = load i32, i32* %7
%164 = load i32, i32* @PATH_MAX
%165 = icmp eq i32 %163, %164
br i1 %165, label %166, label %169
166: ; preds = %162
%167 = load i64, i64* @errno
%168 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %167, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.10, i64 0, i64 0), i8* %22)
br label %169
169: ; preds = %166, %162
%170 = load i32, i32* %12
%171 = call i32 @close(i32 %170)
store i32 %171, i32* %7
%172 = load i32, i32* %7
%173 = icmp slt i32 %172, 0
br i1 %173, label %174, label %177
174: ; preds = %169
%175 = load i64, i64* @errno
%176 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %175, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.11, i64 0, i64 0), i8* %22)
br label %177
177: ; preds = %174, %169
%178 = call i8* @strchr(i8* %28, i8 signext 10)
store i8* %178, i8** %16
%179 = load i8*, i8** %16
%180 = icmp ne i8* %179, null
br i1 %180, label %181, label %184
181: ; preds = %177
%182 = load i8*, i8** %16
%183 = call i32 @memset(i8* %182, i8 signext 0, i32 1)
br label %184
184: ; preds = %181, %177
%185 = load i32, i32* @PATH_MAX
%186 = load i8*, i8** %3
%187 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %22, i32 %185, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.14, i64 0, i64 0), i8* %186)
store i32 %187, i32* %11
%188 = load i32, i32* %11
%189 = icmp slt i32 %188, 0
br i1 %189, label %190, label %192
190: ; preds = %184
%191 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 0, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0))
br label %192
192: ; preds = %190, %184
%193 = load i32, i32* %11
%194 = load i32, i32* @PATH_MAX
%195 = icmp sge i32 %193, %194
br i1 %195, label %196, label %198
196: ; preds = %192
%197 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 0, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0))
br label %198
198: ; preds = %196, %192
%199 = load i32, i32* @O_WRONLY
%200 = load i32, i32* @O_SYNC
%201 = or i32 %199, %200
%202 = call i32 @open(i8* %22, i32 %201)
store i32 %202, i32* %12
%203 = load i32, i32* %12
%204 = icmp slt i32 %203, 0
br i1 %204, label %205, label %208
205: ; preds = %198
%206 = load i64, i64* @errno
%207 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %206, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0), i8* %22)
br label %208
208: ; preds = %205, %198
%209 = load i32, i32* %12
%210 = call i64 @strlen(i8* %28)
%211 = call i32 @write(i32 %209, i8* %28, i64 %210)
store i32 %211, i32* %7
%212 = load i32, i32* %12
%213 = call i32 @close(i32 %212)
store i32 %213, i32* %7
%214 = load i32, i32* %7
%215 = icmp slt i32 %214, 0
br i1 %215, label %216, label %219
216: ; preds = %208
%217 = load i64, i64* @errno
%218 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %217, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.11, i64 0, i64 0), i8* %22)
br label %219
219: ; preds = %216, %208
%220 = load i32, i32* @PATH_MAX
%221 = load i8*, i8** %3
%222 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %22, i32 %220, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.15, i64 0, i64 0), i8* %221, i8* %28)
store i32 %222, i32* %11
%223 = load i32, i32* %11
%224 = icmp slt i32 %223, 0
br i1 %224, label %225, label %227
225: ; preds = %219
%226 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 0, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0))
br label %227
227: ; preds = %225, %219
%228 = load i32, i32* %11
%229 = load i32, i32* @PATH_MAX
%230 = icmp sge i32 %228, %229
br i1 %230, label %231, label %233
231: ; preds = %227
%232 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 0, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0))
br label %233
233: ; preds = %231, %227
%234 = load i32, i32* @O_RDONLY
%235 = load i32, i32* @O_SYNC
%236 = or i32 %234, %235
%237 = call i32 @open(i8* %22, i32 %236)
store i32 %237, i32* %12
%238 = load i32, i32* %12
%239 = icmp slt i32 %238, 0
br i1 %239, label %240, label %243
240: ; preds = %233
%241 = load i64, i64* @errno
%242 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %241, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0), i8* %22)
br label %243
243: ; preds = %240, %233
%244 = load i32, i32* %12
%245 = load i32, i32* @PATH_MAX
%246 = call i32 @read(i32 %244, i8* %25, i32 %245)
store i32 %246, i32* %7
%247 = load i32, i32* %7
%248 = icmp slt i32 %247, 0
br i1 %248, label %249, label %252
249: ; preds = %243
%250 = load i64, i64* @errno
%251 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %250, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0), i8* %22)
br label %252
252: ; preds = %249, %243
%253 = load i32, i32* %7
%254 = load i32, i32* @PATH_MAX
%255 = icmp eq i32 %253, %254
br i1 %255, label %256, label %259
256: ; preds = %252
%257 = load i64, i64* @errno
%258 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %257, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.10, i64 0, i64 0), i8* %22)
br label %259
259: ; preds = %256, %252
%260 = load i32, i32* %12
%261 = call i32 @close(i32 %260)
store i32 %261, i32* %7
%262 = load i32, i32* %7
%263 = icmp slt i32 %262, 0
br i1 %263, label %264, label %267
264: ; preds = %259
%265 = load i64, i64* @errno
%266 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %265, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.11, i64 0, i64 0), i8* %22)
br label %267
267: ; preds = %264, %259
%268 = call i8* @strchr(i8* %25, i8 signext 10)
store i8* %268, i8** %16
%269 = load i8*, i8** %16
%270 = icmp ne i8* %269, null
br i1 %270, label %271, label %274
271: ; preds = %267
%272 = load i8*, i8** %16
%273 = call i32 @memset(i8* %272, i8 signext 0, i32 1)
br label %274
274: ; preds = %271, %267
%275 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.16, i64 0, i64 0), i8* %25)
%276 = load i32, i32* @PATH_MAX
%277 = load i8*, i8** %3
%278 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %22, i32 %276, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.17, i64 0, i64 0), i8* %277)
store i32 %278, i32* %11
%279 = load i32, i32* %11
%280 = icmp slt i32 %279, 0
br i1 %280, label %281, label %283
281: ; preds = %274
%282 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 0, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0))
br label %283
283: ; preds = %281, %274
%284 = load i32, i32* %11
%285 = load i32, i32* @PATH_MAX
%286 = icmp sge i32 %284, %285
br i1 %286, label %287, label %289
287: ; preds = %283
%288 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 0, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0))
br label %289
289: ; preds = %287, %283
%290 = load i32, i32* @O_WRONLY
%291 = load i32, i32* @O_SYNC
%292 = or i32 %290, %291
%293 = call i32 @open(i8* %22, i32 %292)
store i32 %293, i32* %12
%294 = load i32, i32* %12
%295 = icmp slt i32 %294, 0
br i1 %295, label %296, label %299
296: ; preds = %289
%297 = load i64, i64* @errno
%298 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %297, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0), i8* %22)
br label %299
299: ; preds = %296, %289
%300 = load i32, i32* %12
%301 = call i64 @strlen(i8* %28)
%302 = call i32 @write(i32 %300, i8* %28, i64 %301)
store i32 %302, i32* %7
%303 = load i32, i32* %7
%304 = icmp slt i32 %303, 0
br i1 %304, label %305, label %308
305: ; preds = %299
%306 = load i64, i64* @errno
%307 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %306, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.18, i64 0, i64 0), i8* %22)
br label %308
308: ; preds = %305, %299
%309 = load i32, i32* %7
%310 = sext i32 %309 to i64
%311 = call i64 @strlen(i8* %28)
%312 = icmp ne i64 %310, %311
br i1 %312, label %313, label %316
313: ; preds = %308
%314 = load i64, i64* @errno
%315 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %314, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.19, i64 0, i64 0), i8* %22)
br label %316
316: ; preds = %313, %308
%317 = load i32, i32* %12
%318 = call i32 @close(i32 %317)
store i32 %318, i32* %7
%319 = load i32, i32* %7
%320 = icmp slt i32 %319, 0
br i1 %320, label %321, label %324
321: ; preds = %316
%322 = load i64, i64* @errno
%323 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %322, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.11, i64 0, i64 0), i8* %22)
br label %324
324: ; preds = %321, %316
%325 = load i8*, i8** %9
%326 = load i32, i32* %1
ret i32 %326
}

LLVM IR (-O2):
%struct.dirent = type { i8* }
@.str = [16 x i8] c"/sys/class/gpio\00"
@.str.1 = [9 x i8] c"gpiochip\00"
@.str.2 = [17 x i8] c"gpio@0x100005000\00"
@PATH_MAX = global i32 0
@errno = global i64 0
@.str.3 = [30 x i8] c"could not open directory '%s'\00"
@.str.4 = [23 x i8] c"reading directory '%s'\00"
@.str.5 = [12 x i8] c"%s/%s/label\00"
@.str.6 = [18 x i8] c"path output error\00"
@.str.7 = [21 x i8] c"path length overflow\00"
@O_RDONLY = global i32 0
@O_SYNC = global i32 0
@.str.8 = [25 x i8] c"could not open file '%s'\00"
@.str.9 = [18 x i8] c"reading from '%s'\00"
@.str.10 = [29 x i8] c"buffer overflow reading '%s'\00"
@.str.11 = [26 x i8] c"could not close file '%s'\00"
@.str.12 = [33 x i8] c"unable to locate gpio controller\00"
@.str.13 = [11 x i8] c"%s/%s/base\00"
@.str.14 = [10 x i8] c"%s/export\00"
@O_WRONLY = global i32 0
@.str.15 = [16 x i8] c"%s/gpio%s/value\00"
@.str.16 = [35 x i8] c"KEY0 push button is at state '%s'\0A\00"
@.str.17 = [12 x i8] c"%s/unexport\00"
@.str.18 = [16 x i8] c"writing to '%s'\00"
@.str.19 = [30 x i8] c"buffer underflow writing '%s'\00"
define i32 @main() {
%1 = load i32, i32* @PATH_MAX
%2 = zext i32 %1 to i64
%3 = alloca i8, i64 %2
%4 = alloca i8, i64 %2
%5 = alloca i8, i64 %2
%6 = tail call i32* @opendir(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %11
8: ; preds = %0
%9 = load i64, i64* @errno
%10 = tail call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %9, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %8, %0
br label %12
12: ; preds = %25, %11
store i64 0, i64* @errno
%13 = call %struct.dirent* @readdir(i32* %6)
%14 = icmp eq %struct.dirent* %13, null
br i1 %14, label %15, label %20
15: ; preds = %12
%16 = load i64, i64* @errno
%17 = icmp eq i64 %16, 0
br i1 %17, label %68, label %18
18: ; preds = %15
%19 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %16, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
br label %20
20: ; preds = %18, %12
%21 = getelementptr inbounds %struct.dirent, %struct.dirent* %13, i64 0, i32 0
%22 = load i8*, i8** %21
%23 = call i32 @strncmp(i8* dereferenceable(1) %22, i8* dereferenceable(9) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i64 8)
%24 = icmp eq i32 %23, 0
br i1 %24, label %26, label %25
25: ; preds = %20, %65
br label %12
26: ; preds = %20
%27 = load i32, i32* @PATH_MAX
%28 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %3, i32 %27, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %22)
%29 = icmp slt i32 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %26
%31 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 0, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0))
br label %32
32: ; preds = %30, %26
%33 = load i32, i32* @PATH_MAX
%34 = icmp slt i32 %28, %33
br i1 %34, label %37, label %35
35: ; preds = %32
%36 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 0, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0))
br label %37
37: ; preds = %35, %32
%38 = load i32, i32* @O_RDONLY
%39 = load i32, i32* @O_SYNC
%40 = or i32 %39, %38
%41 = call i32 @open(i8* %3, i32 %40)
%42 = icmp slt i32 %41, 0
br i1 %42, label %43, label %46
43: ; preds = %37
%44 = load i64, i64* @errno
%45 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %44, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0), i8* %3)
br label %46
46: ; preds = %43, %37
%47 = load i32, i32* @PATH_MAX
%48 = call i32 @read(i32 %41, i8* %4, i32 %47)
%49 = icmp slt i32 %48, 0
br i1 %49, label %50, label %53
50: ; preds = %46
%51 = load i64, i64* @errno
%52 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %51, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0), i8* %3)
br label %53
53: ; preds = %50, %46
%54 = load i32, i32* @PATH_MAX
%55 = icmp eq i32 %48, %54
br i1 %55, label %56, label %59
56: ; preds = %53
%57 = load i64, i64* @errno
%58 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %57, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.10, i64 0, i64 0), i8* %3)
br label %59
59: ; preds = %56, %53
%60 = call i32 @close(i32 %41)
%61 = icmp slt i32 %60, 0
br i1 %61, label %62, label %65
62: ; preds = %59
%63 = load i64, i64* @errno
%64 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %63, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.11, i64 0, i64 0), i8* %3)
br label %65
65: ; preds = %62, %59
%66 = call i8* @strstr(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%67 = icmp eq i8* %66, null
br i1 %67, label %25, label %70
68: ; preds = %15
%69 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 0, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.12, i64 0, i64 0))
br label %70
70: ; preds = %65, %68
%71 = load i32, i32* @PATH_MAX
%72 = getelementptr inbounds %struct.dirent, %struct.dirent* %13, i64 0, i32 0
%73 = load i8*, i8** %72
%74 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %3, i32 %71, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %73)
%75 = icmp slt i32 %74, 0
br i1 %75, label %76, label %78
76: ; preds = %70
%77 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 0, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0))
br label %78
78: ; preds = %76, %70
%79 = load i32, i32* @PATH_MAX
%80 = icmp slt i32 %74, %79
br i1 %80, label %83, label %81
81: ; preds = %78
%82 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 0, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0))
br label %83
83: ; preds = %81, %78
%84 = load i32, i32* @O_RDONLY
%85 = load i32, i32* @O_SYNC
%86 = or i32 %85, %84
%87 = call i32 @open(i8* %3, i32 %86)
%88 = icmp slt i32 %87, 0
br i1 %88, label %89, label %92
89: ; preds = %83
%90 = load i64, i64* @errno
%91 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %90, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0), i8* %3)
br label %92
92: ; preds = %89, %83
%93 = load i32, i32* @PATH_MAX
%94 = call i32 @read(i32 %87, i8* %5, i32 %93)
%95 = icmp slt i32 %94, 0
br i1 %95, label %96, label %99
96: ; preds = %92
%97 = load i64, i64* @errno
%98 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %97, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0), i8* %3)
br label %99
99: ; preds = %96, %92
%100 = load i32, i32* @PATH_MAX
%101 = icmp eq i32 %94, %100
br i1 %101, label %102, label %105
102: ; preds = %99
%103 = load i64, i64* @errno
%104 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %103, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.10, i64 0, i64 0), i8* %3)
br label %105
105: ; preds = %102, %99
%106 = call i32 @close(i32 %87)
%107 = icmp slt i32 %106, 0
br i1 %107, label %108, label %111
108: ; preds = %105
%109 = load i64, i64* @errno
%110 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %109, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.11, i64 0, i64 0), i8* %3)
br label %111
111: ; preds = %108, %105
%112 = call i8* @strchr(i8* %5, i8 signext 10)
%113 = icmp eq i8* %112, null
br i1 %113, label %116, label %114
114: ; preds = %111
%115 = call i32 @memset(i8* %112, i8 signext 0, i32 1)
br label %116
116: ; preds = %114, %111
%117 = load i32, i32* @PATH_MAX
%118 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %3, i32 %117, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.14, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%119 = icmp slt i32 %118, 0
br i1 %119, label %120, label %122
120: ; preds = %116
%121 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 0, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0))
br label %122
122: ; preds = %120, %116
%123 = load i32, i32* @PATH_MAX
%124 = icmp slt i32 %118, %123
br i1 %124, label %127, label %125
125: ; preds = %122
%126 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 0, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0))
br label %127
127: ; preds = %125, %122
%128 = load i32, i32* @O_WRONLY
%129 = load i32, i32* @O_SYNC
%130 = or i32 %129, %128
%131 = call i32 @open(i8* %3, i32 %130)
%132 = icmp slt i32 %131, 0
br i1 %132, label %133, label %136
133: ; preds = %127
%134 = load i64, i64* @errno
%135 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %134, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0), i8* %3)
br label %136
136: ; preds = %133, %127
%137 = call i64 @strlen(i8* %5)
%138 = call i32 @write(i32 %131, i8* %5, i64 %137)
%139 = call i32 @close(i32 %131)
%140 = icmp slt i32 %139, 0
br i1 %140, label %141, label %144
141: ; preds = %136
%142 = load i64, i64* @errno
%143 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %142, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.11, i64 0, i64 0), i8* %3)
br label %144
144: ; preds = %141, %136
%145 = load i32, i32* @PATH_MAX
%146 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %3, i32 %145, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.15, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %5)
%147 = icmp slt i32 %146, 0
br i1 %147, label %148, label %150
148: ; preds = %144
%149 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 0, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0))
br label %150
150: ; preds = %148, %144
%151 = load i32, i32* @PATH_MAX
%152 = icmp slt i32 %146, %151
br i1 %152, label %155, label %153
153: ; preds = %150
%154 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 0, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0))
br label %155
155: ; preds = %153, %150
%156 = load i32, i32* @O_RDONLY
%157 = load i32, i32* @O_SYNC
%158 = or i32 %157, %156
%159 = call i32 @open(i8* %3, i32 %158)
%160 = icmp slt i32 %159, 0
br i1 %160, label %161, label %164
161: ; preds = %155
%162 = load i64, i64* @errno
%163 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %162, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0), i8* %3)
br label %164
164: ; preds = %161, %155
%165 = load i32, i32* @PATH_MAX
%166 = call i32 @read(i32 %159, i8* %4, i32 %165)
%167 = icmp slt i32 %166, 0
br i1 %167, label %168, label %171
168: ; preds = %164
%169 = load i64, i64* @errno
%170 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %169, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0), i8* %3)
br label %171
171: ; preds = %168, %164
%172 = load i32, i32* @PATH_MAX
%173 = icmp eq i32 %166, %172
br i1 %173, label %174, label %177
174: ; preds = %171
%175 = load i64, i64* @errno
%176 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %175, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.10, i64 0, i64 0), i8* %3)
br label %177
177: ; preds = %174, %171
%178 = call i32 @close(i32 %159)
%179 = icmp slt i32 %178, 0
br i1 %179, label %180, label %183
180: ; preds = %177
%181 = load i64, i64* @errno
%182 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %181, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.11, i64 0, i64 0), i8* %3)
br label %183
183: ; preds = %180, %177
%184 = call i8* @strchr(i8* %4, i8 signext 10)
%185 = icmp eq i8* %184, null
br i1 %185, label %188, label %186
186: ; preds = %183
%187 = call i32 @memset(i8* %184, i8 signext 0, i32 1)
br label %188
188: ; preds = %186, %183
%189 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.16, i64 0, i64 0), i8* %4)
%190 = load i32, i32* @PATH_MAX
%191 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %3, i32 %190, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.17, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%192 = icmp slt i32 %191, 0
br i1 %192, label %193, label %195
193: ; preds = %188
%194 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 0, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0))
br label %195
195: ; preds = %193, %188
%196 = load i32, i32* @PATH_MAX
%197 = icmp slt i32 %191, %196
br i1 %197, label %200, label %198
198: ; preds = %195
%199 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 0, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0))
br label %200
200: ; preds = %198, %195
%201 = load i32, i32* @O_WRONLY
%202 = load i32, i32* @O_SYNC
%203 = or i32 %202, %201
%204 = call i32 @open(i8* %3, i32 %203)
%205 = icmp slt i32 %204, 0
br i1 %205, label %206, label %209
206: ; preds = %200
%207 = load i64, i64* @errno
%208 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %207, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0), i8* %3)
br label %209
209: ; preds = %206, %200
%210 = call i64 @strlen(i8* %5)
%211 = call i32 @write(i32 %204, i8* %5, i64 %210)
%212 = icmp slt i32 %211, 0
br i1 %212, label %213, label %216
213: ; preds = %209
%214 = load i64, i64* @errno
%215 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %214, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.18, i64 0, i64 0), i8* %3)
br label %216
216: ; preds = %213, %209
%217 = sext i32 %211 to i64
%218 = call i64 @strlen(i8* %5)
%219 = icmp eq i64 %218, %217
br i1 %219, label %223, label %220
220: ; preds = %216
%221 = load i64, i64* @errno
%222 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %221, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.19, i64 0, i64 0), i8* %3)
br label %223
223: ; preds = %220, %216
%224 = call i32 @close(i32 %204)
%225 = icmp slt i32 %224, 0
br i1 %225, label %226, label %229
226: ; preds = %223
%227 = load i64, i64* @errno
%228 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %227, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.11, i64 0, i64 0), i8* %3)
br label %229
229: ; preds = %226, %223
ret i32 0
}