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

/* Variables and functions */
int /*<<< orphan*/ closedir(int /*<<< orphan*/ *);
int /*<<< orphan*/ file_read_play(char *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ *opendir(char *);
struct dirent *readdir(int /*<<< orphan*/ *);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ strcat(char *, char *);
int strlen(char *);
scalar_t__ strstr(char *, char *);
int main(void) {
  struct dirent *entry;
  DIR *dir;
  char *path = "../../data/media/";
  char fname[32] = {0};
  while (1) {
    dir = opendir(path);
    while ((entry = readdir(dir)) != NULL) {
      if (strlen(entry->d_name) > 5) {
        strcat(fname, path);
        strcat(fname, entry->d_name);
        if (strstr(fname, "media_"))
          file_read_play(fname);
        memset(fname, 0, sizeof(fname));
      }
    }
    closedir(dir);
    sleep(1);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe5a(%rip),%rax
mov    %rax,-0x20(%rbp)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1050 <memset@plt>
mov    -0x20(%rbp),%rdi
call   1030 <opendir@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1070 <readdir@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     1248 <main+0xb8>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1040 <strlen@plt>
cmp    $0x5,%eax
jle    1243 <main+0xb3>
lea    -0x40(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1080 <strcat@plt>
lea    -0x40(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
call   1080 <strcat@plt>
lea    -0x40(%rbp),%rdi
lea    0xdf7(%rip),%rsi
call   10b0 <strstr@plt>
cmp    $0x0,%rax
je     1233 <main+0xa3>
lea    -0x40(%rbp),%rdi
call   1090 <file_read_play@plt>
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1050 <memset@plt>
jmp    11c7 <main+0x37>
mov    -0x18(%rbp),%rdi
call   1060 <closedir@plt>
mov    $0x1,%edi
call   10a0 <sleep@plt>
jmp    11ba <main+0x2a>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x20,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
lea    0xe50(%rip),%r14
mov    %rsp,%r12
lea    0xe58(%rip),%r15
jmp    11d2 <main+0x42>
nopl   0x0(%rax)
mov    %r13,%rdi
call   1060 <closedir@plt>
mov    $0x1,%edi
call   10a0 <sleep@plt>
mov    %r14,%rdi
call   1030 <opendir@plt>
mov    %rax,%r13
mov    %rax,%rdi
call   1070 <readdir@plt>
test   %rax,%rax
je     11c0 <main+0x30>
mov    %rax,%rbx
jmp    120f <main+0x7f>
nop
mov    %r12,%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1050 <memset@plt>
mov    %r13,%rdi
call   1070 <readdir@plt>
mov    %rax,%rbx
test   %rax,%rax
je     11c0 <main+0x30>
mov    (%rbx),%rdi
call   1040 <strlen@plt>
cmp    $0x6,%eax
jl     11ff <main+0x6f>
mov    %r12,%rdi
mov    %r14,%rsi
call   1080 <strcat@plt>
mov    (%rbx),%rsi
mov    %r12,%rdi
call   1080 <strcat@plt>
mov    %r12,%rdi
mov    %r15,%rsi
call   10b0 <strstr@plt>
test   %rax,%rax
je     11f0 <main+0x60>
mov    %r12,%rdi
call   1090 <file_read_play@plt>
jmp    11f0 <main+0x60>

LLVM IR (-O0):
%struct.dirent = type { i8* }
@.str = [18 x i8] c"../../data/media/\00"
@.str.1 = [7 x i8] c"media_\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.dirent*
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca [32 x i8]
store i32 0, i32* %1
store i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8** %4
%6 = bitcast [32 x i8]* %5 to i8*
br label %7
7: ; preds = %0, %39
%8 = load i8*, i8** %4
%9 = call i32* @opendir(i8* %8)
store i32* %9, i32** %3
br label %10
10: ; preds = %38, %7
%11 = load i32*, i32** %3
%12 = call %struct.dirent* @readdir(i32* %11)
store %struct.dirent* %12, %struct.dirent** %2
%13 = icmp ne %struct.dirent* %12, null
br i1 %13, label %14, label %39
14: ; preds = %10
%15 = load %struct.dirent*, %struct.dirent** %2
%16 = getelementptr inbounds %struct.dirent, %struct.dirent* %15, i32 0, i32 0
%17 = load i8*, i8** %16
%18 = call i32 @strlen(i8* %17)
%19 = icmp sgt i32 %18, 5
br i1 %19, label %20, label %38
20: ; preds = %14
%21 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%22 = load i8*, i8** %4
%23 = call i32 @strcat(i8* %21, i8* %22)
%24 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%25 = load %struct.dirent*, %struct.dirent** %2
%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 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%30 = call i64 @strstr(i8* %29, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %35
32: ; preds = %20
%33 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%34 = call i32 @file_read_play(i8* %33)
br label %35
35: ; preds = %32, %20
%36 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%37 = call i32 @memset(i8* %36, i32 0, i32 32)
br label %38
38: ; preds = %35, %14
br label %10
39: ; preds = %10
%40 = load i32*, i32** %3
%41 = call i32 @closedir(i32* %40)
%42 = call i32 @sleep(i32 1)
br label %7
}

LLVM IR (-O2):
%struct.dirent = type { i8* }
@.str = [18 x i8] c"../../data/media/\00"
@.str.1 = [7 x i8] c"media_\00"
define i32 @main() {
%1 = alloca [32 x i8]
%2 = getelementptr inbounds [32 x i8], [32 x i8]* %1, i64 0, i64 0
br label %3
3: ; preds = %26, %0
%4 = call i32* @opendir(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%5 = call %struct.dirent* @readdir(i32* %4)
%6 = icmp eq %struct.dirent* %5, null
br i1 %6, label %26, label %7
7: ; preds = %3, %23
%8 = phi %struct.dirent* [ %24, %23 ], [ %5, %3 ]
%9 = getelementptr inbounds %struct.dirent, %struct.dirent* %8, i64 0, i32 0
%10 = load i8*, i8** %9
%11 = call i32 @strlen(i8* %10)
%12 = icmp sgt i32 %11, 5
br i1 %12, label %13, label %23
13: ; preds = %7
%14 = call i32 @strcat(i8* %2, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%15 = load i8*, i8** %9
%16 = call i32 @strcat(i8* %2, i8* %15)
%17 = call i64 @strstr(i8* %2, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %21, label %19
19: ; preds = %13
%20 = call i32 @file_read_play(i8* %2)
br label %21
21: ; preds = %19, %13
%22 = call i32 @memset(i8* %2, i32 0, i32 32)
br label %23
23: ; preds = %21, %7
%24 = call %struct.dirent* @readdir(i32* %4)
%25 = icmp eq %struct.dirent* %24, null
br i1 %25, label %26, label %7
26: ; preds = %23, %3
%27 = call i32 @closedir(i32* %4)
%28 = call i32 @sleep(i32 1)
br label %3
}