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

/* Forward declarations */

/* Type definitions */
struct stat {
  int /*<<< orphan*/ st_mode;
};
struct option {
  char *member_0;
  char member_3;
  int /*<<< orphan*/ member_2;
  int /*<<< orphan*/ const member_1;
};

/* Variables and functions */
int /*<<< orphan*/ O_WRONLY;
int /*<<< orphan*/ S_ISDIR(int /*<<< orphan*/);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ free(char *);
int getopt_long(int, char **, char *, struct option const *,
                int /*<<< orphan*/ *);
int /*<<< orphan*/ invalid(char **, char *);
char *malloc(int);
#define no_argument 128
int open(char *, int /*<<< orphan*/);
int optind;
int /*<<< orphan*/ snprintf(char *, size_t, char *, char *);
scalar_t__ stat(char *, struct stat *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
char *strerror(int /*<<< orphan*/);
int strlen(char *);
int /*<<< orphan*/ strncat(char *, char *, int);
char *strstr(char *, char *);
int /*<<< orphan*/ usage(char **, int);
scalar_t__ write(int, char *, int);
int main(int argc, char **argv) {
  int c;
  char *devpath;
  char *sysfs_path;
  char *sysfs_data;
  struct stat sysfs_stat;
  int fd;
  char *host_str;
  int host_pos;
  size_t host_len;
  char *host_next_str;
  int host_next_pos;
  size_t host_next_len;
  char *target_str;
  int target_pos;
  size_t target_len;
  char *channel_str;
  int channel_pos;
  int channel_len;
  char *id_str;
  int id_pos;
  int id_len;
  char *dir_str;
  static const struct option longopts[] = {
      {"help", no_argument, 0, 'h'},
      {NULL, no_argument, 0, '0'},
  };
  while ((c = getopt_long(argc, argv, "rh", longopts, NULL)) != -1) {
    switch (c) {
    case 'h':
      usage(argv, 0);
    default:
      usage(argv, 1);
    }
  }
  if (optind >= argc) {
    usage(argv, 1);
  }
  devpath = argv[optind++];
  if (devpath == NULL) {
    usage(argv, 1);
  }
  sysfs_path = malloc(strlen("/sys") + strlen(devpath) + 1);
  if (!sysfs_path) {
    fprintf(stderr, "Memory allocation failure!");
    return 1;
  }
  strcpy(sysfs_path, "/sys");
  strcat(sysfs_path, devpath);
  if (stat(sysfs_path, &sysfs_stat) < 0) {
    fprintf(stderr, "Cannot stat '%s': %s\n", sysfs_path, strerror(errno));
    usage(argv, 1);
  }
  if (!S_ISDIR(sysfs_stat.st_mode))
    invalid(argv, devpath);
  free(sysfs_path);
  if ((host_str = strstr(devpath, "/host")) == NULL)
    invalid(argv, devpath);
  host_pos = strlen(devpath) - strlen(host_str);
  if ((host_next_str = strstr(&devpath[host_pos + 1], "/")) == NULL)
    invalid(argv, devpath);
  host_next_pos = strlen(devpath) - strlen(host_next_str);
  if ((target_str = strstr(devpath, "/target")) == NULL)
    invalid(argv, devpath);
  target_pos = strlen(devpath) - strlen(target_str);
  host_len = host_next_pos - host_pos;
  if (host_len <= strlen("/host"))
    invalid(argv, devpath);
  host_next_len = strlen(&devpath[host_next_pos]);
  if (host_next_len <= strlen("/"))
    invalid(argv, devpath);
  target_len = strlen(&devpath[target_pos]);
  if (target_len <= strlen("/target"))
    invalid(argv, devpath);
  sysfs_path = malloc(strlen("/sys") + strlen(devpath) - host_next_len +
                      strlen("/scsi_host") + host_len + strlen("/scan") + 1);
  if (!sysfs_path) {
    fprintf(stderr, "Memory allocation failure!");
    return 1;
  }
  strcpy(sysfs_path, "/sys");
  strncat(sysfs_path, devpath, host_next_pos);
  strcat(sysfs_path, "/scsi_host");
  snprintf(sysfs_path + strlen(sysfs_path), host_len + 1, "%s", host_str);
  strcat(sysfs_path, "/scan");
  if ((channel_str = strstr(&devpath[target_pos], ":")) == NULL)
    invalid(argv, devpath);
  channel_pos = strlen(&devpath[target_pos]) - strlen(channel_str) + 1;
  if ((id_str = strstr(&devpath[target_pos + channel_pos], ":")) == NULL)
    invalid(argv, devpath);
  id_pos = strlen(&devpath[target_pos + channel_pos]) - strlen(id_str) + 1;
  if ((dir_str = strstr(&devpath[target_pos + channel_pos + id_pos], "/")) ==
      NULL)
    invalid(argv, devpath);
  channel_len = strlen(&devpath[target_pos + channel_pos]) - strlen(id_str);
  if (channel_len < 1)
    invalid(argv, devpath);
  id_len =
      strlen(&devpath[target_pos + channel_pos + id_pos]) - strlen(dir_str);
  if (id_len < 1)
    invalid(argv, devpath);
  sysfs_data = malloc(channel_len + strlen(" ") + id_len + strlen(" -") + 1);
  if (!sysfs_data) {
    free(sysfs_path);
    fprintf(stderr, "Memory allocation failure!");
    return 1;
  }
  sysfs_data[0] = '\0';
  strncat(sysfs_data, &devpath[target_pos + channel_pos], channel_len);
  strcat(sysfs_data, " ");
  strncat(sysfs_data, &devpath[target_pos + channel_pos + id_pos], id_len);
  strcat(sysfs_data, " -");
  if ((fd = open(sysfs_path, O_WRONLY)) < 0) {
    fprintf(stderr, "Cannot open '%s': %s\n", sysfs_path, strerror(errno));
    usage(argv, 1);
  }
  if (write(fd, sysfs_data, strlen(sysfs_data)) < 0) {
    fprintf(stderr, "Cannot write '%s': %s\n", sysfs_path, strerror(errno));
    usage(argv, 1);
  }
  close(fd);
  free(sysfs_path);
  free(sysfs_data);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x160,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xdbe(%rip),%rdx
lea    0x2b82(%rip),%rcx
xor    %eax,%eax
mov    %eax,%r8d
call   1070 <getopt_long@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     1293 <main+0x73>
mov    -0x14(%rbp),%eax
sub    $0x68,%eax
jne    1280 <main+0x60>
jmp    1275 <main+0x55>
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
call   10f0 <usage@plt>
mov    -0x10(%rbp),%rdi
mov    $0x1,%esi
call   10f0 <usage@plt>
jmp    1239 <main+0x19>
mov    0x2d4e(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jl     12b3 <main+0x93>
mov    -0x10(%rbp),%rdi
mov    $0x1,%esi
call   10f0 <usage@plt>
mov    -0x10(%rbp),%rax
mov    0x2d2a(%rip),%rcx
mov    (%rcx),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    0x2d1c(%rip),%rdx
mov    %esi,(%rdx)
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    12f2 <main+0xd2>
mov    -0x10(%rbp),%rdi
mov    $0x1,%esi
call   10f0 <usage@plt>
lea    0xd0f(%rip),%rdi
call   1060 <strlen@plt>
mov    %eax,-0xb4(%rbp)
mov    -0x20(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0xb4(%rbp),%edi
add    %eax,%edi
add    $0x1,%edi
call   10e0 <malloc@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    134f <main+0x12f>
mov    0x2ca5(%rip),%rax
mov    (%rax),%edi
lea    0xcd1(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1af0 <main+0x8d0>
mov    -0x28(%rbp),%rdi
lea    0xcae(%rip),%rsi
call   1040 <strcpy@plt>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1120 <strcat@plt>
mov    -0x28(%rbp),%rdi
lea    -0x38(%rbp),%rsi
call   10d0 <stat@plt>
cmp    $0x0,%rax
jge    13d7 <main+0x1b7>
mov    0x2c4e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc4(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0xc0(%rbp)
mov    0x2c2c(%rip),%rax
mov    (%rax),%edi
call   1130 <strerror@plt>
mov    -0xc4(%rbp),%edi
mov    -0xc0(%rbp),%rdx
mov    %rax,%rcx
lea    0xc66(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
mov    -0x10(%rbp),%rdi
mov    $0x1,%esi
call   10f0 <usage@plt>
mov    -0x38(%rbp),%edi
call   1080 <S_ISDIR@plt>
cmp    $0x0,%eax
jne    13f5 <main+0x1d5>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1100 <invalid@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rdi
lea    0xc35(%rip),%rsi
call   1140 <strstr@plt>
mov    %rax,-0x48(%rbp)
cmp    $0x0,%rax
jne    1429 <main+0x209>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1100 <invalid@plt>
mov    -0x20(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,-0xc8(%rbp)
mov    -0x48(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0xc8(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x4c(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
cltq
add    %rax,%rdi
lea    0xbe0(%rip),%rsi
call   1140 <strstr@plt>
mov    %rax,-0x60(%rbp)
cmp    $0x0,%rax
jne    1484 <main+0x264>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1100 <invalid@plt>
mov    -0x20(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,-0xcc(%rbp)
mov    -0x60(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0xcc(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x64(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xb92(%rip),%rsi
call   1140 <strstr@plt>
mov    %rax,-0x78(%rbp)
cmp    $0x0,%rax
jne    14d4 <main+0x2b4>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1100 <invalid@plt>
mov    -0x20(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,-0xdc(%rbp)
mov    -0x78(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0xdc(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x7c(%rbp)
mov    -0x64(%rbp),%eax
sub    -0x4c(%rbp),%eax
cltq
mov    %rax,-0x58(%rbp)
mov    -0x58(%rbp),%rax
mov    %rax,-0xd8(%rbp)
lea    0xb27(%rip),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0xd8(%rbp),%rax
movslq %ecx,%rcx
cmp    %rcx,%rax
ja     153e <main+0x31e>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1100 <invalid@plt>
mov    -0x20(%rbp),%rdi
movslq -0x64(%rbp),%rax
add    %rax,%rdi
call   1060 <strlen@plt>
cltq
mov    %rax,-0x70(%rbp)
mov    -0x70(%rbp),%rax
mov    %rax,-0xe8(%rbp)
lea    0xade(%rip),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0xe8(%rbp),%rax
movslq %ecx,%rcx
cmp    %rcx,%rax
ja     158d <main+0x36d>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1100 <invalid@plt>
mov    -0x20(%rbp),%rdi
movslq -0x7c(%rbp),%rax
add    %rax,%rdi
call   1060 <strlen@plt>
cltq
mov    %rax,-0x88(%rbp)
mov    -0x88(%rbp),%rax
mov    %rax,-0xf0(%rbp)
lea    0xa8b(%rip),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0xf0(%rbp),%rax
movslq %ecx,%rcx
cmp    %rcx,%rax
ja     15e2 <main+0x3c2>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1100 <invalid@plt>
lea    0xa1f(%rip),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x104(%rbp)
mov    -0x20(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0x104(%rbp),%eax
add    %ecx,%eax
cltq
sub    -0x70(%rbp),%rax
mov    %rax,-0x100(%rbp)
lea    0xa33(%rip),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0x100(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
add    -0x58(%rbp),%rax
mov    %rax,-0xf8(%rbp)
lea    0xa18(%rip),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0xf8(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
add    $0x1,%rax
mov    %eax,%edi
call   10e0 <malloc@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1692 <main+0x472>
mov    0x2962(%rip),%rax
mov    (%rax),%edi
lea    0x98e(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1af0 <main+0x8d0>
mov    -0x28(%rbp),%rdi
lea    0x96b(%rip),%rsi
call   1040 <strcpy@plt>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x64(%rbp),%edx
call   10a0 <strncat@plt>
mov    -0x28(%rbp),%rdi
lea    0x991(%rip),%rsi
call   1120 <strcat@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x110(%rbp)
mov    -0x28(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x110(%rbp),%rdi
cltq
add    %rax,%rdi
mov    -0x58(%rbp),%rsi
add    $0x1,%rsi
mov    -0x48(%rbp),%rcx
lea    0x96a(%rip),%rdx
call   1090 <snprintf@plt>
mov    -0x28(%rbp),%rdi
lea    0x954(%rip),%rsi
call   1120 <strcat@plt>
mov    -0x20(%rbp),%rdi
movslq -0x7c(%rbp),%rax
add    %rax,%rdi
lea    0x946(%rip),%rsi
call   1140 <strstr@plt>
mov    %rax,-0x90(%rbp)
cmp    $0x0,%rax
jne    173f <main+0x51f>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1100 <invalid@plt>
mov    -0x20(%rbp),%rdi
movslq -0x7c(%rbp),%rax
add    %rax,%rdi
call   1060 <strlen@plt>
mov    %eax,-0x114(%rbp)
mov    -0x90(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0x114(%rbp),%eax
sub    %ecx,%eax
add    $0x1,%eax
mov    %eax,-0x94(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x7c(%rbp),%eax
add    -0x94(%rbp),%eax
cltq
add    %rax,%rdi
lea    0x8d5(%rip),%rsi
call   1140 <strstr@plt>
mov    %rax,-0xa0(%rbp)
cmp    $0x0,%rax
jne    17b0 <main+0x590>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1100 <invalid@plt>
mov    -0x20(%rbp),%rdi
mov    -0x7c(%rbp),%eax
add    -0x94(%rbp),%eax
cltq
add    %rax,%rdi
call   1060 <strlen@plt>
mov    %eax,-0x118(%rbp)
mov    -0xa0(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0x118(%rbp),%eax
sub    %ecx,%eax
add    $0x1,%eax
mov    %eax,-0xa4(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x7c(%rbp),%eax
add    -0x94(%rbp),%eax
add    -0xa4(%rbp),%eax
cltq
add    %rax,%rdi
lea    0x839(%rip),%rsi
call   1140 <strstr@plt>
mov    %rax,-0xb0(%rbp)
cmp    $0x0,%rax
jne    182e <main+0x60e>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1100 <invalid@plt>
mov    -0x20(%rbp),%rdi
mov    -0x7c(%rbp),%eax
add    -0x94(%rbp),%eax
cltq
add    %rax,%rdi
call   1060 <strlen@plt>
mov    %eax,-0x11c(%rbp)
mov    -0xa0(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0x11c(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x98(%rbp)
cmpl   $0x1,-0x98(%rbp)
jge    1881 <main+0x661>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1100 <invalid@plt>
mov    -0x20(%rbp),%rdi
mov    -0x7c(%rbp),%eax
add    -0x94(%rbp),%eax
add    -0xa4(%rbp),%eax
cltq
add    %rax,%rdi
call   1060 <strlen@plt>
mov    %eax,-0x120(%rbp)
mov    -0xb0(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0x120(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0xa8(%rbp)
cmpl   $0x1,-0xa8(%rbp)
jge    18da <main+0x6ba>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1100 <invalid@plt>
mov    -0x98(%rbp),%eax
mov    %eax,-0x128(%rbp)
lea    0x777(%rip),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0x128(%rbp),%eax
add    %ecx,%eax
add    -0xa8(%rbp),%eax
mov    %eax,-0x124(%rbp)
lea    0x757(%rip),%rdi
call   1060 <strlen@plt>
mov    -0x124(%rbp),%edi
add    %eax,%edi
add    $0x1,%edi
call   10e0 <malloc@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    195f <main+0x73f>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    0x2695(%rip),%rax
mov    (%rax),%edi
lea    0x6c1(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1af0 <main+0x8d0>
mov    -0x30(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x30(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x7c(%rbp),%eax
add    -0x94(%rbp),%eax
cltq
add    %rax,%rsi
mov    -0x98(%rbp),%edx
call   10a0 <strncat@plt>
mov    -0x30(%rbp),%rdi
lea    0x6d2(%rip),%rsi
call   1120 <strcat@plt>
mov    -0x30(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x7c(%rbp),%eax
add    -0x94(%rbp),%eax
add    -0xa4(%rbp),%eax
cltq
add    %rax,%rsi
mov    -0xa8(%rbp),%edx
call   10a0 <strncat@plt>
mov    -0x30(%rbp),%rdi
lea    0x69d(%rip),%rsi
call   1120 <strcat@plt>
mov    -0x28(%rbp),%rdi
mov    0x25e7(%rip),%rax
mov    (%rax),%esi
call   1110 <open@plt>
mov    %eax,-0x3c(%rbp)
cmp    $0x0,%eax
jge    1a40 <main+0x820>
mov    0x25e5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x134(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x130(%rbp)
mov    0x25c3(%rip),%rax
mov    (%rax),%edi
call   1130 <strerror@plt>
mov    -0x134(%rbp),%edi
mov    -0x130(%rbp),%rdx
mov    %rax,%rcx
lea    0x63e(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
mov    -0x10(%rbp),%rdi
mov    $0x1,%esi
call   10f0 <usage@plt>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x144(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x140(%rbp)
mov    -0x30(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x144(%rbp),%edi
mov    -0x140(%rbp),%rsi
mov    %eax,%edx
call   1050 <write@plt>
cmp    $0x0,%rax
jge    1acf <main+0x8af>
mov    0x2556(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x154(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x150(%rbp)
mov    0x2534(%rip),%rax
mov    (%rax),%edi
call   1130 <strerror@plt>
mov    -0x154(%rbp),%edi
mov    -0x150(%rbp),%rdx
mov    %rax,%rcx
lea    0x5c5(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
mov    -0x10(%rbp),%rdi
mov    $0x1,%esi
call   10f0 <usage@plt>
mov    -0x3c(%rbp),%edi
call   10b0 <close@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x160,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rsi,%r13
mov    %edi,%ebp
lea    0xdbb(%rip),%r14
lea    0x2b7f(%rip),%rbx
jmp    1277 <main+0x47>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r13,%rdi
xor    %esi,%esi
call   1100 <usage@plt>
mov    %r13,%rdi
mov    $0x1,%esi
call   1100 <usage@plt>
mov    %ebp,%edi
mov    %r13,%rsi
mov    %r14,%rdx
mov    %rbx,%rcx
xor    %r8d,%r8d
call   1070 <getopt_long@plt>
cmp    $0x68,%eax
je     1260 <main+0x30>
cmp    $0xffffffff,%eax
jne    126a <main+0x3a>
mov    0x2d4d(%rip),%rbx
mov    (%rbx),%eax
cmp    %ebp,%eax
jl     12b0 <main+0x80>
mov    %r13,%rdi
mov    $0x1,%esi
call   1100 <usage@plt>
mov    (%rbx),%eax
lea    0x1(%rax),%ecx
mov    %ecx,(%rbx)
cltq
mov    0x0(%r13,%rax,8),%r12
test   %r12,%r12
jne    12ce <main+0x9e>
mov    %r13,%rdi
mov    $0x1,%esi
call   1100 <usage@plt>
lea    0xd33(%rip),%rdi
call   1060 <strlen@plt>
mov    %eax,%ebx
mov    %r12,%rdi
call   1060 <strlen@plt>
lea    (%rbx,%rax,1),%edi
add    $0x1,%edi
call   10f0 <malloc@plt>
test   %rax,%rax
je     17d5 <main+0x5a5>
mov    %rax,%rbp
lea    0xd06(%rip),%rsi
mov    %rax,%rdi
call   1040 <strcpy@plt>
mov    %rbp,%rdi
mov    %r12,%rsi
call   1130 <strcat@plt>
lea    0x28(%rsp),%rsi
mov    %rbp,%rdi
call   10e0 <stat@plt>
test   %rax,%rax
jns    1361 <main+0x131>
mov    0x2caa(%rip),%rax
mov    (%rax),%ebx
mov    0x2c99(%rip),%rax
mov    (%rax),%edi
call   1140 <strerror@plt>
lea    0xce3(%rip),%rsi
mov    %ebx,%edi
mov    %rbp,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   10d0 <fprintf@plt>
mov    %r13,%rdi
mov    $0x1,%esi
call   1100 <usage@plt>
mov    0x28(%rsp),%edi
call   1090 <S_ISDIR@plt>
test   %eax,%eax
jne    1379 <main+0x149>
mov    %r13,%rdi
mov    %r12,%rsi
call   1110 <invalid@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
lea    0xcb6(%rip),%rsi
mov    %r12,%rdi
call   1150 <strstr@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    13a3 <main+0x173>
mov    %r13,%rdi
mov    %r12,%rsi
call   1110 <invalid@plt>
mov    %r12,%rdi
call   1060 <strlen@plt>
mov    %eax,%r14d
mov    %rbx,0x18(%rsp)
mov    %rbx,%rdi
call   1060 <strlen@plt>
sub    %eax,%r14d
movslq %r14d,%rax
lea    (%rax,%r12,1),%rdi
add    $0x1,%rdi
mov    $0x2f,%esi
call   1080 <strchr@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    13e6 <main+0x1b6>
mov    %r13,%rdi
mov    %r12,%rsi
call   1110 <invalid@plt>
mov    %r12,%rdi
call   1060 <strlen@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1060 <strlen@plt>
sub    %eax,%ebp
lea    0xc45(%rip),%rsi
mov    %r12,%rdi
call   1150 <strstr@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    141c <main+0x1ec>
mov    %r13,%rdi
mov    %r12,%rsi
call   1110 <invalid@plt>
mov    %r12,%rdi
call   1060 <strlen@plt>
mov    %eax,%r15d
mov    %rbx,%rdi
call   1060 <strlen@plt>
mov    %eax,%ebx
mov    %ebp,(%rsp)
sub    %r14d,%ebp
lea    0xc00(%rip),%rdi
call   1060 <strlen@plt>
cmp    %eax,%ebp
ja     1452 <main+0x222>
mov    %r13,%rdi
mov    %r12,%rsi
call   1110 <invalid@plt>
sub    %ebx,%r15d
movslq (%rsp),%rdi
add    %r12,%rdi
call   1060 <strlen@plt>
mov    %eax,%ebx
lea    0xbda(%rip),%rdi
call   1060 <strlen@plt>
mov    %ebx,0x8(%rsp)
cmp    %eax,%ebx
ja     1482 <main+0x252>
mov    %r13,%rdi
mov    %r12,%rsi
call   1110 <invalid@plt>
mov    %ebp,0x10(%rsp)
movslq %r15d,%rdi
add    %r12,%rdi
mov    %rdi,0x30(%rsp)
call   1060 <strlen@plt>
mov    %eax,%ebx
lea    0xba7(%rip),%rdi
call   1060 <strlen@plt>
cmp    %eax,%ebx
ja     14b3 <main+0x283>
mov    %r13,%rdi
mov    %r12,%rsi
call   1110 <invalid@plt>
lea    0xb4e(%rip),%rdi
call   1060 <strlen@plt>
mov    %eax,%ebx
mov    %r12,%rdi
call   1060 <strlen@plt>
mov    %eax,%ebp
lea    0xb7c(%rip),%rdi
call   1060 <strlen@plt>
mov    %r12,0x20(%rsp)
mov    %eax,%r12d
lea    0xb73(%rip),%rdi
call   1060 <strlen@plt>
mov    0x10(%rsp),%r14d
mov    %r14d,%ecx
sub    0x8(%rsp),%ecx
add    %ebx,%ecx
add    %ebp,%ecx
add    %r12d,%ecx
lea    (%rax,%rcx,1),%edi
add    $0x1,%edi
call   10f0 <malloc@plt>
test   %rax,%rax
je     17d5 <main+0x5a5>
mov    %rax,%r12
movslq %r14d,%rbp
lea    0xae9(%rip),%rsi
mov    %rax,%rdi
call   1040 <strcpy@plt>
mov    %r12,%rdi
mov    0x20(%rsp),%r14
mov    %r14,%rsi
mov    (%rsp),%edx
call   10b0 <strncat@plt>
lea    0xb0d(%rip),%rsi
mov    %r12,%rdi
call   1130 <strcat@plt>
mov    %r12,%rdi
call   1060 <strlen@plt>
movslq %eax,%rdi
add    %r12,%rdi
add    $0x1,%rbp
lea    0xafd(%rip),%rdx
mov    %rbp,%rsi
mov    0x18(%rsp),%rcx
call   10a0 <snprintf@plt>
lea    0xae3(%rip),%rsi
mov    %r12,%rdi
call   1130 <strcat@plt>
mov    0x30(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x3a,%esi
call   1080 <strchr@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    15a3 <main+0x373>
mov    %r13,%rdi
mov    %r14,%rsi
call   1110 <invalid@plt>
mov    %rbp,%rdi
call   1060 <strlen@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1060 <strlen@plt>
add    %ebp,%r15d
sub    %eax,%r15d
add    $0x1,%r15d
mov    %r14,%rbp
movslq %r15d,%r14
add    %rbp,%r14
mov    %r14,%rdi
mov    $0x3a,%esi
call   1080 <strchr@plt>
mov    %rax,(%rsp)
test   %rax,%rax
jne    15e9 <main+0x3b9>
mov    %r13,%rdi
mov    %rbp,%rsi
call   1110 <invalid@plt>
mov    %r14,%rdi
call   1060 <strlen@plt>
mov    %eax,%ebx
mov    (%rsp),%rdi
call   1060 <strlen@plt>
add    %ebx,%r15d
sub    %eax,%r15d
add    $0x1,%r15d
movslq %r15d,%rdi
add    %rbp,%rdi
mov    %rdi,0x10(%rsp)
mov    $0x2f,%esi
call   1080 <strchr@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1630 <main+0x400>
mov    %r13,%rdi
mov    0x20(%rsp),%rsi
call   1110 <invalid@plt>
mov    %r12,0x8(%rsp)
mov    %r14,0x18(%rsp)
mov    %r14,%rdi
call   1060 <strlen@plt>
mov    %eax,%r15d
mov    (%rsp),%rdi
call   1060 <strlen@plt>
sub    %eax,%r15d
mov    0x20(%rsp),%r14
jg     1663 <main+0x433>
mov    %r13,%rdi
mov    %r14,%rsi
call   1110 <invalid@plt>
mov    0x10(%rsp),%rdi
call   1060 <strlen@plt>
mov    %eax,%r12d
mov    %rbx,%rdi
call   1060 <strlen@plt>
sub    %eax,%r12d
jg     1688 <main+0x458>
mov    %r13,%rdi
mov    %r14,%rsi
call   1110 <invalid@plt>
lea    0x9d3(%rip),%rdi
call   1060 <strlen@plt>
mov    %eax,%ebx
lea    0x9c7(%rip),%rdi
call   1060 <strlen@plt>
add    %r15d,%ebx
add    %r12d,%ebx
lea    (%rax,%rbx,1),%edi
add    $0x1,%edi
call   10f0 <malloc@plt>
test   %rax,%rax
je     17cb <main+0x59b>
mov    %rax,%rbp
movb   $0x0,(%rax)
mov    %rax,%rdi
mov    0x18(%rsp),%rsi
mov    %r15d,%edx
call   10b0 <strncat@plt>
lea    0x989(%rip),%rsi
mov    %rbp,%rdi
call   1130 <strcat@plt>
mov    %rbp,%rdi
mov    0x10(%rsp),%rsi
mov    %r12d,%edx
call   10b0 <strncat@plt>
lea    0x96c(%rip),%rsi
mov    %rbp,%rdi
call   1130 <strcat@plt>
mov    0x28b9(%rip),%rax
mov    (%rax),%esi
mov    0x8(%rsp),%rbx
mov    %rbx,%rdi
call   1120 <open@plt>
mov    %eax,%r14d
test   %eax,%eax
jns    1759 <main+0x529>
mov    0x28b4(%rip),%rax
mov    (%rax),%r15d
mov    0x28a2(%rip),%rax
mov    (%rax),%edi
call   1140 <strerror@plt>
lea    0x92b(%rip),%rsi
mov    %r15d,%edi
mov    %rbx,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   10d0 <fprintf@plt>
mov    %r13,%rdi
mov    $0x1,%esi
call   1100 <usage@plt>
mov    %rbp,%rdi
call   1060 <strlen@plt>
mov    %r14d,%edi
mov    %rbp,%rsi
mov    %eax,%edx
call   1050 <write@plt>
test   %rax,%rax
jns    17af <main+0x57f>
mov    0x285e(%rip),%rax
mov    (%rax),%r15d
mov    0x284c(%rip),%rax
mov    (%rax),%edi
call   1140 <strerror@plt>
lea    0x8eb(%rip),%rsi
mov    %r15d,%edi
mov    %rbx,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   10d0 <fprintf@plt>
mov    %r13,%rdi
mov    $0x1,%esi
call   1100 <usage@plt>
mov    %r14d,%edi
call   10c0 <close@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
xor    %eax,%eax
jmp    17f1 <main+0x5c1>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
mov    0x27fc(%rip),%rax
mov    (%rax),%edi
lea    0x828(%rip),%rsi
xor    %eax,%eax
call   10d0 <fprintf@plt>
mov    $0x1,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
%struct.option = type { i8*, i8, i32, i32 }
%struct.stat = type { i32 }
@main.longopts = internal constant [2 x %struct.option] [%struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8 -128, i32 0, i32 104 }, %struct.option { i8* null, i8 -128, i32 0, i32 48 }]
@.str = [5 x i8] c"help\00"
@.str.1 = [3 x i8] c"rh\00"
@optind = global i32 0
@.str.2 = [5 x i8] c"/sys\00"
@stderr = global i32 0
@.str.3 = [27 x i8] c"Memory allocation failure!\00"
@.str.4 = [22 x i8] c"Cannot stat '%s': %s\0A\00"
@errno = global i32 0
@.str.5 = [6 x i8] c"/host\00"
@.str.6 = [2 x i8] c"/\00"
@.str.7 = [8 x i8] c"/target\00"
@.str.8 = [11 x i8] c"/scsi_host\00"
@.str.9 = [6 x i8] c"/scan\00"
@.str.10 = [3 x i8] c"%s\00"
@.str.12 = [2 x i8] c" \00"
@.str.13 = [3 x i8] c" -\00"
@O_WRONLY = global i32 0
@.str.14 = [22 x i8] c"Cannot open '%s': %s\0A\00"
@.str.15 = [23 x i8] c"Cannot write '%s': %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca %struct.stat
%4 = bitcast %struct.stat* %3 to i8*
br label %5
5: ; preds = %9, %2
%6 = tail call i32 @getopt_long(i32 %0, i8** %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), %struct.option* getelementptr inbounds ([2 x %struct.option], [2 x %struct.option]* @main.longopts, i64 0, i64 0), i32* null)
switch i32 %6, label %9 [
i32 -1, label %11
i32 104, label %7
]
7: ; preds = %5
%8 = tail call i32 @usage(i8** %1, i32 0)
br label %9
9: ; preds = %5, %7
%10 = tail call i32 @usage(i8** %1, i32 1)
br label %5
11: ; preds = %5
%12 = load i32, i32* @optind
%13 = icmp slt i32 %12, %0
br i1 %13, label %17, label %14
14: ; preds = %11
%15 = tail call i32 @usage(i8** %1, i32 1)
%16 = load i32, i32* @optind
br label %17
17: ; preds = %14, %11
%18 = phi i32 [ %16, %14 ], [ %12, %11 ]
%19 = add nsw i32 %18, 1
store i32 %19, i32* @optind
%20 = sext i32 %18 to i64
%21 = getelementptr inbounds i8*, i8** %1, i64 %20
%22 = load i8*, i8** %21
%23 = icmp eq i8* %22, null
br i1 %23, label %24, label %26
24: ; preds = %17
%25 = tail call i32 @usage(i8** %1, i32 1)
br label %26
26: ; preds = %24, %17
%27 = tail call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%28 = tail call i32 @strlen(i8* %22)
%29 = add i32 %27, 1
%30 = add i32 %29, %28
%31 = tail call i8* @malloc(i32 %30)
%32 = icmp eq i8* %31, null
br i1 %32, label %33, label %36
33: ; preds = %26
%34 = load i32, i32* @stderr
%35 = tail call i32 (i32, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
br label %214
36: ; preds = %26
%37 = tail call i32 @strcpy(i8* %31, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%38 = tail call i32 @strcat(i8* %31, i8* %22)
%39 = call i64 @stat(i8* %31, %struct.stat* %3)
%40 = icmp slt i64 %39, 0
br i1 %40, label %41, label %47
41: ; preds = %36
%42 = load i32, i32* @stderr
%43 = load i32, i32* @errno
%44 = call i8* @strerror(i32 %43)
%45 = call i32 (i32, i8*, ...) @fprintf(i32 %42, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i8* %31, i8* %44)
%46 = call i32 @usage(i8** %1, i32 1)
br label %47
47: ; preds = %41, %36
%48 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%49 = load i32, i32* %48
%50 = call i32 @S_ISDIR(i32 %49)
%51 = icmp eq i32 %50, 0
br i1 %51, label %52, label %54
52: ; preds = %47
%53 = call i32 @invalid(i8** %1, i8* %22)
br label %54
54: ; preds = %52, %47
%55 = call i32 @free(i8* %31)
%56 = call i8* @strstr(i8* dereferenceable(1) %22, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%57 = icmp eq i8* %56, null
br i1 %57, label %58, label %60
58: ; preds = %54
%59 = call i32 @invalid(i8** %1, i8* %22)
br label %60
60: ; preds = %58, %54
%61 = call i32 @strlen(i8* %22)
%62 = call i32 @strlen(i8* %56)
%63 = sub nsw i32 %61, %62
%64 = add nsw i32 %63, 1
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds i8, i8* %22, i64 %65
%67 = call i8* @strchr(i8* dereferenceable(1) %66, i32 47)
%68 = icmp eq i8* %67, null
br i1 %68, label %69, label %71
69: ; preds = %60
%70 = call i32 @invalid(i8** %1, i8* %22)
br label %71
71: ; preds = %69, %60
%72 = call i32 @strlen(i8* %22)
%73 = call i32 @strlen(i8* %67)
%74 = sub nsw i32 %72, %73
%75 = call i8* @strstr(i8* dereferenceable(1) %22, i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0))
%76 = icmp eq i8* %75, null
br i1 %76, label %77, label %79
77: ; preds = %71
%78 = call i32 @invalid(i8** %1, i8* %22)
br label %79
79: ; preds = %77, %71
%80 = call i32 @strlen(i8* %22)
%81 = call i32 @strlen(i8* %75)
%82 = sub nsw i32 %80, %81
%83 = sub nsw i32 %74, %63
%84 = sext i32 %83 to i64
%85 = call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%86 = icmp ugt i32 %83, %85
br i1 %86, label %89, label %87
87: ; preds = %79
%88 = call i32 @invalid(i8** %1, i8* %22)
br label %89
89: ; preds = %87, %79
%90 = sext i32 %74 to i64
%91 = getelementptr inbounds i8, i8* %22, i64 %90
%92 = call i32 @strlen(i8* %91)
%93 = call i32 @strlen(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%94 = icmp ugt i32 %92, %93
br i1 %94, label %97, label %95
95: ; preds = %89
%96 = call i32 @invalid(i8** %1, i8* %22)
br label %97
97: ; preds = %95, %89
%98 = sext i32 %82 to i64
%99 = getelementptr inbounds i8, i8* %22, i64 %98
%100 = call i32 @strlen(i8* %99)
%101 = call i32 @strlen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0))
%102 = icmp ugt i32 %100, %101
br i1 %102, label %105, label %103
103: ; preds = %97
%104 = call i32 @invalid(i8** %1, i8* %22)
br label %105
105: ; preds = %103, %97
%106 = call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%107 = call i32 @strlen(i8* %22)
%108 = call i32 @strlen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0))
%109 = call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0))
%110 = add i32 %83, 1
%111 = sub i32 %110, %92
%112 = add i32 %111, %106
%113 = add i32 %112, %107
%114 = add i32 %113, %108
%115 = add i32 %114, %109
%116 = call i8* @malloc(i32 %115)
%117 = icmp eq i8* %116, null
br i1 %117, label %118, label %121
118: ; preds = %105
%119 = load i32, i32* @stderr
%120 = call i32 (i32, i8*, ...) @fprintf(i32 %119, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
br label %214
121: ; preds = %105
%122 = call i32 @strcpy(i8* %116, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%123 = call i32 @strncat(i8* %116, i8* %22, i32 %74)
%124 = call i32 @strcat(i8* %116, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0))
%125 = call i32 @strlen(i8* %116)
%126 = sext i32 %125 to i64
%127 = getelementptr inbounds i8, i8* %116, i64 %126
%128 = add nsw i64 %84, 1
%129 = call i32 @snprintf(i8* %127, i64 %128, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0), i8* %56)
%130 = call i32 @strcat(i8* %116, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0))
%131 = call i8* @strchr(i8* dereferenceable(1) %99, i32 58)
%132 = icmp eq i8* %131, null
br i1 %132, label %133, label %135
133: ; preds = %121
%134 = call i32 @invalid(i8** %1, i8* %22)
br label %135
135: ; preds = %133, %121
%136 = call i32 @strlen(i8* %99)
%137 = call i32 @strlen(i8* %131)
%138 = add i32 %82, 1
%139 = add i32 %138, %136
%140 = sub i32 %139, %137
%141 = sext i32 %140 to i64
%142 = getelementptr inbounds i8, i8* %22, i64 %141
%143 = call i8* @strchr(i8* dereferenceable(1) %142, i32 58)
%144 = icmp eq i8* %143, null
br i1 %144, label %145, label %147
145: ; preds = %135
%146 = call i32 @invalid(i8** %1, i8* %22)
br label %147
147: ; preds = %145, %135
%148 = call i32 @strlen(i8* %142)
%149 = call i32 @strlen(i8* %143)
%150 = add i32 %140, 1
%151 = add i32 %150, %148
%152 = sub i32 %151, %149
%153 = sext i32 %152 to i64
%154 = getelementptr inbounds i8, i8* %22, i64 %153
%155 = call i8* @strchr(i8* dereferenceable(1) %154, i32 47)
%156 = icmp eq i8* %155, null
br i1 %156, label %157, label %159
157: ; preds = %147
%158 = call i32 @invalid(i8** %1, i8* %22)
br label %159
159: ; preds = %157, %147
%160 = call i32 @strlen(i8* %142)
%161 = call i32 @strlen(i8* %143)
%162 = sub nsw i32 %160, %161
%163 = icmp slt i32 %162, 1
br i1 %163, label %164, label %166
164: ; preds = %159
%165 = call i32 @invalid(i8** %1, i8* %22)
br label %166
166: ; preds = %164, %159
%167 = call i32 @strlen(i8* %154)
%168 = call i32 @strlen(i8* %155)
%169 = sub nsw i32 %167, %168
%170 = icmp slt i32 %169, 1
br i1 %170, label %171, label %173
171: ; preds = %166
%172 = call i32 @invalid(i8** %1, i8* %22)
br label %173
173: ; preds = %171, %166
%174 = call i32 @strlen(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i64 0, i64 0))
%175 = call i32 @strlen(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0))
%176 = add i32 %162, 1
%177 = add i32 %176, %169
%178 = add i32 %177, %174
%179 = add i32 %178, %175
%180 = call i8* @malloc(i32 %179)
%181 = icmp eq i8* %180, null
br i1 %181, label %182, label %186
182: ; preds = %173
%183 = call i32 @free(i8* %116)
%184 = load i32, i32* @stderr
%185 = call i32 (i32, i8*, ...) @fprintf(i32 %184, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
br label %214
186: ; preds = %173
store i8 0, i8* %180
%187 = call i32 @strncat(i8* %180, i8* %142, i32 %162)
%188 = call i32 @strcat(i8* %180, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i64 0, i64 0))
%189 = call i32 @strncat(i8* %180, i8* %154, i32 %169)
%190 = call i32 @strcat(i8* %180, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0))
%191 = load i32, i32* @O_WRONLY
%192 = call i32 @open(i8* %116, i32 %191)
%193 = icmp slt i32 %192, 0
br i1 %193, label %194, label %200
194: ; preds = %186
%195 = load i32, i32* @stderr
%196 = load i32, i32* @errno
%197 = call i8* @strerror(i32 %196)
%198 = call i32 (i32, i8*, ...) @fprintf(i32 %195, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.14, i64 0, i64 0), i8* %116, i8* %197)
%199 = call i32 @usage(i8** %1, i32 1)
br label %200
200: ; preds = %194, %186
%201 = call i32 @strlen(i8* %180)
%202 = call i64 @write(i32 %192, i8* %180, i32 %201)
%203 = icmp slt i64 %202, 0
br i1 %203, label %204, label %210
204: ; preds = %200
%205 = load i32, i32* @stderr
%206 = load i32, i32* @errno
%207 = call i8* @strerror(i32 %206)
%208 = call i32 (i32, i8*, ...) @fprintf(i32 %205, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.15, i64 0, i64 0), i8* %116, i8* %207)
%209 = call i32 @usage(i8** %1, i32 1)
br label %210
210: ; preds = %204, %200
%211 = call i32 @close(i32 %192)
%212 = call i32 @free(i8* %116)
%213 = call i32 @free(i8* %180)
br label %214
214: ; preds = %210, %182, %118, %33
%215 = phi i32 [ 0, %210 ], [ 1, %182 ], [ 1, %118 ], [ 1, %33 ]
ret i32 %215
}