#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 pollfd {
  int fd;
  int events;
  scalar_t__ revents;
};
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 POLLERR;
int POLLPRI;
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 poll(struct pollfd *, int, int);
int /*<<< orphan*/ printf(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;
  struct pollfd pollfd_struct;
  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/edge", 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_WRONLY | O_SYNC);
  if (file_fd < 0)
    error(1, errno, "could not open file '%s'", path);
  result = write(file_fd, "falling", 7);
  if (result < 0)
    error(1, errno, "writing to '%s'", path);
  if (result != 7)
    error(1, errno, "buffer underflow writing '%s'", path);
  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);
  printf("Please press the KEY0 push button.\n");
  pollfd_struct.fd = file_fd;
  pollfd_struct.events = POLLPRI | POLLERR;
  pollfd_struct.revents = 0;
  result = poll(&pollfd_struct, 1, -1);
  if (result < 0)
    error(1, errno, "poll returned error");
  if (result == 1)
    printf("KEY0 push button pressed.\n");
  else
    printf("Poll returned value other than 1.\n");
  result = close(file_fd);
  if (result < 0)
    error(1, errno, "could not close file '%s'", path);
  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    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xdf7(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    0xdfc(%rip),%rax
mov    %rax,-0x20(%rbp)
lea    0xdfa(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1060 <strlen@plt>
mov    %rax,-0x30(%rbp)
mov    0x2db9(%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,-0xa0(%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,-0x98(%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,-0x90(%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    12e2 <main+0xf2>
mov    0x2cf0(%rip),%rax
mov    (%rax),%rsi
mov    -0x18(%rbp),%rcx
mov    $0x1,%edi
lea    0xd4f(%rip),%rdx
mov    $0x0,%al
call   10f0 <error@plt>
jmp    12e7 <main+0xf7>
jmp    12ec <main+0xfc>
mov    0x2cc5(%rip),%rax
movq   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
call   10d0 <readdir@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    1353 <main+0x163>
mov    0x2c9f(%rip),%rax
cmpq   $0x0,(%rax)
je     1349 <main+0x159>
mov    0x2c8e(%rip),%rax
mov    (%rax),%rsi
mov    -0x18(%rbp),%rcx
mov    $0x1,%edi
lea    0xd0b(%rip),%rdx
mov    $0x0,%al
call   10f0 <error@plt>
jmp    134e <main+0x15e>
jmp    151f <main+0x32f>
jmp    1353 <main+0x163>
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     1379 <main+0x189>
jmp    12e7 <main+0xf7>
mov    -0xa0(%rbp),%rdi
mov    0x2c69(%rip),%rax
mov    (%rax),%esi
mov    -0x18(%rbp),%rcx
mov    -0x40(%rbp),%rax
mov    (%rax),%r8
lea    0xcc4(%rip),%rdx
mov    $0x0,%al
call   1090 <snprintf@plt>
mov    %eax,-0x54(%rbp)
cmpl   $0x0,-0x54(%rbp)
jge    13c6 <main+0x1d6>
mov    $0x1,%edi
xor    %eax,%eax
mov    %eax,%esi
lea    0xcac(%rip),%rdx
mov    $0x0,%al
call   10f0 <error@plt>
mov    -0x54(%rbp),%eax
mov    0x2c20(%rip),%rcx
cmp    (%rcx),%eax
jl     13ef <main+0x1ff>
mov    $0x1,%edi
xor    %eax,%eax
mov    %eax,%esi
lea    0xc95(%rip),%rdx
mov    $0x0,%al
call   10f0 <error@plt>
mov    -0xa0(%rbp),%rdi
mov    0x2bcb(%rip),%rax
mov    (%rax),%esi
mov    0x2bd2(%rip),%rax
or     (%rax),%esi
call   1100 <open@plt>
mov    %eax,-0x58(%rbp)
cmpl   $0x0,-0x58(%rbp)
jge    143e <main+0x24e>
mov    -0xa0(%rbp),%rcx
mov    0x2b90(%rip),%rax
mov    (%rax),%rsi
mov    $0x1,%edi
lea    0xc5b(%rip),%rdx
mov    $0x0,%al
call   10f0 <error@plt>
mov    -0x98(%rbp),%rsi
mov    -0x58(%rbp),%edi
mov    0x2ba1(%rip),%rax
mov    (%rax),%edx
call   10c0 <read@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jge    1487 <main+0x297>
mov    -0xa0(%rbp),%rcx
mov    0x2b47(%rip),%rax
mov    (%rax),%rsi
mov    $0x1,%edi
lea    0xc2b(%rip),%rdx
mov    $0x0,%al
call   10f0 <error@plt>
mov    -0x34(%rbp),%eax
mov    0x2b5f(%rip),%rcx
cmp    (%rcx),%eax
jne    14bd <main+0x2cd>
mov    -0xa0(%rbp),%rcx
mov    0x2b11(%rip),%rax
mov    (%rax),%rsi
mov    $0x1,%edi
lea    0xc07(%rip),%rdx
mov    $0x0,%al
call   10f0 <error@plt>
mov    -0x58(%rbp),%edi
call   10b0 <close@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jge    14f6 <main+0x306>
mov    -0xa0(%rbp),%rcx
mov    0x2ad8(%rip),%rax
mov    (%rax),%rsi
mov    $0x1,%edi
lea    0xbeb(%rip),%rdx
mov    $0x0,%al
call   10f0 <error@plt>
mov    -0x98(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1110 <strstr@plt>
mov    %rax,-0x70(%rbp)
cmpq   $0x0,-0x70(%rbp)
je     151a <main+0x32a>
jmp    151f <main+0x32f>
jmp    12e7 <main+0xf7>
cmpq   $0x0,-0x70(%rbp)
jne    1541 <main+0x351>
mov    $0x1,%edi
xor    %eax,%eax
mov    %eax,%esi
lea    0xbba(%rip),%rdx
mov    $0x0,%al
call   10f0 <error@plt>
mov    -0xa0(%rbp),%rdi
mov    0x2aa1(%rip),%rax
mov    (%rax),%esi
mov    -0x18(%rbp),%rcx
mov    -0x40(%rbp),%rax
mov    (%rax),%r8
lea    0xbb2(%rip),%rdx
mov    $0x0,%al
call   1090 <snprintf@plt>
mov    %eax,-0x54(%rbp)
cmpl   $0x0,-0x54(%rbp)
jge    158e <main+0x39e>
mov    $0x1,%edi
xor    %eax,%eax
mov    %eax,%esi
lea    0xae4(%rip),%rdx
mov    $0x0,%al
call   10f0 <error@plt>
mov    -0x54(%rbp),%eax
mov    0x2a58(%rip),%rcx
cmp    (%rcx),%eax
jl     15b7 <main+0x3c7>
mov    $0x1,%edi
xor    %eax,%eax
mov    %eax,%esi
lea    0xacd(%rip),%rdx
mov    $0x0,%al
call   10f0 <error@plt>
mov    -0xa0(%rbp),%rdi
mov    0x2a03(%rip),%rax
mov    (%rax),%esi
mov    0x2a0a(%rip),%rax
or     (%rax),%esi
call   1100 <open@plt>
mov    %eax,-0x58(%rbp)
cmpl   $0x0,-0x58(%rbp)
jge    1606 <main+0x416>
mov    -0xa0(%rbp),%rcx
mov    0x29c8(%rip),%rax
mov    (%rax),%rsi
mov    $0x1,%edi
lea    0xa93(%rip),%rdx
mov    $0x0,%al
call   10f0 <error@plt>
mov    -0x90(%rbp),%rsi
mov    -0x58(%rbp),%edi
mov    0x29d9(%rip),%rax
mov    (%rax),%edx
call   10c0 <read@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jge    164f <main+0x45f>
mov    -0xa0(%rbp),%rcx
mov    0x297f(%rip),%rax
mov    (%rax),%rsi
mov    $0x1,%edi
lea    0xa63(%rip),%rdx
mov    $0x0,%al
call   10f0 <error@plt>
mov    -0x34(%rbp),%eax
mov    0x2997(%rip),%rcx
cmp    (%rcx),%eax
jne    1685 <main+0x495>
mov    -0xa0(%rbp),%rcx
mov    0x2949(%rip),%rax
mov    (%rax),%rsi
mov    $0x1,%edi
lea    0xa3f(%rip),%rdx
mov    $0x0,%al
call   10f0 <error@plt>
mov    -0x58(%rbp),%edi
call   10b0 <close@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jge    16be <main+0x4ce>
mov    -0xa0(%rbp),%rcx
mov    0x2910(%rip),%rax
mov    (%rax),%rsi
mov    $0x1,%edi
lea    0xa23(%rip),%rdx
mov    $0x0,%al
call   10f0 <error@plt>
mov    -0x90(%rbp),%rdi
mov    $0xa,%esi
call   1070 <strchr@plt>
mov    %rax,-0x78(%rbp)
cmpq   $0x0,-0x78(%rbp)
je     16ee <main+0x4fe>
mov    -0x78(%rbp),%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   10a0 <memset@plt>
mov    -0xa0(%rbp),%rdi
mov    0x28f4(%rip),%rax
mov    (%rax),%esi
mov    -0x18(%rbp),%rcx
lea    0xa17(%rip),%rdx
mov    $0x0,%al
call   1090 <snprintf@plt>
mov    %eax,-0x54(%rbp)
cmpl   $0x0,-0x54(%rbp)
jge    1734 <main+0x544>
mov    $0x1,%edi
xor    %eax,%eax
mov    %eax,%esi
lea    0x93e(%rip),%rdx
mov    $0x0,%al
call   10f0 <error@plt>
mov    -0x54(%rbp),%eax
mov    0x28b2(%rip),%rcx
cmp    (%rcx),%eax
jl     175d <main+0x56d>
mov    $0x1,%edi
xor    %eax,%eax
mov    %eax,%esi
lea    0x927(%rip),%rdx
mov    $0x0,%al
call   10f0 <error@plt>
mov    -0xa0(%rbp),%rdi
mov    0x283d(%rip),%rax
mov    (%rax),%esi
mov    0x2864(%rip),%rax
or     (%rax),%esi
call   1100 <open@plt>
mov    %eax,-0x58(%rbp)
cmpl   $0x0,-0x58(%rbp)
jge    17ac <main+0x5bc>
mov    -0xa0(%rbp),%rcx
mov    0x2822(%rip),%rax
mov    (%rax),%rsi
mov    $0x1,%edi
lea    0x8ed(%rip),%rdx
mov    $0x0,%al
call   10f0 <error@plt>
mov    -0x90(%rbp),%rdi
mov    -0x58(%rbp),%eax
mov    %eax,-0xa4(%rbp)
call   1060 <strlen@plt>
mov    -0xa4(%rbp),%edi
mov    -0x90(%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    1812 <main+0x622>
mov    -0xa0(%rbp),%rcx
mov    0x27bc(%rip),%rax
mov    (%rax),%rsi
mov    $0x1,%edi
lea    0x8cf(%rip),%rdx
mov    $0x0,%al
call   10f0 <error@plt>
mov    -0x90(%rbp),%r8
mov    -0xa0(%rbp),%rdi
mov    0x27c9(%rip),%rax
mov    (%rax),%esi
mov    -0x18(%rbp),%rcx
lea    0x8f6(%rip),%rdx
mov    $0x0,%al
call   1090 <snprintf@plt>
mov    %eax,-0x54(%rbp)
cmpl   $0x0,-0x54(%rbp)
jge    185f <main+0x66f>
mov    $0x1,%edi
xor    %eax,%eax
mov    %eax,%esi
lea    0x813(%rip),%rdx
mov    $0x0,%al
call   10f0 <error@plt>
mov    -0x54(%rbp),%eax
mov    0x2787(%rip),%rcx
cmp    (%rcx),%eax
jl     1888 <main+0x698>
mov    $0x1,%edi
xor    %eax,%eax
mov    %eax,%esi
lea    0x7fc(%rip),%rdx
mov    $0x0,%al
call   10f0 <error@plt>
mov    -0xa0(%rbp),%rdi
mov    0x2712(%rip),%rax
mov    (%rax),%esi
mov    0x2739(%rip),%rax
or     (%rax),%esi
call   1100 <open@plt>
mov    %eax,-0x58(%rbp)
cmpl   $0x0,-0x58(%rbp)
jge    18d7 <main+0x6e7>
mov    -0xa0(%rbp),%rcx
mov    0x26f7(%rip),%rax
mov    (%rax),%rsi
mov    $0x1,%edi
lea    0x7c2(%rip),%rdx
mov    $0x0,%al
call   10f0 <error@plt>
mov    -0x58(%rbp),%edi
lea    0x858(%rip),%rsi
mov    $0x7,%edx
call   1040 <write@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jge    191c <main+0x72c>
mov    -0xa0(%rbp),%rcx
mov    0x26b2(%rip),%rax
mov    (%rax),%rsi
mov    $0x1,%edi
lea    0x82c(%rip),%rdx
mov    $0x0,%al
call   10f0 <error@plt>
cmpl   $0x7,-0x34(%rbp)
je     194a <main+0x75a>
mov    -0xa0(%rbp),%rcx
mov    0x2684(%rip),%rax
mov    (%rax),%rsi
mov    $0x1,%edi
lea    0x80e(%rip),%rdx
mov    $0x0,%al
call   10f0 <error@plt>
mov    -0x58(%rbp),%edi
call   10b0 <close@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jge    1983 <main+0x793>
mov    -0xa0(%rbp),%rcx
mov    0x264b(%rip),%rax
mov    (%rax),%rsi
mov    $0x1,%edi
lea    0x75e(%rip),%rdx
mov    $0x0,%al
call   10f0 <error@plt>
mov    -0x90(%rbp),%r8
mov    -0xa0(%rbp),%rdi
mov    0x2658(%rip),%rax
mov    (%rax),%esi
mov    -0x18(%rbp),%rcx
lea    0x7ca(%rip),%rdx
mov    $0x0,%al
call   1090 <snprintf@plt>
mov    %eax,-0x54(%rbp)
cmpl   $0x0,-0x54(%rbp)
jge    19d0 <main+0x7e0>
mov    $0x1,%edi
xor    %eax,%eax
mov    %eax,%esi
lea    0x6a2(%rip),%rdx
mov    $0x0,%al
call   10f0 <error@plt>
mov    -0x54(%rbp),%eax
mov    0x2616(%rip),%rcx
cmp    (%rcx),%eax
jl     19f9 <main+0x809>
mov    $0x1,%edi
xor    %eax,%eax
mov    %eax,%esi
lea    0x68b(%rip),%rdx
mov    $0x0,%al
call   10f0 <error@plt>
mov    -0xa0(%rbp),%rdi
mov    0x25c1(%rip),%rax
mov    (%rax),%esi
mov    0x25c8(%rip),%rax
or     (%rax),%esi
call   1100 <open@plt>
mov    %eax,-0x58(%rbp)
cmpl   $0x0,-0x58(%rbp)
jge    1a48 <main+0x858>
mov    -0xa0(%rbp),%rcx
mov    0x2586(%rip),%rax
mov    (%rax),%rsi
mov    $0x1,%edi
lea    0x651(%rip),%rdx
mov    $0x0,%al
call   10f0 <error@plt>
mov    -0x98(%rbp),%rsi
mov    -0x58(%rbp),%edi
mov    0x2597(%rip),%rax
mov    (%rax),%edx
call   10c0 <read@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jge    1a91 <main+0x8a1>
mov    -0xa0(%rbp),%rcx
mov    0x253d(%rip),%rax
mov    (%rax),%rsi
mov    $0x1,%edi
lea    0x621(%rip),%rdx
mov    $0x0,%al
call   10f0 <error@plt>
mov    -0x34(%rbp),%eax
mov    0x2555(%rip),%rcx
cmp    (%rcx),%eax
jne    1ac7 <main+0x8d7>
mov    -0xa0(%rbp),%rcx
mov    0x2507(%rip),%rax
mov    (%rax),%rsi
mov    $0x1,%edi
lea    0x5fd(%rip),%rdx
mov    $0x0,%al
call   10f0 <error@plt>
lea    0x6b1(%rip),%rdi
call   1080 <printf@plt>
mov    -0x58(%rbp),%eax
mov    %eax,-0x88(%rbp)
mov    0x2505(%rip),%rax
mov    (%rax),%eax
mov    0x24e4(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x84(%rbp)
movq   $0x0,-0x80(%rbp)
lea    -0x88(%rbp),%rdi
mov    $0x1,%esi
mov    $0xffffffff,%edx
call   10e0 <poll@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jge    1b3c <main+0x94c>
mov    0x2492(%rip),%rax
mov    (%rax),%rsi
mov    $0x1,%edi
lea    0x66e(%rip),%rdx
mov    $0x0,%al
call   10f0 <error@plt>
cmpl   $0x1,-0x34(%rbp)
jne    1b57 <main+0x967>
lea    0x66a(%rip),%rdi
call   1080 <printf@plt>
jmp    1b63 <main+0x973>
lea    0x674(%rip),%rdi
call   1080 <printf@plt>
mov    -0x58(%rbp),%edi
call   10b0 <close@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jge    1b9c <main+0x9ac>
mov    -0xa0(%rbp),%rcx
mov    0x2432(%rip),%rax
mov    (%rax),%rsi
mov    $0x1,%edi
lea    0x545(%rip),%rdx
mov    $0x0,%al
call   10f0 <error@plt>
mov    -0xa0(%rbp),%rdi
mov    0x2446(%rip),%rax
mov    (%rax),%esi
mov    -0x18(%rbp),%rcx
lea    0x63e(%rip),%rdx
mov    $0x0,%al
call   1090 <snprintf@plt>
mov    %eax,-0x54(%rbp)
cmpl   $0x0,-0x54(%rbp)
jge    1be2 <main+0x9f2>
mov    $0x1,%edi
xor    %eax,%eax
mov    %eax,%esi
lea    0x490(%rip),%rdx
mov    $0x0,%al
call   10f0 <error@plt>
mov    -0x54(%rbp),%eax
mov    0x2404(%rip),%rcx
cmp    (%rcx),%eax
jl     1c0b <main+0xa1b>
mov    $0x1,%edi
xor    %eax,%eax
mov    %eax,%esi
lea    0x479(%rip),%rdx
mov    $0x0,%al
call   10f0 <error@plt>
mov    -0xa0(%rbp),%rdi
mov    0x238f(%rip),%rax
mov    (%rax),%esi
mov    0x23b6(%rip),%rax
or     (%rax),%esi
call   1100 <open@plt>
mov    %eax,-0x58(%rbp)
cmpl   $0x0,-0x58(%rbp)
jge    1c5a <main+0xa6a>
mov    -0xa0(%rbp),%rcx
mov    0x2374(%rip),%rax
mov    (%rax),%rsi
mov    $0x1,%edi
lea    0x43f(%rip),%rdx
mov    $0x0,%al
call   10f0 <error@plt>
mov    -0x90(%rbp),%rdi
mov    -0x58(%rbp),%eax
mov    %eax,-0xa8(%rbp)
call   1060 <strlen@plt>
mov    -0xa8(%rbp),%edi
mov    -0x90(%rbp),%rsi
mov    %rax,%rdx
call   1040 <write@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jge    1cb5 <main+0xac5>
mov    -0xa0(%rbp),%rcx
mov    0x2319(%rip),%rax
mov    (%rax),%rsi
mov    $0x1,%edi
lea    0x493(%rip),%rdx
mov    $0x0,%al
call   10f0 <error@plt>
mov    -0x90(%rbp),%rdi
movslq -0x34(%rbp),%rax
mov    %rax,-0xb0(%rbp)
call   1060 <strlen@plt>
mov    %rax,%rcx
mov    -0xb0(%rbp),%rax
cmp    %rcx,%rax
je     1d03 <main+0xb13>
mov    -0xa0(%rbp),%rcx
mov    0x22cb(%rip),%rax
mov    (%rax),%rsi
mov    $0x1,%edi
lea    0x455(%rip),%rdx
mov    $0x0,%al
call   10f0 <error@plt>
mov    -0x58(%rbp),%edi
call   10b0 <close@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jge    1d3c <main+0xb4c>
mov    -0xa0(%rbp),%rcx
mov    0x2292(%rip),%rax
mov    (%rax),%rsi
mov    $0x1,%edi
lea    0x3a5(%rip),%rdx
mov    $0x0,%al
call   10f0 <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    $0x28,%rsp
mov    0x2de8(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%r12
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r12
mov    %r12,%rsp
mov    %rsp,%rcx
sub    %rax,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rcx,%rsp
mov    %rsp,%rcx
sub    %rax,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rcx,%rsp
lea    0xdc4(%rip),%rdi
call   1060 <opendir@plt>
mov    %rax,%r13
test   %rax,%rax
jne    126d <main+0x7d>
mov    0x2d68(%rip),%rax
mov    (%rax),%rsi
lea    0xdd0(%rip),%rdx
lea    0xd9f(%rip),%rcx
mov    $0x1,%edi
xor    %eax,%eax
call   10f0 <error@plt>
mov    0x2d44(%rip),%r14
mov    %r13,-0x40(%rbp)
jmp    12b0 <main+0xc0>
nopw   0x0(%rax,%rax,1)
mov    %r12d,%edi
call   10b0 <close@plt>
test   %eax,%eax
mov    %r13,%r12
js     13c5 <main+0x1d5>
mov    -0x38(%rbp),%rdi
lea    0xd7b(%rip),%rsi
call   1110 <strstr@plt>
test   %rax,%rax
mov    -0x40(%rbp),%r13
jne    143e <main+0x24e>
movq   $0x0,(%r14)
mov    %r13,%rdi
call   10d0 <readdir@plt>
mov    %rax,%r15
test   %rax,%rax
jne    12ed <main+0xfd>
mov    (%r14),%rsi
test   %rsi,%rsi
je     1429 <main+0x239>
mov    $0x1,%edi
lea    0xd69(%rip),%rdx
lea    0xd1a(%rip),%rcx
xor    %eax,%eax
call   10f0 <error@plt>
mov    (%r15),%rbx
mov    $0x8,%edx
mov    %rbx,%rdi
lea    0xd11(%rip),%rsi
call   1030 <strncmp@plt>
test   %eax,%eax
jne    12b0 <main+0xc0>
mov    %r12,%rdi
mov    0x2cde(%rip),%r12
mov    (%r12),%esi
mov    %rdi,%r13
lea    0xd3f(%rip),%rdx
lea    0xcd9(%rip),%rcx
mov    %rbx,%r8
xor    %eax,%eax
call   1090 <snprintf@plt>
mov    %eax,%ebx
test   %eax,%eax
jns    134c <main+0x15c>
mov    $0x1,%edi
xor    %esi,%esi
lea    0xd26(%rip),%rdx
xor    %eax,%eax
call   10f0 <error@plt>
cmp    (%r12),%ebx
mov    %r12,%rbx
jl     136a <main+0x17a>
mov    $0x1,%edi
xor    %esi,%esi
lea    0xd1a(%rip),%rdx
xor    %eax,%eax
call   10f0 <error@plt>
mov    0x2c67(%rip),%rax
mov    (%rax),%esi
mov    0x2c4e(%rip),%rax
or     (%rax),%esi
mov    %r13,%rdi
call   1100 <open@plt>
mov    %eax,%r12d
test   %eax,%eax
jns    13a4 <main+0x1b4>
mov    (%r14),%rsi
mov    $0x1,%edi
lea    0xcf8(%rip),%rdx
mov    %r13,%rcx
xor    %eax,%eax
call   10f0 <error@plt>
mov    (%rbx),%edx
mov    %r12d,%edi
mov    -0x38(%rbp),%rsi
call   10c0 <read@plt>
mov    %rbx,%rcx
mov    %eax,%ebx
test   %eax,%eax
js     13e3 <main+0x1f3>
cmp    (%rcx),%ebx
jne    1280 <main+0x90>
jmp    140b <main+0x21b>
mov    (%r14),%rsi
mov    $0x1,%edi
lea    0xd06(%rip),%rdx
mov    %r12,%rcx
xor    %eax,%eax
call   10f0 <error@plt>
jmp    1293 <main+0xa3>
mov    (%r14),%rsi
mov    $0x1,%edi
lea    0xcb9(%rip),%rdx
mov    %r13,%rcx
xor    %eax,%eax
call   10f0 <error@plt>
mov    0x2bed(%rip),%rcx
cmp    (%rcx),%ebx
jne    1280 <main+0x90>
mov    (%r14),%rsi
mov    $0x1,%edi
lea    0xca3(%rip),%rdx
mov    %r13,%rcx
xor    %eax,%eax
call   10f0 <error@plt>
jmp    1280 <main+0x90>
lea    0xcc4(%rip),%rdx
mov    $0x1,%edi
xor    %esi,%esi
xor    %eax,%eax
call   10f0 <error@plt>
mov    %r14,%r13
mov    0x2ba8(%rip),%r14
mov    (%r14),%esi
mov    (%r15),%r8
lea    0xcc0(%rip),%rdx
lea    0xba4(%rip),%rcx
mov    %r12,%rdi
xor    %eax,%eax
call   1090 <snprintf@plt>
mov    %eax,%ebx
test   %eax,%eax
jns    1481 <main+0x291>
lea    0xbf8(%rip),%rdx
mov    $0x1,%edi
xor    %esi,%esi
xor    %eax,%eax
call   10f0 <error@plt>
cmp    (%r14),%ebx
mov    %r14,%rbx
jl     149e <main+0x2ae>
lea    0xbed(%rip),%rdx
mov    $0x1,%edi
xor    %esi,%esi
xor    %eax,%eax
call   10f0 <error@plt>
mov    0x2b33(%rip),%rax
mov    (%rax),%esi
mov    0x2b1a(%rip),%rax
or     (%rax),%esi
mov    %r12,%rdi
call   1100 <open@plt>
mov    %eax,%r14d
test   %eax,%eax
jns    14d9 <main+0x2e9>
mov    0x0(%r13),%rsi
lea    0xbc8(%rip),%rdx
mov    $0x1,%edi
mov    %r12,%rcx
xor    %eax,%eax
call   10f0 <error@plt>
mov    (%rbx),%edx
mov    %r14d,%edi
mov    -0x30(%rbp),%rsi
call   10c0 <read@plt>
mov    %rbx,%r15
mov    %eax,%ebx
test   %eax,%eax
jns    150a <main+0x31a>
mov    0x0(%r13),%rsi
lea    0xbb0(%rip),%rdx
mov    $0x1,%edi
mov    %r12,%rcx
xor    %eax,%eax
call   10f0 <error@plt>
cmp    (%r15),%ebx
mov    %r15,%rbx
jne    152c <main+0x33c>
mov    0x0(%r13),%rsi
lea    0xba0(%rip),%rdx
mov    $0x1,%edi
mov    %r12,%rcx
xor    %eax,%eax
call   10f0 <error@plt>
mov    %r14d,%edi
call   10b0 <close@plt>
test   %eax,%eax
jns    1552 <main+0x362>
mov    0x0(%r13),%rsi
lea    0xb97(%rip),%rdx
mov    $0x1,%edi
mov    %r12,%rcx
xor    %eax,%eax
call   10f0 <error@plt>
mov    -0x30(%rbp),%r14
mov    %r14,%rdi
mov    $0xa,%esi
call   1080 <strchr@plt>
test   %rax,%rax
je     1577 <main+0x387>
mov    %rax,%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   10a0 <memset@plt>
mov    (%rbx),%esi
lea    0xba0(%rip),%rdx
lea    0xa79(%rip),%rcx
mov    %r12,%rdi
xor    %eax,%eax
call   1090 <snprintf@plt>
mov    %rbx,%r15
mov    %eax,%ebx
test   %eax,%eax
js     16cd <main+0x4dd>
cmp    (%r15),%ebx
jl     15b8 <main+0x3c8>
lea    0xad3(%rip),%rdx
mov    $0x1,%edi
xor    %esi,%esi
xor    %eax,%eax
call   10f0 <error@plt>
mov    0x29e9(%rip),%rcx
mov    0x2a12(%rip),%rax
mov    (%rax),%esi
or     (%rcx),%esi
mov    %r12,%rdi
call   1100 <open@plt>
mov    %eax,%ebx
test   %eax,%eax
jns    15f2 <main+0x402>
mov    0x0(%r13),%rsi
lea    0xaaf(%rip),%rdx
mov    $0x1,%edi
mov    %r12,%rcx
xor    %eax,%eax
call   10f0 <error@plt>
mov    %r14,%rdi
call   1070 <strlen@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    %rax,%rdx
call   1050 <write@plt>
mov    %ebx,%edi
call   10b0 <close@plt>
test   %eax,%eax
jns    162c <main+0x43c>
mov    0x0(%r13),%rsi
lea    0xabd(%rip),%rdx
mov    $0x1,%edi
mov    %r12,%rcx
xor    %eax,%eax
call   10f0 <error@plt>
mov    0x29bd(%rip),%r15
mov    (%r15),%esi
lea    0xaed(%rip),%rdx
lea    0x9bc(%rip),%rcx
mov    %r12,%rdi
mov    %r14,%r8
xor    %eax,%eax
call   1090 <snprintf@plt>
mov    %eax,%ebx
test   %eax,%eax
js     16f0 <main+0x500>
cmp    (%r15),%ebx
jl     1675 <main+0x485>
lea    0xa16(%rip),%rdx
mov    $0x1,%edi
xor    %esi,%esi
xor    %eax,%eax
call   10f0 <error@plt>
mov    0x295c(%rip),%rax
mov    (%rax),%esi
mov    0x2923(%rip),%rax
or     (%rax),%esi
mov    %r12,%rdi
call   1100 <open@plt>
mov    %eax,%ebx
test   %eax,%eax
jns    16af <main+0x4bf>
mov    0x0(%r13),%rsi
lea    0x9f2(%rip),%rdx
mov    $0x1,%edi
mov    %r12,%rcx
xor    %eax,%eax
call   10f0 <error@plt>
lea    0xa83(%rip),%rsi
mov    $0x7,%edx
mov    %ebx,%edi
call   1050 <write@plt>
test   %eax,%eax
js     1713 <main+0x523>
cmp    $0x7,%eax
jne    172d <main+0x53d>
jmp    1747 <main+0x557>
lea    0x997(%rip),%rdx
mov    $0x1,%edi
xor    %esi,%esi
xor    %eax,%eax
call   10f0 <error@plt>
cmp    (%r15),%ebx
jge    15a3 <main+0x3b3>
jmp    15b8 <main+0x3c8>
lea    0x974(%rip),%rdx
mov    $0x1,%edi
xor    %esi,%esi
xor    %eax,%eax
call   10f0 <error@plt>
cmp    (%r15),%ebx
jge    1660 <main+0x470>
jmp    1675 <main+0x485>
mov    0x0(%r13),%rsi
lea    0xa23(%rip),%rdx
mov    $0x1,%edi
mov    %r12,%rcx
xor    %eax,%eax
call   10f0 <error@plt>
mov    0x0(%r13),%rsi
lea    0xa19(%rip),%rdx
mov    $0x1,%edi
mov    %r12,%rcx
xor    %eax,%eax
call   10f0 <error@plt>
mov    %ebx,%edi
call   10b0 <close@plt>
test   %eax,%eax
jns    176c <main+0x57c>
mov    0x0(%r13),%rsi
lea    0x97d(%rip),%rdx
mov    $0x1,%edi
mov    %r12,%rcx
xor    %eax,%eax
call   10f0 <error@plt>
mov    0x287d(%rip),%r15
mov    (%r15),%esi
lea    0x9f2(%rip),%rdx
lea    0x87c(%rip),%rcx
mov    %r12,%rdi
mov    %r14,%r8
xor    %eax,%eax
call   1090 <snprintf@plt>
mov    %eax,%ebx
test   %eax,%eax
js     187a <main+0x68a>
cmp    (%r15),%ebx
jl     17b5 <main+0x5c5>
lea    0x8d6(%rip),%rdx
mov    $0x1,%edi
xor    %esi,%esi
xor    %eax,%eax
call   10f0 <error@plt>
mov    0x281c(%rip),%rax
mov    (%rax),%esi
mov    0x2803(%rip),%rax
or     (%rax),%esi
mov    %r12,%rdi
call   1100 <open@plt>
mov    %eax,%r14d
test   %eax,%eax
jns    17f0 <main+0x600>
mov    0x0(%r13),%rsi
lea    0x8b1(%rip),%rdx
mov    $0x1,%edi
mov    %r12,%rcx
xor    %eax,%eax
call   10f0 <error@plt>
mov    (%r15),%edx
mov    %r14d,%edi
mov    -0x38(%rbp),%rsi
call   10c0 <read@plt>
mov    %eax,%ebx
test   %eax,%eax
js     189d <main+0x6ad>
cmp    (%r15),%ebx
jne    1828 <main+0x638>
mov    0x0(%r13),%rsi
lea    0x8a4(%rip),%rdx
mov    $0x1,%edi
mov    %r12,%rcx
xor    %eax,%eax
call   10f0 <error@plt>
lea    0x970(%rip),%rdi
call   1040 <puts@plt>
mov    %r14d,-0x50(%rbp)
mov    0x27a9(%rip),%rax
mov    0x278a(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
mov    %ecx,-0x4c(%rbp)
movq   $0x0,-0x48(%rbp)
lea    -0x50(%rbp),%rdi
mov    $0x1,%esi
mov    $0xffffffff,%edx
call   10e0 <poll@plt>
test   %eax,%eax
js     18c5 <main+0x6d5>
cmp    $0x1,%eax
jne    18dc <main+0x6ec>
lea    0x96c(%rip),%rdi
jmp    18e3 <main+0x6f3>
lea    0x7ea(%rip),%rdx
mov    $0x1,%edi
xor    %esi,%esi
xor    %eax,%eax
call   10f0 <error@plt>
cmp    (%r15),%ebx
jge    17a0 <main+0x5b0>
jmp    17b5 <main+0x5c5>
mov    0x0(%r13),%rsi
lea    0x803(%rip),%rdx
mov    $0x1,%edi
mov    %r12,%rcx
xor    %eax,%eax
call   10f0 <error@plt>
cmp    (%r15),%ebx
je     180e <main+0x61e>
jmp    1828 <main+0x638>
mov    0x0(%r13),%rsi
lea    0x8af(%rip),%rdx
mov    $0x1,%edi
xor    %eax,%eax
call   10f0 <error@plt>
lea    0x8df(%rip),%rdi
call   1040 <puts@plt>
mov    %r14d,%edi
call   10b0 <close@plt>
test   %eax,%eax
jns    190e <main+0x71e>
mov    0x0(%r13),%rsi
lea    0x7db(%rip),%rdx
mov    $0x1,%edi
mov    %r12,%rcx
xor    %eax,%eax
call   10f0 <error@plt>
mov    (%r15),%esi
lea    0x87b(%rip),%rdx
lea    0x6e1(%rip),%rcx
mov    %r12,%rdi
xor    %eax,%eax
call   1090 <snprintf@plt>
mov    %eax,%ebx
test   %eax,%eax
js     1a24 <main+0x834>
cmp    (%r15),%ebx
jl     194d <main+0x75d>
lea    0x73e(%rip),%rdx
mov    $0x1,%edi
xor    %esi,%esi
xor    %eax,%eax
call   10f0 <error@plt>
mov    0x2684(%rip),%rax
mov    (%rax),%esi
mov    0x264b(%rip),%rax
or     (%rax),%esi
mov    %r12,%rdi
call   1100 <open@plt>
mov    %eax,%r14d
test   %eax,%eax
jns    1988 <main+0x798>
mov    0x0(%r13),%rsi
lea    0x719(%rip),%rdx
mov    $0x1,%edi
mov    %r12,%rcx
xor    %eax,%eax
call   10f0 <error@plt>
mov    -0x30(%rbp),%rbx
mov    %rbx,%rdi
call   1070 <strlen@plt>
mov    %r14d,%edi
mov    %rbx,%rsi
mov    %rax,%rdx
call   1050 <write@plt>
mov    %eax,%r15d
test   %eax,%eax
jns    19c3 <main+0x7d3>
mov    0x0(%r13),%rsi
lea    0x78d(%rip),%rdx
mov    $0x1,%edi
mov    %r12,%rcx
xor    %eax,%eax
call   10f0 <error@plt>
movslq %r15d,%r15
mov    %rbx,%rdi
call   1070 <strlen@plt>
cmp    %r15,%rax
je     19ed <main+0x7fd>
mov    0x0(%r13),%rsi
lea    0x773(%rip),%rdx
mov    $0x1,%edi
mov    %r12,%rcx
xor    %eax,%eax
call   10f0 <error@plt>
mov    %r14d,%edi
call   10b0 <close@plt>
test   %eax,%eax
jns    1a13 <main+0x823>
mov    0x0(%r13),%rsi
lea    0x6d6(%rip),%rdx
mov    $0x1,%edi
mov    %r12,%rcx
xor    %eax,%eax
call   10f0 <error@plt>
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x640(%rip),%rdx
mov    $0x1,%edi
xor    %esi,%esi
xor    %eax,%eax
call   10f0 <error@plt>
cmp    (%r15),%ebx
jge    1938 <main+0x748>
jmp    194d <main+0x75d>

LLVM IR (-O0):
%struct.dirent = type { i8* }
%struct.pollfd = type { i32, i32, i64 }
@.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 = [15 x i8] c"%s/gpio%s/edge\00"
@.str.16 = [8 x i8] c"falling\00"
@.str.17 = [16 x i8] c"writing to '%s'\00"
@.str.18 = [30 x i8] c"buffer underflow writing '%s'\00"
@.str.19 = [16 x i8] c"%s/gpio%s/value\00"
@.str.20 = [36 x i8] c"Please press the KEY0 push button.\0A\00"
@POLLPRI = global i32 0
@POLLERR = global i32 0
@.str.21 = [20 x i8] c"poll returned error\00"
@.str.22 = [27 x i8] c"KEY0 push button pressed.\0A\00"
@.str.23 = [35 x i8] c"Poll returned value other than 1.\0A\00"
@.str.24 = [12 x i8] c"%s/unexport\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*
%17 = alloca %struct.pollfd
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
%18 = load i8*, i8** %4
%19 = call i64 @strlen(i8* %18)
store i64 %19, i64* %6
%20 = load i32, i32* @PATH_MAX
%21 = zext i32 %20 to i64
%22 = call i8* @llvm.stacksave()
store i8* %22, i8** %9
%23 = alloca i8, i64 %21
store i64 %21, i64* %10
%24 = load i32, i32* @PATH_MAX
%25 = zext i32 %24 to i64
%26 = alloca i8, i64 %25
store i64 %25, i64* %13
%27 = load i32, i32* @PATH_MAX
%28 = zext i32 %27 to i64
%29 = alloca i8, i64 %28
store i64 %28, i64* %14
store i8* null, i8** %15
%30 = load i8*, i8** %3
%31 = call i32* @opendir(i8* %30)
store i32* %31, i32** %2
%32 = load i32*, i32** %2
%33 = icmp eq i32* %32, null
br i1 %33, label %34, label %38
34: ; preds = %0
%35 = load i64, i64* @errno
%36 = load i8*, i8** %3
%37 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %35, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i8* %36)
br label %38
38: ; preds = %34, %0
br label %39
39: ; preds = %121, %63, %38
br label %40
40: ; preds = %39
store i64 0, i64* @errno
%41 = load i32*, i32** %2
%42 = call %struct.dirent* @readdir(i32* %41)
store %struct.dirent* %42, %struct.dirent** %8
%43 = load %struct.dirent*, %struct.dirent** %8
%44 = icmp eq %struct.dirent* %43, null
br i1 %44, label %45, label %54
45: ; preds = %40
%46 = load i64, i64* @errno
%47 = icmp ne i64 %46, 0
br i1 %47, label %48, label %52
48: ; preds = %45
%49 = load i64, i64* @errno
%50 = load i8*, i8** %3
%51 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %49, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i8* %50)
br label %53
52: ; preds = %45
br label %122
53: ; preds = %48
br label %54
54: ; preds = %53, %40
%55 = load %struct.dirent*, %struct.dirent** %8
%56 = getelementptr inbounds %struct.dirent, %struct.dirent* %55, i32 0, i32 0
%57 = load i8*, i8** %56
%58 = load i8*, i8** %4
%59 = load i64, i64* %6
%60 = call i32 @strncmp(i8* %57, i8* %58, i64 %59)
store i32 %60, i32* %7
%61 = load i32, i32* %7
%62 = icmp ne i32 %61, 0
br i1 %62, label %63, label %64
63: ; preds = %54
br label %39
64: ; preds = %54
%65 = load i32, i32* @PATH_MAX
%66 = load i8*, i8** %3
%67 = load %struct.dirent*, %struct.dirent** %8
%68 = getelementptr inbounds %struct.dirent, %struct.dirent* %67, i32 0, i32 0
%69 = load i8*, i8** %68
%70 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %23, i32 %65, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i8* %66, i8* %69)
store i32 %70, i32* %11
%71 = load i32, i32* %11
%72 = icmp slt i32 %71, 0
br i1 %72, label %73, label %75
73: ; preds = %64
%74 = 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 %75
75: ; preds = %73, %64
%76 = load i32, i32* %11
%77 = load i32, i32* @PATH_MAX
%78 = icmp sge i32 %76, %77
br i1 %78, label %79, label %81
79: ; preds = %75
%80 = 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 %81
81: ; preds = %79, %75
%82 = load i32, i32* @O_RDONLY
%83 = load i32, i32* @O_SYNC
%84 = or i32 %82, %83
%85 = call i32 @open(i8* %23, i32 %84)
store i32 %85, i32* %12
%86 = load i32, i32* %12
%87 = icmp slt i32 %86, 0
br i1 %87, label %88, label %91
88: ; preds = %81
%89 = load i64, i64* @errno
%90 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %89, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0), i8* %23)
br label %91
91: ; preds = %88, %81
%92 = load i32, i32* %12
%93 = load i32, i32* @PATH_MAX
%94 = call i32 @read(i32 %92, i8* %26, i32 %93)
store i32 %94, i32* %7
%95 = load i32, i32* %7
%96 = icmp slt i32 %95, 0
br i1 %96, label %97, label %100
97: ; preds = %91
%98 = load i64, i64* @errno
%99 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %98, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0), i8* %23)
br label %100
100: ; preds = %97, %91
%101 = load i32, i32* %7
%102 = load i32, i32* @PATH_MAX
%103 = icmp eq i32 %101, %102
br i1 %103, label %104, label %107
104: ; preds = %100
%105 = load i64, i64* @errno
%106 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %105, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.10, i64 0, i64 0), i8* %23)
br label %107
107: ; preds = %104, %100
%108 = load i32, i32* %12
%109 = call i32 @close(i32 %108)
store i32 %109, i32* %7
%110 = load i32, i32* %7
%111 = icmp slt i32 %110, 0
br i1 %111, label %112, label %115
112: ; preds = %107
%113 = load i64, i64* @errno
%114 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %113, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.11, i64 0, i64 0), i8* %23)
br label %115
115: ; preds = %112, %107
%116 = load i8*, i8** %5
%117 = call i8* @strstr(i8* %26, i8* %116)
store i8* %117, i8** %15
%118 = load i8*, i8** %15
%119 = icmp ne i8* %118, null
br i1 %119, label %120, label %121
120: ; preds = %115
br label %122
121: ; preds = %115
br label %39
122: ; preds = %120, %52
%123 = load i8*, i8** %15
%124 = icmp eq i8* %123, null
br i1 %124, label %125, label %127
125: ; preds = %122
%126 = 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 %127
127: ; preds = %125, %122
%128 = load i32, i32* @PATH_MAX
%129 = load i8*, i8** %3
%130 = load %struct.dirent*, %struct.dirent** %8
%131 = getelementptr inbounds %struct.dirent, %struct.dirent* %130, i32 0, i32 0
%132 = load i8*, i8** %131
%133 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %23, i32 %128, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.13, i64 0, i64 0), i8* %129, i8* %132)
store i32 %133, i32* %11
%134 = load i32, i32* %11
%135 = icmp slt i32 %134, 0
br i1 %135, label %136, label %138
136: ; preds = %127
%137 = 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 %138
138: ; preds = %136, %127
%139 = load i32, i32* %11
%140 = load i32, i32* @PATH_MAX
%141 = icmp sge i32 %139, %140
br i1 %141, label %142, label %144
142: ; preds = %138
%143 = 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 %144
144: ; preds = %142, %138
%145 = load i32, i32* @O_RDONLY
%146 = load i32, i32* @O_SYNC
%147 = or i32 %145, %146
%148 = call i32 @open(i8* %23, i32 %147)
store i32 %148, i32* %12
%149 = load i32, i32* %12
%150 = icmp slt i32 %149, 0
br i1 %150, label %151, label %154
151: ; preds = %144
%152 = load i64, i64* @errno
%153 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %152, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0), i8* %23)
br label %154
154: ; preds = %151, %144
%155 = load i32, i32* %12
%156 = load i32, i32* @PATH_MAX
%157 = call i32 @read(i32 %155, i8* %29, i32 %156)
store i32 %157, i32* %7
%158 = load i32, i32* %7
%159 = icmp slt i32 %158, 0
br i1 %159, label %160, label %163
160: ; preds = %154
%161 = load i64, i64* @errno
%162 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %161, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0), i8* %23)
br label %163
163: ; preds = %160, %154
%164 = load i32, i32* %7
%165 = load i32, i32* @PATH_MAX
%166 = icmp eq i32 %164, %165
br i1 %166, label %167, label %170
167: ; preds = %163
%168 = load i64, i64* @errno
%169 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %168, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.10, i64 0, i64 0), i8* %23)
br label %170
170: ; preds = %167, %163
%171 = load i32, i32* %12
%172 = call i32 @close(i32 %171)
store i32 %172, i32* %7
%173 = load i32, i32* %7
%174 = icmp slt i32 %173, 0
br i1 %174, label %175, label %178
175: ; preds = %170
%176 = load i64, i64* @errno
%177 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %176, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.11, i64 0, i64 0), i8* %23)
br label %178
178: ; preds = %175, %170
%179 = call i8* @strchr(i8* %29, i8 signext 10)
store i8* %179, i8** %16
%180 = load i8*, i8** %16
%181 = icmp ne i8* %180, null
br i1 %181, label %182, label %185
182: ; preds = %178
%183 = load i8*, i8** %16
%184 = call i32 @memset(i8* %183, i8 signext 0, i32 1)
br label %185
185: ; preds = %182, %178
%186 = load i32, i32* @PATH_MAX
%187 = load i8*, i8** %3
%188 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %23, i32 %186, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.14, i64 0, i64 0), i8* %187)
store i32 %188, i32* %11
%189 = load i32, i32* %11
%190 = icmp slt i32 %189, 0
br i1 %190, label %191, label %193
191: ; preds = %185
%192 = 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 %193
193: ; preds = %191, %185
%194 = load i32, i32* %11
%195 = load i32, i32* @PATH_MAX
%196 = icmp sge i32 %194, %195
br i1 %196, label %197, label %199
197: ; preds = %193
%198 = 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 %199
199: ; preds = %197, %193
%200 = load i32, i32* @O_WRONLY
%201 = load i32, i32* @O_SYNC
%202 = or i32 %200, %201
%203 = call i32 @open(i8* %23, i32 %202)
store i32 %203, i32* %12
%204 = load i32, i32* %12
%205 = icmp slt i32 %204, 0
br i1 %205, label %206, label %209
206: ; preds = %199
%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* %23)
br label %209
209: ; preds = %206, %199
%210 = load i32, i32* %12
%211 = call i64 @strlen(i8* %29)
%212 = call i32 @write(i32 %210, i8* %29, i64 %211)
store i32 %212, i32* %7
%213 = load i32, i32* %12
%214 = call i32 @close(i32 %213)
store i32 %214, i32* %7
%215 = load i32, i32* %7
%216 = icmp slt i32 %215, 0
br i1 %216, label %217, label %220
217: ; preds = %209
%218 = load i64, i64* @errno
%219 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %218, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.11, i64 0, i64 0), i8* %23)
br label %220
220: ; preds = %217, %209
%221 = load i32, i32* @PATH_MAX
%222 = load i8*, i8** %3
%223 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %23, i32 %221, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.15, i64 0, i64 0), i8* %222, i8* %29)
store i32 %223, i32* %11
%224 = load i32, i32* %11
%225 = icmp slt i32 %224, 0
br i1 %225, label %226, label %228
226: ; preds = %220
%227 = 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 %228
228: ; preds = %226, %220
%229 = load i32, i32* %11
%230 = load i32, i32* @PATH_MAX
%231 = icmp sge i32 %229, %230
br i1 %231, label %232, label %234
232: ; preds = %228
%233 = 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 %234
234: ; preds = %232, %228
%235 = load i32, i32* @O_WRONLY
%236 = load i32, i32* @O_SYNC
%237 = or i32 %235, %236
%238 = call i32 @open(i8* %23, i32 %237)
store i32 %238, i32* %12
%239 = load i32, i32* %12
%240 = icmp slt i32 %239, 0
br i1 %240, label %241, label %244
241: ; preds = %234
%242 = load i64, i64* @errno
%243 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %242, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0), i8* %23)
br label %244
244: ; preds = %241, %234
%245 = load i32, i32* %12
%246 = call i32 @write(i32 %245, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.16, i64 0, i64 0), i64 7)
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 = %244
%250 = load i64, i64* @errno
%251 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %250, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.17, i64 0, i64 0), i8* %23)
br label %252
252: ; preds = %249, %244
%253 = load i32, i32* %7
%254 = icmp ne i32 %253, 7
br i1 %254, label %255, label %258
255: ; preds = %252
%256 = load i64, i64* @errno
%257 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %256, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.18, i64 0, i64 0), i8* %23)
br label %258
258: ; preds = %255, %252
%259 = load i32, i32* %12
%260 = call i32 @close(i32 %259)
store i32 %260, i32* %7
%261 = load i32, i32* %7
%262 = icmp slt i32 %261, 0
br i1 %262, label %263, label %266
263: ; preds = %258
%264 = load i64, i64* @errno
%265 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %264, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.11, i64 0, i64 0), i8* %23)
br label %266
266: ; preds = %263, %258
%267 = load i32, i32* @PATH_MAX
%268 = load i8*, i8** %3
%269 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %23, i32 %267, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.19, i64 0, i64 0), i8* %268, i8* %29)
store i32 %269, i32* %11
%270 = load i32, i32* %11
%271 = icmp slt i32 %270, 0
br i1 %271, label %272, label %274
272: ; preds = %266
%273 = 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 %274
274: ; preds = %272, %266
%275 = load i32, i32* %11
%276 = load i32, i32* @PATH_MAX
%277 = icmp sge i32 %275, %276
br i1 %277, label %278, label %280
278: ; preds = %274
%279 = 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 %280
280: ; preds = %278, %274
%281 = load i32, i32* @O_RDONLY
%282 = load i32, i32* @O_SYNC
%283 = or i32 %281, %282
%284 = call i32 @open(i8* %23, i32 %283)
store i32 %284, i32* %12
%285 = load i32, i32* %12
%286 = icmp slt i32 %285, 0
br i1 %286, label %287, label %290
287: ; preds = %280
%288 = load i64, i64* @errno
%289 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %288, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0), i8* %23)
br label %290
290: ; preds = %287, %280
%291 = load i32, i32* %12
%292 = load i32, i32* @PATH_MAX
%293 = call i32 @read(i32 %291, i8* %26, i32 %292)
store i32 %293, i32* %7
%294 = load i32, i32* %7
%295 = icmp slt i32 %294, 0
br i1 %295, label %296, label %299
296: ; preds = %290
%297 = load i64, i64* @errno
%298 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %297, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0), i8* %23)
br label %299
299: ; preds = %296, %290
%300 = load i32, i32* %7
%301 = load i32, i32* @PATH_MAX
%302 = icmp eq i32 %300, %301
br i1 %302, label %303, label %306
303: ; preds = %299
%304 = load i64, i64* @errno
%305 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %304, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.10, i64 0, i64 0), i8* %23)
br label %306
306: ; preds = %303, %299
%307 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.20, i64 0, i64 0))
%308 = load i32, i32* %12
%309 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %17, i32 0, i32 0
store i32 %308, i32* %309
%310 = load i32, i32* @POLLPRI
%311 = load i32, i32* @POLLERR
%312 = or i32 %310, %311
%313 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %17, i32 0, i32 1
store i32 %312, i32* %313
%314 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %17, i32 0, i32 2
store i64 0, i64* %314
%315 = call i32 @poll(%struct.pollfd* %17, i32 1, i32 -1)
store i32 %315, i32* %7
%316 = load i32, i32* %7
%317 = icmp slt i32 %316, 0
br i1 %317, label %318, label %321
318: ; preds = %306
%319 = load i64, i64* @errno
%320 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %319, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.21, i64 0, i64 0))
br label %321
321: ; preds = %318, %306
%322 = load i32, i32* %7
%323 = icmp eq i32 %322, 1
br i1 %323, label %324, label %326
324: ; preds = %321
%325 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.22, i64 0, i64 0))
br label %328
326: ; preds = %321
%327 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.23, i64 0, i64 0))
br label %328
328: ; preds = %326, %324
%329 = load i32, i32* %12
%330 = call i32 @close(i32 %329)
store i32 %330, i32* %7
%331 = load i32, i32* %7
%332 = icmp slt i32 %331, 0
br i1 %332, label %333, label %336
333: ; preds = %328
%334 = load i64, i64* @errno
%335 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %334, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.11, i64 0, i64 0), i8* %23)
br label %336
336: ; preds = %333, %328
%337 = load i32, i32* @PATH_MAX
%338 = load i8*, i8** %3
%339 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %23, i32 %337, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.24, i64 0, i64 0), i8* %338)
store i32 %339, i32* %11
%340 = load i32, i32* %11
%341 = icmp slt i32 %340, 0
br i1 %341, label %342, label %344
342: ; preds = %336
%343 = 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 %344
344: ; preds = %342, %336
%345 = load i32, i32* %11
%346 = load i32, i32* @PATH_MAX
%347 = icmp sge i32 %345, %346
br i1 %347, label %348, label %350
348: ; preds = %344
%349 = 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 %350
350: ; preds = %348, %344
%351 = load i32, i32* @O_WRONLY
%352 = load i32, i32* @O_SYNC
%353 = or i32 %351, %352
%354 = call i32 @open(i8* %23, i32 %353)
store i32 %354, i32* %12
%355 = load i32, i32* %12
%356 = icmp slt i32 %355, 0
br i1 %356, label %357, label %360
357: ; preds = %350
%358 = load i64, i64* @errno
%359 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %358, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0), i8* %23)
br label %360
360: ; preds = %357, %350
%361 = load i32, i32* %12
%362 = call i64 @strlen(i8* %29)
%363 = call i32 @write(i32 %361, i8* %29, i64 %362)
store i32 %363, i32* %7
%364 = load i32, i32* %7
%365 = icmp slt i32 %364, 0
br i1 %365, label %366, label %369
366: ; preds = %360
%367 = load i64, i64* @errno
%368 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %367, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.17, i64 0, i64 0), i8* %23)
br label %369
369: ; preds = %366, %360
%370 = load i32, i32* %7
%371 = sext i32 %370 to i64
%372 = call i64 @strlen(i8* %29)
%373 = icmp ne i64 %371, %372
br i1 %373, label %374, label %377
374: ; preds = %369
%375 = load i64, i64* @errno
%376 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %375, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.18, i64 0, i64 0), i8* %23)
br label %377
377: ; preds = %374, %369
%378 = load i32, i32* %12
%379 = call i32 @close(i32 %378)
store i32 %379, i32* %7
%380 = load i32, i32* %7
%381 = icmp slt i32 %380, 0
br i1 %381, label %382, label %385
382: ; preds = %377
%383 = load i64, i64* @errno
%384 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %383, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.11, i64 0, i64 0), i8* %23)
br label %385
385: ; preds = %382, %377
%386 = load i8*, i8** %9
%387 = load i32, i32* %1
ret i32 %387
}

LLVM IR (-O2):
%struct.pollfd = type { i32, i32, i64 }
%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 = [15 x i8] c"%s/gpio%s/edge\00"
@.str.16 = [8 x i8] c"falling\00"
@.str.17 = [16 x i8] c"writing to '%s'\00"
@.str.18 = [30 x i8] c"buffer underflow writing '%s'\00"
@.str.19 = [16 x i8] c"%s/gpio%s/value\00"
@POLLPRI = global i32 0
@POLLERR = global i32 0
@.str.21 = [20 x i8] c"poll returned error\00"
@.str.24 = [12 x i8] c"%s/unexport\00"
@str = [35 x i8] c"Please press the KEY0 push button.\00"
@str.25 = [34 x i8] c"Poll returned value other than 1.\00"
@str.26 = [26 x i8] c"KEY0 push button pressed.\00"
define i32 @main() {
%1 = alloca %struct.pollfd
%2 = load i32, i32* @PATH_MAX
%3 = zext i32 %2 to i64
%4 = alloca i8, i64 %3
%5 = alloca i8, i64 %3
%6 = alloca i8, i64 %3
%7 = bitcast %struct.pollfd* %1 to i8*
%8 = tail call i32* @opendir(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %13
10: ; preds = %0
%11 = load i64, i64* @errno
%12 = tail call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %11, 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 %13
13: ; preds = %10, %0
br label %14
14: ; preds = %27, %13
store i64 0, i64* @errno
%15 = call %struct.dirent* @readdir(i32* %8)
%16 = icmp eq %struct.dirent* %15, null
br i1 %16, label %17, label %22
17: ; preds = %14
%18 = load i64, i64* @errno
%19 = icmp eq i64 %18, 0
br i1 %19, label %70, label %20
20: ; preds = %17
%21 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %18, 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 %22
22: ; preds = %20, %14
%23 = getelementptr inbounds %struct.dirent, %struct.dirent* %15, i64 0, i32 0
%24 = load i8*, i8** %23
%25 = call i32 @strncmp(i8* dereferenceable(1) %24, i8* dereferenceable(9) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i64 8)
%26 = icmp eq i32 %25, 0
br i1 %26, label %28, label %27
27: ; preds = %22, %67
br label %14
28: ; preds = %22
%29 = load i32, i32* @PATH_MAX
%30 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %4, i32 %29, 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* %24)
%31 = icmp slt i32 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %28
%33 = 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 %34
34: ; preds = %32, %28
%35 = load i32, i32* @PATH_MAX
%36 = icmp slt i32 %30, %35
br i1 %36, label %39, label %37
37: ; preds = %34
%38 = 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 %39
39: ; preds = %37, %34
%40 = load i32, i32* @O_RDONLY
%41 = load i32, i32* @O_SYNC
%42 = or i32 %41, %40
%43 = call i32 @open(i8* %4, i32 %42)
%44 = icmp slt i32 %43, 0
br i1 %44, label %45, label %48
45: ; preds = %39
%46 = load i64, i64* @errno
%47 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %46, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0), i8* %4)
br label %48
48: ; preds = %45, %39
%49 = load i32, i32* @PATH_MAX
%50 = call i32 @read(i32 %43, i8* %5, i32 %49)
%51 = icmp slt i32 %50, 0
br i1 %51, label %52, label %55
52: ; preds = %48
%53 = load i64, i64* @errno
%54 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %53, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0), i8* %4)
br label %55
55: ; preds = %52, %48
%56 = load i32, i32* @PATH_MAX
%57 = icmp eq i32 %50, %56
br i1 %57, label %58, label %61
58: ; preds = %55
%59 = load i64, i64* @errno
%60 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %59, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.10, i64 0, i64 0), i8* %4)
br label %61
61: ; preds = %58, %55
%62 = call i32 @close(i32 %43)
%63 = icmp slt i32 %62, 0
br i1 %63, label %64, label %67
64: ; preds = %61
%65 = load i64, i64* @errno
%66 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %65, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.11, i64 0, i64 0), i8* %4)
br label %67
67: ; preds = %64, %61
%68 = call i8* @strstr(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%69 = icmp eq i8* %68, null
br i1 %69, label %27, label %72
70: ; preds = %17
%71 = 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 %72
72: ; preds = %67, %70
%73 = load i32, i32* @PATH_MAX
%74 = getelementptr inbounds %struct.dirent, %struct.dirent* %15, i64 0, i32 0
%75 = load i8*, i8** %74
%76 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %4, i32 %73, 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* %75)
%77 = icmp slt i32 %76, 0
br i1 %77, label %78, label %80
78: ; preds = %72
%79 = 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 %80
80: ; preds = %78, %72
%81 = load i32, i32* @PATH_MAX
%82 = icmp slt i32 %76, %81
br i1 %82, label %85, label %83
83: ; preds = %80
%84 = 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 %85
85: ; preds = %83, %80
%86 = load i32, i32* @O_RDONLY
%87 = load i32, i32* @O_SYNC
%88 = or i32 %87, %86
%89 = call i32 @open(i8* %4, i32 %88)
%90 = icmp slt i32 %89, 0
br i1 %90, label %91, label %94
91: ; preds = %85
%92 = load i64, i64* @errno
%93 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %92, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0), i8* %4)
br label %94
94: ; preds = %91, %85
%95 = load i32, i32* @PATH_MAX
%96 = call i32 @read(i32 %89, i8* %6, i32 %95)
%97 = icmp slt i32 %96, 0
br i1 %97, label %98, label %101
98: ; preds = %94
%99 = load i64, i64* @errno
%100 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %99, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0), i8* %4)
br label %101
101: ; preds = %98, %94
%102 = load i32, i32* @PATH_MAX
%103 = icmp eq i32 %96, %102
br i1 %103, label %104, label %107
104: ; preds = %101
%105 = load i64, i64* @errno
%106 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %105, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.10, i64 0, i64 0), i8* %4)
br label %107
107: ; preds = %104, %101
%108 = call i32 @close(i32 %89)
%109 = icmp slt i32 %108, 0
br i1 %109, label %110, label %113
110: ; preds = %107
%111 = load i64, i64* @errno
%112 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %111, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.11, i64 0, i64 0), i8* %4)
br label %113
113: ; preds = %110, %107
%114 = call i8* @strchr(i8* %6, i8 signext 10)
%115 = icmp eq i8* %114, null
br i1 %115, label %118, label %116
116: ; preds = %113
%117 = call i32 @memset(i8* %114, i8 signext 0, i32 1)
br label %118
118: ; preds = %116, %113
%119 = load i32, i32* @PATH_MAX
%120 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %4, i32 %119, 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))
%121 = icmp slt i32 %120, 0
br i1 %121, label %122, label %124
122: ; preds = %118
%123 = 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 %124
124: ; preds = %122, %118
%125 = load i32, i32* @PATH_MAX
%126 = icmp slt i32 %120, %125
br i1 %126, label %129, label %127
127: ; preds = %124
%128 = 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 %129
129: ; preds = %127, %124
%130 = load i32, i32* @O_WRONLY
%131 = load i32, i32* @O_SYNC
%132 = or i32 %131, %130
%133 = call i32 @open(i8* %4, i32 %132)
%134 = icmp slt i32 %133, 0
br i1 %134, label %135, label %138
135: ; preds = %129
%136 = load i64, i64* @errno
%137 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %136, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0), i8* %4)
br label %138
138: ; preds = %135, %129
%139 = call i64 @strlen(i8* %6)
%140 = call i32 @write(i32 %133, i8* %6, i64 %139)
%141 = call i32 @close(i32 %133)
%142 = icmp slt i32 %141, 0
br i1 %142, label %143, label %146
143: ; preds = %138
%144 = load i64, i64* @errno
%145 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %144, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.11, i64 0, i64 0), i8* %4)
br label %146
146: ; preds = %143, %138
%147 = load i32, i32* @PATH_MAX
%148 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %4, i32 %147, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.15, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %6)
%149 = icmp slt i32 %148, 0
br i1 %149, label %150, label %152
150: ; preds = %146
%151 = 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 %152
152: ; preds = %150, %146
%153 = load i32, i32* @PATH_MAX
%154 = icmp slt i32 %148, %153
br i1 %154, label %157, label %155
155: ; preds = %152
%156 = 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 %157
157: ; preds = %155, %152
%158 = load i32, i32* @O_WRONLY
%159 = load i32, i32* @O_SYNC
%160 = or i32 %159, %158
%161 = call i32 @open(i8* %4, i32 %160)
%162 = icmp slt i32 %161, 0
br i1 %162, label %163, label %166
163: ; preds = %157
%164 = load i64, i64* @errno
%165 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %164, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0), i8* %4)
br label %166
166: ; preds = %163, %157
%167 = call i32 @write(i32 %161, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.16, i64 0, i64 0), i64 7)
%168 = icmp slt i32 %167, 0
br i1 %168, label %169, label %172
169: ; preds = %166
%170 = load i64, i64* @errno
%171 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %170, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.17, i64 0, i64 0), i8* %4)
br label %174
172: ; preds = %166
%173 = icmp eq i32 %167, 7
br i1 %173, label %177, label %174
174: ; preds = %169, %172
%175 = load i64, i64* @errno
%176 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %175, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.18, i64 0, i64 0), i8* %4)
br label %177
177: ; preds = %174, %172
%178 = call i32 @close(i32 %161)
%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* %4)
br label %183
183: ; preds = %180, %177
%184 = load i32, i32* @PATH_MAX
%185 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %4, i32 %184, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.19, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %6)
%186 = icmp slt i32 %185, 0
br i1 %186, label %187, label %189
187: ; preds = %183
%188 = 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 %189
189: ; preds = %187, %183
%190 = load i32, i32* @PATH_MAX
%191 = icmp slt i32 %185, %190
br i1 %191, label %194, label %192
192: ; preds = %189
%193 = 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 %194
194: ; preds = %192, %189
%195 = load i32, i32* @O_RDONLY
%196 = load i32, i32* @O_SYNC
%197 = or i32 %196, %195
%198 = call i32 @open(i8* %4, i32 %197)
%199 = icmp slt i32 %198, 0
br i1 %199, label %200, label %203
200: ; preds = %194
%201 = load i64, i64* @errno
%202 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %201, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0), i8* %4)
br label %203
203: ; preds = %200, %194
%204 = load i32, i32* @PATH_MAX
%205 = call i32 @read(i32 %198, i8* %5, i32 %204)
%206 = icmp slt i32 %205, 0
br i1 %206, label %207, label %210
207: ; preds = %203
%208 = load i64, i64* @errno
%209 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %208, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0), i8* %4)
br label %210
210: ; preds = %207, %203
%211 = load i32, i32* @PATH_MAX
%212 = icmp eq i32 %205, %211
br i1 %212, label %213, label %216
213: ; preds = %210
%214 = load i64, i64* @errno
%215 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %214, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.10, i64 0, i64 0), i8* %4)
br label %216
216: ; preds = %213, %210
%217 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str, i64 0, i64 0))
%218 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %1, i64 0, i32 0
store i32 %198, i32* %218
%219 = load i32, i32* @POLLPRI
%220 = load i32, i32* @POLLERR
%221 = or i32 %220, %219
%222 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %1, i64 0, i32 1
store i32 %221, i32* %222
%223 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %1, i64 0, i32 2
store i64 0, i64* %223
%224 = call i32 @poll(%struct.pollfd* %1, i32 1, i32 -1)
%225 = icmp slt i32 %224, 0
br i1 %225, label %226, label %229
226: ; preds = %216
%227 = load i64, i64* @errno
%228 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %227, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.21, i64 0, i64 0))
br label %231
229: ; preds = %216
%230 = icmp eq i32 %224, 1
br i1 %230, label %232, label %231
231: ; preds = %226, %229
br label %232
232: ; preds = %229, %231
%233 = phi i8* [ getelementptr inbounds ([34 x i8], [34 x i8]* @str.25, i64 0, i64 0), %231 ], [ getelementptr inbounds ([26 x i8], [26 x i8]* @str.26, i64 0, i64 0), %229 ]
%234 = call i32 @puts(i8* dereferenceable(1) %233)
%235 = call i32 @close(i32 %198)
%236 = icmp slt i32 %235, 0
br i1 %236, label %237, label %240
237: ; preds = %232
%238 = load i64, i64* @errno
%239 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %238, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.11, i64 0, i64 0), i8* %4)
br label %240
240: ; preds = %237, %232
%241 = load i32, i32* @PATH_MAX
%242 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %4, i32 %241, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.24, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%243 = icmp slt i32 %242, 0
br i1 %243, label %244, label %246
244: ; preds = %240
%245 = 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 %246
246: ; preds = %244, %240
%247 = load i32, i32* @PATH_MAX
%248 = icmp slt i32 %242, %247
br i1 %248, label %251, label %249
249: ; preds = %246
%250 = 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 %251
251: ; preds = %249, %246
%252 = load i32, i32* @O_WRONLY
%253 = load i32, i32* @O_SYNC
%254 = or i32 %253, %252
%255 = call i32 @open(i8* %4, i32 %254)
%256 = icmp slt i32 %255, 0
br i1 %256, label %257, label %260
257: ; preds = %251
%258 = load i64, i64* @errno
%259 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %258, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0), i8* %4)
br label %260
260: ; preds = %257, %251
%261 = call i64 @strlen(i8* %6)
%262 = call i32 @write(i32 %255, i8* %6, i64 %261)
%263 = icmp slt i32 %262, 0
br i1 %263, label %264, label %267
264: ; preds = %260
%265 = load i64, i64* @errno
%266 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %265, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.17, i64 0, i64 0), i8* %4)
br label %267
267: ; preds = %264, %260
%268 = sext i32 %262 to i64
%269 = call i64 @strlen(i8* %6)
%270 = icmp eq i64 %269, %268
br i1 %270, label %274, label %271
271: ; preds = %267
%272 = load i64, i64* @errno
%273 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %272, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.18, i64 0, i64 0), i8* %4)
br label %274
274: ; preds = %271, %267
%275 = call i32 @close(i32 %255)
%276 = icmp slt i32 %275, 0
br i1 %276, label %277, label %280
277: ; preds = %274
%278 = load i64, i64* @errno
%279 = call i32 (i32, i64, i8*, ...) @error(i32 1, i64 %278, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.11, i64 0, i64 0), i8* %4)
br label %280
280: ; preds = %277, %274
ret i32 0
}