#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 Node {
  int dummy;
};

/* Variables and functions */
struct Node **createTable(int);
int /*<<< orphan*/ freeTable(struct Node **, int);
int /*<<< orphan*/ insertTable(int, int, struct Node **);
int /*<<< orphan*/ printList(struct Node *);
void p2(void) {
  int i, sizeArray = 11, buckets = 3;
  struct Node **tablePtr = createTable(buckets);
  int array[] = {8, 10, 9, 1, 5, 0, 6, 4, 3, 2, 7};
  for (i = 0; i < sizeArray; i++) {
    insertTable(array[i], buckets, tablePtr);
  }
  for (i = 0; i < buckets; i++) {
    printList(tablePtr[i]);
  }
  freeTable(tablePtr, buckets);
}


x86 assembly (clang, -O0):
<p2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0xb,-0x8(%rbp)
movl   $0x3,-0xc(%rbp)
mov    -0xc(%rbp),%edi
call   1060 <createTable@plt>
mov    %rax,-0x18(%rbp)
lea    -0x50(%rbp),%rdi
lea    0xe83(%rip),%rsi
mov    $0x2c,%edx
call   1040 <memcpy@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11bc <p2+0x6c>
movslq -0x4(%rbp),%rax
mov    -0x50(%rbp,%rax,4),%edi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rdx
call   1030 <insertTable@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    118e <p2+0x3e>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11ee <p2+0x9e>
mov    -0x18(%rbp),%rax
movslq -0x4(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1070 <printList@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    11c3 <p2+0x73>
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1050 <freeTable@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<p2>:
push   %rbx
mov    $0x3,%edi
call   1050 <createTable@plt>
mov    %rax,%rbx
mov    $0x8,%edi
mov    $0x3,%esi
mov    %rax,%rdx
call   1030 <insertTable@plt>
mov    $0xa,%edi
mov    $0x3,%esi
mov    %rbx,%rdx
call   1030 <insertTable@plt>
mov    $0x9,%edi
mov    $0x3,%esi
mov    %rbx,%rdx
call   1030 <insertTable@plt>
mov    $0x1,%edi
mov    $0x3,%esi
mov    %rbx,%rdx
call   1030 <insertTable@plt>
mov    $0x5,%edi
mov    $0x3,%esi
mov    %rbx,%rdx
call   1030 <insertTable@plt>
xor    %edi,%edi
mov    $0x3,%esi
mov    %rbx,%rdx
call   1030 <insertTable@plt>
mov    $0x6,%edi
mov    $0x3,%esi
mov    %rbx,%rdx
call   1030 <insertTable@plt>
mov    $0x4,%edi
mov    $0x3,%esi
mov    %rbx,%rdx
call   1030 <insertTable@plt>
mov    $0x3,%edi
mov    $0x3,%esi
mov    %rbx,%rdx
call   1030 <insertTable@plt>
mov    $0x2,%edi
mov    $0x3,%esi
mov    %rbx,%rdx
call   1030 <insertTable@plt>
mov    $0x7,%edi
mov    $0x3,%esi
mov    %rbx,%rdx
call   1030 <insertTable@plt>
mov    (%rbx),%rdi
call   1060 <printList@plt>
mov    0x8(%rbx),%rdi
call   1060 <printList@plt>
mov    0x10(%rbx),%rdi
call   1060 <printList@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
pop    %rbx
jmp    1040 <freeTable@plt>

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

LLVM IR (-O2):
%struct.Node = type { i32 }
define void @p2() {
%1 = tail call %struct.Node** @createTable(i32 3)
%2 = tail call i32 @insertTable(i32 8, i32 3, %struct.Node** %1)
%3 = tail call i32 @insertTable(i32 10, i32 3, %struct.Node** %1)
%4 = tail call i32 @insertTable(i32 9, i32 3, %struct.Node** %1)
%5 = tail call i32 @insertTable(i32 1, i32 3, %struct.Node** %1)
%6 = tail call i32 @insertTable(i32 5, i32 3, %struct.Node** %1)
%7 = tail call i32 @insertTable(i32 0, i32 3, %struct.Node** %1)
%8 = tail call i32 @insertTable(i32 6, i32 3, %struct.Node** %1)
%9 = tail call i32 @insertTable(i32 4, i32 3, %struct.Node** %1)
%10 = tail call i32 @insertTable(i32 3, i32 3, %struct.Node** %1)
%11 = tail call i32 @insertTable(i32 2, i32 3, %struct.Node** %1)
%12 = tail call i32 @insertTable(i32 7, i32 3, %struct.Node** %1)
%13 = load %struct.Node*, %struct.Node** %1
%14 = tail call i32 @printList(%struct.Node* %13)
%15 = getelementptr inbounds %struct.Node*, %struct.Node** %1, i64 1
%16 = load %struct.Node*, %struct.Node** %15
%17 = tail call i32 @printList(%struct.Node* %16)
%18 = getelementptr inbounds %struct.Node*, %struct.Node** %1, i64 2
%19 = load %struct.Node*, %struct.Node** %18
%20 = tail call i32 @printList(%struct.Node* %19)
%21 = tail call i32 @freeTable(%struct.Node** %1, i32 3)
ret void
}