#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 *);
void free_set(int depth, int size, void *set) {
  if (set == ((void *)1))
    return;
  if (set == ((void *)2))
    return;
  if (depth) {
    int i;
    depth--;
    for (i = 0; i < size; i++) {
      free_set(depth, size, ((void **)set)[i]);
    }
  }
  free(set);
}


x86 assembly (clang, -O0):
<free_set>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    $0x1,%eax
cmp    %rax,-0x10(%rbp)
jne    1146 <free_set+0x26>
jmp    11b3 <free_set+0x93>
mov    $0x2,%eax
cmp    %rax,-0x10(%rbp)
jne    115a <free_set+0x3a>
jmp    11b3 <free_set+0x93>
cmpl   $0x0,-0x4(%rbp)
je     11aa <free_set+0x8a>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11a5 <free_set+0x85>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
call   1040 <free_set@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1174 <free_set+0x54>
jmp    11aa <free_set+0x8a>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<free_set>:
lea    -0x1(%rdx),%rax
cmp    $0x2,%rax
jae    112b <free_set+0xb>
ret
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdx,%r12
mov    %edi,%r15d
test   %edi,%edi
je     1168 <free_set+0x48>
mov    %esi,%r14d
test   %esi,%esi
jle    1168 <free_set+0x48>
add    $0xffffffff,%r15d
mov    %r14d,%ebp
xor    %ebx,%ebx
nopl   (%rax)
mov    (%r12,%rbx,8),%rdx
mov    %r15d,%edi
mov    %r14d,%esi
call   1040 <free_set@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1150 <free_set+0x30>
mov    %r12,%rdi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

LLVM IR (-O0):
define void @free_set(i32 %0, i32 %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i8* %2, i8** %6
%8 = load i8*, i8** %6
%9 = icmp eq i8* %8, inttoptr (i64 1 to i8*)
br i1 %9, label %10, label %11
10: ; preds = %3
br label %41
11: ; preds = %3
%12 = load i8*, i8** %6
%13 = icmp eq i8* %12, inttoptr (i64 2 to i8*)
br i1 %13, label %14, label %15
14: ; preds = %11
br label %41
15: ; preds = %11
%16 = load i32, i32* %4
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %38
18: ; preds = %15
%19 = load i32, i32* %4
%20 = add nsw i32 %19, -1
store i32 %20, i32* %4
store i32 0, i32* %7
br label %21
21: ; preds = %34, %18
%22 = load i32, i32* %7
%23 = load i32, i32* %5
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %37
25: ; preds = %21
%26 = load i32, i32* %4
%27 = load i32, i32* %5
%28 = load i8*, i8** %6
%29 = bitcast i8* %28 to i8**
%30 = load i32, i32* %7
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8*, i8** %29, i64 %31
%33 = load i8*, i8** %32
br label %34
34: ; preds = %25
%35 = load i32, i32* %7
%36 = add nsw i32 %35, 1
store i32 %36, i32* %7
br label %21
37: ; preds = %21
br label %38
38: ; preds = %37, %15
%39 = load i8*, i8** %6
%40 = call i32 @free(i8* %39)
br label %41
41: ; preds = %38, %14, %10
ret void
}

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