#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 */
int /*<<< orphan*/ free(void **);
int length_l(void **);
void free_l(void **list) {
  if (list == NULL)
    return;
  int i, n = length_l(list);
  for (i = 0; i < n; i++)
    free(list[i]);
  free(list);
}


x86 assembly (clang, -O0):
<free_l>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    113c <free_l+0x1c>
jmp    1183 <free_l+0x63>
mov    -0x8(%rbp),%rdi
call   1040 <length_l@plt>
mov    %eax,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    117a <free_l+0x5a>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <free@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    114f <free_l+0x2f>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<free_l>:
test   %rdi,%rdi
je     115f <free_l+0x3f>
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
call   1040 <length_l@plt>
test   %eax,%eax
jle    1152 <free_l+0x32>
mov    %eax,%r15d
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    (%r14,%rbx,8),%rdi
call   1030 <free@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1140 <free_l+0x20>
mov    %r14,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <free@plt>
ret

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

LLVM IR (-O2):
define void @free_l(i8** %0) {
%2 = icmp eq i8** %0, null
br i1 %2, label %18, label %3
3: ; preds = %1
%4 = tail call i32 @length_l(i8** %0)
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %16
6: ; preds = %3
%7 = zext i32 %4 to i64
br label %8
8: ; preds = %6, %8
%9 = phi i64 [ 0, %6 ], [ %14, %8 ]
%10 = getelementptr inbounds i8*, i8** %0, i64 %9
%11 = bitcast i8** %10 to i8***
%12 = load i8**, i8*** %11
%13 = tail call i32 @free(i8** %12)
%14 = add nuw nsw i64 %9, 1
%15 = icmp eq i64 %14, %7
br i1 %15, label %16, label %8
16: ; preds = %8, %3
%17 = tail call i32 @free(i8** %0)
br label %18
18: ; preds = %1, %16
ret void
}