#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 */
int /*<<< orphan*/ ENOENT;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ free(char *);
char *realloc(char *, int);
int /*<<< orphan*/ stderr;
char *strchr(char *, char);
scalar_t__ strcmp(char *, char *);
char *strdup(char *);
char *strerror(int /*<<< orphan*/);
int strlen(char *);
int /*<<< orphan*/ strncmp(char const *, char *, int);
char *strrchr(char *, char);
int find_union(const char *path, char **options, char **actual_path,
               int uniononly) {
  FILE *f = NULL;
  char *s = NULL;
  char *s2 = NULL;
  char *p;
  char *q;
  int candidate = 0;
  int mallocsize = 1024;
retry:
  if (*options) {
    free(*options);
    *options = NULL;
  }
  if (*actual_path) {
    free(*actual_path);
    *actual_path = NULL;
  }
  if (f) {
    fclose(f);
    f = NULL;
  }
  s2 = realloc(s, mallocsize);
  if (!s2) {
    fprintf(stderr, "realloc(%d): %s\n", mallocsize, strerror(errno));
    goto out;
  }
  s = s2;
  f = fopen("/proc/mounts", "r");
  if (!f) {
    fprintf(stderr, "fopen(/proc/mounts): %s\n", strerror(errno));
    goto out;
  }
  while (fgets(s, mallocsize, f)) {
    int testcan;
    if (strlen(s) == (mallocsize - 1)) {
      mallocsize *= 2;
      goto retry;
    }
    p = strchr(s, ' ');
    if (!p)
      continue;
    p++;
    q = strchr(p, ' ');
    if (!q)
      continue;
    *q++ = '\0';
    testcan = strlen(p);
    if (testcan <= candidate) {
      continue;
    }
    if (!strncmp(path, p, testcan)) {
      if (*actual_path) {
        free(*actual_path);
      }
      *actual_path = strdup(p);
      if (!*actual_path) {
        fprintf(stderr, "strdup: %s\n", strerror(errno));
        goto out;
      }
      p = strchr(q, ' ');
      if (!p)
        continue;
      *p++ = '\0';
      if (uniononly) {
        if (strcmp(q, "unionfs")) {
          candidate = 0;
          continue;
        }
      }
      candidate = testcan;
      q = strrchr(p, ' ');
      if (!q)
        continue;
      *q = '\0';
      q = strrchr(p, ' ');
      if (!q)
        continue;
      *q = '\0';
      if (*options) {
        free(*options);
      }
      *options = strdup(p);
      if (!*options) {
        fprintf(stderr, "strdup: %s\n", strerror(errno));
        goto out;
      }
    }
  }
out:
  if (s)
    free(s);
  if (f)
    fclose(f);
  if (*options) {
    return 0;
  }
  errno = -ENOENT;
  return -1;
}


x86 assembly (clang, -O0):
<find_union>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
movq   $0x0,-0x40(%rbp)
movl   $0x0,-0x54(%rbp)
movl   $0x400,-0x58(%rbp)
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
je     1232 <find_union+0x62>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x20(%rbp),%rax
cmpq   $0x0,(%rax)
je     1257 <find_union+0x87>
mov    -0x20(%rbp),%rax
mov    (%rax),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rax
movq   $0x0,(%rax)
cmpq   $0x0,-0x30(%rbp)
je     1273 <find_union+0xa3>
mov    -0x30(%rbp),%rdi
call   1050 <fclose@plt>
movq   $0x0,-0x30(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x58(%rbp),%esi
call   10c0 <realloc@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    12ca <find_union+0xfa>
mov    0x2d4b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x64(%rbp)
mov    -0x58(%rbp),%eax
mov    %eax,-0x60(%rbp)
mov    0x2d31(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
mov    -0x64(%rbp),%edi
mov    -0x60(%rbp),%edx
mov    %rax,%rcx
lea    0xd42(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
jmp    15af <find_union+0x3df>
mov    -0x40(%rbp),%rax
mov    %rax,-0x38(%rbp)
lea    0xd38(%rip),%rdi
lea    0xd3e(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1327 <find_union+0x157>
mov    0x2ce5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x68(%rbp)
mov    0x2cd1(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
mov    -0x68(%rbp),%edi
mov    %rax,%rdx
lea    0xd05(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
jmp    15af <find_union+0x3df>
jmp    132c <find_union+0x15c>
mov    -0x38(%rbp),%rdi
mov    -0x58(%rbp),%esi
mov    -0x30(%rbp),%rdx
call   1090 <fgets@plt>
cmp    $0x0,%rax
je     15aa <find_union+0x3da>
mov    -0x38(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x58(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    136b <find_union+0x19b>
mov    -0x58(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x58(%rbp)
jmp    120d <find_union+0x3d>
mov    -0x38(%rbp),%rdi
mov    $0x20,%esi
call   1070 <strchr@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
jne    138d <find_union+0x1bd>
jmp    132c <find_union+0x15c>
mov    -0x48(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rdi
mov    $0x20,%esi
call   1070 <strchr@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
jne    13bb <find_union+0x1eb>
jmp    132c <find_union+0x15c>
mov    -0x50(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x50(%rbp)
movb   $0x0,(%rax)
mov    -0x48(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x5c(%rbp)
mov    -0x5c(%rbp),%eax
cmp    -0x54(%rbp),%eax
jg     13ea <find_union+0x21a>
jmp    132c <find_union+0x15c>
mov    -0x10(%rbp),%rdi
mov    -0x48(%rbp),%rsi
mov    -0x5c(%rbp),%edx
call   1040 <strncmp@plt>
cmp    $0x0,%eax
jne    15a5 <find_union+0x3d5>
mov    -0x20(%rbp),%rax
cmpq   $0x0,(%rax)
je     141d <find_union+0x24d>
mov    -0x20(%rbp),%rax
mov    (%rax),%rdi
call   1030 <free@plt>
mov    -0x48(%rbp),%rdi
call   10e0 <strdup@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rax
cmpq   $0x0,(%rax)
jne    1471 <find_union+0x2a1>
mov    0x2b9b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x6c(%rbp)
mov    0x2b87(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
mov    -0x6c(%rbp),%edi
mov    %rax,%rdx
lea    0xbd4(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
jmp    15af <find_union+0x3df>
mov    -0x50(%rbp),%rdi
mov    $0x20,%esi
call   1070 <strchr@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
jne    1493 <find_union+0x2c3>
jmp    132c <find_union+0x15c>
mov    -0x48(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x48(%rbp)
movb   $0x0,(%rax)
cmpl   $0x0,-0x24(%rbp)
je     14da <find_union+0x30a>
mov    -0x50(%rbp),%rdi
lea    0xb8b(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%rax
je     14d5 <find_union+0x305>
movl   $0x0,-0x54(%rbp)
jmp    132c <find_union+0x15c>
jmp    14da <find_union+0x30a>
mov    -0x5c(%rbp),%eax
mov    %eax,-0x54(%rbp)
mov    -0x48(%rbp),%rdi
mov    $0x20,%esi
call   1080 <strrchr@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
jne    1502 <find_union+0x332>
jmp    132c <find_union+0x15c>
mov    -0x50(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x48(%rbp),%rdi
mov    $0x20,%esi
call   1080 <strrchr@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
jne    152b <find_union+0x35b>
jmp    132c <find_union+0x15c>
mov    -0x50(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
je     154c <find_union+0x37c>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   1030 <free@plt>
mov    -0x48(%rbp),%rdi
call   10e0 <strdup@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
jne    15a0 <find_union+0x3d0>
mov    0x2a6c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x70(%rbp)
mov    0x2a58(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
mov    -0x70(%rbp),%edi
mov    %rax,%rdx
lea    0xaa5(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
jmp    15af <find_union+0x3df>
jmp    15a5 <find_union+0x3d5>
jmp    132c <find_union+0x15c>
jmp    15af <find_union+0x3df>
cmpq   $0x0,-0x38(%rbp)
je     15c3 <find_union+0x3f3>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
cmpq   $0x0,-0x30(%rbp)
je     15d7 <find_union+0x407>
mov    -0x30(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
je     15f1 <find_union+0x421>
movl   $0x0,-0x4(%rbp)
jmp    160c <find_union+0x43c>
xor    %ecx,%ecx
mov    0x29ce(%rip),%rax
sub    (%rax),%ecx
mov    0x29d5(%rip),%rax
mov    %ecx,(%rax)
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_union>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %ecx,0x18(%rsp)
mov    %rdx,%r12
mov    %rsi,%r15
mov    %rdi,0x20(%rsp)
mov    $0x400,%ebp
xor    %ebx,%ebx
xor    %r14d,%r14d
movl   $0x0,0x4(%rsp)
mov    %rsi,0x8(%rsp)
mov    %rdx,0x10(%rsp)
mov    (%r15),%rdi
test   %rdi,%rdi
je     121d <find_union+0x4d>
call   1030 <free@plt>
movq   $0x0,(%r15)
mov    (%r12),%rdi
test   %rdi,%rdi
je     1233 <find_union+0x63>
call   1030 <free@plt>
movq   $0x0,(%r12)
test   %rbx,%rbx
je     1240 <find_union+0x70>
mov    %rbx,%rdi
call   1050 <fclose@plt>
mov    %r14,%rdi
mov    %ebp,%esi
call   10c0 <realloc@plt>
test   %rax,%rax
je     14b3 <find_union+0x2e3>
mov    %rax,%r13
lea    0xdb4(%rip),%rdi
lea    0xdba(%rip),%rsi
call   10d0 <fopen@plt>
test   %rax,%rax
je     14e6 <find_union+0x316>
mov    %rax,%rbx
mov    %r13,%rdi
mov    %ebp,%esi
mov    %rax,%rdx
call   1090 <fgets@plt>
test   %rax,%rax
je     1434 <find_union+0x264>
lea    -0x1(%rbp),%eax
mov    %eax,0x1c(%rsp)
jmp    12bc <find_union+0xec>
mov    %r14d,0x4(%rsp)
nopl   0x0(%rax)
mov    %r13,%rdi
mov    %r15,%rbp
mov    %ebp,%esi
mov    %r12,%rbx
mov    %r12,%rdx
call   1090 <fgets@plt>
test   %rax,%rax
je     1424 <find_union+0x254>
mov    %r13,%rdi
call   1060 <strlen@plt>
cmp    0x1c(%rsp),%eax
je     1410 <find_union+0x240>
mov    %rbp,%r15
mov    %rbx,%r12
mov    %r13,%rdi
mov    $0x20,%esi
call   1070 <strchr@plt>
test   %rax,%rax
je     12a0 <find_union+0xd0>
mov    %rax,%rbx
add    $0x1,%rbx
mov    %rbx,%rdi
mov    $0x20,%esi
call   1070 <strchr@plt>
test   %rax,%rax
je     12a0 <find_union+0xd0>
mov    %rax,%rbp
movb   $0x0,(%rax)
mov    %rbx,%rdi
call   1060 <strlen@plt>
cmp    0x4(%rsp),%eax
jle    12a0 <find_union+0xd0>
mov    %eax,%r14d
mov    0x20(%rsp),%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1040 <strncmp@plt>
test   %eax,%eax
jne    12a0 <find_union+0xd0>
mov    0x10(%rsp),%rax
mov    (%rax),%rdi
test   %rdi,%rdi
je     133f <find_union+0x16f>
call   1030 <free@plt>
mov    %rbx,%rdi
call   10e0 <strdup@plt>
mov    0x10(%rsp),%rcx
mov    %rax,(%rcx)
test   %rax,%rax
je     1479 <find_union+0x2a9>
add    $0x1,%rbp
mov    %rbp,%rdi
mov    $0x20,%esi
call   1070 <strchr@plt>
test   %rax,%rax
je     12a0 <find_union+0xd0>
mov    %rax,%rbx
movb   $0x0,(%rax)
cmpl   $0x0,0x18(%rsp)
je     139f <find_union+0x1cf>
mov    %rbp,%rdi
lea    0xcbc(%rip),%rsi
call   10a0 <strcmp@plt>
movl   $0x0,0x4(%rsp)
test   %rax,%rax
jne    12a0 <find_union+0xd0>
add    $0x1,%rbx
mov    %rbx,%rdi
mov    $0x20,%esi
call   1080 <strrchr@plt>
test   %rax,%rax
je     1294 <find_union+0xc4>
movb   $0x0,(%rax)
mov    %rbx,%rdi
mov    $0x20,%esi
call   1080 <strrchr@plt>
test   %rax,%rax
je     1294 <find_union+0xc4>
movb   $0x0,(%rax)
mov    0x8(%rsp),%rax
mov    (%rax),%rdi
test   %rdi,%rdi
je     13e7 <find_union+0x217>
call   1030 <free@plt>
mov    %rbx,%rdi
call   10e0 <strdup@plt>
mov    0x8(%rsp),%rcx
mov    %rax,(%rcx)
mov    %r14d,0x4(%rsp)
test   %rax,%rax
jne    12a0 <find_union+0xd0>
jmp    1479 <find_union+0x2a9>
nopw   0x0(%rax,%rax,1)
add    %ebp,%ebp
mov    %r13,%r14
mov    0x8(%rsp),%r15
mov    0x10(%rsp),%r12
jmp    1209 <find_union+0x39>
mov    %r13,%r14
mov    0x8(%rsp),%r15
mov    %r14,%r13
test   %r14,%r14
je     143c <find_union+0x26c>
mov    %r13,%rdi
call   1030 <free@plt>
test   %rbx,%rbx
je     1449 <find_union+0x279>
mov    %rbx,%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
cmpq   $0x0,(%r15)
jne    146a <find_union+0x29a>
mov    0x2b70(%rip),%rax
xor    %ecx,%ecx
sub    (%rax),%ecx
mov    0x2b75(%rip),%rax
mov    %ecx,(%rax)
mov    $0xffffffff,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2b60(%rip),%rax
mov    (%rax),%ebx
mov    0x2b4f(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
lea    0xba2(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    %r13,%r14
mov    0x8(%rsp),%r15
mov    %r12,%rbx
jmp    142c <find_union+0x25c>
mov    0x2b26(%rip),%rax
mov    (%rax),%ebx
mov    0x2b15(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
lea    0xb2f(%rip),%rsi
mov    %ebx,%edi
xor    %ebx,%ebx
mov    %ebp,%edx
mov    %rax,%rcx
xor    %eax,%eax
call   10b0 <fprintf@plt>
jmp    142c <find_union+0x25c>
mov    0x2af3(%rip),%rax
mov    (%rax),%ebp
mov    0x2ae2(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
lea    0xb1c(%rip),%rsi
xor    %ebx,%ebx
mov    %ebp,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   10b0 <fprintf@plt>
jmp    1434 <find_union+0x264>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [17 x i8] c"realloc(%d): %s\0A\00"
@errno = global i32 0
@.str.1 = [13 x i8] c"/proc/mounts\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [25 x i8] c"fopen(/proc/mounts): %s\0A\00"
@.str.4 = [12 x i8] c"strdup: %s\0A\00"
@.str.5 = [8 x i8] c"unionfs\00"
@ENOENT = global i32 0
define i32 @find_union(i8* %0, i8** %1, i8** %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8**
%8 = alloca i8**
%9 = alloca i32
%10 = alloca i32*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
store i8* %0, i8** %6
store i8** %1, i8*** %7
store i8** %2, i8*** %8
store i32 %3, i32* %9
store i32* null, i32** %10
store i8* null, i8** %11
store i8* null, i8** %12
store i32 0, i32* %15
store i32 1024, i32* %16
br label %18
18: ; preds = %77, %4
%19 = load i8**, i8*** %7
%20 = load i8*, i8** %19
%21 = icmp ne i8* %20, null
br i1 %21, label %22, label %27
22: ; preds = %18
%23 = load i8**, i8*** %7
%24 = load i8*, i8** %23
%25 = call i32 @free(i8* %24)
%26 = load i8**, i8*** %7
store i8* null, i8** %26
br label %27
27: ; preds = %22, %18
%28 = load i8**, i8*** %8
%29 = load i8*, i8** %28
%30 = icmp ne i8* %29, null
br i1 %30, label %31, label %36
31: ; preds = %27
%32 = load i8**, i8*** %8
%33 = load i8*, i8** %32
%34 = call i32 @free(i8* %33)
%35 = load i8**, i8*** %8
store i8* null, i8** %35
br label %36
36: ; preds = %31, %27
%37 = load i32*, i32** %10
%38 = icmp ne i32* %37, null
br i1 %38, label %39, label %42
39: ; preds = %36
%40 = load i32*, i32** %10
%41 = call i32 @fclose(i32* %40)
store i32* null, i32** %10
br label %42
42: ; preds = %39, %36
%43 = load i8*, i8** %11
%44 = load i32, i32* %16
%45 = call i8* @realloc(i8* %43, i32 %44)
store i8* %45, i8** %12
%46 = load i8*, i8** %12
%47 = icmp ne i8* %46, null
br i1 %47, label %54, label %48
48: ; preds = %42
%49 = load i32, i32* @stderr
%50 = load i32, i32* %16
%51 = load i32, i32* @errno
%52 = call i8* @strerror(i32 %51)
%53 = call i32 (i32, i8*, ...) @fprintf(i32 %49, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %50, i8* %52)
br label %184
54: ; preds = %42
%55 = load i8*, i8** %12
store i8* %55, i8** %11
%56 = call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %56, i32** %10
%57 = load i32*, i32** %10
%58 = icmp ne i32* %57, null
br i1 %58, label %64, label %59
59: ; preds = %54
%60 = load i32, i32* @stderr
%61 = load i32, i32* @errno
%62 = call i8* @strerror(i32 %61)
%63 = call i32 (i32, i8*, ...) @fprintf(i32 %60, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i8* %62)
br label %184
64: ; preds = %54
br label %65
65: ; preds = %182, %159, %152, %144, %134, %102, %93, %85, %64
%66 = load i8*, i8** %11
%67 = load i32, i32* %16
%68 = load i32*, i32** %10
%69 = call i64 @fgets(i8* %66, i32 %67, i32* %68)
%70 = icmp ne i64 %69, 0
br i1 %70, label %71, label %183
71: ; preds = %65
%72 = load i8*, i8** %11
%73 = call i32 @strlen(i8* %72)
%74 = load i32, i32* %16
%75 = sub nsw i32 %74, 1
%76 = icmp eq i32 %73, %75
br i1 %76, label %77, label %80
77: ; preds = %71
%78 = load i32, i32* %16
%79 = mul nsw i32 %78, 2
store i32 %79, i32* %16
br label %18
80: ; preds = %71
%81 = load i8*, i8** %11
%82 = call i8* @strchr(i8* %81, i8 signext 32)
store i8* %82, i8** %13
%83 = load i8*, i8** %13
%84 = icmp ne i8* %83, null
br i1 %84, label %86, label %85
85: ; preds = %80
br label %65
86: ; preds = %80
%87 = load i8*, i8** %13
%88 = getelementptr inbounds i8, i8* %87, i32 1
store i8* %88, i8** %13
%89 = load i8*, i8** %13
%90 = call i8* @strchr(i8* %89, i8 signext 32)
store i8* %90, i8** %14
%91 = load i8*, i8** %14
%92 = icmp ne i8* %91, null
br i1 %92, label %94, label %93
93: ; preds = %86
br label %65
94: ; preds = %86
%95 = load i8*, i8** %14
%96 = getelementptr inbounds i8, i8* %95, i32 1
store i8* %96, i8** %14
store i8 0, i8* %95
%97 = load i8*, i8** %13
%98 = call i32 @strlen(i8* %97)
store i32 %98, i32* %17
%99 = load i32, i32* %17
%100 = load i32, i32* %15
%101 = icmp sle i32 %99, %100
br i1 %101, label %102, label %103
102: ; preds = %94
br label %65
103: ; preds = %94
%104 = load i8*, i8** %6
%105 = load i8*, i8** %13
%106 = load i32, i32* %17
%107 = call i32 @strncmp(i8* %104, i8* %105, i32 %106)
%108 = icmp ne i32 %107, 0
br i1 %108, label %182, label %109
109: ; preds = %103
%110 = load i8**, i8*** %8
%111 = load i8*, i8** %110
%112 = icmp ne i8* %111, null
br i1 %112, label %113, label %117
113: ; preds = %109
%114 = load i8**, i8*** %8
%115 = load i8*, i8** %114
%116 = call i32 @free(i8* %115)
br label %117
117: ; preds = %113, %109
%118 = load i8*, i8** %13
%119 = call i8* @strdup(i8* %118)
%120 = load i8**, i8*** %8
store i8* %119, i8** %120
%121 = load i8**, i8*** %8
%122 = load i8*, i8** %121
%123 = icmp ne i8* %122, null
br i1 %123, label %129, label %124
124: ; preds = %117
%125 = load i32, i32* @stderr
%126 = load i32, i32* @errno
%127 = call i8* @strerror(i32 %126)
%128 = call i32 (i32, i8*, ...) @fprintf(i32 %125, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i8* %127)
br label %184
129: ; preds = %117
%130 = load i8*, i8** %14
%131 = call i8* @strchr(i8* %130, i8 signext 32)
store i8* %131, i8** %13
%132 = load i8*, i8** %13
%133 = icmp ne i8* %132, null
br i1 %133, label %135, label %134
134: ; preds = %129
br label %65
135: ; preds = %129
%136 = load i8*, i8** %13
%137 = getelementptr inbounds i8, i8* %136, i32 1
store i8* %137, i8** %13
store i8 0, i8* %136
%138 = load i32, i32* %9
%139 = icmp ne i32 %138, 0
br i1 %139, label %140, label %146
140: ; preds = %135
%141 = load i8*, i8** %14
%142 = call i64 @strcmp(i8* %141, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
%143 = icmp ne i64 %142, 0
br i1 %143, label %144, label %145
144: ; preds = %140
store i32 0, i32* %15
br label %65
145: ; preds = %140
br label %146
146: ; preds = %145, %135
%147 = load i32, i32* %17
store i32 %147, i32* %15
%148 = load i8*, i8** %13
%149 = call i8* @strrchr(i8* %148, i8 signext 32)
store i8* %149, i8** %14
%150 = load i8*, i8** %14
%151 = icmp ne i8* %150, null
br i1 %151, label %153, label %152
152: ; preds = %146
br label %65
153: ; preds = %146
%154 = load i8*, i8** %14
store i8 0, i8* %154
%155 = load i8*, i8** %13
%156 = call i8* @strrchr(i8* %155, i8 signext 32)
store i8* %156, i8** %14
%157 = load i8*, i8** %14
%158 = icmp ne i8* %157, null
br i1 %158, label %160, label %159
159: ; preds = %153
br label %65
160: ; preds = %153
%161 = load i8*, i8** %14
store i8 0, i8* %161
%162 = load i8**, i8*** %7
%163 = load i8*, i8** %162
%164 = icmp ne i8* %163, null
br i1 %164, label %165, label %169
165: ; preds = %160
%166 = load i8**, i8*** %7
%167 = load i8*, i8** %166
%168 = call i32 @free(i8* %167)
br label %169
169: ; preds = %165, %160
%170 = load i8*, i8** %13
%171 = call i8* @strdup(i8* %170)
%172 = load i8**, i8*** %7
store i8* %171, i8** %172
%173 = load i8**, i8*** %7
%174 = load i8*, i8** %173
%175 = icmp ne i8* %174, null
br i1 %175, label %181, label %176
176: ; preds = %169
%177 = load i32, i32* @stderr
%178 = load i32, i32* @errno
%179 = call i8* @strerror(i32 %178)
%180 = call i32 (i32, i8*, ...) @fprintf(i32 %177, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i8* %179)
br label %184
181: ; preds = %169
br label %182
182: ; preds = %181, %103
br label %65
183: ; preds = %65
br label %184
184: ; preds = %183, %176, %124, %59, %48
%185 = load i8*, i8** %11
%186 = icmp ne i8* %185, null
br i1 %186, label %187, label %190
187: ; preds = %184
%188 = load i8*, i8** %11
%189 = call i32 @free(i8* %188)
br label %190
190: ; preds = %187, %184
%191 = load i32*, i32** %10
%192 = icmp ne i32* %191, null
br i1 %192, label %193, label %196
193: ; preds = %190
%194 = load i32*, i32** %10
%195 = call i32 @fclose(i32* %194)
br label %196
196: ; preds = %193, %190
%197 = load i8**, i8*** %7
%198 = load i8*, i8** %197
%199 = icmp ne i8* %198, null
br i1 %199, label %200, label %201
200: ; preds = %196
store i32 0, i32* %5
br label %204
201: ; preds = %196
%202 = load i32, i32* @ENOENT
%203 = sub nsw i32 0, %202
store i32 %203, i32* @errno
store i32 -1, i32* %5
br label %204
204: ; preds = %201, %200
%205 = load i32, i32* %5
ret i32 %205
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [17 x i8] c"realloc(%d): %s\0A\00"
@errno = global i32 0
@.str.1 = [13 x i8] c"/proc/mounts\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [25 x i8] c"fopen(/proc/mounts): %s\0A\00"
@.str.4 = [12 x i8] c"strdup: %s\0A\00"
@.str.5 = [8 x i8] c"unionfs\00"
@ENOENT = global i32 0
define i32 @find_union(i8* %0, i8** nocapture %1, i8** nocapture %2, i32 %3) {
%5 = icmp eq i32 %3, 0
br label %8
6: ; preds = %47
%7 = shl nsw i32 %12, 1
br label %8
8: ; preds = %6, %4
%9 = phi i32* [ null, %4 ], [ %35, %6 ]
%10 = phi i8* [ null, %4 ], [ %27, %6 ]
%11 = phi i32 [ 0, %4 ], [ %48, %6 ]
%12 = phi i32 [ 1024, %4 ], [ %7, %6 ]
%13 = load i8*, i8** %1
%14 = icmp eq i8* %13, null
br i1 %14, label %17, label %15
15: ; preds = %8
%16 = tail call i32 @free(i8* %13)
store i8* null, i8** %1
br label %17
17: ; preds = %15, %8
%18 = load i8*, i8** %2
%19 = icmp eq i8* %18, null
br i1 %19, label %22, label %20
20: ; preds = %17
%21 = tail call i32 @free(i8* %18)
store i8* null, i8** %2
br label %22
22: ; preds = %20, %17
%23 = icmp eq i32* %9, null
br i1 %23, label %26, label %24
24: ; preds = %22
%25 = tail call i32 @fclose(i32* %9)
br label %26
26: ; preds = %24, %22
%27 = tail call i8* @realloc(i8* %10, i32 %12)
%28 = icmp eq i8* %27, null
br i1 %28, label %29, label %34
29: ; preds = %26
%30 = load i32, i32* @stderr
%31 = load i32, i32* @errno
%32 = tail call i8* @strerror(i32 %31)
%33 = tail call i32 (i32, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %12, i8* %32)
br label %109
34: ; preds = %26
%35 = tail call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%36 = icmp eq i32* %35, null
br i1 %36, label %42, label %37
37: ; preds = %34
%38 = tail call i64 @fgets(i8* %27, i32 %12, i32* %35)
%39 = icmp eq i64 %38, 0
br i1 %39, label %113, label %40
40: ; preds = %37
%41 = add nsw i32 %12, -1
br label %47
42: ; preds = %34
%43 = load i32, i32* @stderr
%44 = load i32, i32* @errno
%45 = tail call i8* @strerror(i32 %44)
%46 = tail call i32 (i32, i8*, ...) @fprintf(i32 %43, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i8* %45)
br label %113
47: ; preds = %40, %105
%48 = phi i32 [ %106, %105 ], [ %11, %40 ]
%49 = tail call i32 @strlen(i8* %27)
%50 = icmp eq i32 %49, %41
br i1 %50, label %6, label %51
51: ; preds = %47
%52 = tail call i8* @strchr(i8* %27, i8 signext 32)
%53 = icmp eq i8* %52, null
br i1 %53, label %105, label %54
54: ; preds = %51
%55 = getelementptr inbounds i8, i8* %52, i64 1
%56 = tail call i8* @strchr(i8* %55, i8 signext 32)
%57 = icmp eq i8* %56, null
br i1 %57, label %105, label %58
58: ; preds = %54
%59 = getelementptr inbounds i8, i8* %56, i64 1
store i8 0, i8* %56
%60 = tail call i32 @strlen(i8* %55)
%61 = icmp sgt i32 %60, %48
br i1 %61, label %62, label %105
62: ; preds = %58
%63 = tail call i32 @strncmp(i8* %0, i8* %55, i32 %60)
%64 = icmp eq i32 %63, 0
br i1 %64, label %65, label %105
65: ; preds = %62
%66 = load i8*, i8** %2
%67 = icmp eq i8* %66, null
br i1 %67, label %70, label %68
68: ; preds = %65
%69 = tail call i32 @free(i8* %66)
br label %70
70: ; preds = %68, %65
%71 = tail call i8* @strdup(i8* %55)
store i8* %71, i8** %2
%72 = icmp eq i8* %71, null
br i1 %72, label %73, label %78
73: ; preds = %70
%74 = load i32, i32* @stderr
%75 = load i32, i32* @errno
%76 = tail call i8* @strerror(i32 %75)
%77 = tail call i32 (i32, i8*, ...) @fprintf(i32 %74, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i8* %76)
br label %109
78: ; preds = %70
%79 = tail call i8* @strchr(i8* %59, i8 signext 32)
%80 = icmp eq i8* %79, null
br i1 %80, label %105, label %81
81: ; preds = %78
%82 = getelementptr inbounds i8, i8* %79, i64 1
store i8 0, i8* %79
br i1 %5, label %86, label %83
83: ; preds = %81
%84 = tail call i64 @strcmp(i8* %59, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
%85 = icmp eq i64 %84, 0
br i1 %85, label %86, label %105
86: ; preds = %83, %81
%87 = tail call i8* @strrchr(i8* %82, i8 signext 32)
%88 = icmp eq i8* %87, null
br i1 %88, label %105, label %89
89: ; preds = %86
store i8 0, i8* %87
%90 = tail call i8* @strrchr(i8* %82, i8 signext 32)
%91 = icmp eq i8* %90, null
br i1 %91, label %105, label %92
92: ; preds = %89
store i8 0, i8* %90
%93 = load i8*, i8** %1
%94 = icmp eq i8* %93, null
br i1 %94, label %97, label %95
95: ; preds = %92
%96 = tail call i32 @free(i8* %93)
br label %97
97: ; preds = %95, %92
%98 = tail call i8* @strdup(i8* %82)
store i8* %98, i8** %1
%99 = icmp eq i8* %98, null
br i1 %99, label %100, label %105
100: ; preds = %97
%101 = load i32, i32* @stderr
%102 = load i32, i32* @errno
%103 = tail call i8* @strerror(i32 %102)
%104 = tail call i32 (i32, i8*, ...) @fprintf(i32 %101, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i8* %103)
br label %109
105: ; preds = %51, %54, %58, %78, %83, %86, %89, %62, %97
%106 = phi i32 [ %60, %97 ], [ %48, %62 ], [ %60, %89 ], [ %60, %86 ], [ 0, %83 ], [ %48, %78 ], [ %48, %58 ], [ %48, %54 ], [ %48, %51 ]
%107 = tail call i64 @fgets(i8* %27, i32 %12, i32* %35)
%108 = icmp eq i64 %107, 0
br i1 %108, label %109, label %47
109: ; preds = %105, %73, %100, %29
%110 = phi i32* [ null, %29 ], [ %35, %100 ], [ %35, %73 ], [ %35, %105 ]
%111 = phi i8* [ %10, %29 ], [ %27, %100 ], [ %27, %73 ], [ %27, %105 ]
%112 = icmp eq i8* %111, null
br i1 %112, label %117, label %113
113: ; preds = %37, %42, %109
%114 = phi i8* [ %27, %42 ], [ %111, %109 ], [ %27, %37 ]
%115 = phi i32* [ null, %42 ], [ %110, %109 ], [ %35, %37 ]
%116 = tail call i32 @free(i8* %114)
br label %117
117: ; preds = %113, %109
%118 = phi i32* [ %115, %113 ], [ %110, %109 ]
%119 = icmp eq i32* %118, null
br i1 %119, label %122, label %120
120: ; preds = %117
%121 = tail call i32 @fclose(i32* %118)
br label %122
122: ; preds = %120, %117
%123 = load i8*, i8** %1
%124 = icmp eq i8* %123, null
br i1 %124, label %125, label %128
125: ; preds = %122
%126 = load i32, i32* @ENOENT
%127 = sub nsw i32 0, %126
store i32 %127, i32* @errno
br label %128
128: ; preds = %122, %125
%129 = phi i32 [ -1, %125 ], [ 0, %122 ]
ret i32 %129
}