#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 */

/* Variables and functions */
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, int);
char **removeSubfolders(char **, int, int *);
int main() {
  char **arr = (char **)malloc(sizeof(char *) * 5);
  arr[0] = "/a";
  arr[1] = "/a/b";
  arr[2] = "/c/d";
  arr[3] = "/c/d/e";
  arr[4] = "/c/f";
  int retsize = 0;
  char **ret = removeSubfolders(arr, 5, &retsize);
  printf("retsize %d\n", retsize);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x28,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
lea    0xea8(%rip),%rcx
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
lea    0xe9d(%rip),%rcx
mov    %rcx,0x8(%rax)
mov    -0x10(%rbp),%rax
lea    0xe93(%rip),%rcx
mov    %rcx,0x10(%rax)
mov    -0x10(%rbp),%rax
lea    0xe89(%rip),%rcx
mov    %rcx,0x18(%rax)
mov    -0x10(%rbp),%rax
lea    0xe81(%rip),%rcx
mov    %rcx,0x20(%rax)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x5,%esi
lea    -0x14(%rbp),%rdx
call   1030 <removeSubfolders@plt>
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe5b(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    $0x28,%edi
call   1050 <malloc@plt>
lea    0xebe(%rip),%rcx
mov    %rcx,(%rax)
lea    0xeb7(%rip),%rcx
mov    %rcx,0x8(%rax)
lea    0xeb1(%rip),%rcx
mov    %rcx,0x10(%rax)
lea    0xeab(%rip),%rcx
mov    %rcx,0x18(%rax)
lea    0xea7(%rip),%rcx
mov    %rcx,0x20(%rax)
movl   $0x0,0x4(%rsp)
lea    0x4(%rsp),%rdx
mov    %rax,%rdi
mov    $0x5,%esi
call   1030 <removeSubfolders@plt>
mov    0x4(%rsp),%esi
lea    0xe83(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"/a\00"
@.str.1 = [5 x i8] c"/a/b\00"
@.str.2 = [5 x i8] c"/c/d\00"
@.str.3 = [7 x i8] c"/c/d/e\00"
@.str.4 = [5 x i8] c"/c/f\00"
@.str.5 = [12 x i8] c"retsize %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8**
%3 = alloca i32
%4 = alloca i8**
store i32 0, i32* %1
%5 = call i64 @malloc(i32 40)
%6 = inttoptr i64 %5 to i8**
store i8** %6, i8*** %2
%7 = load i8**, i8*** %2
%8 = getelementptr inbounds i8*, i8** %7, i64 0
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %8
%9 = load i8**, i8*** %2
%10 = getelementptr inbounds i8*, i8** %9, i64 1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8** %10
%11 = load i8**, i8*** %2
%12 = getelementptr inbounds i8*, i8** %11, i64 2
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8** %12
%13 = load i8**, i8*** %2
%14 = getelementptr inbounds i8*, i8** %13, i64 3
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8** %14
%15 = load i8**, i8*** %2
%16 = getelementptr inbounds i8*, i8** %15, i64 4
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8** %16
store i32 0, i32* %3
%17 = load i8**, i8*** %2
%18 = call i8** @removeSubfolders(i8** %17, i32 5, i32* %3)
store i8** %18, i8*** %4
%19 = load i32, i32* %3
%20 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 %19)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"/a\00"
@.str.1 = [5 x i8] c"/a/b\00"
@.str.2 = [5 x i8] c"/c/d\00"
@.str.3 = [7 x i8] c"/c/d/e\00"
@.str.4 = [5 x i8] c"/c/f\00"
@.str.5 = [12 x i8] c"retsize %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = tail call i64 @malloc(i32 40)
%3 = inttoptr i64 %2 to i8**
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %3
%4 = getelementptr inbounds i8*, i8** %3, i64 1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8** %4
%5 = getelementptr inbounds i8*, i8** %3, i64 2
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8** %5
%6 = getelementptr inbounds i8*, i8** %3, i64 3
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8** %6
%7 = getelementptr inbounds i8*, i8** %3, i64 4
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8** %7
%8 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%9 = call i8** @removeSubfolders(i8** %3, i32 5, i32* %1)
%10 = load i32, i32* %1
%11 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 %10)
ret i32 0
}