#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*/ FILE;

/* Variables and functions */
#define EEXIST 129
#define EINVAL 128
unsigned int atoi(char *);
scalar_t__ basename(char *);
int errno;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fileno(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, char *, ...);
int getopt(int, char **, char *);
int ioctl(int /*<<< orphan*/, int, unsigned int);
char *optarg;
size_t optind;
int /*<<< orphan*/ stderr;
char *strerror(int);
int /*<<< orphan*/ usage();
int main(int argc, char **argv) {
  char *progname = (char *)basename(argv[0]);
  int dis = 0, ro = 0, create = 0, remove = 0;
  int opt;
  char *file = 0;
  unsigned size = 0, off = 0;
  while ((opt = getopt(argc, argv, "cxrdo:s:")) != -1) {
    switch (opt) {
    case 'd':
      dis = 1;
      break;
    case 'r':
      ro = 1;
      break;
    case 'o':
      off = atoi(optarg);
      break;
    case 's':
      size = atoi(optarg);
      break;
    case 'c':
      create = 1;
      break;
    case 'x':
      remove = 1;
      break;
    }
  }
  char *loop = argv[optind];
  if (!loop) {
    usage();
    return 1;
  }
  if (!dis && !remove) {
    file = argv[optind + 1];
    if (!file) {
      usage();
      return 1;
    }
  }
  FILE *f = fopen(loop, "rw");
  if (!f && !create) {
    fprintf(stderr, "%s: could not open loop device '%s': %s\n", progname,
            argv[optind], strerror(errno));
    return 2;
  }
  int ret = 0;
  if (create) {
    if (!f) {
      f = fopen("/dev/loop0", "r");
      if (!f) {
        fprintf(stderr, "%s: could not open loop device '%s': %s\n", progname,
                "/dev/loop0", strerror(errno));
        return 2;
      }
      int rret = ioctl(fileno(f), 7, atoi(file));
      if (rret < 0) {
        fprintf(stderr, "%s: could not create loop device '%s': %s\n", progname,
                loop, strerror(errno));
      }
      fclose(f);
    } else {
      fprintf(stderr, "%s: could not create loop device '%s': file exists\n",
              progname, loop);
      return 2;
    }
  } else if (remove) {
    ret = ioctl(fileno(f), 5, 0);
  } else if (dis) {
    ret = ioctl(fileno(f), 1, 0);
  } else {
    ret = ioctl(fileno(f), 0, (int)file);
    if (ret)
      goto errors;
    if (ro) {
      if (ioctl(fileno(f), 6, 1)) {
        fprintf(stderr, "%s: could not set loop device '%s' as read only: %s\n",
                progname, loop, strerror(errno));
        ret = 4;
      }
    }
    if (size) {
      if (ioctl(fileno(f), 3, size)) {
        fprintf(stderr, "%s: could not set size on loop device '%s': %s\n",
                progname, loop, strerror(errno));
        ret = 5;
      }
    }
    if (off) {
      if (ioctl(fileno(f), 2, off)) {
        fprintf(stderr, "%s: could not set offset on loop device '%s': %s\n",
                progname, loop, strerror(errno));
        ret = 6;
      }
    }
  }
errors:
  if (ret == -1) {
    switch (errno) {
    case EINVAL:
      fprintf(stderr, "%s: Invalid loop device '%s'\n", progname, argv[optind]);
      break;
    case EEXIST:
      fprintf(stderr, "%s: Loop device '%s' is busy\n", progname, argv[optind]);
      break;
    default:
      fprintf(stderr, "%s: %s: %s\n", progname, argv[optind + 1],
              strerror(errno));
      break;
    }
  }
  return ret < 0 ? 3 : ret;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1060 <basename@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movq   $0x0,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
movl   $0x0,-0x40(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe4f(%rip),%rdx
call   10a0 <getopt@plt>
mov    %eax,-0x2c(%rbp)
cmp    $0xffffffff,%eax
je     12a1 <main+0x101>
mov    -0x2c(%rbp),%eax
add    $0xffffff9d,%eax
mov    %eax,%ecx
mov    %rcx,-0x60(%rbp)
sub    $0x15,%eax
ja     129c <main+0xfc>
mov    -0x60(%rbp),%rax
lea    0xdc6(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x1,-0x1c(%rbp)
jmp    129c <main+0xfc>
movl   $0x1,-0x20(%rbp)
jmp    129c <main+0xfc>
mov    0x2d96(%rip),%rax
mov    (%rax),%rdi
call   10b0 <atoi@plt>
mov    %eax,-0x40(%rbp)
jmp    129c <main+0xfc>
mov    0x2d7f(%rip),%rax
mov    (%rax),%rdi
call   10b0 <atoi@plt>
mov    %eax,-0x3c(%rbp)
jmp    129c <main+0xfc>
movl   $0x1,-0x24(%rbp)
jmp    129c <main+0xfc>
movl   $0x1,-0x28(%rbp)
jmp    11fb <main+0x5b>
mov    -0x10(%rbp),%rax
mov    0x2d34(%rip),%rcx
mov    (%rcx),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
jne    12d5 <main+0x135>
mov    $0x0,%al
call   1080 <usage@plt>
movl   $0x1,-0x4(%rbp)
jmp    1884 <main+0x6e4>
cmpl   $0x0,-0x1c(%rbp)
jne    1323 <main+0x183>
cmpl   $0x0,-0x28(%rbp)
jne    1323 <main+0x183>
mov    -0x10(%rbp),%rax
mov    0x2cec(%rip),%rcx
mov    (%rcx),%rcx
mov    0x8(%rax,%rcx,8),%rax
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    131e <main+0x17e>
mov    $0x0,%al
call   1080 <usage@plt>
movl   $0x1,-0x4(%rbp)
jmp    1884 <main+0x6e4>
jmp    1323 <main+0x183>
mov    -0x48(%rbp),%rdi
lea    0xd33(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
jne    13ac <main+0x20c>
cmpl   $0x0,-0x24(%rbp)
jne    13ac <main+0x20c>
mov    0x2c7d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x74(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    -0x10(%rbp),%rax
mov    0x2c75(%rip),%rcx
mov    (%rcx),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x68(%rbp)
mov    0x2c4b(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
mov    -0x74(%rbp),%edi
mov    -0x70(%rbp),%rdx
mov    -0x68(%rbp),%rcx
mov    %rax,%r8
lea    0xccb(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x2,-0x4(%rbp)
jmp    1884 <main+0x6e4>
movl   $0x0,-0x54(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     150a <main+0x36a>
cmpq   $0x0,-0x50(%rbp)
jne    14da <main+0x33a>
lea    0xcbe(%rip),%rdi
lea    0xcc2(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
jne    143d <main+0x29d>
mov    0x2bdf(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x84(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    0x2bc0(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
mov    -0x84(%rbp),%edi
mov    -0x80(%rbp),%rdx
mov    %rax,%r8
lea    0xc41(%rip),%rsi
lea    0xc63(%rip),%rcx
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x2,-0x4(%rbp)
jmp    1884 <main+0x6e4>
mov    -0x50(%rbp),%rdi
call   1070 <fileno@plt>
mov    %eax,-0x88(%rbp)
mov    -0x38(%rbp),%rdi
call   10b0 <atoi@plt>
mov    -0x88(%rbp),%edi
mov    %eax,%edx
mov    $0x7,%esi
call   1040 <ioctl@plt>
mov    %eax,-0x58(%rbp)
cmpl   $0x0,-0x58(%rbp)
jge    14cc <main+0x32c>
mov    0x2b55(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x9c(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x98(%rbp)
mov    -0x48(%rbp),%rax
mov    %rax,-0x90(%rbp)
mov    0x2b28(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
mov    -0x9c(%rbp),%edi
mov    -0x98(%rbp),%rdx
mov    -0x90(%rbp),%rcx
mov    %rax,%r8
lea    0xbd5(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x50(%rbp),%rdi
call   1030 <fclose@plt>
jmp    1505 <main+0x365>
mov    0x2aef(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
mov    -0x48(%rbp),%rcx
lea    0xbd3(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x2,-0x4(%rbp)
jmp    1884 <main+0x6e4>
jmp    1744 <main+0x5a4>
cmpl   $0x0,-0x28(%rbp)
je     1533 <main+0x393>
mov    -0x50(%rbp),%rdi
call   1070 <fileno@plt>
mov    %eax,%edi
mov    $0x5,%esi
xor    %edx,%edx
call   1040 <ioctl@plt>
mov    %eax,-0x54(%rbp)
jmp    173f <main+0x59f>
cmpl   $0x0,-0x1c(%rbp)
je     155c <main+0x3bc>
mov    -0x50(%rbp),%rdi
call   1070 <fileno@plt>
mov    %eax,%edi
mov    $0x1,%esi
xor    %edx,%edx
call   1040 <ioctl@plt>
mov    %eax,-0x54(%rbp)
jmp    173a <main+0x59a>
mov    -0x50(%rbp),%rdi
call   1070 <fileno@plt>
mov    %eax,%edi
mov    -0x38(%rbp),%rax
mov    %eax,%edx
xor    %esi,%esi
call   1040 <ioctl@plt>
mov    %eax,-0x54(%rbp)
cmpl   $0x0,-0x54(%rbp)
je     1586 <main+0x3e6>
jmp    1749 <main+0x5a9>
cmpl   $0x0,-0x20(%rbp)
je     1617 <main+0x477>
mov    -0x50(%rbp),%rdi
call   1070 <fileno@plt>
mov    %eax,%edi
mov    $0x6,%esi
mov    $0x1,%edx
call   1040 <ioctl@plt>
cmp    $0x0,%eax
je     1612 <main+0x472>
mov    0x2a16(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xb4(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0xb0(%rbp)
mov    -0x48(%rbp),%rax
mov    %rax,-0xa8(%rbp)
mov    0x29e9(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
mov    -0xb4(%rbp),%edi
mov    -0xb0(%rbp),%rdx
mov    -0xa8(%rbp),%rcx
mov    %rax,%r8
lea    0xaf5(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x4,-0x54(%rbp)
jmp    1617 <main+0x477>
cmpl   $0x0,-0x3c(%rbp)
je     16a6 <main+0x506>
mov    -0x50(%rbp),%rdi
call   1070 <fileno@plt>
mov    %eax,%edi
mov    -0x3c(%rbp),%edx
mov    $0x3,%esi
call   1040 <ioctl@plt>
cmp    $0x0,%eax
je     16a1 <main+0x501>
mov    0x2987(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xcc(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0xc8(%rbp)
mov    -0x48(%rbp),%rax
mov    %rax,-0xc0(%rbp)
mov    0x295a(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
mov    -0xcc(%rbp),%edi
mov    -0xc8(%rbp),%rdx
mov    -0xc0(%rbp),%rcx
mov    %rax,%r8
lea    0xa9b(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x5,-0x54(%rbp)
jmp    16a6 <main+0x506>
cmpl   $0x0,-0x40(%rbp)
je     1735 <main+0x595>
mov    -0x50(%rbp),%rdi
call   1070 <fileno@plt>
mov    %eax,%edi
mov    -0x40(%rbp),%edx
mov    $0x2,%esi
call   1040 <ioctl@plt>
cmp    $0x0,%eax
je     1730 <main+0x590>
mov    0x28f8(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xe4(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0xe0(%rbp)
mov    -0x48(%rbp),%rax
mov    %rax,-0xd8(%rbp)
mov    0x28cb(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
mov    -0xe4(%rbp),%edi
mov    -0xe0(%rbp),%rdx
mov    -0xd8(%rbp),%rcx
mov    %rax,%r8
lea    0xa3c(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x6,-0x54(%rbp)
jmp    1735 <main+0x595>
jmp    173a <main+0x59a>
jmp    173f <main+0x59f>
jmp    1744 <main+0x5a4>
jmp    1749 <main+0x5a9>
cmpl   $0xffffffff,-0x54(%rbp)
jne    1858 <main+0x6b8>
mov    0x286e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xe8(%rbp)
sub    $0x80,%eax
je     1788 <main+0x5e8>
jmp    1772 <main+0x5d2>
mov    -0xe8(%rbp),%eax
sub    $0x81,%eax
je     17ba <main+0x61a>
jmp    17ec <main+0x64c>
mov    0x2841(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
mov    -0x10(%rbp),%rax
mov    0x2840(%rip),%rcx
mov    (%rcx),%rcx
mov    (%rax,%rcx,8),%rcx
lea    0x9e2(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    1853 <main+0x6b3>
mov    0x280f(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
mov    -0x10(%rbp),%rax
mov    0x280e(%rip),%rcx
mov    (%rcx),%rcx
mov    (%rax,%rcx,8),%rcx
lea    0x9ce(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    1853 <main+0x6b3>
mov    0x27dd(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xfc(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0xf8(%rbp)
mov    -0x10(%rbp),%rax
mov    0x27cf(%rip),%rcx
mov    (%rcx),%rcx
mov    0x8(%rax,%rcx,8),%rax
mov    %rax,-0xf0(%rbp)
mov    0x27a1(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
mov    -0xfc(%rbp),%edi
mov    -0xf8(%rbp),%rdx
mov    -0xf0(%rbp),%rcx
mov    %rax,%r8
lea    0x980(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    1858 <main+0x6b8>
cmpl   $0x0,-0x54(%rbp)
jge    1872 <main+0x6d2>
mov    $0x3,%eax
mov    %eax,-0x100(%rbp)
jmp    187b <main+0x6db>
mov    -0x54(%rbp),%eax
mov    %eax,-0x100(%rbp)
mov    -0x100(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
mov    (%rsi),%rdi
call   1060 <basename@plt>
mov    %rax,(%rsp)
movl   $0x0,0x14(%rsp)
lea    0xe8a(%rip),%r15
lea    0xe2b(%rip),%r13
xor    %r12d,%r12d
movl   $0x0,0x10(%rsp)
movl   $0x0,0x8(%rsp)
movl   $0x0,0xc(%rsp)
xor    %r14d,%r14d
jmp    1205 <main+0x65>
cs nopw 0x0(%rax,%rax,1)
nop
cmp    $0xffffffff,%eax
je     126f <main+0xcf>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r15,%rdx
call   10a0 <getopt@plt>
lea    -0x63(%rax),%ecx
cmp    $0x15,%ecx
ja     1200 <main+0x60>
movslq 0x0(%r13,%rcx,4),%rax
add    %r13,%rax
jmp    *%rax
mov    $0x1,%r12b
jmp    1205 <main+0x65>
mov    $0x1,%r14d
jmp    1205 <main+0x65>
mov    0x2dc0(%rip),%rax
mov    (%rax),%rdi
call   10b0 <atoi@plt>
mov    %eax,0xc(%rsp)
jmp    1205 <main+0x65>
movl   $0x1,0x14(%rsp)
jmp    1205 <main+0x65>
mov    0x2da1(%rip),%rax
mov    (%rax),%rdi
call   10b0 <atoi@plt>
mov    %eax,0x8(%rsp)
jmp    1205 <main+0x65>
movl   $0x1,0x10(%rsp)
jmp    1205 <main+0x65>
mov    0x2d6a(%rip),%r13
mov    0x0(%r13),%rax
mov    (%rbx,%rax,8),%rbp
test   %rbp,%rbp
je     12eb <main+0x14b>
mov    %r14d,%ecx
or     0x10(%rsp),%ecx
je     1291 <main+0xf1>
xor    %r15d,%r15d
jmp    129b <main+0xfb>
mov    0x8(%rbx,%rax,8),%r15
test   %r15,%r15
je     12eb <main+0x14b>
lea    0xdbf(%rip),%rsi
mov    %rbp,%rdi
call   1090 <fopen@plt>
test   %rax,%rax
setne  %cl
or     %r12b,%cl
test   $0x1,%cl
je     12f9 <main+0x159>
test   $0x1,%r12b
je     1348 <main+0x1a8>
test   %rax,%rax
je     13a2 <main+0x202>
mov    0x2cfe(%rip),%rax
mov    (%rax),%edi
lea    0xdea(%rip),%rsi
mov    (%rsp),%rdx
mov    %rbp,%rcx
xor    %eax,%eax
call   1050 <fprintf@plt>
jmp    1332 <main+0x192>
xor    %eax,%eax
call   1080 <usage@plt>
mov    $0x1,%ebp
jmp    1337 <main+0x197>
mov    0x2cd0(%rip),%rax
mov    (%rax),%ebp
mov    0x0(%r13),%rax
mov    (%rbx,%rax,8),%rbx
mov    0x2cb7(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
lea    0xd45(%rip),%rsi
mov    %ebp,%edi
mov    (%rsp),%rdx
mov    %rbx,%rcx
mov    %rax,%r8
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x2,%ebp
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rax,%r12
mov    %rax,%rdi
call   1070 <fileno@plt>
mov    0x10(%rsp),%edx
or     %edx,%r14d
je     1375 <main+0x1d5>
xor    %ecx,%ecx
test   %edx,%edx
setne  %cl
lea    0x1(,%rcx,4),%esi
mov    %eax,%edi
xor    %edx,%edx
call   1040 <ioctl@plt>
jmp    138e <main+0x1ee>
mov    %rbp,%r14
xor    %ebp,%ebp
mov    %eax,%edi
xor    %esi,%esi
mov    %r15d,%edx
call   1040 <ioctl@plt>
test   %eax,%eax
je     1466 <main+0x2c6>
cmp    $0xffffffff,%eax
je     1428 <main+0x288>
mov    %eax,%ebp
test   %eax,%eax
jns    1337 <main+0x197>
jmp    154e <main+0x3ae>
lea    0xce4(%rip),%rdi
lea    0xce8(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     14d6 <main+0x336>
mov    %rax,%rbx
mov    %rbp,%r14
mov    %rax,%rdi
call   1070 <fileno@plt>
mov    %eax,%ebp
mov    %r15,%rdi
call   10b0 <atoi@plt>
mov    %ebp,%edi
mov    $0x7,%esi
mov    %eax,%edx
call   1040 <ioctl@plt>
test   %eax,%eax
jns    1419 <main+0x279>
mov    0x2be1(%rip),%rax
mov    (%rax),%ebp
mov    0x2bd0(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
lea    0xc94(%rip),%rsi
mov    %ebp,%edi
mov    (%rsp),%rdx
mov    %r14,%rcx
mov    %rax,%r8
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %ebp,%ebp
jmp    1337 <main+0x197>
mov    0x2b99(%rip),%rax
mov    (%rax),%edi
mov    0x2b98(%rip),%rax
cmp    $0x81,%edi
je     1506 <main+0x366>
cmp    $0x80,%edi
jne    1524 <main+0x384>
mov    (%rax),%edi
mov    0x0(%r13),%rax
mov    (%rbx,%rax,8),%rcx
lea    0xd2f(%rip),%rsi
jmp    1517 <main+0x377>
cmpl   $0x0,0x14(%rsp)
je     1558 <main+0x3b8>
mov    %r12,%rdi
call   1070 <fileno@plt>
mov    %eax,%edi
mov    $0x6,%esi
mov    $0x1,%edx
call   1040 <ioctl@plt>
test   %eax,%eax
mov    0xc(%rsp),%r15d
mov    0x8(%rsp),%ebx
je     1561 <main+0x3c1>
mov    0x2b2e(%rip),%rax
mov    (%rax),%ebp
mov    0x2b1d(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
lea    0xc40(%rip),%rsi
mov    %ebp,%edi
mov    (%rsp),%rdx
mov    %r14,%rcx
mov    %rax,%r8
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x4,%ebp
jmp    1561 <main+0x3c1>
mov    0x2af3(%rip),%rax
mov    (%rax),%ebx
mov    0x2ae2(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
lea    0xb70(%rip),%rsi
lea    0xb92(%rip),%rcx
mov    %ebx,%edi
mov    (%rsp),%rdx
jmp    1328 <main+0x188>
mov    (%rax),%edi
mov    0x0(%r13),%rax
mov    (%rbx,%rax,8),%rcx
lea    0xc97(%rip),%rsi
mov    (%rsp),%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
jmp    154e <main+0x3ae>
mov    (%rax),%ebp
mov    0x0(%r13),%rax
mov    0x8(%rbx,%rax,8),%rbx
call   10c0 <strerror@plt>
lea    0xc91(%rip),%rsi
mov    %ebp,%edi
mov    (%rsp),%rdx
mov    %rbx,%rcx
mov    %rax,%r8
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x3,%ebp
jmp    1337 <main+0x197>
mov    0xc(%rsp),%r15d
mov    0x8(%rsp),%ebx
test   %ebx,%ebx
je     15b5 <main+0x415>
mov    %r12,%rdi
call   1070 <fileno@plt>
mov    %eax,%edi
mov    $0x3,%esi
mov    %ebx,%edx
call   1040 <ioctl@plt>
test   %eax,%eax
je     15b5 <main+0x415>
mov    0x2a4a(%rip),%rax
mov    (%rax),%ebp
mov    0x2a39(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
lea    0xb91(%rip),%rsi
mov    %ebp,%edi
mov    (%rsp),%rdx
mov    %r14,%rcx
mov    %rax,%r8
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x5,%ebp
test   %r15d,%r15d
je     1337 <main+0x197>
mov    %r12,%rdi
call   1070 <fileno@plt>
mov    %eax,%edi
mov    $0x2,%esi
mov    %r15d,%edx
call   1040 <ioctl@plt>
test   %eax,%eax
je     1337 <main+0x197>
mov    0x29ec(%rip),%rax
mov    (%rax),%ebx
mov    0x29db(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
lea    0xb63(%rip),%rsi
mov    %ebx,%edi
mov    (%rsp),%rdx
mov    %r14,%rcx
mov    %rax,%r8
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x6,%ebp
jmp    1337 <main+0x197>

LLVM IR (-O0):
@.str = [9 x i8] c"cxrdo:s:\00"
@optarg = global i8* null
@optind = global i64 0
@.str.1 = [3 x i8] c"rw\00"
@stderr = global i32 0
@.str.2 = [41 x i8] c"%s: could not open loop device '%s': %s\0A\00"
@errno = global i32 0
@.str.3 = [11 x i8] c"/dev/loop0\00"
@.str.4 = [2 x i8] c"r\00"
@.str.5 = [43 x i8] c"%s: could not create loop device '%s': %s\0A\00"
@.str.6 = [52 x i8] c"%s: could not create loop device '%s': file exists\0A\00"
@.str.7 = [53 x i8] c"%s: could not set loop device '%s' as read only: %s\0A\00"
@.str.8 = [48 x i8] c"%s: could not set size on loop device '%s': %s\0A\00"
@.str.9 = [50 x i8] c"%s: could not set offset on loop device '%s': %s\0A\00"
@.str.10 = [30 x i8] c"%s: Invalid loop device '%s'\0A\00"
@.str.11 = [30 x i8] c"%s: Loop device '%s' is busy\0A\00"
@.str.12 = [12 x i8] c"%s: %s: %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i32
%14 = alloca i32
%15 = alloca i8*
%16 = alloca i32*
%17 = alloca i32
%18 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 0
%21 = load i8*, i8** %20
%22 = call i64 @basename(i8* %21)
%23 = inttoptr i64 %22 to i8*
store i8* %23, i8** %6
store i32 0, i32* %7
store i32 0, i32* %8
store i32 0, i32* %9
store i32 0, i32* %10
store i8* null, i8** %12
store i32 0, i32* %13
store i32 0, i32* %14
br label %24
24: ; preds = %41, %2
%25 = load i32, i32* %4
%26 = load i8**, i8*** %5
%27 = call i32 @getopt(i32 %25, i8** %26, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
store i32 %27, i32* %11
%28 = icmp ne i32 %27, -1
br i1 %28, label %29, label %42
29: ; preds = %24
%30 = load i32, i32* %11
switch i32 %30, label %41 [
i32 100, label %31
i32 114, label %32
i32 111, label %33
i32 115, label %36
i32 99, label %39
i32 120, label %40
]
31: ; preds = %29
store i32 1, i32* %7
br label %41
32: ; preds = %29
store i32 1, i32* %8
br label %41
33: ; preds = %29
%34 = load i8*, i8** @optarg
%35 = call i32 @atoi(i8* %34)
store i32 %35, i32* %14
br label %41
36: ; preds = %29
%37 = load i8*, i8** @optarg
%38 = call i32 @atoi(i8* %37)
store i32 %38, i32* %13
br label %41
39: ; preds = %29
store i32 1, i32* %9
br label %41
40: ; preds = %29
store i32 1, i32* %10
br label %41
41: ; preds = %29, %40, %39, %36, %33, %32, %31
br label %24
42: ; preds = %24
%43 = load i8**, i8*** %5
%44 = load i64, i64* @optind
%45 = getelementptr inbounds i8*, i8** %43, i64 %44
%46 = load i8*, i8** %45
store i8* %46, i8** %15
%47 = load i8*, i8** %15
%48 = icmp ne i8* %47, null
br i1 %48, label %51, label %49
49: ; preds = %42
%50 = call i32 (...) @usage()
store i32 1, i32* %3
br label %244
51: ; preds = %42
%52 = load i32, i32* %7
%53 = icmp ne i32 %52, 0
br i1 %53, label %68, label %54
54: ; preds = %51
%55 = load i32, i32* %10
%56 = icmp ne i32 %55, 0
br i1 %56, label %68, label %57
57: ; preds = %54
%58 = load i8**, i8*** %5
%59 = load i64, i64* @optind
%60 = add i64 %59, 1
%61 = getelementptr inbounds i8*, i8** %58, i64 %60
%62 = load i8*, i8** %61
store i8* %62, i8** %12
%63 = load i8*, i8** %12
%64 = icmp ne i8* %63, null
br i1 %64, label %67, label %65
65: ; preds = %57
%66 = call i32 (...) @usage()
store i32 1, i32* %3
br label %244
67: ; preds = %57
br label %68
68: ; preds = %67, %54, %51
%69 = load i8*, i8** %15
%70 = call i32* @fopen(i8* %69, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %70, i32** %16
%71 = load i32*, i32** %16
%72 = icmp ne i32* %71, null
br i1 %72, label %86, label %73
73: ; preds = %68
%74 = load i32, i32* %9
%75 = icmp ne i32 %74, 0
br i1 %75, label %86, label %76
76: ; preds = %73
%77 = load i32, i32* @stderr
%78 = load i8*, i8** %6
%79 = load i8**, i8*** %5
%80 = load i64, i64* @optind
%81 = getelementptr inbounds i8*, i8** %79, i64 %80
%82 = load i8*, i8** %81
%83 = load i32, i32* @errno
%84 = call i8* @strerror(i32 %83)
%85 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %77, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i8* %78, i8* %82, i8* %84)
store i32 2, i32* %3
br label %244
86: ; preds = %73, %68
store i32 0, i32* %17
%87 = load i32, i32* %9
%88 = icmp ne i32 %87, 0
br i1 %88, label %89, label %126
89: ; preds = %86
%90 = load i32*, i32** %16
%91 = icmp ne i32* %90, null
br i1 %91, label %120, label %92
92: ; preds = %89
%93 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %93, i32** %16
%94 = load i32*, i32** %16
%95 = icmp ne i32* %94, null
br i1 %95, label %102, label %96
96: ; preds = %92
%97 = load i32, i32* @stderr
%98 = load i8*, i8** %6
%99 = load i32, i32* @errno
%100 = call i8* @strerror(i32 %99)
%101 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %97, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i8* %98, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* %100)
store i32 2, i32* %3
br label %244
102: ; preds = %92
%103 = load i32*, i32** %16
%104 = call i32 @fileno(i32* %103)
%105 = load i8*, i8** %12
%106 = call i32 @atoi(i8* %105)
%107 = call i32 @ioctl(i32 %104, i32 7, i32 %106)
store i32 %107, i32* %18
%108 = load i32, i32* %18
%109 = icmp slt i32 %108, 0
br i1 %109, label %110, label %117
110: ; preds = %102
%111 = load i32, i32* @stderr
%112 = load i8*, i8** %6
%113 = load i8*, i8** %15
%114 = load i32, i32* @errno
%115 = call i8* @strerror(i32 %114)
%116 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %111, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0), i8* %112, i8* %113, i8* %115)
br label %117
117: ; preds = %110, %102
%118 = load i32*, i32** %16
%119 = call i32 @fclose(i32* %118)
br label %125
120: ; preds = %89
%121 = load i32, i32* @stderr
%122 = load i8*, i8** %6
%123 = load i8*, i8** %15
%124 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %121, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.6, i64 0, i64 0), i8* %122, i8* %123)
store i32 2, i32* %3
br label %244
125: ; preds = %117
br label %202
126: ; preds = %86
%127 = load i32, i32* %10
%128 = icmp ne i32 %127, 0
br i1 %128, label %129, label %133
129: ; preds = %126
%130 = load i32*, i32** %16
%131 = call i32 @fileno(i32* %130)
%132 = call i32 @ioctl(i32 %131, i32 5, i32 0)
store i32 %132, i32* %17
br label %201
133: ; preds = %126
%134 = load i32, i32* %7
%135 = icmp ne i32 %134, 0
br i1 %135, label %136, label %140
136: ; preds = %133
%137 = load i32*, i32** %16
%138 = call i32 @fileno(i32* %137)
%139 = call i32 @ioctl(i32 %138, i32 1, i32 0)
store i32 %139, i32* %17
br label %200
140: ; preds = %133
%141 = load i32*, i32** %16
%142 = call i32 @fileno(i32* %141)
%143 = load i8*, i8** %12
%144 = ptrtoint i8* %143 to i32
%145 = call i32 @ioctl(i32 %142, i32 0, i32 %144)
store i32 %145, i32* %17
%146 = load i32, i32* %17
%147 = icmp ne i32 %146, 0
br i1 %147, label %148, label %149
148: ; preds = %140
br label %203
149: ; preds = %140
%150 = load i32, i32* %8
%151 = icmp ne i32 %150, 0
br i1 %151, label %152, label %165
152: ; preds = %149
%153 = load i32*, i32** %16
%154 = call i32 @fileno(i32* %153)
%155 = call i32 @ioctl(i32 %154, i32 6, i32 1)
%156 = icmp ne i32 %155, 0
br i1 %156, label %157, label %164
157: ; preds = %152
%158 = load i32, i32* @stderr
%159 = load i8*, i8** %6
%160 = load i8*, i8** %15
%161 = load i32, i32* @errno
%162 = call i8* @strerror(i32 %161)
%163 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %158, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.7, i64 0, i64 0), i8* %159, i8* %160, i8* %162)
store i32 4, i32* %17
br label %164
164: ; preds = %157, %152
br label %165
165: ; preds = %164, %149
%166 = load i32, i32* %13
%167 = icmp ne i32 %166, 0
br i1 %167, label %168, label %182
168: ; preds = %165
%169 = load i32*, i32** %16
%170 = call i32 @fileno(i32* %169)
%171 = load i32, i32* %13
%172 = call i32 @ioctl(i32 %170, i32 3, i32 %171)
%173 = icmp ne i32 %172, 0
br i1 %173, label %174, label %181
174: ; preds = %168
%175 = load i32, i32* @stderr
%176 = load i8*, i8** %6
%177 = load i8*, i8** %15
%178 = load i32, i32* @errno
%179 = call i8* @strerror(i32 %178)
%180 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %175, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.8, i64 0, i64 0), i8* %176, i8* %177, i8* %179)
store i32 5, i32* %17
br label %181
181: ; preds = %174, %168
br label %182
182: ; preds = %181, %165
%183 = load i32, i32* %14
%184 = icmp ne i32 %183, 0
br i1 %184, label %185, label %199
185: ; preds = %182
%186 = load i32*, i32** %16
%187 = call i32 @fileno(i32* %186)
%188 = load i32, i32* %14
%189 = call i32 @ioctl(i32 %187, i32 2, i32 %188)
%190 = icmp ne i32 %189, 0
br i1 %190, label %191, label %198
191: ; preds = %185
%192 = load i32, i32* @stderr
%193 = load i8*, i8** %6
%194 = load i8*, i8** %15
%195 = load i32, i32* @errno
%196 = call i8* @strerror(i32 %195)
%197 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %192, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.9, i64 0, i64 0), i8* %193, i8* %194, i8* %196)
store i32 6, i32* %17
br label %198
198: ; preds = %191, %185
br label %199
199: ; preds = %198, %182
br label %200
200: ; preds = %199, %136
br label %201
201: ; preds = %200, %129
br label %202
202: ; preds = %201, %125
br label %203
203: ; preds = %202, %148
%204 = load i32, i32* %17
%205 = icmp eq i32 %204, -1
br i1 %205, label %206, label %236
206: ; preds = %203
%207 = load i32, i32* @errno
switch i32 %207, label %224 [
i32 128, label %208
i32 129, label %216
]
208: ; preds = %206
%209 = load i32, i32* @stderr
%210 = load i8*, i8** %6
%211 = load i8**, i8*** %5
%212 = load i64, i64* @optind
%213 = getelementptr inbounds i8*, i8** %211, i64 %212
%214 = load i8*, i8** %213
%215 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %209, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.10, i64 0, i64 0), i8* %210, i8* %214)
br label %235
216: ; preds = %206
%217 = load i32, i32* @stderr
%218 = load i8*, i8** %6
%219 = load i8**, i8*** %5
%220 = load i64, i64* @optind
%221 = getelementptr inbounds i8*, i8** %219, i64 %220
%222 = load i8*, i8** %221
%223 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %217, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.11, i64 0, i64 0), i8* %218, i8* %222)
br label %235
224: ; preds = %206
%225 = load i32, i32* @stderr
%226 = load i8*, i8** %6
%227 = load i8**, i8*** %5
%228 = load i64, i64* @optind
%229 = add i64 %228, 1
%230 = getelementptr inbounds i8*, i8** %227, i64 %229
%231 = load i8*, i8** %230
%232 = load i32, i32* @errno
%233 = call i8* @strerror(i32 %232)
%234 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %225, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.12, i64 0, i64 0), i8* %226, i8* %231, i8* %233)
br label %235
235: ; preds = %224, %216, %208
br label %236
236: ; preds = %235, %203
%237 = load i32, i32* %17
%238 = icmp slt i32 %237, 0
br i1 %238, label %239, label %240
239: ; preds = %236
br label %242
240: ; preds = %236
%241 = load i32, i32* %17
br label %242
242: ; preds = %240, %239
%243 = phi i32 [ 3, %239 ], [ %241, %240 ]
store i32 %243, i32* %3
br label %244
244: ; preds = %242, %120, %96, %76, %65, %49
%245 = load i32, i32* %3
ret i32 %245
}

LLVM IR (-O2):
@.str = [9 x i8] c"cxrdo:s:\00"
@optarg = global i8* null
@optind = global i64 0
@.str.1 = [3 x i8] c"rw\00"
@stderr = global i32 0
@.str.2 = [41 x i8] c"%s: could not open loop device '%s': %s\0A\00"
@errno = global i32 0
@.str.3 = [11 x i8] c"/dev/loop0\00"
@.str.4 = [2 x i8] c"r\00"
@.str.5 = [43 x i8] c"%s: could not create loop device '%s': %s\0A\00"
@.str.6 = [52 x i8] c"%s: could not create loop device '%s': file exists\0A\00"
@.str.7 = [53 x i8] c"%s: could not set loop device '%s' as read only: %s\0A\00"
@.str.8 = [48 x i8] c"%s: could not set size on loop device '%s': %s\0A\00"
@.str.9 = [50 x i8] c"%s: could not set offset on loop device '%s': %s\0A\00"
@.str.10 = [30 x i8] c"%s: Invalid loop device '%s'\0A\00"
@.str.11 = [30 x i8] c"%s: Loop device '%s' is busy\0A\00"
@.str.12 = [12 x i8] c"%s: %s: %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = load i8*, i8** %1
%4 = tail call i64 @basename(i8* %3)
br label %5
5: ; preds = %32, %2
%6 = phi i1 [ false, %2 ], [ true, %32 ]
%7 = phi i32 [ 0, %2 ], [ %13, %32 ]
%8 = phi i32 [ 0, %2 ], [ %19, %32 ]
%9 = phi i32 [ 0, %2 ], [ %24, %32 ]
%10 = phi i32 [ 0, %2 ], [ %28, %32 ]
%11 = phi i32 [ 0, %2 ], [ %31, %32 ]
br label %12
12: ; preds = %32, %5
%13 = phi i32 [ %7, %5 ], [ 1, %32 ]
%14 = phi i32 [ %8, %5 ], [ %19, %32 ]
%15 = phi i32 [ %9, %5 ], [ %24, %32 ]
%16 = phi i32 [ %10, %5 ], [ %28, %32 ]
%17 = phi i32 [ %11, %5 ], [ %31, %32 ]
br label %18
18: ; preds = %32, %12
%19 = phi i32 [ %14, %12 ], [ 1, %32 ]
%20 = phi i32 [ %15, %12 ], [ %24, %32 ]
%21 = phi i32 [ %16, %12 ], [ %28, %32 ]
%22 = phi i32 [ %17, %12 ], [ %31, %32 ]
br label %23
23: ; preds = %18, %37
%24 = phi i32 [ %20, %18 ], [ %39, %37 ]
%25 = phi i32 [ %21, %18 ], [ %28, %37 ]
%26 = phi i32 [ %22, %18 ], [ %31, %37 ]
br label %27
27: ; preds = %23, %34
%28 = phi i32 [ %25, %23 ], [ %36, %34 ]
%29 = phi i32 [ %26, %23 ], [ %31, %34 ]
br label %30
30: ; preds = %32, %27
%31 = phi i32 [ %29, %27 ], [ 1, %32 ]
br label %32
32: ; preds = %30, %32
%33 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
switch i32 %33, label %32 [
i32 -1, label %40
i32 100, label %30
i32 114, label %18
i32 111, label %34
i32 115, label %37
i32 99, label %5
i32 120, label %12
]
34: ; preds = %32
%35 = load i8*, i8** @optarg
%36 = tail call i32 @atoi(i8* %35)
br label %27
37: ; preds = %32
%38 = load i8*, i8** @optarg
%39 = tail call i32 @atoi(i8* %38)
br label %23
40: ; preds = %32
%41 = inttoptr i64 %4 to i8*
%42 = load i64, i64* @optind
%43 = getelementptr inbounds i8*, i8** %1, i64 %42
%44 = load i8*, i8** %43
%45 = icmp eq i8* %44, null
br i1 %45, label %46, label %48
46: ; preds = %40
%47 = tail call i32 (...) @usage()
br label %171
48: ; preds = %40
%49 = icmp ne i32 %31, 0
%50 = icmp ne i32 %13, 0
%51 = select i1 %49, i1 true, i1 %50
br i1 %51, label %59, label %52
52: ; preds = %48
%53 = add i64 %42, 1
%54 = getelementptr inbounds i8*, i8** %1, i64 %53
%55 = load i8*, i8** %54
%56 = icmp eq i8* %55, null
br i1 %56, label %57, label %59
57: ; preds = %52
%58 = tail call i32 (...) @usage()
br label %171
59: ; preds = %52, %48
%60 = phi i8* [ null, %48 ], [ %55, %52 ]
%61 = tail call i32* @fopen(i8* %44, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%62 = icmp ne i32* %61, null
%63 = or i1 %62, %6
br i1 %63, label %72, label %64
64: ; preds = %59
%65 = load i32, i32* @stderr
%66 = load i64, i64* @optind
%67 = getelementptr inbounds i8*, i8** %1, i64 %66
%68 = load i8*, i8** %67
%69 = load i32, i32* @errno
%70 = tail call i8* @strerror(i32 %69)
%71 = tail call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %65, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i8* %41, i8* %68, i8* %70)
br label %171
72: ; preds = %59
br i1 %6, label %73, label %97
73: ; preds = %72
br i1 %62, label %94, label %74
74: ; preds = %73
%75 = tail call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%76 = icmp eq i32* %75, null
br i1 %76, label %77, label %82
77: ; preds = %74
%78 = load i32, i32* @stderr
%79 = load i32, i32* @errno
%80 = tail call i8* @strerror(i32 %79)
%81 = tail call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %78, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i8* %41, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* %80)
br label %171
82: ; preds = %74
%83 = tail call i32 @fileno(i32* %75)
%84 = tail call i32 @atoi(i8* %60)
%85 = tail call i32 @ioctl(i32 %83, i32 7, i32 %84)
%86 = icmp slt i32 %85, 0
br i1 %86, label %87, label %92
87: ; preds = %82
%88 = load i32, i32* @stderr
%89 = load i32, i32* @errno
%90 = tail call i8* @strerror(i32 %89)
%91 = tail call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %88, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0), i8* %41, i8* %44, i8* %90)
br label %92
92: ; preds = %87, %82
%93 = tail call i32 @fclose(i32* %75)
br label %171
94: ; preds = %73
%95 = load i32, i32* @stderr
%96 = tail call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %95, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.6, i64 0, i64 0), i8* %41, i8* %44)
br label %171
97: ; preds = %72
%98 = tail call i32 @fileno(i32* %61)
%99 = select i1 %50, i1 true, i1 %49
br i1 %99, label %140, label %100
100: ; preds = %97
%101 = ptrtoint i8* %60 to i64
%102 = trunc i64 %101 to i32
%103 = tail call i32 @ioctl(i32 %98, i32 0, i32 %102)
%104 = icmp eq i32 %103, 0
br i1 %104, label %105, label %143
105: ; preds = %100
%106 = icmp eq i32 %19, 0
br i1 %106, label %116, label %107
107: ; preds = %105
%108 = tail call i32 @fileno(i32* %61)
%109 = tail call i32 @ioctl(i32 %108, i32 6, i32 1)
%110 = icmp eq i32 %109, 0
br i1 %110, label %116, label %111
111: ; preds = %107
%112 = load i32, i32* @stderr
%113 = load i32, i32* @errno
%114 = tail call i8* @strerror(i32 %113)
%115 = tail call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %112, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.7, i64 0, i64 0), i8* %41, i8* %44, i8* %114)
br label %116
116: ; preds = %107, %111, %105
%117 = phi i32 [ 4, %111 ], [ 0, %107 ], [ 0, %105 ]
%118 = icmp eq i32 %24, 0
br i1 %118, label %128, label %119
119: ; preds = %116
%120 = tail call i32 @fileno(i32* %61)
%121 = tail call i32 @ioctl(i32 %120, i32 3, i32 %24)
%122 = icmp eq i32 %121, 0
br i1 %122, label %128, label %123
123: ; preds = %119
%124 = load i32, i32* @stderr
%125 = load i32, i32* @errno
%126 = tail call i8* @strerror(i32 %125)
%127 = tail call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %124, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.8, i64 0, i64 0), i8* %41, i8* %44, i8* %126)
br label %128
128: ; preds = %119, %123, %116
%129 = phi i32 [ 5, %123 ], [ %117, %119 ], [ %117, %116 ]
%130 = icmp eq i32 %28, 0
br i1 %130, label %171, label %131
131: ; preds = %128
%132 = tail call i32 @fileno(i32* %61)
%133 = tail call i32 @ioctl(i32 %132, i32 2, i32 %28)
%134 = icmp eq i32 %133, 0
br i1 %134, label %171, label %135
135: ; preds = %131
%136 = load i32, i32* @stderr
%137 = load i32, i32* @errno
%138 = tail call i8* @strerror(i32 %137)
%139 = tail call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %136, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.9, i64 0, i64 0), i8* %41, i8* %44, i8* %138)
br label %171
140: ; preds = %97
%141 = select i1 %50, i32 5, i32 1
%142 = tail call i32 @ioctl(i32 %98, i32 %141, i32 0)
br label %143
143: ; preds = %140, %100
%144 = phi i32 [ %103, %100 ], [ %142, %140 ]
%145 = icmp eq i32 %144, -1
br i1 %145, label %146, label %168
146: ; preds = %143
%147 = load i32, i32* @errno
switch i32 %147, label %160 [
i32 128, label %148
i32 129, label %154
]
148: ; preds = %146
%149 = load i32, i32* @stderr
%150 = load i64, i64* @optind
%151 = getelementptr inbounds i8*, i8** %1, i64 %150
%152 = load i8*, i8** %151
%153 = tail call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %149, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.10, i64 0, i64 0), i8* %41, i8* %152)
br label %170
154: ; preds = %146
%155 = load i32, i32* @stderr
%156 = load i64, i64* @optind
%157 = getelementptr inbounds i8*, i8** %1, i64 %156
%158 = load i8*, i8** %157
%159 = tail call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %155, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.11, i64 0, i64 0), i8* %41, i8* %158)
br label %170
160: ; preds = %146
%161 = load i32, i32* @stderr
%162 = load i64, i64* @optind
%163 = add i64 %162, 1
%164 = getelementptr inbounds i8*, i8** %1, i64 %163
%165 = load i8*, i8** %164
%166 = tail call i8* @strerror(i32 %147)
%167 = tail call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %161, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.12, i64 0, i64 0), i8* %41, i8* %165, i8* %166)
br label %170
168: ; preds = %143
%169 = icmp slt i32 %144, 0
br i1 %169, label %170, label %171
170: ; preds = %160, %154, %148, %168
br label %171
171: ; preds = %92, %135, %131, %128, %170, %168, %64, %94, %77, %57, %46
%172 = phi i32 [ 1, %57 ], [ 1, %46 ], [ 2, %64 ], [ 2, %94 ], [ 2, %77 ], [ 3, %170 ], [ %144, %168 ], [ 0, %92 ], [ 6, %135 ], [ %129, %131 ], [ %129, %128 ]
ret i32 %172
}