#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 *sll = SLL_create(n, A);
  struct SLL **arrsll = (struct SLL **)malloc(3 * sizeof(struct SLL *));
  int i;
  for (i = 0; i < 3; ++i)
    arrsll[i] = sll;
  SLL_destroy(sll);
  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)
lea    -0x20(%rbp),%rsi
mov    $0x5,%edi
call   1060 <SLL_create@plt>
mov    %rax,-0x30(%rbp)
mov    $0x18,%edi
call   1050 <malloc@plt>
mov    %rax,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
cmpl   $0x3,-0x3c(%rbp)
jge    11c4 <main+0x84>
mov    -0x30(%rbp),%rdx
mov    -0x38(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    119c <main+0x5c>
mov    -0x30(%rbp),%rdi
call   1040 <SLL_destroy@plt>
mov    -0x38(%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    %rsp,%rsi
mov    $0x5,%edi
call   1060 <SLL_create@plt>
mov    %rax,%r14
mov    $0x18,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
mov    %r14,(%rax)
mov    %r14,0x8(%rax)
mov    %r14,0x10(%rax)
mov    %r14,%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 %struct.SLL**
%6 = alloca i32
store i32 0, i32* %1
%7 = bitcast [5 x i32]* %2 to i8*
store i32 5, i32* %3
%8 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 0
%9 = call %struct.SLL* @SLL_create(i32 5, i32* %8)
store %struct.SLL* %9, %struct.SLL** %4
%10 = call i64 @malloc(i32 24)
%11 = inttoptr i64 %10 to %struct.SLL**
store %struct.SLL** %11, %struct.SLL*** %5
store i32 0, i32* %6
br label %12
12: ; preds = %21, %0
%13 = load i32, i32* %6
%14 = icmp slt i32 %13, 3
br i1 %14, label %15, label %24
15: ; preds = %12
%16 = load %struct.SLL*, %struct.SLL** %4
%17 = load %struct.SLL**, %struct.SLL*** %5
%18 = load i32, i32* %6
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds %struct.SLL*, %struct.SLL** %17, i64 %19
store %struct.SLL* %16, %struct.SLL** %20
br label %21
21: ; preds = %15
%22 = load i32, i32* %6
%23 = add nsw i32 %22, 1
store i32 %23, i32* %6
br label %12
24: ; preds = %12
%25 = load %struct.SLL*, %struct.SLL** %4
%26 = call i32 @SLL_destroy(%struct.SLL* %25)
%27 = load %struct.SLL**, %struct.SLL*** %5
%28 = bitcast %struct.SLL** %27 to i8*
%29 = call i32 @free(i8* %28)
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 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 0
%4 = call %struct.SLL* @SLL_create(i32 5, i32* %3)
%5 = call i64 @malloc(i32 24)
%6 = inttoptr i64 %5 to %struct.SLL**
store %struct.SLL* %4, %struct.SLL** %6
%7 = getelementptr inbounds %struct.SLL*, %struct.SLL** %6, i64 1
store %struct.SLL* %4, %struct.SLL** %7
%8 = getelementptr inbounds %struct.SLL*, %struct.SLL** %6, i64 2
store %struct.SLL* %4, %struct.SLL** %8
%9 = call i32 @SLL_destroy(%struct.SLL* %4)
%10 = inttoptr i64 %5 to i8*
%11 = call i32 @free(i8* %10)
ret i32 0
}