#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*/ *);
char *get_extension(char *);
int /*<<< orphan*/ load_list(char *);
int /*<<< orphan*/ *opendir(char *);
int /*<<< orphan*/ printf(char *, char *);
struct dirent *readdir(int /*<<< orphan*/ *);
scalar_t__ strcmp(char *, char *);
void listSearch(void) {
  DIR *d;
  struct dirent *dir;
  d = opendir(".");
  if (d) {
    while ((dir = readdir(d)) != NULL) {
      char *ext = get_extension(dir->d_name);
      if (ext != NULL && strcmp(ext, ".list") == 0) {
        printf("Loading \"%s\"...\n", dir->d_name);
        load_list(dir->d_name);
      }
    }
    closedir(d);
  }
}


x86 assembly (clang, -O0):
<listSearch>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xe81(%rip),%rdi
call   1030 <opendir@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1211 <listSearch+0xa1>
jmp    1198 <listSearch+0x28>
mov    -0x8(%rbp),%rdi
call   1080 <readdir@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     1208 <listSearch+0x98>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1090 <get_extension@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1203 <listSearch+0x93>
mov    -0x18(%rbp),%rdi
lea    0xe2d(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    1203 <listSearch+0x93>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe16(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1060 <load_list@plt>
jmp    1198 <listSearch+0x28>
mov    -0x8(%rbp),%rdi
call   1050 <closedir@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<listSearch>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xe81(%rip),%rdi
call   1030 <opendir@plt>
test   %rax,%rax
je     1205 <listSearch+0x95>
mov    %rax,%r12
mov    %rax,%rdi
call   1080 <readdir@plt>
test   %rax,%rax
je     11f2 <listSearch+0x82>
mov    %rax,%rbx
lea    0xe5f(%rip),%r14
lea    0xe5e(%rip),%r15
jmp    11c0 <listSearch+0x50>
nopl   0x0(%rax)
mov    %r12,%rdi
call   1080 <readdir@plt>
mov    %rax,%rbx
test   %rax,%rax
je     11f2 <listSearch+0x82>
mov    (%rbx),%rdi
call   1090 <get_extension@plt>
test   %rax,%rax
je     11b0 <listSearch+0x40>
mov    %rax,%rdi
mov    %r14,%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
jne    11b0 <listSearch+0x40>
mov    (%rbx),%rsi
mov    %r15,%rdi
call   1040 <printf@plt>
mov    (%rbx),%rdi
call   1060 <load_list@plt>
jmp    11b0 <listSearch+0x40>
mov    %r12,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1050 <closedir@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
%struct.dirent = type { i8* }
@.str = [2 x i8] c".\00"
@.str.1 = [6 x i8] c".list\00"
@.str.2 = [17 x i8] c"Loading \22%s\22...\0A\00"
define void @listSearch() {
%1 = tail call i32* @opendir(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%2 = icmp eq i32* %1, null
br i1 %2, label %25, label %3
3: ; preds = %0
%4 = tail call %struct.dirent* @readdir(i32* %1)
%5 = icmp eq %struct.dirent* %4, null
br i1 %5, label %23, label %6
6: ; preds = %3, %20
%7 = phi %struct.dirent* [ %21, %20 ], [ %4, %3 ]
%8 = getelementptr inbounds %struct.dirent, %struct.dirent* %7, i64 0, i32 0
%9 = load i8*, i8** %8
%10 = tail call i8* @get_extension(i8* %9)
%11 = icmp eq i8* %10, null
br i1 %11, label %20, label %12
12: ; preds = %6
%13 = tail call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %20
15: ; preds = %12
%16 = load i8*, i8** %8
%17 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* %16)
%18 = load i8*, i8** %8
%19 = tail call i32 @load_list(i8* %18)
br label %20
20: ; preds = %15, %12, %6
%21 = tail call %struct.dirent* @readdir(i32* %1)
%22 = icmp eq %struct.dirent* %21, null
br i1 %22, label %23, label %6
23: ; preds = %20, %3
%24 = tail call i32 @closedir(i32* %1)
br label %25
25: ; preds = %23, %0
ret void
}