#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int /*<<< orphan*/ swirr;
struct gpiohandle_request {
  unsigned int *lineoffsets;
  int lines;
  int fd;
  int *values;
  int /*<<< orphan*/ consumer_label;
  int /*<<< orphan*/ flags;
};
struct gpiohandle_data {
  unsigned int *lineoffsets;
  int lines;
  int fd;
  int *values;
  int /*<<< orphan*/ consumer_label;
  int /*<<< orphan*/ flags;
};

/* Variables and functions */
int ENOMEM;
int /*<<< orphan*/ GPIOHANDLE_GET_LINE_VALUES_IOCTL;
int /*<<< orphan*/ GPIOHANDLE_REQUEST_OUTPUT;
int /*<<< orphan*/ GPIOHANDLE_SET_LINE_VALUES_IOCTL;
int /*<<< orphan*/ GPIO_GET_LINEHANDLE_IOCTL;
int asprintf(char **, char *, char const *);
int close(int);
int errno;
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ free(char *);
int ioctl(int, int /*<<< orphan*/, struct gpiohandle_request *);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strcpy(int /*<<< orphan*/, char *);
int hammer_device(const char *device_name, unsigned int *lines, int nlines,
                  unsigned int loops) {
  struct gpiohandle_request req;
  struct gpiohandle_data data;
  char *chrdev_name;
  char swirr[] = "-\\|/";
  int fd;
  int ret;
  int i, j;
  unsigned int iteration = 0;
  ret = asprintf(&chrdev_name, "/dev/%s", device_name);
  if (ret < 0)
    return -ENOMEM;
  fd = open(chrdev_name, 0);
  if (fd == -1) {
    ret = -errno;
    fprintf(stderr, "Failed to open %s\n", chrdev_name);
    goto exit_close_error;
  }
  for (i = 0; i < nlines; i++)
    req.lineoffsets[i] = lines[i];
  req.flags = GPIOHANDLE_REQUEST_OUTPUT;
  strcpy(req.consumer_label, "gpio-hammer");
  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;
  }
  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;
  }
  fprintf(stdout, "Hammer lines [");
  for (i = 0; i < nlines; i++) {
    fprintf(stdout, "%d", lines[i]);
    if (i != (nlines - 1))
      fprintf(stdout, ", ");
  }
  fprintf(stdout, "] on %s, initial states: [", device_name);
  for (i = 0; i < nlines; i++) {
    fprintf(stdout, "%d", data.values[i]);
    if (i != (nlines - 1))
      fprintf(stdout, ", ");
  }
  fprintf(stdout, "]\n");
  j = 0;
  while (1) {
    for (i = 0; i < nlines; i++)
      data.values[i] = !data.values[i];
    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;
    }
    fprintf(stdout, "[%c] ", swirr[j]);
    j++;
    if (j == sizeof(swirr) - 1)
      j = 0;
    fprintf(stdout, "[");
    for (i = 0; i < nlines; i++) {
      fprintf(stdout, "%d: %d", lines[i], data.values[i]);
      if (i != (nlines - 1))
        fprintf(stdout, ", ");
    }
    fprintf(stdout, "]\r");
    fflush(stdout);
    sleep(1);
    iteration++;
    if (loops && iteration == loops)
      break;
  }
  fprintf(stdout, "\n");
  ret = 0;
exit_close_error:
  if (close(fd) == -1)
    perror("Failed to close GPIO character device file");
  free(chrdev_name);
  return ret;
}


x86 assembly (clang, -O0):
<hammer_device>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %ecx,-0x20(%rbp)
mov    0xe41(%rip),%eax
mov    %eax,-0x6d(%rbp)
mov    0xe3c(%rip),%al
mov    %al,-0x69(%rbp)
movl   $0x0,-0x84(%rbp)
mov    -0x10(%rbp),%rdx
lea    -0x68(%rbp),%rdi
lea    0xe21(%rip),%rsi
call   1090 <asprintf@plt>
mov    %eax,-0x78(%rbp)
cmpl   $0x0,-0x78(%rbp)
jge    1209 <hammer_device+0x69>
xor    %eax,%eax
mov    0x2dc9(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    16d0 <hammer_device+0x530>
mov    -0x68(%rbp),%rdi
xor    %esi,%esi
call   10a0 <open@plt>
mov    %eax,-0x74(%rbp)
cmpl   $0xffffffff,-0x74(%rbp)
jne    124f <hammer_device+0xaf>
xor    %eax,%eax
mov    0x2d86(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x78(%rbp)
mov    0x2d82(%rip),%rax
mov    (%rax),%edi
mov    -0x68(%rbp),%rdx
lea    0xdca(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
jmp    16a4 <hammer_device+0x504>
movl   $0x0,-0x7c(%rbp)
mov    -0x7c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1286 <hammer_device+0xe6>
mov    -0x18(%rbp),%rax
movslq -0x7c(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x40(%rbp),%rax
movslq -0x7c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x7c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7c(%rbp)
jmp    1256 <hammer_device+0xb6>
mov    0x2d53(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x28(%rbp),%edi
lea    0xd84(%rip),%rsi
call   1040 <strcpy@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x74(%rbp),%edi
mov    0x2d1f(%rip),%rax
mov    (%rax),%esi
lea    -0x40(%rbp),%rdx
call   1050 <ioctl@plt>
mov    %eax,-0x78(%rbp)
cmpl   $0xffffffff,-0x78(%rbp)
jne    12f6 <hammer_device+0x156>
xor    %eax,%eax
mov    0x2cde(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x78(%rbp)
mov    0x2cda(%rip),%rax
mov    (%rax),%edi
mov    -0x78(%rbp),%edx
lea    0xd42(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
jmp    16a4 <hammer_device+0x504>
mov    -0x34(%rbp),%edi
mov    0x2cf0(%rip),%rax
mov    (%rax),%esi
lea    -0x60(%rbp),%rdx
call   1050 <ioctl@plt>
mov    %eax,-0x78(%rbp)
cmpl   $0xffffffff,-0x78(%rbp)
jne    1345 <hammer_device+0x1a5>
xor    %eax,%eax
mov    0x2c8f(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x78(%rbp)
mov    0x2c8b(%rip),%rax
mov    (%rax),%edi
mov    -0x78(%rbp),%edx
lea    0xd1e(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
jmp    16a4 <hammer_device+0x504>
mov    0x2c5c(%rip),%rax
mov    (%rax),%edi
lea    0xd39(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0x0,-0x7c(%rbp)
mov    -0x7c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    13cc <hammer_device+0x22c>
mov    0x2c32(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rax
movslq -0x7c(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xd75(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x7c(%rbp),%eax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
je     13b9 <hammer_device+0x219>
mov    0x2bff(%rip),%rax
mov    (%rax),%edi
lea    0xceb(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
jmp    13be <hammer_device+0x21e>
mov    -0x7c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7c(%rbp)
jmp    1363 <hammer_device+0x1c3>
mov    0x2bd5(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xcc0(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0x0,-0x7c(%rbp)
mov    -0x7c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1457 <hammer_device+0x2b7>
mov    0x2ba7(%rip),%rax
mov    (%rax),%edi
mov    -0x50(%rbp),%rax
movslq -0x7c(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xcea(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x7c(%rbp),%eax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
je     1444 <hammer_device+0x2a4>
mov    0x2b74(%rip),%rax
mov    (%rax),%edi
lea    0xc60(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
jmp    1449 <hammer_device+0x2a9>
mov    -0x7c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7c(%rbp)
jmp    13ee <hammer_device+0x24e>
mov    0x2b4a(%rip),%rax
mov    (%rax),%edi
lea    0xc54(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0x0,-0x80(%rbp)
movl   $0x0,-0x7c(%rbp)
mov    -0x7c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    14b7 <hammer_device+0x317>
mov    -0x50(%rbp),%rax
movslq -0x7c(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edx
mov    -0x50(%rbp),%rax
movslq -0x7c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x7c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7c(%rbp)
jmp    147c <hammer_device+0x2dc>
mov    -0x34(%rbp),%edi
mov    0x2aff(%rip),%rax
mov    (%rax),%esi
lea    -0x60(%rbp),%rdx
call   1050 <ioctl@plt>
mov    %eax,-0x78(%rbp)
cmpl   $0xffffffff,-0x78(%rbp)
jne    1506 <hammer_device+0x366>
xor    %eax,%eax
mov    0x2ace(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x78(%rbp)
mov    0x2aca(%rip),%rax
mov    (%rax),%edi
mov    -0x78(%rbp),%edx
lea    0xbc4(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
jmp    16a4 <hammer_device+0x504>
mov    -0x34(%rbp),%edi
mov    0x2ae0(%rip),%rax
mov    (%rax),%esi
lea    -0x60(%rbp),%rdx
call   1050 <ioctl@plt>
mov    %eax,-0x78(%rbp)
cmpl   $0xffffffff,-0x78(%rbp)
jne    1555 <hammer_device+0x3b5>
xor    %eax,%eax
mov    0x2a7f(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x78(%rbp)
mov    0x2a7b(%rip),%rax
mov    (%rax),%edi
mov    -0x78(%rbp),%edx
lea    0xb0e(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
jmp    16a4 <hammer_device+0x504>
mov    0x2a4c(%rip),%rax
mov    (%rax),%edi
movslq -0x80(%rbp),%rax
movsbl -0x6d(%rbp,%rax,1),%edx
lea    0xb87(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x80(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x80(%rbp)
movslq -0x80(%rbp),%rax
cmp    $0x4,%rax
jne    1593 <hammer_device+0x3f3>
movl   $0x0,-0x80(%rbp)
mov    0x2a0e(%rip),%rax
mov    (%rax),%edi
lea    0xb16(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0x0,-0x7c(%rbp)
mov    -0x7c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1625 <hammer_device+0x485>
mov    0x29e4(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rax
movslq -0x7c(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x50(%rbp),%rax
movslq -0x7c(%rbp),%rcx
mov    (%rax,%rcx,4),%ecx
lea    0xb18(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x7c(%rbp),%eax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
je     1612 <hammer_device+0x472>
mov    0x29a6(%rip),%rax
mov    (%rax),%edi
lea    0xa92(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
jmp    1617 <hammer_device+0x477>
mov    -0x7c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7c(%rbp)
jmp    15b1 <hammer_device+0x411>
mov    0x297c(%rip),%rax
mov    (%rax),%edi
lea    0xacd(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2965(%rip),%rax
mov    (%rax),%edi
call   1080 <fflush@plt>
mov    $0x1,%edi
call   10c0 <sleep@plt>
mov    -0x84(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x84(%rbp)
cmpl   $0x0,-0x20(%rbp)
je     1681 <hammer_device+0x4e1>
mov    -0x84(%rbp),%eax
cmp    -0x20(%rbp),%eax
jne    1681 <hammer_device+0x4e1>
jmp    1686 <hammer_device+0x4e6>
jmp    1475 <hammer_device+0x2d5>
mov    0x291b(%rip),%rax
mov    (%rax),%edi
lea    0x9bf(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0x0,-0x78(%rbp)
mov    -0x74(%rbp),%edi
call   1060 <close@plt>
cmp    $0xffffffff,%eax
jne    16c1 <hammer_device+0x521>
lea    0xa49(%rip),%rdi
call   10b0 <perror@plt>
mov    -0x68(%rbp),%rdi
call   1030 <free@plt>
mov    -0x78(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hammer_device>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
mov    %ecx,0xc(%rsp)
mov    %edx,%ebx
mov    %rsi,%r15
mov    %rdi,%r13
lea    0xe41(%rip),%rsi
lea    0x18(%rsp),%rdi
mov    %r13,%rdx
call   1090 <asprintf@plt>
test   %eax,%eax
js     1290 <hammer_device+0xf0>
mov    %rbx,(%rsp)
mov    0x18(%rsp),%rdi
xor    %esi,%esi
call   10a0 <open@plt>
mov    %eax,%r14d
cmp    $0xffffffff,%eax
je     12a0 <hammer_device+0x100>
mov    (%rsp),%rax
mov    %eax,%r12d
test   %eax,%eax
jle    13a8 <hammer_device+0x208>
mov    0x48(%rsp),%rax
cmpl   $0x8,(%rsp)
jb     1229 <hammer_device+0x89>
lea    (%r15,%r12,4),%rcx
cmp    %rcx,%rax
jae    12cc <hammer_device+0x12c>
lea    (%rax,%r12,4),%rcx
cmp    %r15,%rcx
jbe    12cc <hammer_device+0x12c>
xor    %ecx,%ecx
mov    %rcx,%rdx
not    %rdx
add    %r12,%rdx
mov    %r12,%rsi
and    $0x3,%rsi
je     1251 <hammer_device+0xb1>
nopl   (%rax)
mov    (%r15,%rcx,4),%edi
mov    %edi,(%rax,%rcx,4)
add    $0x1,%rcx
add    $0xffffffffffffffff,%rsi
jne    1240 <hammer_device+0xa0>
cmp    $0x3,%rdx
jb     13a8 <hammer_device+0x208>
nopl   0x0(%rax,%rax,1)
mov    (%r15,%rcx,4),%edx
mov    %edx,(%rax,%rcx,4)
mov    0x4(%r15,%rcx,4),%edx
mov    %edx,0x4(%rax,%rcx,4)
mov    0x8(%r15,%rcx,4),%edx
mov    %edx,0x8(%rax,%rcx,4)
mov    0xc(%r15,%rcx,4),%edx
mov    %edx,0xc(%rax,%rcx,4)
add    $0x4,%rcx
cmp    %rcx,%r12
jne    1260 <hammer_device+0xc0>
jmp    13a8 <hammer_device+0x208>
mov    0x2d31(%rip),%rax
xor    %ebx,%ebx
sub    (%rax),%ebx
jmp    1872 <hammer_device+0x6d2>
mov    0x2d09(%rip),%rax
xor    %ebx,%ebx
sub    (%rax),%ebx
mov    0x2d06(%rip),%rax
mov    (%rax),%edi
mov    0x18(%rsp),%rdx
lea    0xd4d(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
jmp    185b <hammer_device+0x6bb>
mov    %r12d,%ecx
and    $0xfffffff8,%ecx
lea    -0x8(%rcx),%rdi
mov    %rdi,%rsi
shr    $0x3,%rsi
add    $0x1,%rsi
mov    %esi,%edx
and    $0x3,%edx
cmp    $0x18,%rdi
jae    12f0 <hammer_device+0x150>
xor    %edi,%edi
jmp    1364 <hammer_device+0x1c4>
and    $0xfffffffffffffffc,%rsi
xor    %edi,%edi
cs nopw 0x0(%rax,%rax,1)
movups (%r15,%rdi,4),%xmm0
movups 0x10(%r15,%rdi,4),%xmm1
movups %xmm0,(%rax,%rdi,4)
movups %xmm1,0x10(%rax,%rdi,4)
movups 0x20(%r15,%rdi,4),%xmm0
movups 0x30(%r15,%rdi,4),%xmm1
movups %xmm0,0x20(%rax,%rdi,4)
movups %xmm1,0x30(%rax,%rdi,4)
movups 0x40(%r15,%rdi,4),%xmm0
movups 0x50(%r15,%rdi,4),%xmm1
movups %xmm0,0x40(%rax,%rdi,4)
movups %xmm1,0x50(%rax,%rdi,4)
movdqu 0x60(%r15,%rdi,4),%xmm0
movdqu 0x70(%r15,%rdi,4),%xmm1
movdqu %xmm0,0x60(%rax,%rdi,4)
movdqu %xmm1,0x70(%rax,%rdi,4)
add    $0x20,%rdi
add    $0xfffffffffffffffc,%rsi
jne    1300 <hammer_device+0x160>
test   %rdx,%rdx
je     139f <hammer_device+0x1ff>
lea    (%rax,%rdi,4),%rsi
add    $0x10,%rsi
lea    (%r15,%rdi,4),%rdi
add    $0x10,%rdi
shl    $0x5,%rdx
xor    %ebx,%ebx
nop
movdqu -0x10(%rdi,%rbx,1),%xmm0
movdqu (%rdi,%rbx,1),%xmm1
movdqu %xmm0,-0x10(%rsi,%rbx,1)
movdqu %xmm1,(%rsi,%rbx,1)
add    $0x20,%rbx
cmp    %rbx,%rdx
jne    1380 <hammer_device+0x1e0>
cmp    %r12,%rcx
jne    122b <hammer_device+0x8b>
mov    0x2c31(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x64(%rsp)
mov    0x60(%rsp),%edi
lea    0xc60(%rip),%rsi
call   1040 <strcpy@plt>
mov    (%rsp),%rax
mov    %eax,0x50(%rsp)
mov    0x2bfc(%rip),%rax
mov    (%rax),%esi
lea    0x48(%rsp),%rdx
mov    %r14d,%edi
call   1050 <ioctl@plt>
cmp    $0xffffffff,%eax
je     1482 <hammer_device+0x2e2>
mov    0x54(%rsp),%edi
mov    0x2bf9(%rip),%rax
mov    (%rax),%esi
lea    0x68(%rsp),%rdx
call   1050 <ioctl@plt>
cmp    $0xffffffff,%eax
je     1517 <hammer_device+0x377>
mov    0x2b95(%rip),%rbp
mov    0x0(%rbp),%edi
lea    0xc71(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    (%rsp),%rbx
test   %ebx,%ebx
mov    %r14d,0x8(%rsp)
jle    1546 <hammer_device+0x3a6>
mov    %r13,0x10(%rsp)
lea    -0x1(%rbx),%r13d
lea    0xcba(%rip),%rbx
xor    %r14d,%r14d
jmp    1459 <hammer_device+0x2b9>
nopw   0x0(%rax,%rax,1)
add    $0x1,%r14
cmp    %r14,%r12
je     14a2 <hammer_device+0x302>
mov    0x0(%rbp),%edi
mov    (%r15,%r14,4),%edx
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
cmp    %r14,%r13
je     1450 <hammer_device+0x2b0>
mov    0x0(%rbp),%edi
lea    0xc24(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
jmp    1450 <hammer_device+0x2b0>
mov    0x2b27(%rip),%rax
xor    %ebx,%ebx
sub    (%rax),%ebx
mov    0x2b24(%rip),%rax
mov    (%rax),%edi
lea    0xb8f(%rip),%rsi
jmp    1532 <hammer_device+0x392>
mov    0x0(%rbp),%edi
lea    0xbf4(%rip),%rsi
mov    0x10(%rsp),%rdx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    (%rsp),%r14
test   %r14d,%r14d
jle    1563 <hammer_device+0x3c3>
lea    0xc33(%rip),%rbx
xor    %r14d,%r14d
jmp    14e9 <hammer_device+0x349>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%r14
cmp    %r14,%r12
je     1540 <hammer_device+0x3a0>
mov    0x0(%rbp),%edi
mov    0x78(%rsp),%rax
mov    (%rax,%r14,4),%edx
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
cmp    %r14,%r13
je     14e0 <hammer_device+0x340>
mov    0x0(%rbp),%edi
lea    0xb8f(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
jmp    14e0 <hammer_device+0x340>
mov    0x2a92(%rip),%rax
xor    %ebx,%ebx
sub    (%rax),%ebx
mov    0x2a8f(%rip),%rax
mov    (%rax),%edi
lea    0xb25(%rip),%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1070 <fprintf@plt>
jmp    185b <hammer_device+0x6bb>
mov    (%rsp),%r14
jmp    1567 <hammer_device+0x3c7>
mov    0x0(%rbp),%edi
lea    0xb50(%rip),%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    %rbx,%r14
lea    -0x1(%rbx),%r13d
jmp    1567 <hammer_device+0x3c7>
lea    -0x1(%r14),%r13d
mov    0x0(%rbp),%edi
lea    0xb4a(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    %r12d,%eax
and    $0xfffffff8,%eax
mov    %rax,0x40(%rsp)
add    $0xfffffffffffffff8,%rax
mov    %rax,0x38(%rsp)
shr    $0x3,%rax
add    $0x1,%rax
movabs $0x3ffffffffffffffc,%rdx
ff ff 3f
or     $0x2,%rdx
mov    %rax,%rcx
mov    %rax,0x30(%rsp)
and    %rax,%rdx
mov    %rdx,0x28(%rsp)
pxor   %xmm4,%xmm4
lea    0x68(%rsp),%rdx
xor    %eax,%eax
mov    %rax,0x10(%rsp)
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %eax,0x24(%rsp)
test   %r14d,%r14d
jle    16c6 <hammer_device+0x526>
mov    0x78(%rsp),%rax
cmp    $0x8,%r14d
jae    15f0 <hammer_device+0x450>
xor    %ecx,%ecx
jmp    16b0 <hammer_device+0x510>
nop
cmpq   $0x0,0x38(%rsp)
je     17ee <hammer_device+0x64e>
mov    0x28(%rsp),%rsi
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movdqu (%rax,%rcx,4),%xmm0
movdqu 0x10(%rax,%rcx,4),%xmm1
movdqu 0x20(%rax,%rcx,4),%xmm2
movdqu 0x30(%rax,%rcx,4),%xmm3
pcmpeqd %xmm4,%xmm0
psrld  $0x1f,%xmm0
pcmpeqd %xmm4,%xmm1
psrld  $0x1f,%xmm1
movdqu %xmm0,(%rax,%rcx,4)
movdqu %xmm1,0x10(%rax,%rcx,4)
pcmpeqd %xmm4,%xmm2
psrld  $0x1f,%xmm2
pcmpeqd %xmm4,%xmm3
psrld  $0x1f,%xmm3
movdqu %xmm2,0x20(%rax,%rcx,4)
movdqu %xmm3,0x30(%rax,%rcx,4)
add    $0x10,%rcx
add    $0xfffffffffffffffe,%rsi
jne    1610 <hammer_device+0x470>
testb  $0x1,0x30(%rsp)
je     169b <hammer_device+0x4fb>
movdqu (%rax,%rcx,4),%xmm0
movdqu 0x10(%rax,%rcx,4),%xmm1
pcmpeqd %xmm4,%xmm0
psrld  $0x1f,%xmm0
pcmpeqd %xmm4,%xmm1
psrld  $0x1f,%xmm1
movdqu %xmm0,(%rax,%rcx,4)
movdqu %xmm1,0x10(%rax,%rcx,4)
mov    0x40(%rsp),%rsi
mov    %rsi,%rcx
cmp    %r12,%rsi
je     16c6 <hammer_device+0x526>
nopl   0x0(%rax,%rax,1)
xor    %esi,%esi
cmpl   $0x0,(%rax,%rcx,4)
sete   %sil
mov    %esi,(%rax,%rcx,4)
add    $0x1,%rcx
cmp    %rcx,%r12
jne    16b0 <hammer_device+0x510>
mov    0x54(%rsp),%edi
mov    0x28ef(%rip),%rax
mov    (%rax),%esi
mov    %rdx,%rbx
call   1050 <ioctl@plt>
cmp    $0xffffffff,%eax
je     1800 <hammer_device+0x660>
mov    0x54(%rsp),%edi
mov    0x2901(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdx
call   1050 <ioctl@plt>
cmp    $0xffffffff,%eax
je     181d <hammer_device+0x67d>
mov    0x0(%rbp),%edi
mov    0x10(%rsp),%rbx
movslq %ebx,%rbx
lea    0x8ec(%rip),%rax
movsbl (%rbx,%rax,1),%edx
lea    0x9d6(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
add    $0x1,%ebx
cmp    $0x4,%ebx
mov    $0x0,%eax
cmove  %eax,%ebx
mov    %rbx,0x10(%rsp)
mov    0x0(%rbp),%edi
lea    0x976(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
test   %r14d,%r14d
lea    0x9a7(%rip),%rbx
jle    17a0 <hammer_device+0x600>
xor    %r14d,%r14d
jmp    1769 <hammer_device+0x5c9>
nopl   0x0(%rax,%rax,1)
add    $0x1,%r14
cmp    %r14,%r12
je     17a0 <hammer_device+0x600>
mov    0x0(%rbp),%edi
mov    (%r15,%r14,4),%edx
mov    0x78(%rsp),%rax
mov    (%rax,%r14,4),%ecx
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
cmp    %r14,%r13
je     1760 <hammer_device+0x5c0>
mov    0x0(%rbp),%edi
lea    0x90b(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
jmp    1760 <hammer_device+0x5c0>
nopl   0x0(%rax,%rax,1)
mov    0x0(%rbp),%edi
lea    0x958(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    0x0(%rbp),%edi
call   1080 <fflush@plt>
mov    $0x1,%edi
call   10c0 <sleep@plt>
mov    0x24(%rsp),%eax
add    $0x1,%eax
cmpl   $0x0,0xc(%rsp)
mov    (%rsp),%r14
pxor   %xmm4,%xmm4
lea    0x68(%rsp),%rdx
je     15d0 <hammer_device+0x430>
cmp    0xc(%rsp),%eax
jne    15d0 <hammer_device+0x430>
jmp    1843 <hammer_device+0x6a3>
xor    %ecx,%ecx
testb  $0x1,0x30(%rsp)
jne    1673 <hammer_device+0x4d3>
jmp    169b <hammer_device+0x4fb>
mov    0x27a9(%rip),%rax
xor    %ebx,%ebx
sub    (%rax),%ebx
mov    0x27a6(%rip),%rax
mov    (%rax),%edi
lea    0x8a3(%rip),%rsi
jmp    1838 <hammer_device+0x698>
mov    0x278c(%rip),%rax
xor    %ebx,%ebx
sub    (%rax),%ebx
mov    0x2789(%rip),%rax
mov    (%rax),%edi
lea    0x81f(%rip),%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1070 <fprintf@plt>
jmp    1856 <hammer_device+0x6b6>
mov    0x0(%rbp),%edi
lea    0x808(%rip),%rsi
xor    %ebx,%ebx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    0x8(%rsp),%r14d
mov    %r14d,%edi
call   1060 <close@plt>
cmp    $0xffffffff,%eax
je     1886 <hammer_device+0x6e6>
mov    0x18(%rsp),%rdi
call   1030 <free@plt>
mov    %ebx,%eax
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x878(%rip),%rdi
call   10b0 <perror@plt>
jmp    1868 <hammer_device+0x6c8>

LLVM IR (-O0):
%struct.gpiohandle_request = type { i32*, i32, i32, i32*, i32, i32 }
%struct.gpiohandle_data = type { i32*, i32, i32, i32*, i32, i32 }
@__const.hammer_device.swirr = [5 x i8] c"-\\|/\00"
@.str = [8 x i8] c"/dev/%s\00"
@ENOMEM = global i32 0
@errno = global i32 0
@stderr = global i32 0
@.str.1 = [19 x i8] c"Failed to open %s\0A\00"
@GPIOHANDLE_REQUEST_OUTPUT = global i32 0
@.str.2 = [12 x i8] c"gpio-hammer\00"
@GPIO_GET_LINEHANDLE_IOCTL = global i32 0
@.str.3 = [43 x i8] c"Failed to issue GET LINEHANDLE IOCTL (%d)\0A\00"
@GPIOHANDLE_GET_LINE_VALUES_IOCTL = global i32 0
@.str.4 = [55 x i8] c"Failed to issue GPIOHANDLE GET LINE VALUES IOCTL (%d)\0A\00"
@stdout = global i32 0
@.str.5 = [15 x i8] c"Hammer lines [\00"
@.str.6 = [3 x i8] c"%d\00"
@.str.7 = [3 x i8] c", \00"
@.str.8 = [27 x i8] c"] on %s, initial states: [\00"
@.str.9 = [3 x i8] c"]\0A\00"
@GPIOHANDLE_SET_LINE_VALUES_IOCTL = global i32 0
@.str.10 = [55 x i8] c"Failed to issue GPIOHANDLE SET LINE VALUES IOCTL (%d)\0A\00"
@.str.11 = [6 x i8] c"[%c] \00"
@.str.12 = [2 x i8] c"[\00"
@.str.13 = [7 x i8] c"%d: %d\00"
@.str.14 = [3 x i8] c"]\0D\00"
@.str.15 = [2 x i8] c"\0A\00"
@.str.16 = [43 x i8] c"Failed to close GPIO character device file\00"
define i32 @hammer_device(i8* %0, i32* %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
%10 = alloca %struct.gpiohandle_request
%11 = alloca %struct.gpiohandle_data
%12 = alloca i8*
%13 = alloca [5 x i8]
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
store i8* %0, i8** %6
store i32* %1, i32** %7
store i32 %2, i32* %8
store i32 %3, i32* %9
%19 = bitcast [5 x i8]* %13 to i8*
store i32 0, i32* %18
%20 = load i8*, i8** %6
%21 = call i32 @asprintf(i8** %12, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %20)
store i32 %21, i32* %15
%22 = load i32, i32* %15
%23 = icmp slt i32 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %4
%25 = load i32, i32* @ENOMEM
%26 = sub nsw i32 0, %25
store i32 %26, i32* %5
br label %273
27: ; preds = %4
%28 = load i8*, i8** %12
%29 = call i32 @open(i8* %28, i32 0)
store i32 %29, i32* %14
%30 = load i32, i32* %14
%31 = icmp eq i32 %30, -1
br i1 %31, label %32, label %38
32: ; preds = %27
%33 = load i32, i32* @errno
%34 = sub nsw i32 0, %33
store i32 %34, i32* %15
%35 = load i32, i32* @stderr
%36 = load i8*, i8** %12
%37 = call i32 (i32, i8*, ...) @fprintf(i32 %35, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %36)
br label %263
38: ; preds = %27
store i32 0, i32* %16
br label %39
39: ; preds = %54, %38
%40 = load i32, i32* %16
%41 = load i32, i32* %8
%42 = icmp slt i32 %40, %41
br i1 %42, label %43, label %57
43: ; preds = %39
%44 = load i32*, i32** %7
%45 = load i32, i32* %16
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i32, i32* %44, i64 %46
%48 = load i32, i32* %47
%49 = getelementptr inbounds %struct.gpiohandle_request, %struct.gpiohandle_request* %10, i32 0, i32 0
%50 = load i32*, i32** %49
%51 = load i32, i32* %16
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i32, i32* %50, i64 %52
store i32 %48, i32* %53
br label %54
54: ; preds = %43
%55 = load i32, i32* %16
%56 = add nsw i32 %55, 1
store i32 %56, i32* %16
br label %39
57: ; preds = %39
%58 = load i32, i32* @GPIOHANDLE_REQUEST_OUTPUT
%59 = getelementptr inbounds %struct.gpiohandle_request, %struct.gpiohandle_request* %10, i32 0, i32 5
store i32 %58, i32* %59
%60 = getelementptr inbounds %struct.gpiohandle_request, %struct.gpiohandle_request* %10, i32 0, i32 4
%61 = load i32, i32* %60
%62 = call i32 @strcpy(i32 %61, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%63 = load i32, i32* %8
%64 = getelementptr inbounds %struct.gpiohandle_request, %struct.gpiohandle_request* %10, i32 0, i32 1
store i32 %63, i32* %64
%65 = load i32, i32* %14
%66 = load i32, i32* @GPIO_GET_LINEHANDLE_IOCTL
%67 = call i32 @ioctl(i32 %65, i32 %66, %struct.gpiohandle_request* %10)
store i32 %67, i32* %15
%68 = load i32, i32* %15
%69 = icmp eq i32 %68, -1
br i1 %69, label %70, label %76
70: ; preds = %57
%71 = load i32, i32* @errno
%72 = sub nsw i32 0, %71
store i32 %72, i32* %15
%73 = load i32, i32* @stderr
%74 = load i32, i32* %15
%75 = call i32 (i32, i8*, ...) @fprintf(i32 %73, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0), i32 %74)
br label %263
76: ; preds = %57
%77 = getelementptr inbounds %struct.gpiohandle_request, %struct.gpiohandle_request* %10, i32 0, i32 2
%78 = load i32, i32* %77
%79 = load i32, i32* @GPIOHANDLE_GET_LINE_VALUES_IOCTL
%80 = bitcast %struct.gpiohandle_data* %11 to %struct.gpiohandle_request*
%81 = call i32 @ioctl(i32 %78, i32 %79, %struct.gpiohandle_request* %80)
store i32 %81, i32* %15
%82 = load i32, i32* %15
%83 = icmp eq i32 %82, -1
br i1 %83, label %84, label %90
84: ; preds = %76
%85 = load i32, i32* @errno
%86 = sub nsw i32 0, %85
store i32 %86, i32* %15
%87 = load i32, i32* @stderr
%88 = load i32, i32* %15
%89 = call i32 (i32, i8*, ...) @fprintf(i32 %87, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.4, i64 0, i64 0), i32 %88)
br label %263
90: ; preds = %76
%91 = load i32, i32* @stdout
%92 = call i32 (i32, i8*, ...) @fprintf(i32 %91, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %16
br label %93
93: ; preds = %113, %90
%94 = load i32, i32* %16
%95 = load i32, i32* %8
%96 = icmp slt i32 %94, %95
br i1 %96, label %97, label %116
97: ; preds = %93
%98 = load i32, i32* @stdout
%99 = load i32*, i32** %7
%100 = load i32, i32* %16
%101 = sext i32 %100 to i64
%102 = getelementptr inbounds i32, i32* %99, i64 %101
%103 = load i32, i32* %102
%104 = call i32 (i32, i8*, ...) @fprintf(i32 %98, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32 %103)
%105 = load i32, i32* %16
%106 = load i32, i32* %8
%107 = sub nsw i32 %106, 1
%108 = icmp ne i32 %105, %107
br i1 %108, label %109, label %112
109: ; preds = %97
%110 = load i32, i32* @stdout
%111 = call i32 (i32, i8*, ...) @fprintf(i32 %110, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
br label %112
112: ; preds = %109, %97
br label %113
113: ; preds = %112
%114 = load i32, i32* %16
%115 = add nsw i32 %114, 1
store i32 %115, i32* %16
br label %93
116: ; preds = %93
%117 = load i32, i32* @stdout
%118 = load i8*, i8** %6
%119 = call i32 (i32, i8*, ...) @fprintf(i32 %117, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.8, i64 0, i64 0), i8* %118)
store i32 0, i32* %16
br label %120
120: ; preds = %141, %116
%121 = load i32, i32* %16
%122 = load i32, i32* %8
%123 = icmp slt i32 %121, %122
br i1 %123, label %124, label %144
124: ; preds = %120
%125 = load i32, i32* @stdout
%126 = getelementptr inbounds %struct.gpiohandle_data, %struct.gpiohandle_data* %11, i32 0, i32 3
%127 = load i32*, i32** %126
%128 = load i32, i32* %16
%129 = sext i32 %128 to i64
%130 = getelementptr inbounds i32, i32* %127, i64 %129
%131 = load i32, i32* %130
%132 = call i32 (i32, i8*, ...) @fprintf(i32 %125, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32 %131)
%133 = load i32, i32* %16
%134 = load i32, i32* %8
%135 = sub nsw i32 %134, 1
%136 = icmp ne i32 %133, %135
br i1 %136, label %137, label %140
137: ; preds = %124
%138 = load i32, i32* @stdout
%139 = call i32 (i32, i8*, ...) @fprintf(i32 %138, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
br label %140
140: ; preds = %137, %124
br label %141
141: ; preds = %140
%142 = load i32, i32* %16
%143 = add nsw i32 %142, 1
store i32 %143, i32* %16
br label %120
144: ; preds = %120
%145 = load i32, i32* @stdout
%146 = call i32 (i32, i8*, ...) @fprintf(i32 %145, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0))
store i32 0, i32* %17
br label %147
147: ; preds = %144, %259
store i32 0, i32* %16
br label %148
148: ; preds = %167, %147
%149 = load i32, i32* %16
%150 = load i32, i32* %8
%151 = icmp slt i32 %149, %150
br i1 %151, label %152, label %170
152: ; preds = %148
%153 = getelementptr inbounds %struct.gpiohandle_data, %struct.gpiohandle_data* %11, i32 0, i32 3
%154 = load i32*, i32** %153
%155 = load i32, i32* %16
%156 = sext i32 %155 to i64
%157 = getelementptr inbounds i32, i32* %154, i64 %156
%158 = load i32, i32* %157
%159 = icmp ne i32 %158, 0
%160 = xor i1 %159, true
%161 = zext i1 %160 to i32
%162 = getelementptr inbounds %struct.gpiohandle_data, %struct.gpiohandle_data* %11, i32 0, i32 3
%163 = load i32*, i32** %162
%164 = load i32, i32* %16
%165 = sext i32 %164 to i64
%166 = getelementptr inbounds i32, i32* %163, i64 %165
store i32 %161, i32* %166
br label %167
167: ; preds = %152
%168 = load i32, i32* %16
%169 = add nsw i32 %168, 1
store i32 %169, i32* %16
br label %148
170: ; preds = %148
%171 = getelementptr inbounds %struct.gpiohandle_request, %struct.gpiohandle_request* %10, i32 0, i32 2
%172 = load i32, i32* %171
%173 = load i32, i32* @GPIOHANDLE_SET_LINE_VALUES_IOCTL
%174 = bitcast %struct.gpiohandle_data* %11 to %struct.gpiohandle_request*
%175 = call i32 @ioctl(i32 %172, i32 %173, %struct.gpiohandle_request* %174)
store i32 %175, i32* %15
%176 = load i32, i32* %15
%177 = icmp eq i32 %176, -1
br i1 %177, label %178, label %184
178: ; preds = %170
%179 = load i32, i32* @errno
%180 = sub nsw i32 0, %179
store i32 %180, i32* %15
%181 = load i32, i32* @stderr
%182 = load i32, i32* %15
%183 = call i32 (i32, i8*, ...) @fprintf(i32 %181, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.10, i64 0, i64 0), i32 %182)
br label %263
184: ; preds = %170
%185 = getelementptr inbounds %struct.gpiohandle_request, %struct.gpiohandle_request* %10, i32 0, i32 2
%186 = load i32, i32* %185
%187 = load i32, i32* @GPIOHANDLE_GET_LINE_VALUES_IOCTL
%188 = bitcast %struct.gpiohandle_data* %11 to %struct.gpiohandle_request*
%189 = call i32 @ioctl(i32 %186, i32 %187, %struct.gpiohandle_request* %188)
store i32 %189, i32* %15
%190 = load i32, i32* %15
%191 = icmp eq i32 %190, -1
br i1 %191, label %192, label %198
192: ; preds = %184
%193 = load i32, i32* @errno
%194 = sub nsw i32 0, %193
store i32 %194, i32* %15
%195 = load i32, i32* @stderr
%196 = load i32, i32* %15
%197 = call i32 (i32, i8*, ...) @fprintf(i32 %195, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.4, i64 0, i64 0), i32 %196)
br label %263
198: ; preds = %184
%199 = load i32, i32* @stdout
%200 = load i32, i32* %17
%201 = sext i32 %200 to i64
%202 = getelementptr inbounds [5 x i8], [5 x i8]* %13, i64 0, i64 %201
%203 = load i8, i8* %202
%204 = sext i8 %203 to i32
%205 = call i32 (i32, i8*, ...) @fprintf(i32 %199, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0), i32 %204)
%206 = load i32, i32* %17
%207 = add nsw i32 %206, 1
store i32 %207, i32* %17
%208 = load i32, i32* %17
%209 = sext i32 %208 to i64
%210 = icmp eq i64 %209, 4
br i1 %210, label %211, label %212
211: ; preds = %198
store i32 0, i32* %17
br label %212
212: ; preds = %211, %198
%213 = load i32, i32* @stdout
%214 = call i32 (i32, i8*, ...) @fprintf(i32 %213, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i64 0, i64 0))
store i32 0, i32* %16
br label %215
215: ; preds = %241, %212
%216 = load i32, i32* %16
%217 = load i32, i32* %8
%218 = icmp slt i32 %216, %217
br i1 %218, label %219, label %244
219: ; preds = %215
%220 = load i32, i32* @stdout
%221 = load i32*, i32** %7
%222 = load i32, i32* %16
%223 = sext i32 %222 to i64
%224 = getelementptr inbounds i32, i32* %221, i64 %223
%225 = load i32, i32* %224
%226 = getelementptr inbounds %struct.gpiohandle_data, %struct.gpiohandle_data* %11, i32 0, i32 3
%227 = load i32*, i32** %226
%228 = load i32, i32* %16
%229 = sext i32 %228 to i64
%230 = getelementptr inbounds i32, i32* %227, i64 %229
%231 = load i32, i32* %230
%232 = call i32 (i32, i8*, ...) @fprintf(i32 %220, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.13, i64 0, i64 0), i32 %225, i32 %231)
%233 = load i32, i32* %16
%234 = load i32, i32* %8
%235 = sub nsw i32 %234, 1
%236 = icmp ne i32 %233, %235
br i1 %236, label %237, label %240
237: ; preds = %219
%238 = load i32, i32* @stdout
%239 = call i32 (i32, i8*, ...) @fprintf(i32 %238, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
br label %240
240: ; preds = %237, %219
br label %241
241: ; preds = %240
%242 = load i32, i32* %16
%243 = add nsw i32 %242, 1
store i32 %243, i32* %16
br label %215
244: ; preds = %215
%245 = load i32, i32* @stdout
%246 = call i32 (i32, i8*, ...) @fprintf(i32 %245, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.14, i64 0, i64 0))
%247 = load i32, i32* @stdout
%248 = call i32 @fflush(i32 %247)
%249 = call i32 @sleep(i32 1)
%250 = load i32, i32* %18
%251 = add i32 %250, 1
store i32 %251, i32* %18
%252 = load i32, i32* %9
%253 = icmp ne i32 %252, 0
br i1 %253, label %254, label %259
254: ; preds = %244
%255 = load i32, i32* %18
%256 = load i32, i32* %9
%257 = icmp eq i32 %255, %256
br i1 %257, label %258, label %259
258: ; preds = %254
br label %260
259: ; preds = %254, %244
br label %147
260: ; preds = %258
%261 = load i32, i32* @stdout
%262 = call i32 (i32, i8*, ...) @fprintf(i32 %261, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.15, i64 0, i64 0))
store i32 0, i32* %15
br label %263
263: ; preds = %260, %192, %178, %84, %70, %32
%264 = load i32, i32* %14
%265 = call i32 @close(i32 %264)
%266 = icmp eq i32 %265, -1
br i1 %266, label %267, label %269
267: ; preds = %263
%268 = call i32 @perror(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.16, i64 0, i64 0))
br label %269
269: ; preds = %267, %263
%270 = load i8*, i8** %12
%271 = call i32 @free(i8* %270)
%272 = load i32, i32* %15
store i32 %272, i32* %5
br label %273
273: ; preds = %269, %24
%274 = load i32, i32* %5
ret i32 %274
}

LLVM IR (-O2):
%struct.gpiohandle_request = type { i32*, i32, i32, i32*, i32, i32 }
%struct.gpiohandle_data = type { i32*, i32, i32, i32*, i32, i32 }
@__const.hammer_device.swirr = [5 x i8] c"-\\|/\00"
@.str = [8 x i8] c"/dev/%s\00"
@ENOMEM = global i32 0
@errno = global i32 0
@stderr = global i32 0
@.str.1 = [19 x i8] c"Failed to open %s\0A\00"
@GPIOHANDLE_REQUEST_OUTPUT = global i32 0
@.str.2 = [12 x i8] c"gpio-hammer\00"
@GPIO_GET_LINEHANDLE_IOCTL = global i32 0
@.str.3 = [43 x i8] c"Failed to issue GET LINEHANDLE IOCTL (%d)\0A\00"
@GPIOHANDLE_GET_LINE_VALUES_IOCTL = global i32 0
@.str.4 = [55 x i8] c"Failed to issue GPIOHANDLE GET LINE VALUES IOCTL (%d)\0A\00"
@stdout = global i32 0
@.str.5 = [15 x i8] c"Hammer lines [\00"
@.str.6 = [3 x i8] c"%d\00"
@.str.7 = [3 x i8] c", \00"
@.str.8 = [27 x i8] c"] on %s, initial states: [\00"
@.str.9 = [3 x i8] c"]\0A\00"
@GPIOHANDLE_SET_LINE_VALUES_IOCTL = global i32 0
@.str.10 = [55 x i8] c"Failed to issue GPIOHANDLE SET LINE VALUES IOCTL (%d)\0A\00"
@.str.11 = [6 x i8] c"[%c] \00"
@.str.12 = [2 x i8] c"[\00"
@.str.13 = [7 x i8] c"%d: %d\00"
@.str.14 = [3 x i8] c"]\0D\00"
@.str.15 = [2 x i8] c"\0A\00"
@.str.16 = [43 x i8] c"Failed to close GPIO character device file\00"
define i32 @hammer_device(i8* %0, i32* nocapture %1, i32 %2, i32 %3) {
%5 = alloca %struct.gpiohandle_request
%6 = alloca %struct.gpiohandle_data
%7 = alloca i8*
%8 = bitcast %struct.gpiohandle_request* %5 to i8*
%9 = bitcast %struct.gpiohandle_data* %6 to i8*
%10 = bitcast i8** %7 to i8*
%11 = call i32 @asprintf(i8** %7, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %0)
%12 = icmp slt i32 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %4
%14 = load i32, i32* @ENOMEM
%15 = sub nsw i32 0, %14
br label %381
16: ; preds = %4
%17 = load i8*, i8** %7
%18 = call i32 @open(i8* %17, i32 0)
%19 = icmp eq i32 %18, -1
br i1 %19, label %130, label %20
20: ; preds = %16
%21 = icmp sgt i32 %2, 0
br i1 %21, label %22, label %155
22: ; preds = %20
%23 = getelementptr inbounds %struct.gpiohandle_request, %struct.gpiohandle_request* %5, i64 0, i32 0
%24 = load i32*, i32** %23
%25 = zext i32 %2 to i64
%26 = icmp ult i32 %2, 8
br i1 %26, label %112, label %27
27: ; preds = %22
%28 = getelementptr i32, i32* %24, i64 %25
%29 = getelementptr i32, i32* %1, i64 %25
%30 = icmp ult i32* %24, %29
%31 = icmp ugt i32* %28, %1
%32 = and i1 %30, %31
br i1 %32, label %112, label %33
33: ; preds = %27
%34 = and i64 %25, 4294967288
%35 = add nsw i64 %34, -8
%36 = lshr exact i64 %35, 3
%37 = add nuw nsw i64 %36, 1
%38 = and i64 %37, 3
%39 = icmp ult i64 %35, 24
br i1 %39, label %91, label %40
40: ; preds = %33
%41 = and i64 %37, 4611686018427387900
br label %42
42: ; preds = %42, %40
%43 = phi i64 [ 0, %40 ], [ %88, %42 ]
%44 = phi i64 [ 0, %40 ], [ %89, %42 ]
%45 = getelementptr inbounds i32, i32* %1, i64 %43
%46 = bitcast i32* %45 to <4 x i32>*
%47 = load <4 x i32>, <4 x i32>* %46
%48 = getelementptr inbounds i32, i32* %45, i64 4
%49 = bitcast i32* %48 to <4 x i32>*
%50 = load <4 x i32>, <4 x i32>* %49
%51 = getelementptr inbounds i32, i32* %24, i64 %43
%52 = bitcast i32* %51 to <4 x i32>*
store <4 x i32> %47, <4 x i32>* %52
%53 = getelementptr inbounds i32, i32* %51, i64 4
%54 = bitcast i32* %53 to <4 x i32>*
store <4 x i32> %50, <4 x i32>* %54
%55 = or i64 %43, 8
%56 = getelementptr inbounds i32, i32* %1, i64 %55
%57 = bitcast i32* %56 to <4 x i32>*
%58 = load <4 x i32>, <4 x i32>* %57
%59 = getelementptr inbounds i32, i32* %56, i64 4
%60 = bitcast i32* %59 to <4 x i32>*
%61 = load <4 x i32>, <4 x i32>* %60
%62 = getelementptr inbounds i32, i32* %24, i64 %55
%63 = bitcast i32* %62 to <4 x i32>*
store <4 x i32> %58, <4 x i32>* %63
%64 = getelementptr inbounds i32, i32* %62, i64 4
%65 = bitcast i32* %64 to <4 x i32>*
store <4 x i32> %61, <4 x i32>* %65
%66 = or i64 %43, 16
%67 = getelementptr inbounds i32, i32* %1, i64 %66
%68 = bitcast i32* %67 to <4 x i32>*
%69 = load <4 x i32>, <4 x i32>* %68
%70 = getelementptr inbounds i32, i32* %67, i64 4
%71 = bitcast i32* %70 to <4 x i32>*
%72 = load <4 x i32>, <4 x i32>* %71
%73 = getelementptr inbounds i32, i32* %24, i64 %66
%74 = bitcast i32* %73 to <4 x i32>*
store <4 x i32> %69, <4 x i32>* %74
%75 = getelementptr inbounds i32, i32* %73, i64 4
%76 = bitcast i32* %75 to <4 x i32>*
store <4 x i32> %72, <4 x i32>* %76
%77 = or i64 %43, 24
%78 = getelementptr inbounds i32, i32* %1, i64 %77
%79 = bitcast i32* %78 to <4 x i32>*
%80 = load <4 x i32>, <4 x i32>* %79
%81 = getelementptr inbounds i32, i32* %78, i64 4
%82 = bitcast i32* %81 to <4 x i32>*
%83 = load <4 x i32>, <4 x i32>* %82
%84 = getelementptr inbounds i32, i32* %24, i64 %77
%85 = bitcast i32* %84 to <4 x i32>*
store <4 x i32> %80, <4 x i32>* %85
%86 = getelementptr inbounds i32, i32* %84, i64 4
%87 = bitcast i32* %86 to <4 x i32>*
store <4 x i32> %83, <4 x i32>* %87
%88 = add nuw i64 %43, 32
%89 = add i64 %44, 4
%90 = icmp eq i64 %89, %41
br i1 %90, label %91, label %42
91: ; preds = %42, %33
%92 = phi i64 [ 0, %33 ], [ %88, %42 ]
%93 = icmp eq i64 %38, 0
br i1 %93, label %110, label %94
94: ; preds = %91, %94
%95 = phi i64 [ %107, %94 ], [ %92, %91 ]
%96 = phi i64 [ %108, %94 ], [ 0, %91 ]
%97 = getelementptr inbounds i32, i32* %1, i64 %95
%98 = bitcast i32* %97 to <4 x i32>*
%99 = load <4 x i32>, <4 x i32>* %98
%100 = getelementptr inbounds i32, i32* %97, i64 4
%101 = bitcast i32* %100 to <4 x i32>*
%102 = load <4 x i32>, <4 x i32>* %101
%103 = getelementptr inbounds i32, i32* %24, i64 %95
%104 = bitcast i32* %103 to <4 x i32>*
store <4 x i32> %99, <4 x i32>* %104
%105 = getelementptr inbounds i32, i32* %103, i64 4
%106 = bitcast i32* %105 to <4 x i32>*
store <4 x i32> %102, <4 x i32>* %106
%107 = add nuw i64 %95, 8
%108 = add i64 %96, 1
%109 = icmp eq i64 %108, %38
br i1 %109, label %110, label %94
110: ; preds = %94, %91
%111 = icmp eq i64 %34, %25
br i1 %111, label %155, label %112
112: ; preds = %27, %22, %110
%113 = phi i64 [ 0, %27 ], [ 0, %22 ], [ %34, %110 ]
%114 = xor i64 %113, -1
%115 = add nsw i64 %114, %25
%116 = and i64 %25, 3
%117 = icmp eq i64 %116, 0
br i1 %117, label %127, label %118
118: ; preds = %112, %118
%119 = phi i64 [ %124, %118 ], [ %113, %112 ]
%120 = phi i64 [ %125, %118 ], [ 0, %112 ]
%121 = getelementptr inbounds i32, i32* %1, i64 %119
%122 = load i32, i32* %121
%123 = getelementptr inbounds i32, i32* %24, i64 %119
store i32 %122, i32* %123
%124 = add nuw nsw i64 %119, 1
%125 = add i64 %120, 1
%126 = icmp eq i64 %125, %116
br i1 %126, label %127, label %118
127: ; preds = %118, %112
%128 = phi i64 [ %113, %112 ], [ %124, %118 ]
%129 = icmp ult i64 %115, 3
br i1 %129, label %155, label %136
130: ; preds = %16
%131 = load i32, i32* @errno
%132 = sub nsw i32 0, %131
%133 = load i32, i32* @stderr
%134 = load i8*, i8** %7
%135 = call i32 (i32, i8*, ...) @fprintf(i32 %133, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %134)
br label %372
136: ; preds = %127, %136
%137 = phi i64 [ %153, %136 ], [ %128, %127 ]
%138 = getelementptr inbounds i32, i32* %1, i64 %137
%139 = load i32, i32* %138
%140 = getelementptr inbounds i32, i32* %24, i64 %137
store i32 %139, i32* %140
%141 = add nuw nsw i64 %137, 1
%142 = getelementptr inbounds i32, i32* %1, i64 %141
%143 = load i32, i32* %142
%144 = getelementptr inbounds i32, i32* %24, i64 %141
store i32 %143, i32* %144
%145 = add nuw nsw i64 %137, 2
%146 = getelementptr inbounds i32, i32* %1, i64 %145
%147 = load i32, i32* %146
%148 = getelementptr inbounds i32, i32* %24, i64 %145
store i32 %147, i32* %148
%149 = add nuw nsw i64 %137, 3
%150 = getelementptr inbounds i32, i32* %1, i64 %149
%151 = load i32, i32* %150
%152 = getelementptr inbounds i32, i32* %24, i64 %149
store i32 %151, i32* %152
%153 = add nuw nsw i64 %137, 4
%154 = icmp eq i64 %153, %25
br i1 %154, label %155, label %136
155: ; preds = %127, %136, %110, %20
%156 = load i32, i32* @GPIOHANDLE_REQUEST_OUTPUT
%157 = getelementptr inbounds %struct.gpiohandle_request, %struct.gpiohandle_request* %5, i64 0, i32 5
store i32 %156, i32* %157
%158 = getelementptr inbounds %struct.gpiohandle_request, %struct.gpiohandle_request* %5, i64 0, i32 4
%159 = load i32, i32* %158
%160 = call i32 @strcpy(i32 %159, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%161 = getelementptr inbounds %struct.gpiohandle_request, %struct.gpiohandle_request* %5, i64 0, i32 1
store i32 %2, i32* %161
%162 = load i32, i32* @GPIO_GET_LINEHANDLE_IOCTL
%163 = call i32 @ioctl(i32 %18, i32 %162, %struct.gpiohandle_request* %5)
%164 = icmp eq i32 %163, -1
br i1 %164, label %165, label %170
165: ; preds = %155
%166 = load i32, i32* @errno
%167 = sub nsw i32 0, %166
%168 = load i32, i32* @stderr
%169 = call i32 (i32, i8*, ...) @fprintf(i32 %168, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0), i32 %167)
br label %372
170: ; preds = %155
%171 = getelementptr inbounds %struct.gpiohandle_request, %struct.gpiohandle_request* %5, i64 0, i32 2
%172 = load i32, i32* %171
%173 = load i32, i32* @GPIOHANDLE_GET_LINE_VALUES_IOCTL
%174 = bitcast %struct.gpiohandle_data* %6 to %struct.gpiohandle_request*
%175 = call i32 @ioctl(i32 %172, i32 %173, %struct.gpiohandle_request* %174)
%176 = icmp eq i32 %175, -1
br i1 %176, label %177, label %182
177: ; preds = %170
%178 = load i32, i32* @errno
%179 = sub nsw i32 0, %178
%180 = load i32, i32* @stderr
%181 = call i32 (i32, i8*, ...) @fprintf(i32 %180, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.4, i64 0, i64 0), i32 %179)
br label %372
182: ; preds = %170
%183 = load i32, i32* @stdout
%184 = call i32 (i32, i8*, ...) @fprintf(i32 %183, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
br i1 %21, label %188, label %185
185: ; preds = %182
%186 = load i32, i32* @stdout
%187 = call i32 (i32, i8*, ...) @fprintf(i32 %186, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.8, i64 0, i64 0), i8* %0)
br label %208
188: ; preds = %182
%189 = add nsw i32 %2, -1
%190 = zext i32 %189 to i64
%191 = zext i32 %2 to i64
br label %192
192: ; preds = %188, %202
%193 = phi i64 [ 0, %188 ], [ %203, %202 ]
%194 = load i32, i32* @stdout
%195 = getelementptr inbounds i32, i32* %1, i64 %193
%196 = load i32, i32* %195
%197 = call i32 (i32, i8*, ...) @fprintf(i32 %194, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32 %196)
%198 = icmp eq i64 %193, %190
br i1 %198, label %202, label %199
199: ; preds = %192
%200 = load i32, i32* @stdout
%201 = call i32 (i32, i8*, ...) @fprintf(i32 %200, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
br label %202
202: ; preds = %192, %199
%203 = add nuw nsw i64 %193, 1
%204 = icmp eq i64 %203, %191
br i1 %204, label %205, label %192
205: ; preds = %202
%206 = load i32, i32* @stdout
%207 = call i32 (i32, i8*, ...) @fprintf(i32 %206, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.8, i64 0, i64 0), i8* %0)
br i1 %21, label %211, label %208
208: ; preds = %185, %205
%209 = add nsw i32 %2, -1
%210 = zext i32 %209 to i64
br label %230
211: ; preds = %205
%212 = getelementptr inbounds %struct.gpiohandle_data, %struct.gpiohandle_data* %6, i64 0, i32 3
%213 = add nsw i32 %2, -1
%214 = zext i32 %213 to i64
%215 = zext i32 %2 to i64
br label %216
216: ; preds = %211, %227
%217 = phi i64 [ 0, %211 ], [ %228, %227 ]
%218 = load i32, i32* @stdout
%219 = load i32*, i32** %212
%220 = getelementptr inbounds i32, i32* %219, i64 %217
%221 = load i32, i32* %220
%222 = call i32 (i32, i8*, ...) @fprintf(i32 %218, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32 %221)
%223 = icmp eq i64 %217, %214
br i1 %223, label %227, label %224
224: ; preds = %216
%225 = load i32, i32* @stdout
%226 = call i32 (i32, i8*, ...) @fprintf(i32 %225, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
br label %227
227: ; preds = %216, %224
%228 = add nuw nsw i64 %217, 1
%229 = icmp eq i64 %228, %215
br i1 %229, label %230, label %216
230: ; preds = %227, %208
%231 = phi i64 [ %210, %208 ], [ %214, %227 ]
%232 = load i32, i32* @stdout
%233 = call i32 (i32, i8*, ...) @fprintf(i32 %232, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0))
%234 = getelementptr inbounds %struct.gpiohandle_data, %struct.gpiohandle_data* %6, i64 0, i32 3
%235 = icmp ne i32 %3, 0
%236 = zext i32 %2 to i64
%237 = zext i32 %2 to i64
%238 = and i64 %236, 4294967288
%239 = add nsw i64 %238, -8
%240 = lshr exact i64 %239, 3
%241 = add nuw nsw i64 %240, 1
%242 = icmp ult i32 %2, 8
%243 = and i64 %236, 4294967288
%244 = and i64 %241, 1
%245 = icmp eq i64 %239, 0
%246 = and i64 %241, 4611686018427387902
%247 = icmp eq i64 %244, 0
%248 = icmp eq i64 %243, %236
br label %249
249: ; preds = %360, %230
%250 = phi i32 [ 0, %230 ], [ %341, %360 ]
%251 = phi i32 [ 0, %230 ], [ %366, %360 ]
br i1 %21, label %252, label %312
252: ; preds = %249
%253 = load i32*, i32** %234
br i1 %242, label %302, label %254
254: ; preds = %252
br i1 %245, label %286, label %255
255: ; preds = %254, %255
%256 = phi i64 [ %283, %255 ], [ 0, %254 ]
%257 = phi i64 [ %284, %255 ], [ 0, %254 ]
%258 = getelementptr inbounds i32, i32* %253, i64 %256
%259 = bitcast i32* %258 to <4 x i32>*
%260 = load <4 x i32>, <4 x i32>* %259
%261 = getelementptr inbounds i32, i32* %258, i64 4
%262 = bitcast i32* %261 to <4 x i32>*
%263 = load <4 x i32>, <4 x i32>* %262
%264 = icmp eq <4 x i32> %260, zeroinitializer
%265 = icmp eq <4 x i32> %263, zeroinitializer
%266 = zext <4 x i1> %264 to <4 x i32>
%267 = zext <4 x i1> %265 to <4 x i32>
%268 = bitcast i32* %258 to <4 x i32>*
store <4 x i32> %266, <4 x i32>* %268
%269 = bitcast i32* %261 to <4 x i32>*
store <4 x i32> %267, <4 x i32>* %269
%270 = or i64 %256, 8
%271 = getelementptr inbounds i32, i32* %253, i64 %270
%272 = bitcast i32* %271 to <4 x i32>*
%273 = load <4 x i32>, <4 x i32>* %272
%274 = getelementptr inbounds i32, i32* %271, i64 4
%275 = bitcast i32* %274 to <4 x i32>*
%276 = load <4 x i32>, <4 x i32>* %275
%277 = icmp eq <4 x i32> %273, zeroinitializer
%278 = icmp eq <4 x i32> %276, zeroinitializer
%279 = zext <4 x i1> %277 to <4 x i32>
%280 = zext <4 x i1> %278 to <4 x i32>
%281 = bitcast i32* %271 to <4 x i32>*
store <4 x i32> %279, <4 x i32>* %281
%282 = bitcast i32* %274 to <4 x i32>*
store <4 x i32> %280, <4 x i32>* %282
%283 = add nuw i64 %256, 16
%284 = add i64 %257, 2
%285 = icmp eq i64 %284, %246
br i1 %285, label %286, label %255
286: ; preds = %255, %254
%287 = phi i64 [ 0, %254 ], [ %283, %255 ]
br i1 %247, label %301, label %288
288: ; preds = %286
%289 = getelementptr inbounds i32, i32* %253, i64 %287
%290 = bitcast i32* %289 to <4 x i32>*
%291 = load <4 x i32>, <4 x i32>* %290
%292 = getelementptr inbounds i32, i32* %289, i64 4
%293 = bitcast i32* %292 to <4 x i32>*
%294 = load <4 x i32>, <4 x i32>* %293
%295 = icmp eq <4 x i32> %291, zeroinitializer
%296 = icmp eq <4 x i32> %294, zeroinitializer
%297 = zext <4 x i1> %295 to <4 x i32>
%298 = zext <4 x i1> %296 to <4 x i32>
%299 = bitcast i32* %289 to <4 x i32>*
store <4 x i32> %297, <4 x i32>* %299
%300 = bitcast i32* %292 to <4 x i32>*
store <4 x i32> %298, <4 x i32>* %300
br label %301
301: ; preds = %286, %288
br i1 %248, label %312, label %302
302: ; preds = %252, %301
%303 = phi i64 [ 0, %252 ], [ %243, %301 ]
br label %304
304: ; preds = %302, %304
%305 = phi i64 [ %310, %304 ], [ %303, %302 ]
%306 = getelementptr inbounds i32, i32* %253, i64 %305
%307 = load i32, i32* %306
%308 = icmp eq i32 %307, 0
%309 = zext i1 %308 to i32
store i32 %309, i32* %306
%310 = add nuw nsw i64 %305, 1
%311 = icmp eq i64 %310, %236
br i1 %311, label %312, label %304
312: ; preds = %304, %301, %249
%313 = load i32, i32* %171
%314 = load i32, i32* @GPIOHANDLE_SET_LINE_VALUES_IOCTL
%315 = call i32 @ioctl(i32 %313, i32 %314, %struct.gpiohandle_request* %174)
%316 = icmp eq i32 %315, -1
br i1 %316, label %317, label %322
317: ; preds = %312
%318 = load i32, i32* @errno
%319 = sub nsw i32 0, %318
%320 = load i32, i32* @stderr
%321 = call i32 (i32, i8*, ...) @fprintf(i32 %320, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.10, i64 0, i64 0), i32 %319)
br label %372
322: ; preds = %312
%323 = load i32, i32* %171
%324 = load i32, i32* @GPIOHANDLE_GET_LINE_VALUES_IOCTL
%325 = call i32 @ioctl(i32 %323, i32 %324, %struct.gpiohandle_request* %174)
%326 = icmp eq i32 %325, -1
br i1 %326, label %327, label %332
327: ; preds = %322
%328 = load i32, i32* @errno
%329 = sub nsw i32 0, %328
%330 = load i32, i32* @stderr
%331 = call i32 (i32, i8*, ...) @fprintf(i32 %330, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.4, i64 0, i64 0), i32 %329)
br label %372
332: ; preds = %322
%333 = load i32, i32* @stdout
%334 = sext i32 %250 to i64
%335 = getelementptr inbounds [5 x i8], [5 x i8]* @__const.hammer_device.swirr, i64 0, i64 %334
%336 = load i8, i8* %335
%337 = sext i8 %336 to i32
%338 = call i32 (i32, i8*, ...) @fprintf(i32 %333, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0), i32 %337)
%339 = add nsw i32 %250, 1
%340 = icmp eq i32 %339, 4
%341 = select i1 %340, i32 0, i32 %339
%342 = load i32, i32* @stdout
%343 = call i32 (i32, i8*, ...) @fprintf(i32 %342, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i64 0, i64 0))
br i1 %21, label %344, label %360
344: ; preds = %332, %357
%345 = phi i64 [ %358, %357 ], [ 0, %332 ]
%346 = load i32, i32* @stdout
%347 = getelementptr inbounds i32, i32* %1, i64 %345
%348 = load i32, i32* %347
%349 = load i32*, i32** %234
%350 = getelementptr inbounds i32, i32* %349, i64 %345
%351 = load i32, i32* %350
%352 = call i32 (i32, i8*, ...) @fprintf(i32 %346, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.13, i64 0, i64 0), i32 %348, i32 %351)
%353 = icmp eq i64 %345, %231
br i1 %353, label %357, label %354
354: ; preds = %344
%355 = load i32, i32* @stdout
%356 = call i32 (i32, i8*, ...) @fprintf(i32 %355, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
br label %357
357: ; preds = %344, %354
%358 = add nuw nsw i64 %345, 1
%359 = icmp eq i64 %358, %237
br i1 %359, label %360, label %344
360: ; preds = %357, %332
%361 = load i32, i32* @stdout
%362 = call i32 (i32, i8*, ...) @fprintf(i32 %361, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.14, i64 0, i64 0))
%363 = load i32, i32* @stdout
%364 = call i32 @fflush(i32 %363)
%365 = call i32 @sleep(i32 1)
%366 = add i32 %251, 1
%367 = icmp eq i32 %366, %3
%368 = select i1 %235, i1 %367, i1 false
br i1 %368, label %369, label %249
369: ; preds = %360
%370 = load i32, i32* @stdout
%371 = call i32 (i32, i8*, ...) @fprintf(i32 %370, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.15, i64 0, i64 0))
br label %372
372: ; preds = %369, %327, %317, %177, %165, %130
%373 = phi i32 [ %132, %130 ], [ %167, %165 ], [ %179, %177 ], [ %319, %317 ], [ %329, %327 ], [ 0, %369 ]
%374 = call i32 @close(i32 %18)
%375 = icmp eq i32 %374, -1
br i1 %375, label %376, label %378
376: ; preds = %372
%377 = call i32 @perror(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.16, i64 0, i64 0))
br label %378
378: ; preds = %376, %372
%379 = load i8*, i8** %7
%380 = call i32 @free(i8* %379)
br label %381
381: ; preds = %378, %13
%382 = phi i32 [ %15, %13 ], [ %373, %378 ]
ret i32 %382
}