#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 */
struct SLL {
  int dummy;
};
typedef int /*<<< orphan*/ A;

/* Variables and functions */
struct SLL *SLL_create(int const, int const *);
int /*<<< orphan*/ SLL_destroy(struct SLL *);
int /*<<< orphan*/ free(void *);
scalar_t__ malloc(int);
int main() {
  int const A[] = {1, 2, 3, 4, 5};
  int const n = sizeof(A) / sizeof(A[0]);
  struct SLL **arrsll = (struct SLL **)malloc(3 * sizeof(struct SLL *));
  int i;
  for (i = 0; i < 3; ++i)
    arrsll[i] = SLL_create(n, A);
  for (i = 0; i < 3; ++i)
    SLL_destroy(arrsll[i]);
  free((void *)arrsll);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeaa(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xea7(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xea5(%rip),%eax
mov    %eax,-0x10(%rbp)
movl   $0x5,-0x24(%rbp)
mov    $0x18,%edi
call   1050 <malloc@plt>
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
cmpl   $0x3,-0x34(%rbp)
jge    11bf <main+0x7f>
lea    -0x20(%rbp),%rsi
mov    $0x5,%edi
call   1060 <SLL_create@plt>
mov    %rax,%rdx
mov    -0x30(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    118a <main+0x4a>
movl   $0x0,-0x34(%rbp)
cmpl   $0x3,-0x34(%rbp)
jge    11ef <main+0xaf>
mov    -0x30(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1040 <SLL_destroy@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11c6 <main+0x86>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    0xec3(%rip),%eax
mov    %eax,0x10(%rsp)
movaps 0xea8(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    $0x18,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
mov    %rsp,%r14
mov    $0x5,%edi
mov    %r14,%rsi
call   1060 <SLL_create@plt>
mov    %rax,(%rbx)
mov    $0x5,%edi
mov    %r14,%rsi
call   1060 <SLL_create@plt>
mov    %rax,0x8(%rbx)
mov    $0x5,%edi
mov    %r14,%rsi
call   1060 <SLL_create@plt>
mov    %rax,0x10(%rbx)
mov    (%rbx),%rdi
call   1040 <SLL_destroy@plt>
mov    0x8(%rbx),%rdi
call   1040 <SLL_destroy@plt>
mov    0x10(%rbx),%rdi
call   1040 <SLL_destroy@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
%struct.SLL = type { i32 }
@__const.main.A = [5 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5]
define i32 @main() {
%1 = alloca [5 x i32]
%2 = bitcast [5 x i32]* %1 to i8*
%3 = tail call i64 @malloc(i32 24)
%4 = inttoptr i64 %3 to %struct.SLL**
%5 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 0
%6 = call %struct.SLL* @SLL_create(i32 5, i32* %5)
store %struct.SLL* %6, %struct.SLL** %4
%7 = call %struct.SLL* @SLL_create(i32 5, i32* %5)
%8 = getelementptr inbounds %struct.SLL*, %struct.SLL** %4, i64 1
store %struct.SLL* %7, %struct.SLL** %8
%9 = call %struct.SLL* @SLL_create(i32 5, i32* %5)
%10 = getelementptr inbounds %struct.SLL*, %struct.SLL** %4, i64 2
store %struct.SLL* %9, %struct.SLL** %10
%11 = load %struct.SLL*, %struct.SLL** %4
%12 = call i32 @SLL_destroy(%struct.SLL* %11)
%13 = load %struct.SLL*, %struct.SLL** %8
%14 = call i32 @SLL_destroy(%struct.SLL* %13)
%15 = load %struct.SLL*, %struct.SLL** %10
%16 = call i32 @SLL_destroy(%struct.SLL* %15)
%17 = inttoptr i64 %3 to i8*
%18 = call i32 @free(i8* %17)
ret i32 0
}