#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 option {
  char *member_0;
  char member_3;
  int /*<<< orphan*/ member_2;
  int /*<<< orphan*/ const member_1;
};
struct gpiohandle_request {
  unsigned int *lineoffsets;
  scalar_t__ flags;
  int lines;
  char *values;
  int fd;
  int /*<<< orphan*/ consumer_label;
};
struct gpiohandle_data {
  unsigned int *lineoffsets;
  scalar_t__ flags;
  int lines;
  char *values;
  int fd;
  int /*<<< orphan*/ consumer_label;
};

/* Variables and functions */
int EINVAL;
int ENOMEM;
int GPIOHANDLES_MAX;
int /*<<< orphan*/ GPIOHANDLE_GET_LINE_VALUES_IOCTL;
void *GPIOHANDLE_REQUEST_INPUT;
scalar_t__ GPIOHANDLE_REQUEST_OUTPUT;
int /*<<< orphan*/ GPIOHANDLE_SET_LINE_VALUES_IOCTL;
int /*<<< orphan*/ GPIO_GET_LINEHANDLE_IOCTL;
int asprintf(char **, char *, char *);
int close(int);
int errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ free(char *);
int getopt_long(int, char **, char *, struct option *, int *);
int ioctl(int, int /*<<< orphan*/, struct gpiohandle_request *);
int open(char *, int /*<<< orphan*/);
char *optarg;
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ print_usage();
int /*<<< orphan*/ printf(char *, char *, unsigned int, char);
#define required_argument 128
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(int /*<<< orphan*/, char *);
int strlen(char *);
unsigned int strtoul(char *, int /*<<< orphan*/ *, int);
int main(int argc, char **argv) {
  int fd;
  char *gpio_name = NULL;
  unsigned int lines[GPIOHANDLES_MAX];
  char *value = NULL;
  char *direction = NULL;
  int nlines = 0;
  char *chrdev_name;
  struct gpiohandle_request req;
  struct gpiohandle_data data;
  int ret;
  int opt_i = 0;
  int c;
  int i;
  static struct option long_opts[] = {
      {"direction", required_argument, 0, 'd'},
      {"name", required_argument, 0, 'n'},
      {"offset", required_argument, 0, 'o'},
      {"value", required_argument, 0, 'v'},
      {0, 0, 0, 0},
  };
  while ((c = getopt_long(argc, argv, "d:n:o:v:", long_opts, &opt_i)) != -1) {
    switch (c) {
    case 'd':
      direction = optarg;
      break;
    case 'n':
      gpio_name = optarg;
      break;
    case 'o':
      lines[nlines] = strtoul(optarg, NULL, 10);
      nlines++;
      break;
    case 'v':
      value = optarg;
      break;
    case '?':
      print_usage();
      return 0;
      break;
    }
  }
  if (!gpio_name || !nlines) {
    print_usage();
    return -EINVAL;
  }
  ret = asprintf(&chrdev_name, "/dev/%s", gpio_name);
  if (ret < 0) {
    fprintf(stderr, "Out of memory\n", chrdev_name);
    return -ENOMEM;
  }
  fd = open(chrdev_name, 0);
  if (fd < 0) {
    ret = -errno;
    fprintf(stderr, "Failed to open %s\n", chrdev_name);
    goto exit_free_error;
  }
  for (i = 0; i < nlines; i++)
    req.lineoffsets[i] = lines[i];
  if (direction) {
    if (strcmp(direction, "out") == 0)
      req.flags = GPIOHANDLE_REQUEST_OUTPUT;
    else if (strcmp(direction, "in") == 0)
      req.flags = GPIOHANDLE_REQUEST_INPUT;
    else {
      fprintf(stderr, "Invalid direction %s\n", direction);
      ret = -EINVAL;
      goto exit_close_error;
    }
  } else {
    req.flags = GPIOHANDLE_REQUEST_INPUT;
  }
  strcpy(req.consumer_label, "gpio-util");
  req.lines = nlines;
  ret = ioctl(fd, GPIO_GET_LINEHANDLE_IOCTL, &req);
  if (ret == -1) {
    ret = -errno;
    fprintf(stderr,
            "Failed to issue GET LINEHANDLE "
            "IOCTL (%d)\n",
            ret);
    goto exit_close_error;
  }
  if (value && (req.flags == GPIOHANDLE_REQUEST_OUTPUT)) {
    for (i = 0; i < nlines; i++)
      data.values[i] = value[i % strlen(value)] - '0';
    ret = ioctl(req.fd, GPIOHANDLE_SET_LINE_VALUES_IOCTL, &data);
    if (ret == -1) {
      ret = -errno;
      fprintf(stderr,
              "Failed to issue GPIOHANDLE SET LINE "
              "VALUES IOCTL (%d)\n",
              ret);
      goto exit_close_error;
    }
  }
  ret = ioctl(req.fd, GPIOHANDLE_GET_LINE_VALUES_IOCTL, &data);
  if (ret == -1) {
    ret = -errno;
    fprintf(stderr,
            "Failed to issue GPIOHANDLE GET LINE "
            "VALUES IOCTL (%d)\n",
            ret);
    goto exit_close_error;
  }
  for (i = 0; i < nlines; i++) {
    printf("%s[%d] = %d\n", gpio_name, lines[i], data.values[i]);
  }
exit_close_error:
  if (close(fd) == -1)
    perror("Failed to close GPIO character device file");
exit_free_error:
  free(chrdev_name);
  return ret;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
mov    0x2dc8(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x28(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0xc0(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
movq   $0x0,-0x40(%rbp)
movl   $0x0,-0x44(%rbp)
movl   $0x0,-0xa8(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xdbc(%rip),%rdx
lea    0x2e39(%rip),%rcx
lea    -0xa8(%rbp),%r8
call   1060 <getopt_long@plt>
mov    %eax,-0xac(%rbp)
cmp    $0xffffffff,%eax
je     137d <main+0x19d>
mov    -0xac(%rbp),%eax
mov    %eax,-0xc4(%rbp)
sub    $0x3f,%eax
je     135b <main+0x17b>
jmp    129c <main+0xbc>
mov    -0xc4(%rbp),%eax
sub    $0x64,%eax
je     12ec <main+0x10c>
jmp    12b0 <main+0xd0>
mov    -0xc4(%rbp),%eax
sub    $0x6e,%eax
je     12ff <main+0x11f>
jmp    12c4 <main+0xe4>
mov    -0xc4(%rbp),%eax
sub    $0x6f,%eax
je     1312 <main+0x132>
jmp    12d8 <main+0xf8>
mov    -0xc4(%rbp),%eax
sub    $0x76,%eax
je     1348 <main+0x168>
jmp    1378 <main+0x198>
mov    0x2d05(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x40(%rbp)
jmp    1378 <main+0x198>
mov    0x2cf2(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
jmp    1378 <main+0x198>
mov    0x2cdf(%rip),%rax
mov    (%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   10f0 <strtoul@plt>
mov    %eax,%edx
mov    -0xc0(%rbp),%rax
movslq -0x44(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1378 <main+0x198>
mov    0x2ca9(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
jmp    1378 <main+0x198>
mov    $0x0,%al
call   1100 <print_usage@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0xb4(%rbp)
jmp    17c7 <main+0x5e7>
jmp    1252 <main+0x72>
cmpq   $0x0,-0x20(%rbp)
je     1392 <main+0x1b2>
cmpl   $0x0,-0x44(%rbp)
jne    13b6 <main+0x1d6>
mov    $0x0,%al
call   1100 <print_usage@plt>
xor    %eax,%eax
mov    0x2bee(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0xb4(%rbp)
jmp    17c7 <main+0x5e7>
mov    -0x20(%rbp),%rdx
lea    -0x50(%rbp),%rdi
lea    0xc60(%rip),%rsi
call   10c0 <asprintf@plt>
mov    %eax,-0xa4(%rbp)
cmpl   $0x0,-0xa4(%rbp)
jge    1415 <main+0x235>
mov    0x2bc4(%rip),%rax
mov    (%rax),%edi
mov    -0x50(%rbp),%rdx
lea    0xc3c(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
xor    %eax,%eax
mov    0x2bb7(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0xb4(%rbp)
jmp    17c7 <main+0x5e7>
mov    -0x50(%rbp),%rdi
xor    %esi,%esi
call   10d0 <open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    145e <main+0x27e>
xor    %eax,%eax
mov    0x2b6a(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0xa4(%rbp)
mov    0x2b63(%rip),%rax
mov    (%rax),%edi
mov    -0x50(%rbp),%rdx
lea    0xbea(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
jmp    17ab <main+0x5cb>
movl   $0x0,-0xb0(%rbp)
mov    -0xb0(%rbp),%eax
cmp    -0x44(%rbp),%eax
jge    14aa <main+0x2ca>
mov    -0xc0(%rbp),%rax
movslq -0xb0(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x78(%rbp),%rax
movslq -0xb0(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0xb0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb0(%rbp)
jmp    1468 <main+0x288>
cmpq   $0x0,-0x40(%rbp)
je     154a <main+0x36a>
mov    -0x40(%rbp),%rdi
lea    0xb8f(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%rax
jne    14e2 <main+0x302>
mov    0x2b02(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x70(%rbp)
jmp    1545 <main+0x365>
mov    -0x40(%rbp),%rdi
lea    0xb66(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%rax
jne    150f <main+0x32f>
mov    0x2a95(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x70(%rbp)
jmp    1540 <main+0x360>
mov    0x2a92(%rip),%rax
mov    (%rax),%edi
mov    -0x40(%rbp),%rdx
lea    0xb33(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
xor    %eax,%eax
mov    0x2a5d(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0xa4(%rbp)
jmp    1789 <main+0x5a9>
jmp    1545 <main+0x365>
jmp    1558 <main+0x378>
mov    0x2a47(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x70(%rbp)
mov    -0x54(%rbp),%edi
lea    0xb0a(%rip),%rsi
call   1040 <strcpy@plt>
mov    -0x44(%rbp),%eax
mov    %eax,-0x68(%rbp)
mov    -0x14(%rbp),%edi
mov    0x2a49(%rip),%rax
mov    (%rax),%esi
lea    -0x78(%rbp),%rdx
call   1080 <ioctl@plt>
mov    %eax,-0xa4(%rbp)
cmpl   $0xffffffff,-0xa4(%rbp)
jne    15c8 <main+0x3e8>
xor    %eax,%eax
mov    0x2a02(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0xa4(%rbp)
mov    0x29fb(%rip),%rax
mov    (%rax),%edi
mov    -0xa4(%rbp),%edx
lea    0xaba(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
jmp    1789 <main+0x5a9>
cmpq   $0x0,-0x38(%rbp)
je     16c6 <main+0x4e6>
mov    -0x70(%rbp),%rax
mov    0x29fa(%rip),%rcx
cmp    (%rcx),%rax
jne    16c6 <main+0x4e6>
movl   $0x0,-0xb0(%rbp)
mov    -0xb0(%rbp),%eax
cmp    -0x44(%rbp),%eax
jge    1663 <main+0x483>
mov    -0x38(%rbp),%rax
mov    %rax,-0xd0(%rbp)
mov    -0xb0(%rbp),%eax
mov    %eax,-0xd4(%rbp)
mov    -0x38(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0xd4(%rbp),%eax
cltd
idiv   %ecx
mov    -0xd0(%rbp),%rax
movslq %edx,%rcx
movsbl (%rax,%rcx,1),%eax
sub    $0x30,%eax
mov    %al,%dl
mov    -0x88(%rbp),%rax
movslq -0xb0(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0xb0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb0(%rbp)
jmp    15f1 <main+0x411>
mov    -0x58(%rbp),%edi
mov    0x2943(%rip),%rax
mov    (%rax),%esi
lea    -0xa0(%rbp),%rdx
call   1080 <ioctl@plt>
mov    %eax,-0xa4(%rbp)
cmpl   $0xffffffff,-0xa4(%rbp)
jne    16c1 <main+0x4e1>
xor    %eax,%eax
mov    0x2909(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0xa4(%rbp)
mov    0x2902(%rip),%rax
mov    (%rax),%edi
mov    -0xa4(%rbp),%edx
lea    0x9ec(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
jmp    1789 <main+0x5a9>
jmp    16c6 <main+0x4e6>
mov    -0x58(%rbp),%edi
mov    0x2918(%rip),%rax
mov    (%rax),%esi
lea    -0xa0(%rbp),%rdx
call   1080 <ioctl@plt>
mov    %eax,-0xa4(%rbp)
cmpl   $0xffffffff,-0xa4(%rbp)
jne    1724 <main+0x544>
xor    %eax,%eax
mov    0x28a6(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0xa4(%rbp)
mov    0x289f(%rip),%rax
mov    (%rax),%edi
mov    -0xa4(%rbp),%edx
lea    0x9c0(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
jmp    1789 <main+0x5a9>
movl   $0x0,-0xb0(%rbp)
mov    -0xb0(%rbp),%eax
cmp    -0x44(%rbp),%eax
jge    1784 <main+0x5a4>
mov    -0xc0(%rbp),%rax
mov    -0x20(%rbp),%rsi
movslq -0xb0(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x88(%rbp),%rax
movslq -0xb0(%rbp),%rcx
lea    0x9a8(%rip),%rdi
movsbl (%rax,%rcx,1),%ecx
call   1070 <printf@plt>
mov    -0xb0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb0(%rbp)
jmp    172e <main+0x54e>
jmp    1789 <main+0x5a9>
mov    -0x14(%rbp),%edi
call   1090 <close@plt>
cmp    $0xffffffff,%eax
jne    17a6 <main+0x5c6>
lea    0x97b(%rip),%rdi
call   10e0 <perror@plt>
jmp    17ab <main+0x5cb>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
mov    -0xa4(%rbp),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0xb4(%rbp)
mov    -0x28(%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    $0x88,%rsp
mov    %rsi,%rbx
mov    %edi,%r12d
mov    0x2dbf(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rcx
mov    %rcx,-0x58(%rbp)
mov    %rcx,%rsp
movl   $0x0,-0x4c(%rbp)
xor    %eax,%eax
mov    %rax,-0x60(%rbp)
lea    0x2e60(%rip),%r13
lea    -0x4c(%rbp),%r15
lea    0xdb5(%rip),%r14
xor    %eax,%eax
mov    %rax,-0x40(%rbp)
xor    %eax,%eax
mov    %rax,-0x30(%rbp)
xor    %eax,%eax
mov    %rax,-0x48(%rbp)
nopl   (%rax)
mov    %r12d,%edi
mov    %rbx,%rsi
lea    0xdfb(%rip),%rdx
mov    %r13,%rcx
mov    %r15,%r8
call   1060 <getopt_long@plt>
lea    -0x64(%rax),%ecx
cmp    $0x12,%ecx
ja     12a0 <main+0xb0>
movslq (%r14,%rcx,4),%rax
add    %r14,%rax
jmp    *%rax
mov    0x2d68(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
jmp    1260 <main+0x70>
nopl   0x0(%rax)
cmp    $0xffffffff,%eax
je     1302 <main+0x112>
cmp    $0x3f,%eax
jne    1260 <main+0x70>
jmp    13ce <main+0x1de>
mov    0x2d42(%rip),%rax
mov    (%rax),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1100 <strtoul@plt>
mov    -0x48(%rbp),%rdx
movslq %edx,%rdx
mov    -0x58(%rbp),%rcx
mov    %eax,(%rcx,%rdx,4)
add    $0x1,%edx
mov    %rdx,-0x48(%rbp)
jmp    1260 <main+0x70>
mov    0x2d15(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x40(%rbp)
jmp    1260 <main+0x70>
mov    0x2d02(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x60(%rbp)
jmp    1260 <main+0x70>
mov    -0x60(%rbp),%rbx
test   %rbx,%rbx
mov    -0x48(%rbp),%r15
je     13dd <main+0x1ed>
test   %r15d,%r15d
je     13dd <main+0x1ed>
lea    0xd4e(%rip),%rsi
lea    -0x38(%rbp),%rdi
mov    %rbx,%rdx
call   10d0 <asprintf@plt>
test   %eax,%eax
js     13f6 <main+0x206>
mov    -0x38(%rbp),%rdi
xor    %esi,%esi
call   10e0 <open@plt>
test   %eax,%eax
js     1423 <main+0x233>
mov    %eax,%r13d
test   %r15d,%r15d
mov    -0x58(%rbp),%r14
jle    1365 <main+0x175>
mov    %r15d,%edx
shl    $0x2,%rdx
mov    %r14,%rsi
call   10c0 <memcpy@plt>
mov    -0x30(%rbp),%r12
test   %r12,%r12
je     1450 <main+0x260>
lea    0xd22(%rip),%rsi
mov    %r12,%rdi
call   10a0 <strcmp@plt>
test   %rax,%rax
je     1459 <main+0x269>
lea    0xd0e(%rip),%rsi
mov    %r12,%rdi
call   10a0 <strcmp@plt>
test   %rax,%rax
je     1450 <main+0x260>
mov    0x2bff(%rip),%rax
mov    (%rax),%edi
lea    0xcf0(%rip),%rsi
mov    %r12,%rdx
xor    %r12d,%r12d
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    0x2bca(%rip),%rax
sub    (%rax),%r12d
jmp    15a2 <main+0x3b2>
xor    %r12d,%r12d
xor    %eax,%eax
call   1110 <print_usage@plt>
jmp    15b8 <main+0x3c8>
xor    %r12d,%r12d
xor    %eax,%eax
call   1110 <print_usage@plt>
mov    0x2ba2(%rip),%rax
sub    (%rax),%r12d
jmp    15b8 <main+0x3c8>
mov    0x2bab(%rip),%rax
mov    (%rax),%edi
mov    -0x38(%rbp),%rdx
lea    0xc6f(%rip),%rsi
xor    %r12d,%r12d
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    0x2b9d(%rip),%rax
sub    (%rax),%r12d
jmp    15b8 <main+0x3c8>
mov    0x2b76(%rip),%rax
xor    %r12d,%r12d
sub    (%rax),%r12d
mov    0x2b71(%rip),%rax
mov    (%rax),%edi
mov    -0x38(%rbp),%rdx
lea    0xc44(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
jmp    15af <main+0x3bf>
mov    0x2b41(%rip),%rax
jmp    1460 <main+0x270>
mov    0x2b78(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x80(%rbp)
lea    0xc4a(%rip),%rsi
call   1040 <strcpy@plt>
mov    %r15d,-0x78(%rbp)
mov    0x2b42(%rip),%rax
mov    (%rax),%esi
lea    -0x88(%rbp),%rdx
mov    %r13d,%edi
call   1080 <ioctl@plt>
cmp    $0xffffffff,%eax
je     153d <main+0x34d>
cmpq   $0x0,-0x40(%rbp)
je     14d9 <main+0x2e9>
mov    -0x80(%rbp),%rax
mov    0x2b2e(%rip),%rcx
cmp    (%rcx),%rax
jne    14d9 <main+0x2e9>
test   %r15d,%r15d
jg     15d8 <main+0x3e8>
mov    -0x68(%rbp),%edi
mov    0x2aee(%rip),%rax
mov    (%rax),%esi
lea    -0xb0(%rbp),%rdx
call   1080 <ioctl@plt>
cmp    $0xffffffff,%eax
je     157b <main+0x38b>
mov    -0x68(%rbp),%edi
mov    0x2b05(%rip),%rax
mov    (%rax),%esi
lea    -0xb0(%rbp),%rdx
call   1080 <ioctl@plt>
cmp    $0xffffffff,%eax
je     155c <main+0x36c>
mov    %eax,%r12d
test   %r15d,%r15d
jle    15a2 <main+0x3b2>
mov    %r13d,-0x30(%rbp)
mov    %r15d,%r13d
mov    %rbx,%r15
xor    %ebx,%ebx
xchg   %ax,%ax
mov    (%r14,%rbx,4),%edx
mov    -0x98(%rbp),%rax
movsbl (%rax,%rbx,1),%ecx
lea    0xc35(%rip),%rdi
mov    %r15,%rsi
call   1070 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r13
jne    1510 <main+0x320>
mov    -0x30(%rbp),%r13d
jmp    15a2 <main+0x3b2>
mov    0x2a5c(%rip),%rax
xor    %r12d,%r12d
sub    (%rax),%r12d
mov    0x2a57(%rip),%rax
mov    (%rax),%edi
lea    0xb68(%rip),%rsi
jmp    1598 <main+0x3a8>
mov    0x2a3d(%rip),%rax
xor    %r12d,%r12d
sub    (%rax),%r12d
mov    0x2a38(%rip),%rax
mov    (%rax),%edi
lea    0xbab(%rip),%rsi
jmp    1598 <main+0x3a8>
mov    0x2a1e(%rip),%rax
xor    %r12d,%r12d
sub    (%rax),%r12d
mov    0x2a19(%rip),%rax
mov    (%rax),%edi
lea    0xb55(%rip),%rsi
mov    %r12d,%edx
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    %r13d,%edi
call   1090 <close@plt>
cmp    $0xffffffff,%eax
je     15ca <main+0x3da>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    %r12d,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xb97(%rip),%rdi
call   10f0 <perror@plt>
jmp    15af <main+0x3bf>
mov    -0x40(%rbp),%rdi
call   1050 <strlen@plt>

LLVM IR (-O0):
%struct.option = type { i8*, i8, i32, i32 }
%struct.gpiohandle_request = type { i32*, i64, i32, i8*, i32, i32 }
%struct.gpiohandle_data = type { i32*, i64, i32, i8*, i32, i32 }
@GPIOHANDLES_MAX = global i32 0
@main.long_opts = internal global [5 x %struct.option] [%struct.option { i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i32 0, i32 0), i8 -128, i32 0, i32 100 }, %struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i32 0, i32 0), i8 -128, i32 0, i32 110 }, %struct.option { i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i32 0, i32 0), i8 -128, i32 0, i32 111 }, %struct.option { i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i32 0, i32 0), i8 -128, i32 0, i32 118 }, %struct.option zeroinitializer]
@.str = [10 x i8] c"direction\00"
@.str.1 = [5 x i8] c"name\00"
@.str.2 = [7 x i8] c"offset\00"
@.str.3 = [6 x i8] c"value\00"
@.str.4 = [9 x i8] c"d:n:o:v:\00"
@optarg = global i8* null
@EINVAL = global i32 0
@.str.5 = [8 x i8] c"/dev/%s\00"
@stderr = global i32 0
@.str.6 = [15 x i8] c"Out of memory\0A\00"
@ENOMEM = global i32 0
@errno = global i32 0
@.str.7 = [19 x i8] c"Failed to open %s\0A\00"
@.str.8 = [4 x i8] c"out\00"
@GPIOHANDLE_REQUEST_OUTPUT = global i64 0
@.str.9 = [3 x i8] c"in\00"
@GPIOHANDLE_REQUEST_INPUT = global i8* null
@.str.10 = [22 x i8] c"Invalid direction %s\0A\00"
@.str.11 = [10 x i8] c"gpio-util\00"
@GPIO_GET_LINEHANDLE_IOCTL = global i32 0
@.str.12 = [43 x i8] c"Failed to issue GET LINEHANDLE IOCTL (%d)\0A\00"
@GPIOHANDLE_SET_LINE_VALUES_IOCTL = global i32 0
@.str.13 = [55 x i8] c"Failed to issue GPIOHANDLE SET LINE VALUES IOCTL (%d)\0A\00"
@GPIOHANDLE_GET_LINE_VALUES_IOCTL = global i32 0
@.str.14 = [55 x i8] c"Failed to issue GPIOHANDLE GET LINE VALUES IOCTL (%d)\0A\00"
@.str.15 = [13 x i8] c"%s[%d] = %d\0A\00"
@.str.16 = [43 x i8] c"Failed to close GPIO character device file\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i8*
%14 = alloca %struct.gpiohandle_request
%15 = alloca %struct.gpiohandle_data
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %7
%21 = load i32, i32* @GPIOHANDLES_MAX
%22 = zext i32 %21 to i64
%23 = call i8* @llvm.stacksave()
store i8* %23, i8** %8
%24 = alloca i32, i64 %22
store i64 %22, i64* %9
store i8* null, i8** %10
store i8* null, i8** %11
store i32 0, i32* %12
store i32 0, i32* %17
br label %25
25: ; preds = %48, %2
%26 = load i32, i32* %4
%27 = load i8**, i8*** %5
%28 = call i32 @getopt_long(i32 %26, i8** %27, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), %struct.option* getelementptr inbounds ([5 x %struct.option], [5 x %struct.option]* @main.long_opts, i64 0, i64 0), i32* %17)
store i32 %28, i32* %18
%29 = icmp ne i32 %28, -1
br i1 %29, label %30, label %49
30: ; preds = %25
%31 = load i32, i32* %18
switch i32 %31, label %48 [
i32 100, label %32
i32 110, label %34
i32 111, label %36
i32 118, label %44
i32 63, label %46
]
32: ; preds = %30
%33 = load i8*, i8** @optarg
store i8* %33, i8** %11
br label %48
34: ; preds = %30
%35 = load i8*, i8** @optarg
store i8* %35, i8** %7
br label %48
36: ; preds = %30
%37 = load i8*, i8** @optarg
%38 = call i32 @strtoul(i8* %37, i32* null, i32 10)
%39 = load i32, i32* %12
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i32, i32* %24, i64 %40
store i32 %38, i32* %41
%42 = load i32, i32* %12
%43 = add nsw i32 %42, 1
store i32 %43, i32* %12
br label %48
44: ; preds = %30
%45 = load i8*, i8** @optarg
store i8* %45, i8** %10
br label %48
46: ; preds = %30
%47 = call i32 (...) @print_usage()
store i32 0, i32* %3
store i32 1, i32* %20
br label %241
48: ; preds = %30, %44, %36, %34, %32
br label %25
49: ; preds = %25
%50 = load i8*, i8** %7
%51 = icmp ne i8* %50, null
br i1 %51, label %52, label %55
52: ; preds = %49
%53 = load i32, i32* %12
%54 = icmp ne i32 %53, 0
br i1 %54, label %59, label %55
55: ; preds = %52, %49
%56 = call i32 (...) @print_usage()
%57 = load i32, i32* @EINVAL
%58 = sub nsw i32 0, %57
store i32 %58, i32* %3
store i32 1, i32* %20
br label %241
59: ; preds = %52
%60 = load i8*, i8** %7
%61 = call i32 @asprintf(i8** %13, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8* %60)
store i32 %61, i32* %16
%62 = load i32, i32* %16
%63 = icmp slt i32 %62, 0
br i1 %63, label %64, label %70
64: ; preds = %59
%65 = load i32, i32* @stderr
%66 = load i8*, i8** %13
%67 = call i32 (i32, i8*, ...) @fprintf(i32 %65, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i8* %66)
%68 = load i32, i32* @ENOMEM
%69 = sub nsw i32 0, %68
store i32 %69, i32* %3
store i32 1, i32* %20
br label %241
70: ; preds = %59
%71 = load i8*, i8** %13
%72 = call i32 @open(i8* %71, i32 0)
store i32 %72, i32* %6
%73 = load i32, i32* %6
%74 = icmp slt i32 %73, 0
br i1 %74, label %75, label %81
75: ; preds = %70
%76 = load i32, i32* @errno
%77 = sub nsw i32 0, %76
store i32 %77, i32* %16
%78 = load i32, i32* @stderr
%79 = load i8*, i8** %13
%80 = call i32 (i32, i8*, ...) @fprintf(i32 %78, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0), i8* %79)
br label %237
81: ; preds = %70
store i32 0, i32* %19
br label %82
82: ; preds = %96, %81
%83 = load i32, i32* %19
%84 = load i32, i32* %12
%85 = icmp slt i32 %83, %84
br i1 %85, label %86, label %99
86: ; preds = %82
%87 = load i32, i32* %19
%88 = sext i32 %87 to i64
%89 = getelementptr inbounds i32, i32* %24, i64 %88
%90 = load i32, i32* %89
%91 = getelementptr inbounds %struct.gpiohandle_request, %struct.gpiohandle_request* %14, i32 0, i32 0
%92 = load i32*, i32** %91
%93 = load i32, i32* %19
%94 = sext i32 %93 to i64
%95 = getelementptr inbounds i32, i32* %92, i64 %94
store i32 %90, i32* %95
br label %96
96: ; preds = %86
%97 = load i32, i32* %19
%98 = add nsw i32 %97, 1
store i32 %98, i32* %19
br label %82
99: ; preds = %82
%100 = load i8*, i8** %11
%101 = icmp ne i8* %100, null
br i1 %101, label %102, label %125
102: ; preds = %99
%103 = load i8*, i8** %11
%104 = call i64 @strcmp(i8* %103, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
%105 = icmp eq i64 %104, 0
br i1 %105, label %106, label %109
106: ; preds = %102
%107 = load i64, i64* @GPIOHANDLE_REQUEST_OUTPUT
%108 = getelementptr inbounds %struct.gpiohandle_request, %struct.gpiohandle_request* %14, i32 0, i32 1
store i64 %107, i64* %108
br label %124
109: ; preds = %102
%110 = load i8*, i8** %11
%111 = call i64 @strcmp(i8* %110, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0))
%112 = icmp eq i64 %111, 0
br i1 %112, label %113, label %117
113: ; preds = %109
%114 = load i8*, i8** @GPIOHANDLE_REQUEST_INPUT
%115 = ptrtoint i8* %114 to i64
%116 = getelementptr inbounds %struct.gpiohandle_request, %struct.gpiohandle_request* %14, i32 0, i32 1
store i64 %115, i64* %116
br label %123
117: ; preds = %109
%118 = load i32, i32* @stderr
%119 = load i8*, i8** %11
%120 = call i32 (i32, i8*, ...) @fprintf(i32 %118, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.10, i64 0, i64 0), i8* %119)
%121 = load i32, i32* @EINVAL
%122 = sub nsw i32 0, %121
store i32 %122, i32* %16
br label %230
123: ; preds = %113
br label %124
124: ; preds = %123, %106
br label %129
125: ; preds = %99
%126 = load i8*, i8** @GPIOHANDLE_REQUEST_INPUT
%127 = ptrtoint i8* %126 to i64
%128 = getelementptr inbounds %struct.gpiohandle_request, %struct.gpiohandle_request* %14, i32 0, i32 1
store i64 %127, i64* %128
br label %129
129: ; preds = %125, %124
%130 = getelementptr inbounds %struct.gpiohandle_request, %struct.gpiohandle_request* %14, i32 0, i32 5
%131 = load i32, i32* %130
%132 = call i32 @strcpy(i32 %131, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0))
%133 = load i32, i32* %12
%134 = getelementptr inbounds %struct.gpiohandle_request, %struct.gpiohandle_request* %14, i32 0, i32 2
store i32 %133, i32* %134
%135 = load i32, i32* %6
%136 = load i32, i32* @GPIO_GET_LINEHANDLE_IOCTL
%137 = call i32 @ioctl(i32 %135, i32 %136, %struct.gpiohandle_request* %14)
store i32 %137, i32* %16
%138 = load i32, i32* %16
%139 = icmp eq i32 %138, -1
br i1 %139, label %140, label %146
140: ; preds = %129
%141 = load i32, i32* @errno
%142 = sub nsw i32 0, %141
store i32 %142, i32* %16
%143 = load i32, i32* @stderr
%144 = load i32, i32* %16
%145 = call i32 (i32, i8*, ...) @fprintf(i32 %143, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.12, i64 0, i64 0), i32 %144)
br label %230
146: ; preds = %129
%147 = load i8*, i8** %10
%148 = icmp ne i8* %147, null
br i1 %148, label %149, label %194
149: ; preds = %146
%150 = getelementptr inbounds %struct.gpiohandle_request, %struct.gpiohandle_request* %14, i32 0, i32 1
%151 = load i64, i64* %150
%152 = load i64, i64* @GPIOHANDLE_REQUEST_OUTPUT
%153 = icmp eq i64 %151, %152
br i1 %153, label %154, label %194
154: ; preds = %149
store i32 0, i32* %19
br label %155
155: ; preds = %176, %154
%156 = load i32, i32* %19
%157 = load i32, i32* %12
%158 = icmp slt i32 %156, %157
br i1 %158, label %159, label %179
159: ; preds = %155
%160 = load i8*, i8** %10
%161 = load i32, i32* %19
%162 = load i8*, i8** %10
%163 = call i32 @strlen(i8* %162)
%164 = srem i32 %161, %163
%165 = sext i32 %164 to i64
%166 = getelementptr inbounds i8, i8* %160, i64 %165
%167 = load i8, i8* %166
%168 = sext i8 %167 to i32
%169 = sub nsw i32 %168, 48
%170 = trunc i32 %169 to i8
%171 = getelementptr inbounds %struct.gpiohandle_data, %struct.gpiohandle_data* %15, i32 0, i32 3
%172 = load i8*, i8** %171
%173 = load i32, i32* %19
%174 = sext i32 %173 to i64
%175 = getelementptr inbounds i8, i8* %172, i64 %174
store i8 %170, i8* %175
br label %176
176: ; preds = %159
%177 = load i32, i32* %19
%178 = add nsw i32 %177, 1
store i32 %178, i32* %19
br label %155
179: ; preds = %155
%180 = getelementptr inbounds %struct.gpiohandle_request, %struct.gpiohandle_request* %14, i32 0, i32 4
%181 = load i32, i32* %180
%182 = load i32, i32* @GPIOHANDLE_SET_LINE_VALUES_IOCTL
%183 = bitcast %struct.gpiohandle_data* %15 to %struct.gpiohandle_request*
%184 = call i32 @ioctl(i32 %181, i32 %182, %struct.gpiohandle_request* %183)
store i32 %184, i32* %16
%185 = load i32, i32* %16
%186 = icmp eq i32 %185, -1
br i1 %186, label %187, label %193
187: ; preds = %179
%188 = load i32, i32* @errno
%189 = sub nsw i32 0, %188
store i32 %189, i32* %16
%190 = load i32, i32* @stderr
%191 = load i32, i32* %16
%192 = call i32 (i32, i8*, ...) @fprintf(i32 %190, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.13, i64 0, i64 0), i32 %191)
br label %230
193: ; preds = %179
br label %194
194: ; preds = %193, %149, %146
%195 = getelementptr inbounds %struct.gpiohandle_request, %struct.gpiohandle_request* %14, i32 0, i32 4
%196 = load i32, i32* %195
%197 = load i32, i32* @GPIOHANDLE_GET_LINE_VALUES_IOCTL
%198 = bitcast %struct.gpiohandle_data* %15 to %struct.gpiohandle_request*
%199 = call i32 @ioctl(i32 %196, i32 %197, %struct.gpiohandle_request* %198)
store i32 %199, i32* %16
%200 = load i32, i32* %16
%201 = icmp eq i32 %200, -1
br i1 %201, label %202, label %208
202: ; preds = %194
%203 = load i32, i32* @errno
%204 = sub nsw i32 0, %203
store i32 %204, i32* %16
%205 = load i32, i32* @stderr
%206 = load i32, i32* %16
%207 = call i32 (i32, i8*, ...) @fprintf(i32 %205, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.14, i64 0, i64 0), i32 %206)
br label %230
208: ; preds = %194
store i32 0, i32* %19
br label %209
209: ; preds = %226, %208
%210 = load i32, i32* %19
%211 = load i32, i32* %12
%212 = icmp slt i32 %210, %211
br i1 %212, label %213, label %229
213: ; preds = %209
%214 = load i8*, i8** %7
%215 = load i32, i32* %19
%216 = sext i32 %215 to i64
%217 = getelementptr inbounds i32, i32* %24, i64 %216
%218 = load i32, i32* %217
%219 = getelementptr inbounds %struct.gpiohandle_data, %struct.gpiohandle_data* %15, i32 0, i32 3
%220 = load i8*, i8** %219
%221 = load i32, i32* %19
%222 = sext i32 %221 to i64
%223 = getelementptr inbounds i8, i8* %220, i64 %222
%224 = load i8, i8* %223
%225 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.15, i64 0, i64 0), i8* %214, i32 %218, i8 signext %224)
br label %226
226: ; preds = %213
%227 = load i32, i32* %19
%228 = add nsw i32 %227, 1
store i32 %228, i32* %19
br label %209
229: ; preds = %209
br label %230
230: ; preds = %229, %202, %187, %140, %117
%231 = load i32, i32* %6
%232 = call i32 @close(i32 %231)
%233 = icmp eq i32 %232, -1
br i1 %233, label %234, label %236
234: ; preds = %230
%235 = call i32 @perror(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.16, i64 0, i64 0))
br label %236
236: ; preds = %234, %230
br label %237
237: ; preds = %236, %75
%238 = load i8*, i8** %13
%239 = call i32 @free(i8* %238)
%240 = load i32, i32* %16
store i32 %240, i32* %3
store i32 1, i32* %20
br label %241
241: ; preds = %237, %64, %55, %46
%242 = load i8*, i8** %8
%243 = load i32, i32* %3
ret i32 %243
}

LLVM IR (-O2):
%struct.option = type { i8*, i8, i32, i32 }
%struct.gpiohandle_request = type { i32*, i64, i32, i8*, i32, i32 }
%struct.gpiohandle_data = type { i32*, i64, i32, i8*, i32, i32 }
@GPIOHANDLES_MAX = global i32 0
@main.long_opts = internal global [5 x %struct.option] [%struct.option { i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i32 0, i32 0), i8 -128, i32 0, i32 100 }, %struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i32 0, i32 0), i8 -128, i32 0, i32 110 }, %struct.option { i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i32 0, i32 0), i8 -128, i32 0, i32 111 }, %struct.option { i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i32 0, i32 0), i8 -128, i32 0, i32 118 }, %struct.option zeroinitializer]
@.str = [10 x i8] c"direction\00"
@.str.1 = [5 x i8] c"name\00"
@.str.2 = [7 x i8] c"offset\00"
@.str.3 = [6 x i8] c"value\00"
@.str.4 = [9 x i8] c"d:n:o:v:\00"
@optarg = global i8* null
@EINVAL = global i32 0
@.str.5 = [8 x i8] c"/dev/%s\00"
@stderr = global i32 0
@.str.6 = [15 x i8] c"Out of memory\0A\00"
@ENOMEM = global i32 0
@errno = global i32 0
@.str.7 = [19 x i8] c"Failed to open %s\0A\00"
@.str.8 = [4 x i8] c"out\00"
@GPIOHANDLE_REQUEST_OUTPUT = global i64 0
@.str.9 = [3 x i8] c"in\00"
@GPIOHANDLE_REQUEST_INPUT = global i8* null
@.str.10 = [22 x i8] c"Invalid direction %s\0A\00"
@.str.11 = [10 x i8] c"gpio-util\00"
@GPIO_GET_LINEHANDLE_IOCTL = global i32 0
@.str.12 = [43 x i8] c"Failed to issue GET LINEHANDLE IOCTL (%d)\0A\00"
@GPIOHANDLE_SET_LINE_VALUES_IOCTL = global i32 0
@.str.13 = [55 x i8] c"Failed to issue GPIOHANDLE SET LINE VALUES IOCTL (%d)\0A\00"
@GPIOHANDLE_GET_LINE_VALUES_IOCTL = global i32 0
@.str.14 = [55 x i8] c"Failed to issue GPIOHANDLE GET LINE VALUES IOCTL (%d)\0A\00"
@.str.15 = [13 x i8] c"%s[%d] = %d\0A\00"
@.str.16 = [43 x i8] c"Failed to close GPIO character device file\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i8*
%4 = alloca %struct.gpiohandle_request
%5 = alloca %struct.gpiohandle_data
%6 = alloca i32
%7 = load i32, i32* @GPIOHANDLES_MAX
%8 = zext i32 %7 to i64
%9 = alloca i32, i64 %8
%10 = bitcast i32* %9 to i8*
%11 = bitcast i8** %3 to i8*
%12 = bitcast %struct.gpiohandle_request* %4 to i8*
%13 = bitcast %struct.gpiohandle_data* %5 to i8*
%14 = bitcast i32* %6 to i8*
store i32 0, i32* %6
br label %15
15: ; preds = %33, %2
%16 = phi i8* [ %34, %33 ], [ null, %2 ]
%17 = phi i8* [ %21, %33 ], [ null, %2 ]
%18 = phi i8* [ %25, %33 ], [ null, %2 ]
%19 = phi i32 [ %28, %33 ], [ 0, %2 ]
br label %20
20: ; preds = %15, %41
%21 = phi i8* [ %17, %15 ], [ %42, %41 ]
%22 = phi i8* [ %18, %15 ], [ %25, %41 ]
%23 = phi i32 [ %19, %15 ], [ %28, %41 ]
br label %24
24: ; preds = %20, %31
%25 = phi i8* [ %22, %20 ], [ %32, %31 ]
%26 = phi i32 [ %23, %20 ], [ %28, %31 ]
br label %27
27: ; preds = %24, %35
%28 = phi i32 [ %26, %24 ], [ %40, %35 ]
br label %29
29: ; preds = %27, %29
%30 = call i32 @getopt_long(i32 %0, i8** %1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), %struct.option* getelementptr inbounds ([5 x %struct.option], [5 x %struct.option]* @main.long_opts, i64 0, i64 0), i32* %6)
switch i32 %30, label %29 [
i32 -1, label %45
i32 100, label %31
i32 110, label %33
i32 111, label %35
i32 118, label %41
i32 63, label %43
]
31: ; preds = %29
%32 = load i8*, i8** @optarg
br label %24
33: ; preds = %29
%34 = load i8*, i8** @optarg
br label %15
35: ; preds = %29
%36 = load i8*, i8** @optarg
%37 = call i32 @strtoul(i8* nocapture %36, i32* null, i32 10)
%38 = sext i32 %28 to i64
%39 = getelementptr inbounds i32, i32* %9, i64 %38
store i32 %37, i32* %39
%40 = add nsw i32 %28, 1
br label %27
41: ; preds = %29
%42 = load i8*, i8** @optarg
br label %20
43: ; preds = %29
%44 = call i32 (...) @print_usage()
br label %169
45: ; preds = %29
%46 = icmp ne i8* %16, null
%47 = icmp ne i32 %28, 0
%48 = select i1 %46, i1 %47, i1 false
br i1 %48, label %53, label %49
49: ; preds = %45
%50 = call i32 (...) @print_usage()
%51 = load i32, i32* @EINVAL
%52 = sub nsw i32 0, %51
br label %169
53: ; preds = %45
%54 = call i32 @asprintf(i8** %3, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8* %16)
%55 = icmp slt i32 %54, 0
br i1 %55, label %56, label %62
56: ; preds = %53
%57 = load i32, i32* @stderr
%58 = load i8*, i8** %3
%59 = call i32 (i32, i8*, ...) @fprintf(i32 %57, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i8* %58)
%60 = load i32, i32* @ENOMEM
%61 = sub nsw i32 0, %60
br label %169
62: ; preds = %53
%63 = load i8*, i8** %3
%64 = call i32 @open(i8* %63, i32 0)
%65 = icmp slt i32 %64, 0
br i1 %65, label %71, label %66
66: ; preds = %62
%67 = icmp sgt i32 %28, 0
br i1 %67, label %68, label %77
68: ; preds = %66
%69 = zext i32 %28 to i64
%70 = shl nuw nsw i64 %69, 2
br label %77
71: ; preds = %62
%72 = load i32, i32* @errno
%73 = sub nsw i32 0, %72
%74 = load i32, i32* @stderr
%75 = load i8*, i8** %3
%76 = call i32 (i32, i8*, ...) @fprintf(i32 %74, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0), i8* %75)
br label %165
77: ; preds = %68, %66
%78 = icmp eq i8* %25, null
br i1 %78, label %95, label %79
79: ; preds = %77
%80 = call i64 @strcmp(i8* %25, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
%81 = icmp eq i64 %80, 0
br i1 %81, label %82, label %84
82: ; preds = %79
%83 = load i64, i64* @GPIOHANDLE_REQUEST_OUTPUT
br label %98
84: ; preds = %79
%85 = call i64 @strcmp(i8* %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0))
%86 = icmp eq i64 %85, 0
br i1 %86, label %87, label %90
87: ; preds = %84
%88 = load i8*, i8** @GPIOHANDLE_REQUEST_INPUT
%89 = ptrtoint i8* %88 to i64
br label %98
90: ; preds = %84
%91 = load i32, i32* @stderr
%92 = call i32 (i32, i8*, ...) @fprintf(i32 %91, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.10, i64 0, i64 0), i8* %25)
%93 = load i32, i32* @EINVAL
%94 = sub nsw i32 0, %93
br label %159
95: ; preds = %77
%96 = load i8*, i8** @GPIOHANDLE_REQUEST_INPUT
%97 = ptrtoint i8* %96 to i64
br label %98
98: ; preds = %82, %87, %95
%99 = phi i64 [ %83, %82 ], [ %89, %87 ], [ %97, %95 ]
%100 = getelementptr inbounds %struct.gpiohandle_request, %struct.gpiohandle_request* %4, i64 0, i32 1
store i64 %99, i64* %100
%101 = call i32 @strcpy(i32 undef, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0))
%102 = getelementptr inbounds %struct.gpiohandle_request, %struct.gpiohandle_request* %4, i64 0, i32 2
store i32 %28, i32* %102
%103 = load i32, i32* @GPIO_GET_LINEHANDLE_IOCTL
%104 = call i32 @ioctl(i32 %64, i32 %103, %struct.gpiohandle_request* %4)
%105 = icmp eq i32 %104, -1
br i1 %105, label %106, label %111
106: ; preds = %98
%107 = load i32, i32* @errno
%108 = sub nsw i32 0, %107
%109 = load i32, i32* @stderr
%110 = call i32 (i32, i8*, ...) @fprintf(i32 %109, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.12, i64 0, i64 0), i32 %108)
br label %159
111: ; preds = %98
%112 = icmp eq i8* %21, null
br i1 %112, label %133, label %113
113: ; preds = %111
%114 = getelementptr inbounds %struct.gpiohandle_request, %struct.gpiohandle_request* %4, i64 0, i32 1
%115 = load i64, i64* %114
%116 = load i64, i64* @GPIOHANDLE_REQUEST_OUTPUT
%117 = icmp eq i64 %115, %116
br i1 %117, label %118, label %133
118: ; preds = %113
br i1 %67, label %119, label %121
119: ; preds = %118
%120 = call i32 @strlen(i8* %21)
unreachable
121: ; preds = %118
%122 = getelementptr inbounds %struct.gpiohandle_request, %struct.gpiohandle_request* %4, i64 0, i32 4
%123 = load i32, i32* %122
%124 = load i32, i32* @GPIOHANDLE_SET_LINE_VALUES_IOCTL
%125 = bitcast %struct.gpiohandle_data* %5 to %struct.gpiohandle_request*
%126 = call i32 @ioctl(i32 %123, i32 %124, %struct.gpiohandle_request* %125)
%127 = icmp eq i32 %126, -1
br i1 %127, label %128, label %133
128: ; preds = %121
%129 = load i32, i32* @errno
%130 = sub nsw i32 0, %129
%131 = load i32, i32* @stderr
%132 = call i32 (i32, i8*, ...) @fprintf(i32 %131, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.13, i64 0, i64 0), i32 %130)
br label %159
133: ; preds = %121, %113, %111
%134 = getelementptr inbounds %struct.gpiohandle_request, %struct.gpiohandle_request* %4, i64 0, i32 4
%135 = load i32, i32* %134
%136 = load i32, i32* @GPIOHANDLE_GET_LINE_VALUES_IOCTL
%137 = bitcast %struct.gpiohandle_data* %5 to %struct.gpiohandle_request*
%138 = call i32 @ioctl(i32 %135, i32 %136, %struct.gpiohandle_request* %137)
%139 = icmp eq i32 %138, -1
br i1 %139, label %144, label %140
140: ; preds = %133
br i1 %67, label %141, label %159
141: ; preds = %140
%142 = getelementptr inbounds %struct.gpiohandle_data, %struct.gpiohandle_data* %5, i64 0, i32 3
%143 = zext i32 %28 to i64
br label %149
144: ; preds = %133
%145 = load i32, i32* @errno
%146 = sub nsw i32 0, %145
%147 = load i32, i32* @stderr
%148 = call i32 (i32, i8*, ...) @fprintf(i32 %147, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.14, i64 0, i64 0), i32 %146)
br label %159
149: ; preds = %141, %149
%150 = phi i64 [ 0, %141 ], [ %157, %149 ]
%151 = getelementptr inbounds i32, i32* %9, i64 %150
%152 = load i32, i32* %151
%153 = load i8*, i8** %142
%154 = getelementptr inbounds i8, i8* %153, i64 %150
%155 = load i8, i8* %154
%156 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.15, i64 0, i64 0), i8* %16, i32 %152, i8 signext %155)
%157 = add nuw nsw i64 %150, 1
%158 = icmp eq i64 %157, %143
br i1 %158, label %159, label %149
159: ; preds = %149, %140, %144, %128, %106, %90
%160 = phi i32 [ %108, %106 ], [ %130, %128 ], [ %146, %144 ], [ %94, %90 ], [ %138, %140 ], [ %138, %149 ]
%161 = call i32 @close(i32 %64)
%162 = icmp eq i32 %161, -1
br i1 %162, label %163, label %165
163: ; preds = %159
%164 = call i32 @perror(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.16, i64 0, i64 0))
br label %165
165: ; preds = %159, %163, %71
%166 = phi i32 [ %73, %71 ], [ %160, %163 ], [ %160, %159 ]
%167 = load i8*, i8** %3
%168 = call i32 @free(i8* %167)
br label %169
169: ; preds = %165, %56, %49, %43
%170 = phi i32 [ 0, %43 ], [ %61, %56 ], [ %166, %165 ], [ %52, %49 ]
ret i32 %170
}