#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;
  int d_type;
};
typedef int /*<<< orphan*/ DIR;

/* Variables and functions */
int /*<<< orphan*/ closedir(int /*<<< orphan*/ *);
int /*<<< orphan*/ *opendir(char *);
int /*<<< orphan*/ print_30_bytes(char *, char *, int const);
struct dirent *readdir(int /*<<< orphan*/ *);
int /*<<< orphan*/ strcat(char *, char *);
scalar_t__ strcmp(char *, char *);
void exploring(char path[], char word[256], const int max_input) {
  DIR *d;
  struct dirent *dir;
  d = opendir(path);
  if (d) {
    while ((dir = readdir(d)) != NULL) {
      char dir_name[256] = "";
      strcat(dir_name, path);
      strcat(dir_name, dir->d_name);
      if (!(strcmp(dir->d_name, ".") == 0)) {
        if (!(strcmp(dir->d_name, "..") == 0)) {
          if (dir->d_type == 4) {
            strcat(dir_name, "/");
            exploring(dir_name, word, max_input);
          } else {
            print_30_bytes(dir_name, word, max_input);
          }
        }
      }
    }
    closedir(d);
  }
}


x86 assembly (clang, -O0):
<exploring>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <opendir@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     129e <exploring+0x11e>
jmp    11b3 <exploring+0x33>
mov    -0x20(%rbp),%rdi
call   1080 <readdir@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
je     1295 <exploring+0x115>
lea    -0x130(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1050 <memset@plt>
lea    -0x130(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   10a0 <strcat@plt>
lea    -0x130(%rbp),%rdi
mov    -0x28(%rbp),%rax
mov    (%rax),%rsi
call   10a0 <strcat@plt>
mov    -0x28(%rbp),%rax
mov    (%rax),%rdi
lea    0xdf3(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
je     1290 <exploring+0x110>
mov    -0x28(%rbp),%rax
mov    (%rax),%rdi
lea    0xdd5(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
je     128b <exploring+0x10b>
mov    -0x28(%rbp),%rax
cmpl   $0x4,0x8(%rax)
jne    1273 <exploring+0xf3>
lea    -0x130(%rbp),%rdi
lea    0xdad(%rip),%rsi
call   10a0 <strcat@plt>
lea    -0x130(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1040 <exploring@plt>
jmp    1286 <exploring+0x106>
lea    -0x130(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1090 <print_30_bytes@plt>
jmp    128b <exploring+0x10b>
jmp    1290 <exploring+0x110>
jmp    11b3 <exploring+0x33>
mov    -0x20(%rbp),%rdi
call   1060 <closedir@plt>
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<exploring>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x118,%rsp
mov    %edx,0xc(%rsp)
mov    %rsi,%r15
mov    %rdi,%r12
call   1030 <opendir@plt>
test   %rax,%rax
je     12ca <exploring+0x15a>
mov    %rax,%rbx
mov    %rax,%rdi
call   1070 <readdir@plt>
test   %rax,%rax
je     12c2 <exploring+0x152>
mov    %rax,%r14
lea    0x10(%rsp),%rbp
lea    0xe45(%rip),%r13
jmp    11e4 <exploring+0x74>
mov    %rbp,%rdi
mov    %r15,%rsi
mov    0xc(%rsp),%edx
call   1080 <print_30_bytes@plt>
nopl   (%rax)
mov    %rbx,%rdi
call   1070 <readdir@plt>
mov    %rax,%r14
test   %rax,%rax
je     12c2 <exploring+0x152>
xorps  %xmm0,%xmm0
movaps %xmm0,0x100(%rsp)
movaps %xmm0,0xf0(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
mov    %rbp,%rdi
mov    %r12,%rsi
call   1090 <strcat@plt>
mov    (%r14),%rsi
mov    %rbp,%rdi
call   1090 <strcat@plt>
mov    (%r14),%rdi
mov    %r13,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     11d0 <exploring+0x60>
mov    (%r14),%rdi
lea    0xd7a(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     11d0 <exploring+0x60>
cmpl   $0x4,0x8(%r14)
jne    11be <exploring+0x4e>
mov    %rbp,%rdi
lea    0xd5a(%rip),%rsi
call   1090 <strcat@plt>
mov    %rbp,%rdi
mov    %r15,%rsi
mov    0xc(%rsp),%edx
call   1040 <exploring@plt>
jmp    11d0 <exploring+0x60>
mov    %rbx,%rdi
call   1050 <closedir@plt>
add    $0x118,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.dirent = type { i8*, i32 }
@.str = [2 x i8] c".\00"
@.str.1 = [3 x i8] c"..\00"
@.str.2 = [2 x i8] c"/\00"
define void @exploring(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32*
%8 = alloca %struct.dirent*
%9 = alloca [256 x i8]
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%10 = load i8*, i8** %4
%11 = call i32* @opendir(i8* %10)
store i32* %11, i32** %7
%12 = load i32*, i32** %7
%13 = icmp ne i32* %12, null
br i1 %13, label %14, label %62
14: ; preds = %3
br label %15
15: ; preds = %58, %14
%16 = load i32*, i32** %7
%17 = call %struct.dirent* @readdir(i32* %16)
store %struct.dirent* %17, %struct.dirent** %8
%18 = icmp ne %struct.dirent* %17, null
br i1 %18, label %19, label %59
19: ; preds = %15
%20 = bitcast [256 x i8]* %9 to i8*
%21 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%22 = load i8*, i8** %4
%23 = call i32 @strcat(i8* %21, i8* %22)
%24 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%25 = load %struct.dirent*, %struct.dirent** %8
%26 = getelementptr inbounds %struct.dirent, %struct.dirent* %25, i32 0, i32 0
%27 = load i8*, i8** %26
%28 = call i32 @strcat(i8* %24, i8* %27)
%29 = load %struct.dirent*, %struct.dirent** %8
%30 = getelementptr inbounds %struct.dirent, %struct.dirent* %29, i32 0, i32 0
%31 = load i8*, i8** %30
%32 = call i64 @strcmp(i8* %31, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%33 = icmp eq i64 %32, 0
br i1 %33, label %58, label %34
34: ; preds = %19
%35 = load %struct.dirent*, %struct.dirent** %8
%36 = getelementptr inbounds %struct.dirent, %struct.dirent* %35, i32 0, i32 0
%37 = load i8*, i8** %36
%38 = call i64 @strcmp(i8* %37, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%39 = icmp eq i64 %38, 0
br i1 %39, label %57, label %40
40: ; preds = %34
%41 = load %struct.dirent*, %struct.dirent** %8
%42 = getelementptr inbounds %struct.dirent, %struct.dirent* %41, i32 0, i32 1
%43 = load i32, i32* %42
%44 = icmp eq i32 %43, 4
br i1 %44, label %45, label %51
45: ; preds = %40
%46 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%47 = call i32 @strcat(i8* %46, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%48 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%49 = load i8*, i8** %5
%50 = load i32, i32* %6
br label %56
51: ; preds = %40
%52 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%53 = load i8*, i8** %5
%54 = load i32, i32* %6
%55 = call i32 @print_30_bytes(i8* %52, i8* %53, i32 %54)
br label %56
56: ; preds = %51, %45
br label %57
57: ; preds = %56, %34
br label %58
58: ; preds = %57, %19
br label %15
59: ; preds = %15
%60 = load i32*, i32** %7
%61 = call i32 @closedir(i32* %60)
br label %62
62: ; preds = %59, %3
ret void
}

LLVM IR (-O2):
%struct.dirent = type { i8*, i32 }
@.str = [2 x i8] c".\00"
@.str.1 = [3 x i8] c"..\00"
@.str.2 = [2 x i8] c"/\00"
define void @exploring(i8* %0, i8* %1, i32 %2) {
%4 = alloca [256 x i8]
%5 = tail call i32* @opendir(i8* %0)
%6 = icmp eq i32* %5, null
br i1 %6, label %38, label %7
7: ; preds = %3
%8 = call %struct.dirent* @readdir(i32* %5)
%9 = icmp eq %struct.dirent* %8, null
br i1 %9, label %36, label %10
10: ; preds = %7
%11 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
br label %12
12: ; preds = %10, %33
%13 = phi %struct.dirent* [ %8, %10 ], [ %34, %33 ]
%14 = call i32 @strcat(i8* %11, i8* %0)
%15 = getelementptr inbounds %struct.dirent, %struct.dirent* %13, i64 0, i32 0
%16 = load i8*, i8** %15
%17 = call i32 @strcat(i8* %11, i8* %16)
%18 = load i8*, i8** %15
%19 = call i64 @strcmp(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %33, label %21
21: ; preds = %12
%22 = load i8*, i8** %15
%23 = call i64 @strcmp(i8* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %33, label %25
25: ; preds = %21
%26 = getelementptr inbounds %struct.dirent, %struct.dirent* %13, i64 0, i32 1
%27 = load i32, i32* %26
%28 = icmp eq i32 %27, 4
br i1 %28, label %29, label %31
29: ; preds = %25
%30 = call i32 @strcat(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %33
31: ; preds = %25
%32 = call i32 @print_30_bytes(i8* %11, i8* %1, i32 %2)
br label %33
33: ; preds = %21, %31, %29, %12
%34 = call %struct.dirent* @readdir(i32* %5)
%35 = icmp eq %struct.dirent* %34, null
br i1 %35, label %36, label %12
36: ; preds = %33, %7
%37 = call i32 @closedir(i32* %5)
br label %38
38: ; preds = %36, %3
ret void
}