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

/* Variables and functions */
int /*<<< orphan*/ free(int /*<<< orphan*/ ******);
void _scandir_free(struct dirent **namelist, int count) {
  int i = 0;
  if ((namelist == NULL) || (count == 0))
    return;
  for (i = count - 1; i >= 0; --i)
    free(namelist[i]);
  free(namelist);
}


x86 assembly (clang, -O0):
<_scandir_free>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     113b <_scandir_free+0x2b>
cmpl   $0x0,-0xc(%rbp)
jne    1140 <_scandir_free+0x30>
jmp    117b <_scandir_free+0x6b>
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jl     1172 <_scandir_free+0x62>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    1149 <_scandir_free+0x39>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_scandir_free>:
test   %rdi,%rdi
je     1155 <_scandir_free+0x45>
test   %esi,%esi
je     1155 <_scandir_free+0x45>
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
jle    1146 <_scandir_free+0x36>
mov    %esi,%ebx
add    $0x1,%rbx
nopl   0x0(%rax,%rax,1)
lea    -0x2(%rbx),%eax
mov    (%r14,%rax,8),%rdi
call   1030 <free@plt>
add    $0xffffffffffffffff,%rbx
cmp    $0x1,%rbx
ja     1130 <_scandir_free+0x20>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <free@plt>
ret

LLVM IR (-O0):
%struct.dirent = type opaque
define void @_scandir_free(%struct.dirent** %0, i32 %1) {
%3 = alloca %struct.dirent**
%4 = alloca i32
%5 = alloca i32
store %struct.dirent** %0, %struct.dirent*** %3
store i32 %1, i32* %4
store i32 0, i32* %5
%6 = load %struct.dirent**, %struct.dirent*** %3
%7 = icmp eq %struct.dirent** %6, null
br i1 %7, label %11, label %8
8: ; preds = %2
%9 = load i32, i32* %4
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %8, %2
br label %33
12: ; preds = %8
%13 = load i32, i32* %4
%14 = sub nsw i32 %13, 1
store i32 %14, i32* %5
br label %15
15: ; preds = %26, %12
%16 = load i32, i32* %5
%17 = icmp sge i32 %16, 0
br i1 %17, label %18, label %29
18: ; preds = %15
%19 = load %struct.dirent**, %struct.dirent*** %3
%20 = load i32, i32* %5
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds %struct.dirent*, %struct.dirent** %19, i64 %21
%23 = load %struct.dirent*, %struct.dirent** %22
%24 = bitcast %struct.dirent* %23 to i32******
%25 = call i32 @free(i32****** %24)
br label %26
26: ; preds = %18
%27 = load i32, i32* %5
%28 = add nsw i32 %27, -1
store i32 %28, i32* %5
br label %15
29: ; preds = %15
%30 = load %struct.dirent**, %struct.dirent*** %3
%31 = bitcast %struct.dirent** %30 to i32******
%32 = call i32 @free(i32****** %31)
br label %33
33: ; preds = %29, %11
ret void
}

LLVM IR (-O2):
%struct.dirent = type opaque
define void @_scandir_free(%struct.dirent** %0, i32 %1) {
%3 = icmp eq %struct.dirent** %0, null
%4 = icmp eq i32 %1, 0
%5 = or i1 %3, %4
br i1 %5, label %22, label %6
6: ; preds = %2
%7 = icmp sgt i32 %1, 0
br i1 %7, label %8, label %19
8: ; preds = %6
%9 = zext i32 %1 to i64
br label %10
10: ; preds = %8, %10
%11 = phi i64 [ %9, %8 ], [ %12, %10 ]
%12 = add nsw i64 %11, -1
%13 = and i64 %12, 4294967295
%14 = getelementptr inbounds %struct.dirent*, %struct.dirent** %0, i64 %13
%15 = bitcast %struct.dirent** %14 to i32*******
%16 = load i32******, i32******* %15
%17 = tail call i32 @free(i32****** %16)
%18 = icmp ugt i64 %11, 1
br i1 %18, label %10, label %19
19: ; preds = %10, %6
%20 = bitcast %struct.dirent** %0 to i32******
%21 = tail call i32 @free(i32****** %20)
br label %22
22: ; preds = %2, %19
ret void
}