#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*/ uint8_t;
typedef int /*<<< orphan*/ uint64_t;
typedef int uint32_t;

/* Variables and functions */
int EOF;
int O_RDWR;
int O_SYNC;
void *calloc(int, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int getopt(int, char **, char *);
int ioctl(int, int, void *);
int /*<<< orphan*/ memcpy(int /*<<< orphan*/ *, int /*<<< orphan*/ *, int);
int open(char *, int);
char *optarg;
int optind;
int optopt;
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int strtol(char *, int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ strtoull(char *, int /*<<< orphan*/ *, int /*<<< orphan*/);
int ioctl_main(int argc, char *argv[]) {
  int c;
  int fd;
  int res;
  int read_only = 0;
  int length = -1;
  int arg_size = 4;
  int direct_arg = 0;
  uint32_t ioctl_nr;
  void *ioctl_args;
  uint8_t *ioctl_argp;
  uint8_t *ioctl_argp_save;
  int rem;
  do {
    c = getopt(argc, argv, "rdl:a:h");
    if (c == EOF)
      break;
    switch (c) {
    case 'r':
      read_only = 1;
      break;
    case 'd':
      direct_arg = 1;
      break;
    case 'l':
      length = strtol(optarg, NULL, 0);
      break;
    case 'a':
      arg_size = strtol(optarg, NULL, 0);
      break;
    case 'h':
      fprintf(stderr,
              "%s [-l <length>] [-a <argsize>] [-rdh] <device> <ioctlnr>\n"
              "  -l <lenght>   Length of io buffer\n"
              "  -a <argsize>  Size of each argument (1-8)\n"
              "  -r            Open device in read only mode\n"
              "  -d            Direct argument (no iobuffer)\n"
              "  -h            Print help\n",
              argv[0]);
      return -1;
    case '?':
      fprintf(stderr, "%s: invalid option -%c\n", argv[0], optopt);
      exit(1);
    }
  } while (1);
  if (optind + 2 > argc) {
    fprintf(stderr, "%s: too few arguments\n", argv[0]);
    exit(1);
  }
  fd = open(argv[optind], O_RDWR | O_SYNC);
  if (fd < 0) {
    fprintf(stderr, "cannot open %s\n", argv[optind]);
    return 1;
  }
  optind++;
  ioctl_nr = strtol(argv[optind], NULL, 0);
  optind++;
  if (direct_arg) {
    arg_size = 4;
    length = 4;
  }
  if (length < 0) {
    length = (argc - optind) * arg_size;
  }
  if (length) {
    ioctl_args = calloc(1, length);
    ioctl_argp_save = ioctl_argp = ioctl_args;
    rem = length;
    while (optind < argc) {
      uint64_t tmp = strtoull(argv[optind], NULL, 0);
      if (rem < arg_size) {
        fprintf(stderr, "%s: too many arguments\n", argv[0]);
        exit(1);
      }
      memcpy(ioctl_argp, &tmp, arg_size);
      ioctl_argp += arg_size;
      rem -= arg_size;
      optind++;
    }
  }
  printf("sending ioctl 0x%x", ioctl_nr);
  rem = length;
  while (rem--) {
    printf(" 0x%02x", *ioctl_argp_save++);
  }
  printf("\n");
  if (direct_arg)
    res = ioctl(fd, ioctl_nr, *(uint32_t *)ioctl_args);
  else if (length)
    res = ioctl(fd, ioctl_nr, ioctl_args);
  else
    res = ioctl(fd, ioctl_nr, 0);
  if (res < 0) {
    fprintf(stderr, "ioctl 0x%x failed, %d\n", ioctl_nr, res);
    return 1;
  }
  if (length) {
    printf("return buf:");
    ioctl_argp = ioctl_args;
    rem = length;
    while (rem--) {
      printf(" %02x", *ioctl_argp++);
    }
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<ioctl_main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0xffffffff,-0x24(%rbp)
movl   $0x4,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xef7(%rip),%rdx
call   10b0 <getopt@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2ddd(%rip),%rcx
cmp    (%rcx),%eax
jne    11f8 <ioctl_main+0x58>
jmp    12e2 <ioctl_main+0x142>
mov    -0x14(%rbp),%eax
add    $0xffffffc1,%eax
mov    %eax,%ecx
mov    %rcx,-0x58(%rbp)
sub    $0x33,%eax
ja     12ce <ioctl_main+0x12e>
mov    -0x58(%rbp),%rax
lea    0xde8(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x1,-0x20(%rbp)
jmp    12ce <ioctl_main+0x12e>
movl   $0x1,-0x2c(%rbp)
jmp    12ce <ioctl_main+0x12e>
mov    0x2db8(%rip),%rax
mov    (%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1080 <strtol@plt>
mov    %eax,-0x24(%rbp)
jmp    12ce <ioctl_main+0x12e>
mov    0x2d9b(%rip),%rax
mov    (%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1080 <strtol@plt>
mov    %eax,-0x28(%rbp)
jmp    12ce <ioctl_main+0x12e>
mov    0x2d36(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe4e(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    164a <ioctl_main+0x4aa>
mov    0x2d0c(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    0x2d1c(%rip),%rax
mov    (%rax),%ecx
lea    0xf1d(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
jmp    12d3 <ioctl_main+0x133>
mov    $0x1,%al
test   $0x1,%al
jne    11cb <ioctl_main+0x2b>
jmp    12e2 <ioctl_main+0x142>
mov    0x2cd7(%rip),%rax
mov    (%rax),%eax
add    $0x2,%eax
cmp    -0x8(%rbp),%eax
jle    131f <ioctl_main+0x17f>
mov    0x2cb2(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xee4(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x2c96(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rdi
mov    0x2ca8(%rip),%rax
mov    (%rax),%esi
mov    0x2c97(%rip),%rax
or     (%rax),%esi
call   10a0 <open@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    138a <ioctl_main+0x1ea>
mov    0x2c54(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x2c57(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xe92(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    164a <ioctl_main+0x4aa>
mov    0x2c2f(%rip),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    0x2c23(%rip),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
mov    0x2c16(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1080 <strtol@plt>
mov    %eax,-0x30(%rbp)
mov    0x2bfa(%rip),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    0x2bee(%rip),%rax
mov    %ecx,(%rax)
cmpl   $0x0,-0x2c(%rbp)
je     13ec <ioctl_main+0x24c>
movl   $0x4,-0x28(%rbp)
movl   $0x4,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jge    1409 <ioctl_main+0x269>
mov    -0x8(%rbp),%eax
mov    0x2bc0(%rip),%rcx
sub    (%rcx),%eax
imul   -0x28(%rbp),%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     14eb <ioctl_main+0x34b>
mov    -0x24(%rbp),%esi
mov    $0x1,%edi
call   1060 <calloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    %rax,-0x48(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x4c(%rbp)
mov    0x2b83(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jge    14e6 <ioctl_main+0x346>
mov    -0x10(%rbp),%rax
mov    0x2b6d(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1050 <strtoull@plt>
mov    %eax,-0x50(%rbp)
mov    -0x4c(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    149c <ioctl_main+0x2fc>
mov    0x2b35(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xd8e(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    -0x40(%rbp),%rdi
mov    -0x28(%rbp),%edx
lea    -0x50(%rbp),%rsi
call   1090 <memcpy@plt>
mov    -0x28(%rbp),%ecx
mov    -0x40(%rbp),%rax
movslq %ecx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x40(%rbp)
mov    -0x28(%rbp),%ecx
mov    -0x4c(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x4c(%rbp)
mov    0x2aed(%rip),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    0x2ae1(%rip),%rax
mov    %ecx,(%rax)
jmp    1436 <ioctl_main+0x296>
jmp    14eb <ioctl_main+0x34b>
mov    -0x30(%rbp),%esi
lea    0xd3c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x4c(%rbp)
cmp    $0x0,%eax
je     153a <ioctl_main+0x39a>
mov    -0x48(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x48(%rbp)
mov    (%rax),%esi
lea    0xd16(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1502 <ioctl_main+0x362>
lea    0xcaf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x2c(%rbp)
je     156c <ioctl_main+0x3cc>
mov    -0x18(%rbp),%edi
mov    -0x30(%rbp),%esi
mov    -0x38(%rbp),%rax
movslq (%rax),%rdx
call   1040 <ioctl@plt>
mov    %eax,-0x1c(%rbp)
jmp    15a4 <ioctl_main+0x404>
cmpl   $0x0,-0x24(%rbp)
je     158d <ioctl_main+0x3ed>
mov    -0x18(%rbp),%edi
mov    -0x30(%rbp),%esi
mov    -0x38(%rbp),%rdx
call   1040 <ioctl@plt>
mov    %eax,-0x1c(%rbp)
jmp    159f <ioctl_main+0x3ff>
mov    -0x18(%rbp),%edi
mov    -0x30(%rbp),%esi
xor    %eax,%eax
mov    %eax,%edx
call   1040 <ioctl@plt>
mov    %eax,-0x1c(%rbp)
jmp    15a4 <ioctl_main+0x404>
cmpl   $0x0,-0x1c(%rbp)
jge    15d7 <ioctl_main+0x437>
mov    0x29fb(%rip),%rax
mov    (%rax),%edi
mov    -0x30(%rbp),%edx
mov    -0x1c(%rbp),%ecx
lea    0xc88(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    164a <ioctl_main+0x4aa>
cmpl   $0x0,-0x24(%rbp)
je     1643 <ioctl_main+0x4a3>
lea    0xc7b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x38(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x4c(%rbp)
cmp    $0x0,%eax
je     1635 <ioctl_main+0x495>
mov    -0x40(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x40(%rbp)
mov    (%rax),%esi
lea    0xc46(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    15fd <ioctl_main+0x45d>
lea    0xbb4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ioctl_main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %edi,%ebp
lea    0xef1(%rip),%rdx
mov    %rsi,(%rsp)
call   10c0 <getopt@plt>
mov    0x2df1(%rip),%r13
cmp    0x0(%r13),%eax
jne    1366 <ioctl_main+0x1b6>
xor    %r15d,%r15d
mov    $0x4,%ebx
movl   $0xffffffff,0x8(%rsp)
ff
mov    0x2dc8(%rip),%rax
movslq (%rax),%rax
lea    0x2(%rax),%ecx
mov    %ebp,0x14(%rsp)
cmp    %ebp,%ecx
jg     15c4 <ioctl_main+0x414>
mov    (%rsp),%rbp
mov    0x0(%rbp,%rax,8),%rdi
mov    0x2dc6(%rip),%rax
mov    0x2db7(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
call   10b0 <open@plt>
test   %eax,%eax
js     13f9 <ioctl_main+0x249>
mov    %eax,0x10(%rsp)
mov    0x2d83(%rip),%r14
movslq (%r14),%rax
lea    0x1(%rax),%rcx
mov    %ecx,(%r14)
mov    0x8(%rbp,%rax,8),%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1090 <strtol@plt>
mov    %r15,%rcx
mov    %eax,%r15d
mov    (%r14),%r12d
add    $0x1,%r12d
mov    %r12d,(%r14)
mov    %rcx,0x30(%rsp)
test   %ecx,%ecx
mov    $0x4,%eax
mov    0x8(%rsp),%ecx
cmovne %eax,%ecx
cmovne %eax,%ebx
mov    0x14(%rsp),%r14d
mov    %r14d,%r13d
sub    %r12d,%r13d
imul   %ebx,%r13d
test   %ecx,%ecx
cmovns %ecx,%r13d
test   %r13d,%r13d
je     1424 <ioctl_main+0x274>
mov    $0x1,%edi
mov    %r13d,%esi
call   1070 <calloc@plt>
cmp    %r14d,%r12d
mov    %rax,0x20(%rsp)
jge    1437 <ioctl_main+0x287>
mov    %r15d,0x18(%rsp)
movslq %ebx,%rcx
mov    %r13,0x28(%rsp)
lea    (%rbx,%r13,1),%r15d
shl    $0x2,%rcx
mov    %rcx,0x8(%rsp)
mov    %rax,%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movslq %r12d,%rax
mov    0x0(%rbp,%rax,8),%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1060 <strtoull@plt>
mov    %eax,0x1c(%rsp)
sub    %ebx,%r15d
cmp    %ebx,%r15d
jl     156b <ioctl_main+0x3bb>
mov    0x8(%rsp),%rax
lea    (%r14,%rax,1),%r13
mov    %r14,%rdi
lea    0x1c(%rsp),%rsi
mov    %ebx,%edx
call   10a0 <memcpy@plt>
mov    0x2ca0(%rip),%rax
mov    (%rax),%r12d
add    $0x1,%r12d
mov    %r12d,(%rax)
mov    %r13,%r14
cmp    0x14(%rsp),%r12d
mov    (%rsp),%rbp
jl     12e0 <ioctl_main+0x130>
lea    0xeda(%rip),%rdi
mov    0x18(%rsp),%r15d
mov    %r15d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x28(%rsp),%r13
test   %r13d,%r13d
jne    1448 <ioctl_main+0x298>
mov    0x20(%rsp),%r12
jmp    1476 <ioctl_main+0x2c6>
movl   $0xffffffff,0x8(%rsp)
ff
mov    $0x4,%ebx
xor    %r15d,%r15d
lea    0xd3b(%rip),%r12
lea    0xc7c(%rip),%r14
jmp    13ae <ioctl_main+0x1fe>
cs nopw 0x0(%rax,%rax,1)
mov    $0x1,%r15d
mov    %ebp,%edi
mov    (%rsp),%rsi
mov    %r12,%rdx
call   10c0 <getopt@plt>
cmp    0x0(%r13),%eax
je     11f1 <ioctl_main+0x41>
add    $0xffffffc1,%eax
cmp    $0x2d,%eax
ja     1396 <ioctl_main+0x1e6>
movslq (%r14,%rax,4),%rax
add    %r14,%rax
jmp    *%rax
mov    0x2c32(%rip),%rax
mov    (%rax),%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1090 <strtol@plt>
mov    %eax,%ebx
jmp    1396 <ioctl_main+0x1e6>
cs nopw 0x0(%rax,%rax,1)
mov    0x2c11(%rip),%rax
mov    (%rax),%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1090 <strtol@plt>
mov    %eax,0x8(%rsp)
jmp    1396 <ioctl_main+0x1e6>
mov    0x2bb0(%rip),%rax
mov    (%rax),%edi
mov    0x2bb7(%rip),%rax
movslq (%rax),%rax
mov    0x0(%rbp,%rax,8),%rdx
lea    0xdd9(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
jmp    1555 <ioctl_main+0x3a5>
lea    0xdee(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1476 <ioctl_main+0x2c6>
lea    0xddb(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r13d,%ebp
lea    0xdda(%rip),%r14
xor    %ebx,%ebx
mov    0x20(%rsp),%r12
nopl   0x0(%rax)
mov    (%r12,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %ebx,%ebp
jne    1460 <ioctl_main+0x2b0>
mov    $0xa,%edi
call   1030 <putchar@plt>
cmpl   $0x0,0x30(%rsp)
je     14a6 <ioctl_main+0x2f6>
movslq (%r12),%rdx
mov    0x10(%rsp),%edi
mov    %r15d,%esi
call   1050 <ioctl@plt>
test   %eax,%eax
js     1539 <ioctl_main+0x389>
test   %r13d,%r13d
jne    14be <ioctl_main+0x30e>
jmp    1500 <ioctl_main+0x350>
test   %r13d,%r13d
mov    0x10(%rsp),%edi
je     1529 <ioctl_main+0x379>
mov    %r15d,%esi
mov    %r12,%rdx
call   1050 <ioctl@plt>
test   %eax,%eax
js     1539 <ioctl_main+0x389>
lea    0xd86(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r13d,%ebp
lea    0xd81(%rip),%r14
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    (%r12,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %ebx,%ebp
jne    14e0 <ioctl_main+0x330>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %ebx,%ebx
jmp    155a <ioctl_main+0x3aa>
mov    0x2aa5(%rip),%rax
mov    (%rax),%edi
mov    (%rsp),%rax
mov    (%rax),%rdx
lea    0xba5(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0xffffffff,%ebx
jmp    155a <ioctl_main+0x3aa>
xor    %ebx,%ebx
mov    %r15d,%esi
xor    %edx,%edx
call   1050 <ioctl@plt>
test   %eax,%eax
jns    155a <ioctl_main+0x3aa>
mov    0x2a70(%rip),%rcx
mov    (%rcx),%edi
lea    0xceb(%rip),%rsi
mov    %r15d,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2a3e(%rip),%rax
mov    (%rax),%edi
mov    (%rsp),%rax
mov    (%rax),%rdx
lea    0xc7f(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    0x2a16(%rip),%rax
mov    (%rax),%edi
mov    (%rsp),%rax
mov    (%rax),%rdx
mov    0x2a26(%rip),%rax
mov    (%rax),%ecx
lea    0xc0f(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    0x29e5(%rip),%rax
mov    (%rax),%edi
mov    (%rsp),%rax
mov    (%rax),%rdx
lea    0xbff(%rip),%rsi
jmp    1582 <ioctl_main+0x3d2>

LLVM IR (-O0):
@.str = [8 x i8] c"rdl:a:h\00"
@EOF = global i32 0
@optarg = global i8* null
@stderr = global i32 0
@.str.1 = [258 x i8] c"%s [-l <length>] [-a <argsize>] [-rdh] <device> <ioctlnr>\0A -l <lenght> Length of io buffer\0A -a <argsize> Size of each argument (1-8)\0A -r Open device in read only mode\0A -d Direct argument (no iobuffer)\0A -h Print help\0A\00"
@.str.2 = [24 x i8] c"%s: invalid option -%c\0A\00"
@optopt = global i32 0
@optind = global i32 0
@.str.3 = [23 x i8] c"%s: too few arguments\0A\00"
@O_RDWR = global i32 0
@O_SYNC = global i32 0
@.str.4 = [16 x i8] c"cannot open %s\0A\00"
@.str.5 = [24 x i8] c"%s: too many arguments\0A\00"
@.str.6 = [19 x i8] c"sending ioctl 0x%x\00"
@.str.7 = [8 x i8] c" 0x%02x\00"
@.str.8 = [2 x i8] c"\0A\00"
@.str.9 = [23 x i8] c"ioctl 0x%x failed, %d\0A\00"
@.str.10 = [12 x i8] c"return buf:\00"
@.str.11 = [6 x i8] c" %02x\00"
define i32 @ioctl_main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i8*
%15 = alloca i32*
%16 = alloca i32*
%17 = alloca i32
%18 = alloca i32
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %9
store i32 -1, i32* %10
store i32 4, i32* %11
store i32 0, i32* %12
br label %19
19: ; preds = %52, %2
%20 = load i32, i32* %4
%21 = load i8**, i8*** %5
%22 = call i32 @getopt(i32 %20, i8** %21, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
store i32 %22, i32* %6
%23 = load i32, i32* %6
%24 = load i32, i32* @EOF
%25 = icmp eq i32 %23, %24
br i1 %25, label %26, label %27
26: ; preds = %19
br label %53
27: ; preds = %19
%28 = load i32, i32* %6
switch i32 %28, label %51 [
i32 114, label %29
i32 100, label %30
i32 108, label %31
i32 97, label %34
i32 104, label %37
i32 63, label %43
]
29: ; preds = %27
store i32 1, i32* %9
br label %51
30: ; preds = %27
store i32 1, i32* %12
br label %51
31: ; preds = %27
%32 = load i8*, i8** @optarg
%33 = call i32 @strtol(i8* %32, i32* null, i32 0)
store i32 %33, i32* %10
br label %51
34: ; preds = %27
%35 = load i8*, i8** @optarg
%36 = call i32 @strtol(i8* %35, i32* null, i32 0)
store i32 %36, i32* %11
br label %51
37: ; preds = %27
%38 = load i32, i32* @stderr
%39 = load i8**, i8*** %5
%40 = getelementptr inbounds i8*, i8** %39, i64 0
%41 = load i8*, i8** %40
%42 = call i32 (i32, i8*, ...) @fprintf(i32 %38, i8* getelementptr inbounds ([258 x i8], [258 x i8]* @.str.1, i64 0, i64 0), i8* %41)
store i32 -1, i32* %3
br label %219
43: ; preds = %27
%44 = load i32, i32* @stderr
%45 = load i8**, i8*** %5
%46 = getelementptr inbounds i8*, i8** %45, i64 0
%47 = load i8*, i8** %46
%48 = load i32, i32* @optopt
%49 = call i32 (i32, i8*, ...) @fprintf(i32 %44, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* %47, i32 %48)
%50 = call i32 @exit(i32 1)
unreachable
51: ; preds = %27, %34, %31, %30, %29
br label %52
52: ; preds = %51
br i1 true, label %19, label %53
53: ; preds = %52, %26
%54 = load i32, i32* @optind
%55 = add nsw i32 %54, 2
%56 = load i32, i32* %4
%57 = icmp sgt i32 %55, %56
br i1 %57, label %58, label %65
58: ; preds = %53
%59 = load i32, i32* @stderr
%60 = load i8**, i8*** %5
%61 = getelementptr inbounds i8*, i8** %60, i64 0
%62 = load i8*, i8** %61
%63 = call i32 (i32, i8*, ...) @fprintf(i32 %59, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i8* %62)
%64 = call i32 @exit(i32 1)
unreachable
65: ; preds = %53
%66 = load i8**, i8*** %5
%67 = load i32, i32* @optind
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds i8*, i8** %66, i64 %68
%70 = load i8*, i8** %69
%71 = load i32, i32* @O_RDWR
%72 = load i32, i32* @O_SYNC
%73 = or i32 %71, %72
%74 = call i32 @open(i8* %70, i32 %73)
store i32 %74, i32* %7
%75 = load i32, i32* %7
%76 = icmp slt i32 %75, 0
br i1 %76, label %77, label %85
77: ; preds = %65
%78 = load i32, i32* @stderr
%79 = load i8**, i8*** %5
%80 = load i32, i32* @optind
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds i8*, i8** %79, i64 %81
%83 = load i8*, i8** %82
%84 = call i32 (i32, i8*, ...) @fprintf(i32 %78, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i8* %83)
store i32 1, i32* %3
br label %219
85: ; preds = %65
%86 = load i32, i32* @optind
%87 = add nsw i32 %86, 1
store i32 %87, i32* @optind
%88 = load i8**, i8*** %5
%89 = load i32, i32* @optind
%90 = sext i32 %89 to i64
%91 = getelementptr inbounds i8*, i8** %88, i64 %90
%92 = load i8*, i8** %91
%93 = call i32 @strtol(i8* %92, i32* null, i32 0)
store i32 %93, i32* %13
%94 = load i32, i32* @optind
%95 = add nsw i32 %94, 1
store i32 %95, i32* @optind
%96 = load i32, i32* %12
%97 = icmp ne i32 %96, 0
br i1 %97, label %98, label %99
98: ; preds = %85
store i32 4, i32* %11
store i32 4, i32* %10
br label %99
99: ; preds = %98, %85
%100 = load i32, i32* %10
%101 = icmp slt i32 %100, 0
br i1 %101, label %102, label %108
102: ; preds = %99
%103 = load i32, i32* %4
%104 = load i32, i32* @optind
%105 = sub nsw i32 %103, %104
%106 = load i32, i32* %11
%107 = mul nsw i32 %105, %106
store i32 %107, i32* %10
br label %108
108: ; preds = %102, %99
%109 = load i32, i32* %10
%110 = icmp ne i32 %109, 0
br i1 %110, label %111, label %152
111: ; preds = %108
%112 = load i32, i32* %10
%113 = call i8* @calloc(i32 1, i32 %112)
store i8* %113, i8** %14
%114 = load i8*, i8** %14
%115 = bitcast i8* %114 to i32*
store i32* %115, i32** %15
store i32* %115, i32** %16
%116 = load i32, i32* %10
store i32 %116, i32* %17
br label %117
117: ; preds = %138, %111
%118 = load i32, i32* @optind
%119 = load i32, i32* %4
%120 = icmp slt i32 %118, %119
br i1 %120, label %121, label %151
121: ; preds = %117
%122 = load i8**, i8*** %5
%123 = load i32, i32* @optind
%124 = sext i32 %123 to i64
%125 = getelementptr inbounds i8*, i8** %122, i64 %124
%126 = load i8*, i8** %125
%127 = call i32 @strtoull(i8* %126, i32* null, i32 0)
store i32 %127, i32* %18
%128 = load i32, i32* %17
%129 = load i32, i32* %11
%130 = icmp slt i32 %128, %129
br i1 %130, label %131, label %138
131: ; preds = %121
%132 = load i32, i32* @stderr
%133 = load i8**, i8*** %5
%134 = getelementptr inbounds i8*, i8** %133, i64 0
%135 = load i8*, i8** %134
%136 = call i32 (i32, i8*, ...) @fprintf(i32 %132, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i8* %135)
%137 = call i32 @exit(i32 1)
unreachable
138: ; preds = %121
%139 = load i32*, i32** %15
%140 = load i32, i32* %11
%141 = call i32 @memcpy(i32* %139, i32* %18, i32 %140)
%142 = load i32, i32* %11
%143 = load i32*, i32** %15
%144 = sext i32 %142 to i64
%145 = getelementptr inbounds i32, i32* %143, i64 %144
store i32* %145, i32** %15
%146 = load i32, i32* %11
%147 = load i32, i32* %17
%148 = sub nsw i32 %147, %146
store i32 %148, i32* %17
%149 = load i32, i32* @optind
%150 = add nsw i32 %149, 1
store i32 %150, i32* @optind
br label %117
151: ; preds = %117
br label %152
152: ; preds = %151, %108
%153 = load i32, i32* %13
%154 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i32 %153)
%155 = load i32, i32* %10
store i32 %155, i32* %17
br label %156
156: ; preds = %160, %152
%157 = load i32, i32* %17
%158 = add nsw i32 %157, -1
store i32 %158, i32* %17
%159 = icmp ne i32 %157, 0
br i1 %159, label %160, label %165
160: ; preds = %156
%161 = load i32*, i32** %16
%162 = getelementptr inbounds i32, i32* %161, i32 1
store i32* %162, i32** %16
%163 = load i32, i32* %161
%164 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0), i32 %163)
br label %156
165: ; preds = %156
%166 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%167 = load i32, i32* %12
%168 = icmp ne i32 %167, 0
br i1 %168, label %169, label %178
169: ; preds = %165
%170 = load i32, i32* %7
%171 = load i32, i32* %13
%172 = load i8*, i8** %14
%173 = bitcast i8* %172 to i32*
%174 = load i32, i32* %173
%175 = sext i32 %174 to i64
%176 = inttoptr i64 %175 to i8*
%177 = call i32 @ioctl(i32 %170, i32 %171, i8* %176)
store i32 %177, i32* %8
br label %191
178: ; preds = %165
%179 = load i32, i32* %10
%180 = icmp ne i32 %179, 0
br i1 %180, label %181, label %186
181: ; preds = %178
%182 = load i32, i32* %7
%183 = load i32, i32* %13
%184 = load i8*, i8** %14
%185 = call i32 @ioctl(i32 %182, i32 %183, i8* %184)
store i32 %185, i32* %8
br label %190
186: ; preds = %178
%187 = load i32, i32* %7
%188 = load i32, i32* %13
%189 = call i32 @ioctl(i32 %187, i32 %188, i8* null)
store i32 %189, i32* %8
br label %190
190: ; preds = %186, %181
br label %191
191: ; preds = %190, %169
%192 = load i32, i32* %8
%193 = icmp slt i32 %192, 0
br i1 %193, label %194, label %199
194: ; preds = %191
%195 = load i32, i32* @stderr
%196 = load i32, i32* %13
%197 = load i32, i32* %8
%198 = call i32 (i32, i8*, ...) @fprintf(i32 %195, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.9, i64 0, i64 0), i32 %196, i32 %197)
store i32 1, i32* %3
br label %219
199: ; preds = %191
%200 = load i32, i32* %10
%201 = icmp ne i32 %200, 0
br i1 %201, label %202, label %218
202: ; preds = %199
%203 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0))
%204 = load i8*, i8** %14
%205 = bitcast i8* %204 to i32*
store i32* %205, i32** %15
%206 = load i32, i32* %10
store i32 %206, i32* %17
br label %207
207: ; preds = %211, %202
%208 = load i32, i32* %17
%209 = add nsw i32 %208, -1
store i32 %209, i32* %17
%210 = icmp ne i32 %208, 0
br i1 %210, label %211, label %216
211: ; preds = %207
%212 = load i32*, i32** %15
%213 = getelementptr inbounds i32, i32* %212, i32 1
store i32* %213, i32** %15
%214 = load i32, i32* %212
%215 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0), i32 %214)
br label %207
216: ; preds = %207
%217 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
br label %218
218: ; preds = %216, %199
store i32 0, i32* %3
br label %219
219: ; preds = %218, %194, %77, %37
%220 = load i32, i32* %3
ret i32 %220
}

LLVM IR (-O2):
@.str = [8 x i8] c"rdl:a:h\00"
@EOF = global i32 0
@optarg = global i8* null
@stderr = global i32 0
@.str.1 = [258 x i8] c"%s [-l <length>] [-a <argsize>] [-rdh] <device> <ioctlnr>\0A -l <lenght> Length of io buffer\0A -a <argsize> Size of each argument (1-8)\0A -r Open device in read only mode\0A -d Direct argument (no iobuffer)\0A -h Print help\0A\00"
@.str.2 = [24 x i8] c"%s: invalid option -%c\0A\00"
@optopt = global i32 0
@optind = global i32 0
@.str.3 = [23 x i8] c"%s: too few arguments\0A\00"
@O_RDWR = global i32 0
@O_SYNC = global i32 0
@.str.4 = [16 x i8] c"cannot open %s\0A\00"
@.str.5 = [24 x i8] c"%s: too many arguments\0A\00"
@.str.6 = [19 x i8] c"sending ioctl 0x%x\00"
@.str.7 = [8 x i8] c" 0x%02x\00"
@.str.9 = [23 x i8] c"ioctl 0x%x failed, %d\0A\00"
@.str.10 = [12 x i8] c"return buf:\00"
@.str.11 = [6 x i8] c" %02x\00"
define i32 @ioctl_main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%5 = load i32, i32* @EOF
%6 = icmp eq i32 %4, %5
br i1 %6, label %36, label %7
7: ; preds = %2, %29
%8 = phi i32 [ %33, %29 ], [ %4, %2 ]
%9 = phi i32 [ %32, %29 ], [ 0, %2 ]
%10 = phi i32 [ %31, %29 ], [ 4, %2 ]
%11 = phi i32 [ %30, %29 ], [ -1, %2 ]
switch i32 %8, label %29 [
i32 63, label %23
i32 100, label %12
i32 108, label %13
i32 97, label %16
i32 104, label %19
]
12: ; preds = %7
br label %29
13: ; preds = %7
%14 = load i8*, i8** @optarg
%15 = tail call i32 @strtol(i8* nocapture %14, i32* null, i32 0)
br label %29
16: ; preds = %7
%17 = load i8*, i8** @optarg
%18 = tail call i32 @strtol(i8* nocapture %17, i32* null, i32 0)
br label %29
19: ; preds = %7
%20 = load i32, i32* @stderr
%21 = load i8*, i8** %1
%22 = tail call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([258 x i8], [258 x i8]* @.str.1, i64 0, i64 0), i8* %21)
br label %159
23: ; preds = %7
%24 = load i32, i32* @stderr
%25 = load i8*, i8** %1
%26 = load i32, i32* @optopt
%27 = tail call i32 (i32, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* %25, i32 %26)
%28 = tail call i32 @exit(i32 1)
unreachable
29: ; preds = %12, %13, %16, %7
%30 = phi i32 [ %11, %16 ], [ %15, %13 ], [ %11, %12 ], [ %11, %7 ]
%31 = phi i32 [ %18, %16 ], [ %10, %13 ], [ %10, %12 ], [ %10, %7 ]
%32 = phi i32 [ %9, %16 ], [ %9, %13 ], [ 1, %12 ], [ %9, %7 ]
%33 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%34 = load i32, i32* @EOF
%35 = icmp eq i32 %33, %34
br i1 %35, label %36, label %7
36: ; preds = %29, %2
%37 = phi i32 [ -1, %2 ], [ %30, %29 ]
%38 = phi i32 [ 4, %2 ], [ %31, %29 ]
%39 = phi i32 [ 0, %2 ], [ %32, %29 ]
%40 = load i32, i32* @optind
%41 = add nsw i32 %40, 2
%42 = icmp sgt i32 %41, %0
br i1 %42, label %43, label %48
43: ; preds = %36
%44 = load i32, i32* @stderr
%45 = load i8*, i8** %1
%46 = tail call i32 (i32, i8*, ...) @fprintf(i32 %44, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i8* %45)
%47 = tail call i32 @exit(i32 1)
unreachable
48: ; preds = %36
%49 = sext i32 %40 to i64
%50 = getelementptr inbounds i8*, i8** %1, i64 %49
%51 = load i8*, i8** %50
%52 = load i32, i32* @O_RDWR
%53 = load i32, i32* @O_SYNC
%54 = or i32 %53, %52
%55 = tail call i32 @open(i8* %51, i32 %54)
%56 = icmp slt i32 %55, 0
br i1 %56, label %57, label %64
57: ; preds = %48
%58 = load i32, i32* @stderr
%59 = load i32, i32* @optind
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds i8*, i8** %1, i64 %60
%62 = load i8*, i8** %61
%63 = tail call i32 (i32, i8*, ...) @fprintf(i32 %58, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i8* %62)
br label %159
64: ; preds = %48
%65 = load i32, i32* @optind
%66 = add nsw i32 %65, 1
store i32 %66, i32* @optind
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds i8*, i8** %1, i64 %67
%69 = load i8*, i8** %68
%70 = tail call i32 @strtol(i8* nocapture %69, i32* null, i32 0)
%71 = load i32, i32* @optind
%72 = add nsw i32 %71, 1
store i32 %72, i32* @optind
%73 = icmp eq i32 %39, 0
%74 = select i1 %73, i32 %37, i32 4
%75 = select i1 %73, i32 %38, i32 4
%76 = icmp slt i32 %74, 0
%77 = sub nsw i32 %0, %72
%78 = mul nsw i32 %77, %75
%79 = select i1 %76, i32 %78, i32 %74
%80 = icmp eq i32 %79, 0
br i1 %80, label %81, label %83
81: ; preds = %64
%82 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i32 %70)
br label %124
83: ; preds = %64
%84 = tail call i8* @calloc(i32 1, i32 %79)
%85 = bitcast i8* %84 to i32*
%86 = icmp slt i32 %72, %0
br i1 %86, label %89, label %87
87: ; preds = %83
%88 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i32 %70)
br label %115
89: ; preds = %83
%90 = bitcast i32* %3 to i8*
%91 = sext i32 %75 to i64
br label %92
92: ; preds = %89, %106
%93 = phi i32 [ %72, %89 ], [ %111, %106 ]
%94 = phi i32 [ %79, %89 ], [ %109, %106 ]
%95 = phi i32* [ %85, %89 ], [ %108, %106 ]
%96 = sext i32 %93 to i64
%97 = getelementptr inbounds i8*, i8** %1, i64 %96
%98 = load i8*, i8** %97
%99 = call i32 @strtoull(i8* nocapture %98, i32* null, i32 0)
store i32 %99, i32* %3
%100 = icmp slt i32 %94, %75
br i1 %100, label %101, label %106
101: ; preds = %92
%102 = load i32, i32* @stderr
%103 = load i8*, i8** %1
%104 = call i32 (i32, i8*, ...) @fprintf(i32 %102, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i8* %103)
%105 = call i32 @exit(i32 1)
unreachable
106: ; preds = %92
%107 = call i32 @memcpy(i32* %95, i32* %3, i32 %75)
%108 = getelementptr inbounds i32, i32* %95, i64 %91
%109 = sub nsw i32 %94, %75
%110 = load i32, i32* @optind
%111 = add nsw i32 %110, 1
store i32 %111, i32* @optind
%112 = icmp slt i32 %111, %0
br i1 %112, label %92, label %113
113: ; preds = %106
%114 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i32 %70)
br i1 %80, label %124, label %115
115: ; preds = %87, %113
br label %116
116: ; preds = %115, %116
%117 = phi i32 [ %119, %116 ], [ %79, %115 ]
%118 = phi i32* [ %120, %116 ], [ %85, %115 ]
%119 = add nsw i32 %117, -1
%120 = getelementptr inbounds i32, i32* %118, i64 1
%121 = load i32, i32* %118
%122 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0), i32 %121)
%123 = icmp eq i32 %119, 0
br i1 %123, label %124, label %116
124: ; preds = %116, %81, %113
%125 = phi i8* [ undef, %81 ], [ %84, %113 ], [ %84, %116 ]
%126 = call i32 @putchar(i32 10)
br i1 %73, label %127, label %128
127: ; preds = %124
br i1 %80, label %135, label %138
128: ; preds = %124
%129 = bitcast i8* %125 to i32*
%130 = load i32, i32* %129
%131 = sext i32 %130 to i64
%132 = inttoptr i64 %131 to i8*
%133 = call i32 @ioctl(i32 %55, i32 %70, i8* %132)
%134 = icmp slt i32 %133, 0
br i1 %134, label %141, label %145
135: ; preds = %127
%136 = call i32 @ioctl(i32 %55, i32 %70, i8* null)
%137 = icmp slt i32 %136, 0
br i1 %137, label %141, label %159
138: ; preds = %127
%139 = call i32 @ioctl(i32 %55, i32 %70, i8* %125)
%140 = icmp slt i32 %139, 0
br i1 %140, label %141, label %146
141: ; preds = %135, %138, %128
%142 = phi i32 [ %139, %138 ], [ %133, %128 ], [ %136, %135 ]
%143 = load i32, i32* @stderr
%144 = call i32 (i32, i8*, ...) @fprintf(i32 %143, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.9, i64 0, i64 0), i32 %70, i32 %142)
br label %159
145: ; preds = %128
br i1 %80, label %159, label %146
146: ; preds = %145, %138
%147 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0))
%148 = bitcast i8* %125 to i32*
br label %149
149: ; preds = %146, %149
%150 = phi i32 [ %152, %149 ], [ %79, %146 ]
%151 = phi i32* [ %153, %149 ], [ %148, %146 ]
%152 = add nsw i32 %150, -1
%153 = getelementptr inbounds i32, i32* %151, i64 1
%154 = load i32, i32* %151
%155 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0), i32 %154)
%156 = icmp eq i32 %152, 0
br i1 %156, label %157, label %149
157: ; preds = %149
%158 = call i32 @putchar(i32 10)
br label %159
159: ; preds = %135, %145, %157, %141, %57, %19
%160 = phi i32 [ 1, %57 ], [ 1, %141 ], [ -1, %19 ], [ 0, %157 ], [ 0, %145 ], [ 0, %135 ]
ret i32 %160
}