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

/* Variables and functions */
int /*<<< orphan*/ free(int /*<<< orphan*/ **************);
void free_weights(struct wgt ***weighti0, struct wgt ***weighti1,
                  struct wgtc ***weightci, int naa) {
  int aa;
  struct wgt **weight0;
  struct wgt **weight1;
  struct wgtc **weightc;
  weight0 = *weighti0;
  weight1 = *weighti1;
  weightc = *weightci;
  for (aa = 0; aa < naa; aa++) {
    free(weight0[aa]);
  }
  for (aa = 0; aa < naa; aa++) {
    free(weight1[aa]);
  }
  for (aa = 0; aa < naa; aa++) {
    free(weightc[aa]);
  }
  free(weight0);
  free(weight1);
  free(weightc);
}


x86 assembly (clang, -O0):
<free_weights>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    117a <free_weights+0x6a>
mov    -0x28(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    114f <free_weights+0x3f>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11ac <free_weights+0x9c>
mov    -0x30(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1181 <free_weights+0x71>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11de <free_weights+0xce>
mov    -0x38(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11b3 <free_weights+0xa3>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<free_weights>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    (%rdi),%r13
mov    (%rsi),%r15
mov    (%rdx),%r14
test   %ecx,%ecx
jle    1182 <free_weights+0x72>
mov    %ecx,%r12d
mov    %ecx,%ebp
xor    %ebx,%ebx
nop
mov    0x0(%r13,%rbx,8),%rdi
call   1030 <free@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1130 <free_weights+0x20>
test   %r12d,%r12d
jle    1182 <free_weights+0x72>
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    (%r15,%rbx,8),%rdi
call   1030 <free@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1150 <free_weights+0x40>
test   %r12d,%r12d
jle    1182 <free_weights+0x72>
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    (%r14,%rbx,8),%rdi
call   1030 <free@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1170 <free_weights+0x60>
mov    %r13,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

LLVM IR (-O0):
%struct.wgt = type opaque
%struct.wgtc = type opaque
define void @free_weights(%struct.wgt*** %0, %struct.wgt*** %1, %struct.wgtc*** %2, i32 %3) {
%5 = alloca %struct.wgt***
%6 = alloca %struct.wgt***
%7 = alloca %struct.wgtc***
%8 = alloca i32
%9 = alloca i32
%10 = alloca %struct.wgt**
%11 = alloca %struct.wgt**
%12 = alloca %struct.wgtc**
store %struct.wgt*** %0, %struct.wgt**** %5
store %struct.wgt*** %1, %struct.wgt**** %6
store %struct.wgtc*** %2, %struct.wgtc**** %7
store i32 %3, i32* %8
%13 = load %struct.wgt***, %struct.wgt**** %5
%14 = load %struct.wgt**, %struct.wgt*** %13
store %struct.wgt** %14, %struct.wgt*** %10
%15 = load %struct.wgt***, %struct.wgt**** %6
%16 = load %struct.wgt**, %struct.wgt*** %15
store %struct.wgt** %16, %struct.wgt*** %11
%17 = load %struct.wgtc***, %struct.wgtc**** %7
%18 = load %struct.wgtc**, %struct.wgtc*** %17
store %struct.wgtc** %18, %struct.wgtc*** %12
store i32 0, i32* %9
br label %19
19: ; preds = %31, %4
%20 = load i32, i32* %9
%21 = load i32, i32* %8
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %34
23: ; preds = %19
%24 = load %struct.wgt**, %struct.wgt*** %10
%25 = load i32, i32* %9
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds %struct.wgt*, %struct.wgt** %24, i64 %26
%28 = load %struct.wgt*, %struct.wgt** %27
%29 = bitcast %struct.wgt* %28 to i32**************
%30 = call i32 @free(i32************** %29)
br label %31
31: ; preds = %23
%32 = load i32, i32* %9
%33 = add nsw i32 %32, 1
store i32 %33, i32* %9
br label %19
34: ; preds = %19
store i32 0, i32* %9
br label %35
35: ; preds = %47, %34
%36 = load i32, i32* %9
%37 = load i32, i32* %8
%38 = icmp slt i32 %36, %37
br i1 %38, label %39, label %50
39: ; preds = %35
%40 = load %struct.wgt**, %struct.wgt*** %11
%41 = load i32, i32* %9
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds %struct.wgt*, %struct.wgt** %40, i64 %42
%44 = load %struct.wgt*, %struct.wgt** %43
%45 = bitcast %struct.wgt* %44 to i32**************
%46 = call i32 @free(i32************** %45)
br label %47
47: ; preds = %39
%48 = load i32, i32* %9
%49 = add nsw i32 %48, 1
store i32 %49, i32* %9
br label %35
50: ; preds = %35
store i32 0, i32* %9
br label %51
51: ; preds = %63, %50
%52 = load i32, i32* %9
%53 = load i32, i32* %8
%54 = icmp slt i32 %52, %53
br i1 %54, label %55, label %66
55: ; preds = %51
%56 = load %struct.wgtc**, %struct.wgtc*** %12
%57 = load i32, i32* %9
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds %struct.wgtc*, %struct.wgtc** %56, i64 %58
%60 = load %struct.wgtc*, %struct.wgtc** %59
%61 = bitcast %struct.wgtc* %60 to i32**************
%62 = call i32 @free(i32************** %61)
br label %63
63: ; preds = %55
%64 = load i32, i32* %9
%65 = add nsw i32 %64, 1
store i32 %65, i32* %9
br label %51
66: ; preds = %51
%67 = load %struct.wgt**, %struct.wgt*** %10
%68 = bitcast %struct.wgt** %67 to i32**************
%69 = call i32 @free(i32************** %68)
%70 = load %struct.wgt**, %struct.wgt*** %11
%71 = bitcast %struct.wgt** %70 to i32**************
%72 = call i32 @free(i32************** %71)
%73 = load %struct.wgtc**, %struct.wgtc*** %12
%74 = bitcast %struct.wgtc** %73 to i32**************
%75 = call i32 @free(i32************** %74)
ret void
}

LLVM IR (-O2):
%struct.wgt = type opaque
%struct.wgtc = type opaque
define void @free_weights(%struct.wgt*** nocapture %0, %struct.wgt*** nocapture %1, %struct.wgtc*** nocapture %2, i32 %3) {
%5 = load %struct.wgt**, %struct.wgt*** %0
%6 = load %struct.wgt**, %struct.wgt*** %1
%7 = load %struct.wgtc**, %struct.wgtc*** %2
%8 = icmp sgt i32 %3, 0
br i1 %8, label %9, label %41
9: ; preds = %4
%10 = zext i32 %3 to i64
br label %14
11: ; preds = %14
br i1 %8, label %12, label %41
12: ; preds = %11
%13 = zext i32 %3 to i64
br label %25
14: ; preds = %9, %14
%15 = phi i64 [ 0, %9 ], [ %20, %14 ]
%16 = getelementptr inbounds %struct.wgt*, %struct.wgt** %5, i64 %15
%17 = bitcast %struct.wgt** %16 to i32***************
%18 = load i32**************, i32*************** %17
%19 = tail call i32 @free(i32************** %18)
%20 = add nuw nsw i64 %15, 1
%21 = icmp eq i64 %20, %10
br i1 %21, label %11, label %14
22: ; preds = %25
br i1 %8, label %23, label %41
23: ; preds = %22
%24 = zext i32 %3 to i64
br label %33
25: ; preds = %12, %25
%26 = phi i64 [ 0, %12 ], [ %31, %25 ]
%27 = getelementptr inbounds %struct.wgt*, %struct.wgt** %6, i64 %26
%28 = bitcast %struct.wgt** %27 to i32***************
%29 = load i32**************, i32*************** %28
%30 = tail call i32 @free(i32************** %29)
%31 = add nuw nsw i64 %26, 1
%32 = icmp eq i64 %31, %13
br i1 %32, label %22, label %25
33: ; preds = %23, %33
%34 = phi i64 [ 0, %23 ], [ %39, %33 ]
%35 = getelementptr inbounds %struct.wgtc*, %struct.wgtc** %7, i64 %34
%36 = bitcast %struct.wgtc** %35 to i32***************
%37 = load i32**************, i32*************** %36
%38 = tail call i32 @free(i32************** %37)
%39 = add nuw nsw i64 %34, 1
%40 = icmp eq i64 %39, %24
br i1 %40, label %41, label %33
41: ; preds = %33, %4, %11, %22
%42 = bitcast %struct.wgt** %5 to i32**************
%43 = tail call i32 @free(i32************** %42)
%44 = bitcast %struct.wgt** %6 to i32**************
%45 = tail call i32 @free(i32************** %44)
%46 = bitcast %struct.wgtc** %7 to i32**************
%47 = tail call i32 @free(i32************** %46)
ret void
}