#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_rdev;
};
struct dirent {
  char *d_name;
};
typedef int /*<<< orphan*/ FILE;
typedef int /*<<< orphan*/ DIR;

/* Variables and functions */
int /*<<< orphan*/ closedir(int /*<<< orphan*/ *);
char *dinfo_malloc(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int major(int /*<<< orphan*/);
int minor(int /*<<< orphan*/);
int /*<<< orphan*/ *opendir(char *);
int /*<<< orphan*/ printf(char *, ...);
struct dirent *readdir(int /*<<< orphan*/ *);
char *realloc(char *, int);
int /*<<< orphan*/ sprintf(char *, char *, ...);
scalar_t__ stat(char *, struct stat *);
int strlen(char *);
scalar_t__ strncmp(char *, char *, int);
int dinfo_get_uid_from_devnode(char **uidfile, char *devnode) {
  struct stat stat_buffer;
  char stat_dev[80];
  char sys_dev_path[80];
  char *readbuf;
  DIR *directory = NULL;
  struct dirent *dir_entry = NULL;
  FILE *block_dev;
  int readbuflen = 80;
  int offset;
  if (stat(devnode, &stat_buffer) != 0) {
    printf("Error: could not stat %s\n", devnode);
    return -1;
  }
  sprintf(stat_dev, "%d:%d", major(stat_buffer.st_rdev),
          minor(stat_buffer.st_rdev));
  if ((directory = opendir("/sys/block/")) == NULL) {
    printf("Error: could not open directory /sys/block\n");
    return -1;
  }
  if ((readbuf = dinfo_malloc(readbuflen)) == NULL) {
    printf("Error: Not enough memory to allocate readbuffer\n");
    return -1;
  }
  while ((dir_entry = readdir(directory)) != NULL) {
    sprintf(sys_dev_path, "/sys/block/%s/dev", dir_entry->d_name);
    if ((block_dev = fopen(sys_dev_path, "r")) == NULL)
      continue;
    offset = 0;
    while (fgets(readbuf + offset, 80, block_dev) &&
           readbuf[strlen(readbuf) - 1] != '\n') {
      offset += 80 - 1;
      if (offset + 80 - 1 >= readbuflen) {
        readbuf = realloc(readbuf, readbuflen + 80 - 1);
        readbuflen += 80 - 1;
      }
    }
    fclose(block_dev);
    if (strncmp(stat_dev, readbuf,
                ((strlen(stat_dev)) < (strlen(readbuf) - 1)
                     ? (strlen(readbuf) - 1)
                     : (strlen(stat_dev)))) == 0) {
      sprintf(*uidfile, "/sys/block/%s/device/uid", dir_entry->d_name);
      break;
    }
  }
  closedir(directory);
  return 0;
}


x86 assembly (clang, -O0):
<dinfo_get_uid_from_devnode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movq   $0x0,-0xd0(%rbp)
movq   $0x0,-0xd8(%rbp)
movl   $0x50,-0xe4(%rbp)
mov    -0x18(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   10d0 <stat@plt>
cmp    $0x0,%rax
je     1258 <dinfo_get_uid_from_devnode+0x68>
mov    -0x18(%rbp),%rsi
lea    0xdbb(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    152f <dinfo_get_uid_from_devnode+0x33f>
lea    -0x70(%rbp),%rax
mov    %rax,-0xf8(%rbp)
mov    -0x20(%rbp),%edi
call   10a0 <major@plt>
mov    %eax,-0xec(%rbp)
mov    -0x20(%rbp),%edi
call   1070 <minor@plt>
mov    -0xf8(%rbp),%rdi
mov    -0xec(%rbp),%edx
mov    %eax,%ecx
lea    0xd8b(%rip),%rsi
mov    $0x0,%al
call   1110 <sprintf@plt>
lea    0xd83(%rip),%rdi
call   1060 <opendir@plt>
mov    %rax,-0xd0(%rbp)
cmp    $0x0,%rax
jne    12cd <dinfo_get_uid_from_devnode+0xdd>
lea    0xd72(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    152f <dinfo_get_uid_from_devnode+0x33f>
mov    -0xe4(%rbp),%edi
call   1030 <dinfo_malloc@plt>
mov    %rax,-0xc8(%rbp)
cmp    $0x0,%rax
jne    1303 <dinfo_get_uid_from_devnode+0x113>
lea    0xd68(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    152f <dinfo_get_uid_from_devnode+0x33f>
jmp    1308 <dinfo_get_uid_from_devnode+0x118>
mov    -0xd0(%rbp),%rdi
call   10e0 <readdir@plt>
mov    %rax,-0xd8(%rbp)
cmp    $0x0,%rax
je     151c <dinfo_get_uid_from_devnode+0x32c>
lea    -0xc0(%rbp),%rdi
mov    -0xd8(%rbp),%rax
mov    (%rax),%rdx
lea    0xd4c(%rip),%rsi
mov    $0x0,%al
call   1110 <sprintf@plt>
lea    -0xc0(%rbp),%rdi
lea    0xd49(%rip),%rsi
call   1100 <fopen@plt>
mov    %rax,-0xe0(%rbp)
cmp    $0x0,%rax
jne    136d <dinfo_get_uid_from_devnode+0x17d>
jmp    1308 <dinfo_get_uid_from_devnode+0x118>
movl   $0x0,-0xe8(%rbp)
mov    -0xc8(%rbp),%rdi
movslq -0xe8(%rbp),%rax
add    %rax,%rdi
mov    -0xe0(%rbp),%rdx
mov    $0x50,%esi
call   10c0 <fgets@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0xf9(%rbp)
je     13e7 <dinfo_get_uid_from_devnode+0x1f7>
mov    -0xc8(%rbp),%rax
mov    %rax,-0x108(%rbp)
mov    -0xc8(%rbp),%rdi
call   1080 <strlen@plt>
mov    %eax,%ecx
mov    -0x108(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
setne  %al
mov    %al,-0xf9(%rbp)
mov    -0xf9(%rbp),%al
test   $0x1,%al
jne    13fa <dinfo_get_uid_from_devnode+0x20a>
jmp    1454 <dinfo_get_uid_from_devnode+0x264>
mov    -0xe8(%rbp),%eax
add    $0x4f,%eax
mov    %eax,-0xe8(%rbp)
mov    -0xe8(%rbp),%eax
add    $0x50,%eax
sub    $0x1,%eax
cmp    -0xe4(%rbp),%eax
jl     144f <dinfo_get_uid_from_devnode+0x25f>
mov    -0xc8(%rbp),%rdi
mov    -0xe4(%rbp),%esi
add    $0x50,%esi
sub    $0x1,%esi
call   10f0 <realloc@plt>
mov    %rax,-0xc8(%rbp)
mov    -0xe4(%rbp),%eax
add    $0x4f,%eax
mov    %eax,-0xe4(%rbp)
jmp    1377 <dinfo_get_uid_from_devnode+0x187>
mov    -0xe0(%rbp),%rdi
call   1050 <fclose@plt>
lea    -0x70(%rbp),%rax
mov    %rax,-0x120(%rbp)
mov    -0xc8(%rbp),%rax
mov    %rax,-0x118(%rbp)
lea    -0x70(%rbp),%rdi
call   1080 <strlen@plt>
mov    %eax,-0x10c(%rbp)
mov    -0xc8(%rbp),%rdi
call   1080 <strlen@plt>
mov    %eax,%ecx
mov    -0x10c(%rbp),%eax
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    14c1 <dinfo_get_uid_from_devnode+0x2d1>
mov    -0xc8(%rbp),%rdi
call   1080 <strlen@plt>
sub    $0x1,%eax
mov    %eax,-0x124(%rbp)
jmp    14d0 <dinfo_get_uid_from_devnode+0x2e0>
lea    -0x70(%rbp),%rdi
call   1080 <strlen@plt>
mov    %eax,-0x124(%rbp)
mov    -0x118(%rbp),%rsi
mov    -0x120(%rbp),%rdi
mov    -0x124(%rbp),%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    1517 <dinfo_get_uid_from_devnode+0x327>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0xd8(%rbp),%rax
mov    (%rax),%rdx
lea    0xb92(%rip),%rsi
mov    $0x0,%al
call   1110 <sprintf@plt>
jmp    151c <dinfo_get_uid_from_devnode+0x32c>
jmp    1308 <dinfo_get_uid_from_devnode+0x118>
mov    -0xd0(%rbp),%rdi
call   10b0 <closedir@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dinfo_get_uid_from_devnode>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xc8,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   10e0 <stat@plt>
test   %rax,%rax
je     123f <dinfo_get_uid_from_devnode+0x3f>
lea    0xdd0(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   10a0 <printf@plt>
jmp    13ff <dinfo_get_uid_from_devnode+0x1ff>
mov    0x8(%rsp),%edi
call   10b0 <major@plt>
mov    %eax,%ebx
mov    0x8(%rsp),%edi
call   1080 <minor@plt>
lea    0xdc0(%rip),%rsi
lea    0x20(%rsp),%rdi
mov    %ebx,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1120 <sprintf@plt>
lea    0xdaf(%rip),%rdi
call   1070 <opendir@plt>
test   %rax,%rax
je     13ea <dinfo_get_uid_from_devnode+0x1ea>
mov    %rax,%r15
movl   $0x50,0xc(%rsp)
mov    $0x50,%edi
call   1030 <dinfo_malloc@plt>
test   %rax,%rax
je     13f3 <dinfo_get_uid_from_devnode+0x1f3>
mov    %rax,%r13
mov    %r14,0x18(%rsp)
lea    0xd80(%rip),%rbx
lea    0x70(%rsp),%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
call   10f0 <readdir@plt>
test   %rax,%rax
je     13de <dinfo_get_uid_from_devnode+0x1de>
mov    %rax,%r12
mov    (%rax),%rdx
mov    %rbp,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1120 <sprintf@plt>
mov    %rbp,%rdi
lea    0xd97(%rip),%rsi
call   1110 <fopen@plt>
test   %rax,%rax
je     12c0 <dinfo_get_uid_from_devnode+0xc0>
mov    %rax,%r14
mov    %r15,0x10(%rsp)
mov    %r13,%rdi
mov    $0x50,%esi
mov    %rax,%rdx
call   10d0 <fgets@plt>
test   %rax,%rax
je     136c <dinfo_get_uid_from_devnode+0x16c>
mov    $0x4f,%r15d
jmp    133a <dinfo_get_uid_from_devnode+0x13a>
nopl   (%rax)
lea    (%r15,%r13,1),%rdi
mov    $0x50,%esi
mov    %r14,%rdx
call   10d0 <fgets@plt>
add    $0x4f,%r15
test   %rax,%rax
je     136c <dinfo_get_uid_from_devnode+0x16c>
mov    %r13,%rdi
call   1090 <strlen@plt>
cltq
cmpb   $0xa,-0x1(%rax,%r13,1)
je     136c <dinfo_get_uid_from_devnode+0x16c>
lea    0x4f(%r15),%eax
mov    0xc(%rsp),%esi
cmp    %esi,%eax
jl     1320 <dinfo_get_uid_from_devnode+0x120>
add    $0x4f,%esi
mov    %r13,%rdi
mov    %esi,0xc(%rsp)
call   1100 <realloc@plt>
mov    %rax,%r13
jmp    1320 <dinfo_get_uid_from_devnode+0x120>
mov    %r14,%rdi
call   1060 <fclose@plt>
lea    0x20(%rsp),%r14
mov    %r14,%rdi
call   1090 <strlen@plt>
mov    %eax,%r15d
mov    %r13,%rdi
call   1090 <strlen@plt>
add    $0xffffffff,%eax
cmp    %eax,%r15d
jge    13a1 <dinfo_get_uid_from_devnode+0x1a1>
mov    %r13,%rdi
call   1090 <strlen@plt>
add    $0xffffffff,%eax
jmp    13a9 <dinfo_get_uid_from_devnode+0x1a9>
mov    %r14,%rdi
call   1090 <strlen@plt>
mov    0x10(%rsp),%r15
mov    %r14,%rdi
mov    %r13,%rsi
mov    %eax,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
jne    12c0 <dinfo_get_uid_from_devnode+0xc0>
mov    0x18(%rsp),%rax
mov    (%rax),%rdi
mov    (%r12),%rdx
lea    0xc67(%rip),%rsi
xor    %eax,%eax
call   1120 <sprintf@plt>
mov    %r15,%rdi
call   10c0 <closedir@plt>
xor    %eax,%eax
jmp    1404 <dinfo_get_uid_from_devnode+0x204>
lea    0xc96(%rip),%rdi
jmp    13fa <dinfo_get_uid_from_devnode+0x1fa>
lea    0xc5d(%rip),%rdi
call   1050 <puts@plt>
mov    $0xffffffff,%eax
add    $0xc8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.stat = type { i32 }
%struct.dirent = type { i8* }
@.str = [26 x i8] c"Error: could not stat %s\0A\00"
@.str.1 = [6 x i8] c"%d:%d\00"
@.str.2 = [12 x i8] c"/sys/block/\00"
@.str.3 = [44 x i8] c"Error: could not open directory /sys/block\0A\00"
@.str.4 = [49 x i8] c"Error: Not enough memory to allocate readbuffer\0A\00"
@.str.5 = [18 x i8] c"/sys/block/%s/dev\00"
@.str.6 = [2 x i8] c"r\00"
@.str.7 = [25 x i8] c"/sys/block/%s/device/uid\00"
define i32 @dinfo_get_uid_from_devnode(i8** %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i8*
%6 = alloca %struct.stat
%7 = alloca [80 x i8]
%8 = alloca [80 x i8]
%9 = alloca i8*
%10 = alloca i32*
%11 = alloca %struct.dirent*
%12 = alloca i32*
%13 = alloca i32
%14 = alloca i32
store i8** %0, i8*** %4
store i8* %1, i8** %5
store i32* null, i32** %10
store %struct.dirent* null, %struct.dirent** %11
store i32 80, i32* %13
%15 = load i8*, i8** %5
%16 = call i64 @stat(i8* %15, %struct.stat* %6)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %2
%19 = load i8*, i8** %5
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %19)
store i32 -1, i32* %3
br label %126
21: ; preds = %2
%22 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%23 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%24 = load i32, i32* %23
%25 = call i32 @major(i32 %24)
%26 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%27 = load i32, i32* %26
%28 = call i32 @minor(i32 %27)
%29 = call i32 (i8*, i8*, ...) @sprintf(i8* %22, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %25, i32 %28)
%30 = call i32* @opendir(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
store i32* %30, i32** %10
%31 = icmp eq i32* %30, null
br i1 %31, label %32, label %34
32: ; preds = %21
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0))
store i32 -1, i32* %3
br label %126
34: ; preds = %21
%35 = load i32, i32* %13
%36 = call i8* @dinfo_malloc(i32 %35)
store i8* %36, i8** %9
%37 = icmp eq i8* %36, null
br i1 %37, label %38, label %40
38: ; preds = %34
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.4, i64 0, i64 0))
store i32 -1, i32* %3
br label %126
40: ; preds = %34
br label %41
41: ; preds = %122, %54, %40
%42 = load i32*, i32** %10
%43 = call %struct.dirent* @readdir(i32* %42)
store %struct.dirent* %43, %struct.dirent** %11
%44 = icmp ne %struct.dirent* %43, null
br i1 %44, label %45, label %123
45: ; preds = %41
%46 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 0
%47 = load %struct.dirent*, %struct.dirent** %11
%48 = getelementptr inbounds %struct.dirent, %struct.dirent* %47, i32 0, i32 0
%49 = load i8*, i8** %48
%50 = call i32 (i8*, i8*, ...) @sprintf(i8* %46, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i8* %49)
%51 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 0
%52 = call i32* @fopen(i8* %51, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
store i32* %52, i32** %12
%53 = icmp eq i32* %52, null
br i1 %53, label %54, label %55
54: ; preds = %45
br label %41
55: ; preds = %45
store i32 0, i32* %14
br label %56
56: ; preds = %92, %55
%57 = load i8*, i8** %9
%58 = load i32, i32* %14
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds i8, i8* %57, i64 %59
%61 = load i32*, i32** %12
%62 = call i64 @fgets(i8* %60, i32 80, i32* %61)
%63 = icmp ne i64 %62, 0
br i1 %63, label %64, label %74
64: ; preds = %56
%65 = load i8*, i8** %9
%66 = load i8*, i8** %9
%67 = call i32 @strlen(i8* %66)
%68 = sub nsw i32 %67, 1
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds i8, i8* %65, i64 %69
%71 = load i8, i8* %70
%72 = sext i8 %71 to i32
%73 = icmp ne i32 %72, 10
br label %74
74: ; preds = %64, %56
%75 = phi i1 [ false, %56 ], [ %73, %64 ]
br i1 %75, label %76, label %93
76: ; preds = %74
%77 = load i32, i32* %14
%78 = add nsw i32 %77, 79
store i32 %78, i32* %14
%79 = load i32, i32* %14
%80 = add nsw i32 %79, 80
%81 = sub nsw i32 %80, 1
%82 = load i32, i32* %13
%83 = icmp sge i32 %81, %82
br i1 %83, label %84, label %92
84: ; preds = %76
%85 = load i8*, i8** %9
%86 = load i32, i32* %13
%87 = add nsw i32 %86, 80
%88 = sub nsw i32 %87, 1
%89 = call i8* @realloc(i8* %85, i32 %88)
store i8* %89, i8** %9
%90 = load i32, i32* %13
%91 = add nsw i32 %90, 79
store i32 %91, i32* %13
br label %92
92: ; preds = %84, %76
br label %56
93: ; preds = %74
%94 = load i32*, i32** %12
%95 = call i32 @fclose(i32* %94)
%96 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%97 = load i8*, i8** %9
%98 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%99 = call i32 @strlen(i8* %98)
%100 = load i8*, i8** %9
%101 = call i32 @strlen(i8* %100)
%102 = sub nsw i32 %101, 1
%103 = icmp slt i32 %99, %102
br i1 %103, label %104, label %108
104: ; preds = %93
%105 = load i8*, i8** %9
%106 = call i32 @strlen(i8* %105)
%107 = sub nsw i32 %106, 1
br label %111
108: ; preds = %93
%109 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%110 = call i32 @strlen(i8* %109)
br label %111
111: ; preds = %108, %104
%112 = phi i32 [ %107, %104 ], [ %110, %108 ]
%113 = call i64 @strncmp(i8* %96, i8* %97, i32 %112)
%114 = icmp eq i64 %113, 0
br i1 %114, label %115, label %122
115: ; preds = %111
%116 = load i8**, i8*** %4
%117 = load i8*, i8** %116
%118 = load %struct.dirent*, %struct.dirent** %11
%119 = getelementptr inbounds %struct.dirent, %struct.dirent* %118, i32 0, i32 0
%120 = load i8*, i8** %119
%121 = call i32 (i8*, i8*, ...) @sprintf(i8* %117, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0), i8* %120)
br label %123
122: ; preds = %111
br label %41
123: ; preds = %115, %41
%124 = load i32*, i32** %10
%125 = call i32 @closedir(i32* %124)
store i32 0, i32* %3
br label %126
126: ; preds = %123, %38, %32, %18
%127 = load i32, i32* %3
ret i32 %127
}

LLVM IR (-O2):
%struct.stat = type { i32 }
%struct.dirent = type { i8* }
@.str = [26 x i8] c"Error: could not stat %s\0A\00"
@.str.1 = [6 x i8] c"%d:%d\00"
@.str.2 = [12 x i8] c"/sys/block/\00"
@.str.5 = [18 x i8] c"/sys/block/%s/dev\00"
@.str.6 = [2 x i8] c"r\00"
@.str.7 = [25 x i8] c"/sys/block/%s/device/uid\00"
@str = [48 x i8] c"Error: Not enough memory to allocate readbuffer\00"
@str.8 = [43 x i8] c"Error: could not open directory /sys/block\00"
define i32 @dinfo_get_uid_from_devnode(i8** nocapture %0, i8* %1) {
%3 = alloca %struct.stat
%4 = alloca [80 x i8]
%5 = alloca [80 x i8]
%6 = bitcast %struct.stat* %3 to i8*
%7 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%8 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
%9 = call i64 @stat(i8* %1, %struct.stat* %3)
%10 = icmp eq i64 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %2
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %1)
br label %92
13: ; preds = %2
%14 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%15 = load i32, i32* %14
%16 = call i32 @major(i32 %15)
%17 = load i32, i32* %14
%18 = call i32 @minor(i32 %17)
%19 = call i32 (i8*, i8*, ...) @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %16, i32 %18)
%20 = call i32* @opendir(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%21 = icmp eq i32* %20, null
br i1 %21, label %22, label %24
22: ; preds = %13
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str.8, i64 0, i64 0))
br label %92
24: ; preds = %13
%25 = call i8* @dinfo_malloc(i32 80)
%26 = icmp eq i8* %25, null
br i1 %26, label %27, label %82
27: ; preds = %24
%28 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @str, i64 0, i64 0))
br label %92
29: ; preds = %82, %32
%30 = call %struct.dirent* @readdir(i32* %20)
%31 = icmp eq %struct.dirent* %30, null
br i1 %31, label %90, label %32
32: ; preds = %29
%33 = getelementptr inbounds %struct.dirent, %struct.dirent* %30, i64 0, i32 0
%34 = load i8*, i8** %33
%35 = call i32 (i8*, i8*, ...) @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i8* %34)
%36 = call i32* @fopen(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%37 = icmp eq i32* %36, null
br i1 %37, label %29, label %38
38: ; preds = %32
%39 = call i64 @fgets(i8* %83, i32 80, i32* %36)
%40 = icmp eq i64 %39, 0
br i1 %40, label %65, label %41
41: ; preds = %38, %59
%42 = phi i64 [ %52, %59 ], [ 0, %38 ]
%43 = phi i32 [ %61, %59 ], [ %84, %38 ]
%44 = phi i8* [ %60, %59 ], [ %83, %38 ]
%45 = call i32 @strlen(i8* %44)
%46 = add nsw i32 %45, -1
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i8, i8* %44, i64 %47
%49 = load i8, i8* %48
%50 = icmp eq i8 %49, 10
br i1 %50, label %65, label %51
51: ; preds = %41
%52 = add nuw i64 %42, 79
%53 = trunc i64 %42 to i32
%54 = add i32 %53, 158
%55 = icmp slt i32 %54, %43
br i1 %55, label %59, label %56
56: ; preds = %51
%57 = add nsw i32 %43, 79
%58 = call i8* @realloc(i8* %44, i32 %57)
br label %59
59: ; preds = %56, %51
%60 = phi i8* [ %58, %56 ], [ %44, %51 ]
%61 = phi i32 [ %57, %56 ], [ %43, %51 ]
%62 = getelementptr inbounds i8, i8* %60, i64 %52
%63 = call i64 @fgets(i8* %62, i32 80, i32* %36)
%64 = icmp eq i64 %63, 0
br i1 %64, label %65, label %41
65: ; preds = %41, %59, %38
%66 = phi i8* [ %83, %38 ], [ %60, %59 ], [ %44, %41 ]
%67 = phi i32 [ %84, %38 ], [ %61, %59 ], [ %43, %41 ]
%68 = call i32 @fclose(i32* %36)
%69 = call i32 @strlen(i8* %7)
%70 = call i32 @strlen(i8* %66)
%71 = add nsw i32 %70, -1
%72 = icmp slt i32 %69, %71
br i1 %72, label %73, label %76
73: ; preds = %65
%74 = call i32 @strlen(i8* %66)
%75 = add nsw i32 %74, -1
br label %78
76: ; preds = %65
%77 = call i32 @strlen(i8* %7)
br label %78
78: ; preds = %76, %73
%79 = phi i32 [ %75, %73 ], [ %77, %76 ]
%80 = call i64 @strncmp(i8* %7, i8* %66, i32 %79)
%81 = icmp eq i64 %80, 0
br i1 %81, label %85, label %82
82: ; preds = %24, %78
%83 = phi i8* [ %66, %78 ], [ %25, %24 ]
%84 = phi i32 [ %67, %78 ], [ 80, %24 ]
br label %29
85: ; preds = %78
%86 = getelementptr inbounds %struct.dirent, %struct.dirent* %30, i64 0, i32 0
%87 = load i8*, i8** %0
%88 = load i8*, i8** %86
%89 = call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %87, i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0), i8* %88)
br label %90
90: ; preds = %29, %85
%91 = call i32 @closedir(i32* %20)
br label %92
92: ; preds = %90, %27, %22, %11
%93 = phi i32 [ -1, %11 ], [ -1, %22 ], [ -1, %27 ], [ 0, %90 ]
ret i32 %93
}