#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 fs_entry {
  int dummy;
};
struct dirent {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ read_entries(char *, struct dirent **);
int /*<<< orphan*/ split_entries(struct dirent **, char *, struct fs_entry **,
                                 struct fs_entry **, int *, int *);
void get_folders_and_files(char *path, struct fs_entry **folders,
                           struct fs_entry **files, int *num_folders,
                           int *num_files) {
  struct dirent *entries[1024];
  read_entries(path, entries);
  split_entries(entries, path, folders, files, num_folders, num_files);
}


x86 assembly (clang, -O0):
<get_folders_and_files>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2030,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x2030(%rbp),%rsi
call   1030 <read_entries@plt>
lea    -0x2030(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%r8
mov    -0x28(%rbp),%r9
call   1040 <split_entries@plt>
add    $0x2030,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_folders_and_files>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x2008,%rsp
mov    %r8,%r14
mov    %rcx,%r15
mov    %rdx,%r12
mov    %rsi,%r13
mov    %rdi,%rbx
mov    %rsp,%rbp
mov    %rbp,%rsi
call   1030 <read_entries@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %r13,%rdx
mov    %r12,%rcx
mov    %r15,%r8
mov    %r14,%r9
call   1040 <split_entries@plt>
add    $0x2008,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.fs_entry = type { i32 }
%struct.dirent = type { i32 }
define void @get_folders_and_files(i8* %0, %struct.fs_entry** %1, %struct.fs_entry** %2, i32* %3, i32* %4) {
%6 = alloca i8*
%7 = alloca %struct.fs_entry**
%8 = alloca %struct.fs_entry**
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca [1024 x %struct.dirent*]
store i8* %0, i8** %6
store %struct.fs_entry** %1, %struct.fs_entry*** %7
store %struct.fs_entry** %2, %struct.fs_entry*** %8
store i32* %3, i32** %9
store i32* %4, i32** %10
%12 = load i8*, i8** %6
%13 = getelementptr inbounds [1024 x %struct.dirent*], [1024 x %struct.dirent*]* %11, i64 0, i64 0
%14 = call i32 @read_entries(i8* %12, %struct.dirent** %13)
%15 = getelementptr inbounds [1024 x %struct.dirent*], [1024 x %struct.dirent*]* %11, i64 0, i64 0
%16 = load i8*, i8** %6
%17 = load %struct.fs_entry**, %struct.fs_entry*** %7
%18 = load %struct.fs_entry**, %struct.fs_entry*** %8
%19 = load i32*, i32** %9
%20 = load i32*, i32** %10
%21 = call i32 @split_entries(%struct.dirent** %15, i8* %16, %struct.fs_entry** %17, %struct.fs_entry** %18, i32* %19, i32* %20)
ret void
}

LLVM IR (-O2):
%struct.fs_entry = type { i32 }
%struct.dirent = type { i32 }
define void @get_folders_and_files(i8* %0, %struct.fs_entry** %1, %struct.fs_entry** %2, i32* %3, i32* %4) {
%6 = alloca [1024 x %struct.dirent*]
%7 = bitcast [1024 x %struct.dirent*]* %6 to i8*
%8 = getelementptr inbounds [1024 x %struct.dirent*], [1024 x %struct.dirent*]* %6, i64 0, i64 0
%9 = call i32 @read_entries(i8* %0, %struct.dirent** %8)
%10 = call i32 @split_entries(%struct.dirent** %8, i8* %0, %struct.fs_entry** %1, %struct.fs_entry** %2, i32* %3, i32* %4)
ret void
}