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

/* Variables and functions */
int /*<<< orphan*/ closedir(int /*<<< orphan*/ *);
scalar_t__ errno;
int /*<<< orphan*/ *opendir(char *);
int /*<<< orphan*/ printf(char *, ...);
struct dirent *readdir(int /*<<< orphan*/ *);
int /*<<< orphan*/ rewinddir(int /*<<< orphan*/ *);
int /*<<< orphan*/ seekdir(int /*<<< orphan*/ *, long);
char *strerror(scalar_t__);
long telldir(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  int i;
  struct dirent *de;
  DIR *dir;
  long lPos;
  if (argc == 2) {
    printf("Opening directory \"%s\"\n", argv[1]);
    dir = opendir(argv[1]);
  } else {
    printf("Opening \".\"\n");
    dir = opendir(".");
  }
  if (!dir) {
    printf("Directory open failed!\n");
    if (errno) {
      printf("Error : %s\n", strerror(errno));
    }
    return 1;
  }
  i = 0;
  lPos = -1;
  while (de = readdir(dir)) {
    i++;
    printf("%d : \"%s\" (tell %ld)\n", i, de->d_name, telldir(dir));
    if (i == 3) {
      printf("We will seek here later.\n");
      lPos = telldir(dir);
    }
  }
  printf("Rewind directory.\n");
  rewinddir(dir);
  if (de = readdir(dir)) {
    printf("First entry : \"%s\"\n", de->d_name);
  } else {
    printf("Empty directory.\n");
  }
  if (lPos != -1) {
    printf("Seeking to fourth entry.\n");
    seekdir(dir, lPos);
    if (de = readdir(dir)) {
      printf("Fourth entry : \"%s\"\n", de->d_name);
    } else {
      printf("No fourth entry.\n");
    }
  } else {
    printf("Seek position is past end of directory.\n");
  }
  printf("Closing directory.\n");
  closedir(dir);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    11cc <main+0x4c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <opendir@plt>
mov    %rax,-0x28(%rbp)
jmp    11ea <main+0x6a>
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe44(%rip),%rdi
call   1030 <opendir@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1240 <main+0xc0>
lea    0xe2b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2dd6(%rip),%rax
cmpq   $0x0,(%rax)
je     1234 <main+0xb4>
mov    0x2dc5(%rip),%rax
mov    (%rax),%rdi
call   10a0 <strerror@plt>
mov    %rax,%rsi
lea    0xe12(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    13b0 <main+0x230>
movl   $0x0,-0x14(%rbp)
movq   $0xffffffffffffffff,-0x30(%rbp)
ff
mov    -0x28(%rbp),%rdi
call   1070 <readdir@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     12cb <main+0x14b>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
mov    -0x28(%rbp),%rdi
call   1090 <telldir@plt>
mov    -0x3c(%rbp),%esi
mov    -0x38(%rbp),%rdx
mov    %rax,%rcx
lea    0xdb1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x3,-0x14(%rbp)
jne    12c6 <main+0x146>
lea    0xdaf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%rdi
call   1090 <telldir@plt>
mov    %rax,-0x30(%rbp)
jmp    124f <main+0xcf>
lea    0xda9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%rdi
call   1050 <rewinddir@plt>
mov    -0x28(%rbp),%rdi
call   1070 <readdir@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     1313 <main+0x193>
mov    -0x20(%rbp),%rax
mov    (%rax),%rsi
lea    0xd87(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1321 <main+0x1a1>
lea    0xd88(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpq   $0xffffffffffffffff,-0x30(%rbp)
je     138b <main+0x20b>
lea    0xd81(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1080 <seekdir@plt>
mov    -0x28(%rbp),%rdi
call   1070 <readdir@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     1378 <main+0x1f8>
mov    -0x20(%rbp),%rax
mov    (%rax),%rsi
lea    0xd62(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1386 <main+0x206>
lea    0xd64(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1399 <main+0x219>
lea    0xd63(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xd7e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%rdi
call   1060 <closedir@plt>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
cmp    $0x2,%edi
jne    11b8 <main+0x28>
mov    %rsi,%rbx
mov    0x8(%rsi),%rsi
lea    0xe55(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rbx),%rdi
jmp    11cb <main+0x3b>
lea    0xea4(%rip),%rdi
call   1030 <puts@plt>
lea    0xf5a(%rip),%rdi
call   1040 <opendir@plt>
test   %rax,%rax
je     1364 <main+0x1d4>
mov    %rax,%r12
mov    %rax,%rdi
call   1080 <readdir@plt>
mov    $0xffffffffffffffff,%r14
test   %rax,%rax
je     12ed <main+0x15d>
mov    (%rax),%rbp
mov    %r12,%rdi
call   10a0 <telldir@plt>
lea    0xe1e(%rip),%rdi
mov    $0x1,%esi
mov    %rbp,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r12,%rdi
call   1080 <readdir@plt>
test   %rax,%rax
je     12ed <main+0x15d>
mov    (%rax),%rbp
mov    %r12,%rdi
call   10a0 <telldir@plt>
lea    0xde9(%rip),%rdi
mov    $0x2,%esi
mov    %rbp,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r12,%rdi
call   1080 <readdir@plt>
test   %rax,%rax
je     12ed <main+0x15d>
mov    (%rax),%rbp
mov    %r12,%rdi
call   10a0 <telldir@plt>
lea    0xdb4(%rip),%rdi
mov    $0x3,%esi
mov    %rbp,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe85(%rip),%rdi
call   1030 <puts@plt>
mov    %r12,%rdi
call   10a0 <telldir@plt>
mov    %rax,%r14
mov    %r12,%rdi
call   1080 <readdir@plt>
test   %rax,%rax
je     12ed <main+0x15d>
mov    $0x4,%ebp
lea    0xd72(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%rax),%rbx
mov    %r12,%rdi
call   10a0 <telldir@plt>
mov    %r15,%rdi
mov    %ebp,%esi
mov    %rbx,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r12,%rdi
call   1080 <readdir@plt>
add    $0x1,%ebp
test   %rax,%rax
jne    12c0 <main+0x130>
lea    0xd92(%rip),%rdi
call   1030 <puts@plt>
mov    %r12,%rdi
call   1060 <rewinddir@plt>
mov    %r12,%rdi
call   1080 <readdir@plt>
test   %rax,%rax
je     139c <main+0x20c>
mov    (%rax),%rsi
lea    0xd1e(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
cmp    $0xffffffffffffffff,%r14
je     13b2 <main+0x222>
lea    0xdb0(%rip),%rdi
call   1030 <puts@plt>
mov    %r12,%rdi
mov    %r14,%rsi
call   1090 <seekdir@plt>
mov    %r12,%rdi
call   1080 <readdir@plt>
test   %rax,%rax
je     13bb <main+0x22b>
mov    (%rax),%rsi
lea    0xcf3(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    13c7 <main+0x237>
lea    0xd04(%rip),%rdi
call   1030 <puts@plt>
mov    0x2c69(%rip),%rax
mov    (%rax),%rdi
mov    $0x1,%ebx
test   %rdi,%rdi
je     13dd <main+0x24d>
call   10b0 <strerror@plt>
lea    0xc88(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    13dd <main+0x24d>
lea    0xcf5(%rip),%rdi
call   1030 <puts@plt>
cmp    $0xffffffffffffffff,%r14
jne    132d <main+0x19d>
lea    0xcf0(%rip),%rdi
jmp    13c2 <main+0x232>
lea    0xd3b(%rip),%rdi
call   1030 <puts@plt>
lea    0xd03(%rip),%rdi
call   1030 <puts@plt>
mov    %r12,%rdi
call   1070 <closedir@plt>
xor    %ebx,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.dirent = type { i8* }
@.str = [24 x i8] c"Opening directory \22%s\22\0A\00"
@.str.1 = [13 x i8] c"Opening \22.\22\0A\00"
@.str.2 = [2 x i8] c".\00"
@.str.3 = [24 x i8] c"Directory open failed!\0A\00"
@errno = global i64 0
@.str.4 = [12 x i8] c"Error : %s\0A\00"
@.str.5 = [22 x i8] c"%d : \22%s\22 (tell %ld)\0A\00"
@.str.6 = [26 x i8] c"We will seek here later.\0A\00"
@.str.7 = [19 x i8] c"Rewind directory.\0A\00"
@.str.8 = [20 x i8] c"First entry : \22%s\22\0A\00"
@.str.9 = [18 x i8] c"Empty directory.\0A\00"
@.str.10 = [26 x i8] c"Seeking to fourth entry.\0A\00"
@.str.11 = [21 x i8] c"Fourth entry : \22%s\22\0A\00"
@.str.12 = [18 x i8] c"No fourth entry.\0A\00"
@.str.13 = [41 x i8] c"Seek position is past end of directory.\0A\00"
@.str.14 = [20 x i8] c"Closing directory.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca %struct.dirent*
%8 = alloca i32*
%9 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp eq i32 %10, 2
br i1 %11, label %12, label %21
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i32* @opendir(i8* %19)
store i32* %20, i32** %8
br label %24
21: ; preds = %2
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%23 = call i32* @opendir(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %23, i32** %8
br label %24
24: ; preds = %21, %12
%25 = load i32*, i32** %8
%26 = icmp ne i32* %25, null
br i1 %26, label %36, label %27
27: ; preds = %24
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
%29 = load i64, i64* @errno
%30 = icmp ne i64 %29, 0
br i1 %30, label %31, label %35
31: ; preds = %27
%32 = load i64, i64* @errno
%33 = call i8* @strerror(i64 %32)
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i8* %33)
br label %35
35: ; preds = %31, %27
store i32 1, i32* %3
br label %97
36: ; preds = %24
store i32 0, i32* %6
store i64 -1, i64* %9
br label %37
37: ; preds = %57, %36
%38 = load i32*, i32** %8
%39 = call %struct.dirent* @readdir(i32* %38)
store %struct.dirent* %39, %struct.dirent** %7
%40 = icmp ne %struct.dirent* %39, null
br i1 %40, label %41, label %58
41: ; preds = %37
%42 = load i32, i32* %6
%43 = add nsw i32 %42, 1
store i32 %43, i32* %6
%44 = load i32, i32* %6
%45 = load %struct.dirent*, %struct.dirent** %7
%46 = getelementptr inbounds %struct.dirent, %struct.dirent* %45, i32 0, i32 0
%47 = load i8*, i8** %46
%48 = load i32*, i32** %8
%49 = call i64 @telldir(i32* %48)
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i32 %44, i8* %47, i64 %49)
%51 = load i32, i32* %6
%52 = icmp eq i32 %51, 3
br i1 %52, label %53, label %57
53: ; preds = %41
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0))
%55 = load i32*, i32** %8
%56 = call i64 @telldir(i32* %55)
store i64 %56, i64* %9
br label %57
57: ; preds = %53, %41
br label %37
58: ; preds = %37
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0))
%60 = load i32*, i32** %8
%61 = call i32 @rewinddir(i32* %60)
%62 = load i32*, i32** %8
%63 = call %struct.dirent* @readdir(i32* %62)
store %struct.dirent* %63, %struct.dirent** %7
%64 = icmp ne %struct.dirent* %63, null
br i1 %64, label %65, label %70
65: ; preds = %58
%66 = load %struct.dirent*, %struct.dirent** %7
%67 = getelementptr inbounds %struct.dirent, %struct.dirent* %66, i32 0, i32 0
%68 = load i8*, i8** %67
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0), i8* %68)
br label %72
70: ; preds = %58
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0))
br label %72
72: ; preds = %70, %65
%73 = load i64, i64* %9
%74 = icmp ne i64 %73, -1
br i1 %74, label %75, label %91
75: ; preds = %72
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.10, i64 0, i64 0))
%77 = load i32*, i32** %8
%78 = load i64, i64* %9
%79 = call i32 @seekdir(i32* %77, i64 %78)
%80 = load i32*, i32** %8
%81 = call %struct.dirent* @readdir(i32* %80)
store %struct.dirent* %81, %struct.dirent** %7
%82 = icmp ne %struct.dirent* %81, null
br i1 %82, label %83, label %88
83: ; preds = %75
%84 = load %struct.dirent*, %struct.dirent** %7
%85 = getelementptr inbounds %struct.dirent, %struct.dirent* %84, i32 0, i32 0
%86 = load i8*, i8** %85
%87 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.11, i64 0, i64 0), i8* %86)
br label %90
88: ; preds = %75
%89 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.12, i64 0, i64 0))
br label %90
90: ; preds = %88, %83
br label %93
91: ; preds = %72
%92 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.13, i64 0, i64 0))
br label %93
93: ; preds = %91, %90
%94 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.14, i64 0, i64 0))
%95 = load i32*, i32** %8
%96 = call i32 @closedir(i32* %95)
br label %97
97: ; preds = %93, %35
%98 = load i32, i32* %3
ret i32 %98
}

LLVM IR (-O2):
%struct.dirent = type { i8* }
@.str = [24 x i8] c"Opening directory \22%s\22\0A\00"
@.str.2 = [2 x i8] c".\00"
@errno = global i64 0
@.str.4 = [12 x i8] c"Error : %s\0A\00"
@.str.5 = [22 x i8] c"%d : \22%s\22 (tell %ld)\0A\00"
@.str.8 = [20 x i8] c"First entry : \22%s\22\0A\00"
@.str.11 = [21 x i8] c"Fourth entry : \22%s\22\0A\00"
@str = [12 x i8] c"Opening \22.\22\00"
@str.15 = [23 x i8] c"Directory open failed!\00"
@str.16 = [18 x i8] c"Rewind directory.\00"
@str.17 = [17 x i8] c"Empty directory.\00"
@str.18 = [40 x i8] c"Seek position is past end of directory.\00"
@str.19 = [19 x i8] c"Closing directory.\00"
@str.20 = [25 x i8] c"Seeking to fourth entry.\00"
@str.21 = [17 x i8] c"No fourth entry.\00"
@str.22 = [25 x i8] c"We will seek here later.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %4, label %9
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = load i8*, i8** %5
br label %11
9: ; preds = %2
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
br label %11
11: ; preds = %9, %4
%12 = phi i8* [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), %9 ], [ %8, %4 ]
%13 = tail call i32* @opendir(i8* %12)
%14 = icmp eq i32* %13, null
br i1 %14, label %41, label %15
15: ; preds = %11
%16 = tail call %struct.dirent* @readdir(i32* %13)
%17 = icmp eq %struct.dirent* %16, null
br i1 %17, label %58, label %18
18: ; preds = %15
%19 = getelementptr inbounds %struct.dirent, %struct.dirent* %16, i64 0, i32 0
%20 = load i8*, i8** %19
%21 = tail call i64 @telldir(i32* %13)
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i32 1, i8* %20, i64 %21)
%23 = tail call %struct.dirent* @readdir(i32* %13)
%24 = icmp eq %struct.dirent* %23, null
br i1 %24, label %58, label %25
25: ; preds = %18
%26 = getelementptr inbounds %struct.dirent, %struct.dirent* %23, i64 0, i32 0
%27 = load i8*, i8** %26
%28 = tail call i64 @telldir(i32* %13)
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i32 2, i8* %27, i64 %28)
%30 = tail call %struct.dirent* @readdir(i32* %13)
%31 = icmp eq %struct.dirent* %30, null
br i1 %31, label %58, label %32
32: ; preds = %25
%33 = getelementptr inbounds %struct.dirent, %struct.dirent* %30, i64 0, i32 0
%34 = load i8*, i8** %33
%35 = tail call i64 @telldir(i32* %13)
%36 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i32 3, i8* %34, i64 %35)
%37 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.22, i64 0, i64 0))
%38 = tail call i64 @telldir(i32* %13)
%39 = tail call %struct.dirent* @readdir(i32* %13)
%40 = icmp eq %struct.dirent* %39, null
br i1 %40, label %58, label %48
41: ; preds = %11
%42 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.15, i64 0, i64 0))
%43 = load i64, i64* @errno
%44 = icmp eq i64 %43, 0
br i1 %44, label %88, label %45
45: ; preds = %41
%46 = tail call i8* @strerror(i64 %43)
%47 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i8* %46)
br label %88
48: ; preds = %32, %48
%49 = phi %struct.dirent* [ %56, %48 ], [ %39, %32 ]
%50 = phi i32 [ %51, %48 ], [ 3, %32 ]
%51 = add nuw nsw i32 %50, 1
%52 = getelementptr inbounds %struct.dirent, %struct.dirent* %49, i64 0, i32 0
%53 = load i8*, i8** %52
%54 = tail call i64 @telldir(i32* %13)
%55 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i32 %51, i8* %53, i64 %54)
%56 = tail call %struct.dirent* @readdir(i32* %13)
%57 = icmp eq %struct.dirent* %56, null
br i1 %57, label %58, label %48
58: ; preds = %48, %18, %25, %32, %15
%59 = phi i64 [ -1, %15 ], [ -1, %18 ], [ -1, %25 ], [ %38, %32 ], [ %38, %48 ]
%60 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.16, i64 0, i64 0))
%61 = tail call i32 @rewinddir(i32* %13)
%62 = tail call %struct.dirent* @readdir(i32* %13)
%63 = icmp eq %struct.dirent* %62, null
br i1 %63, label %68, label %64
64: ; preds = %58
%65 = getelementptr inbounds %struct.dirent, %struct.dirent* %62, i64 0, i32 0
%66 = load i8*, i8** %65
%67 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0), i8* %66)
br label %70
68: ; preds = %58
%69 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.17, i64 0, i64 0))
br label %70
70: ; preds = %68, %64
%71 = icmp eq i64 %59, -1
br i1 %71, label %83, label %72
72: ; preds = %70
%73 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.20, i64 0, i64 0))
%74 = tail call i32 @seekdir(i32* %13, i64 %59)
%75 = tail call %struct.dirent* @readdir(i32* %13)
%76 = icmp eq %struct.dirent* %75, null
br i1 %76, label %81, label %77
77: ; preds = %72
%78 = getelementptr inbounds %struct.dirent, %struct.dirent* %75, i64 0, i32 0
%79 = load i8*, i8** %78
%80 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.11, i64 0, i64 0), i8* %79)
br label %85
81: ; preds = %72
%82 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.21, i64 0, i64 0))
br label %85
83: ; preds = %70
%84 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.18, i64 0, i64 0))
br label %85
85: ; preds = %77, %81, %83
%86 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.19, i64 0, i64 0))
%87 = tail call i32 @closedir(i32* %13)
br label %88
88: ; preds = %41, %45, %85
%89 = phi i32 [ 0, %85 ], [ 1, %45 ], [ 1, %41 ]
ret i32 %89
}