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

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
struct sll_node *sll_add_at_head(struct sll_node *, int);
struct sll_node *sll_delete_at_index(struct sll_node *, int /*<<< orphan*/);
int /*<<< orphan*/ sll_destroy(struct sll_node *);
int sll_get_len(struct sll_node *);
int /*<<< orphan*/ sll_print(struct sll_node *);
void main() {
  struct sll_node *h = NULL;
  struct sll_node *mid = NULL;
  h = sll_add_at_head(h, 1);
  h = sll_add_at_head(h, 2);
  h = sll_add_at_head(h, 3);
  h = sll_add_at_head(h, 4);
  h = sll_add_at_head(h, 5);
  printf("SLL : ");
  sll_print(h);
  printf("Odd SLL: len: %d\n", sll_get_len(h));
  printf("Delete Head: ");
  h = sll_delete_at_index(h, 0);
  sll_print(h);
  printf("Even SLL: sll: %d\n", sll_get_len(h));
  sll_destroy(h);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movq   $0x0,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x1,%esi
call   1080 <sll_add_at_head@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x2,%esi
call   1080 <sll_add_at_head@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x3,%esi
call   1080 <sll_add_at_head@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x4,%esi
call   1080 <sll_add_at_head@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x5,%esi
call   1080 <sll_add_at_head@plt>
mov    %rax,-0x8(%rbp)
lea    0xe27(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1060 <sll_print@plt>
mov    -0x8(%rbp),%rdi
call   1030 <sll_get_len@plt>
mov    %eax,%esi
lea    0xe0c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe10(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
call   1050 <sll_delete_at_index@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <sll_print@plt>
mov    -0x8(%rbp),%rdi
call   1030 <sll_get_len@plt>
mov    %eax,%esi
lea    0xded(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1070 <sll_destroy@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %edi,%edi
mov    $0x1,%esi
call   1080 <sll_add_at_head@plt>
mov    %rax,%rdi
mov    $0x2,%esi
call   1080 <sll_add_at_head@plt>
mov    %rax,%rdi
mov    $0x3,%esi
call   1080 <sll_add_at_head@plt>
mov    %rax,%rdi
mov    $0x4,%esi
call   1080 <sll_add_at_head@plt>
mov    %rax,%rdi
mov    $0x5,%esi
call   1080 <sll_add_at_head@plt>
mov    %rax,%rbx
lea    0xe55(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1060 <sll_print@plt>
mov    %rbx,%rdi
call   1030 <sll_get_len@plt>
lea    0xe3e(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe40(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   1050 <sll_delete_at_index@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1060 <sll_print@plt>
mov    %rbx,%rdi
call   1030 <sll_get_len@plt>
lea    0xe23(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
pop    %rbx
jmp    1070 <sll_destroy@plt>

LLVM IR (-O0):
%struct.sll_node = type { i32 }
@.str = [7 x i8] c"SLL : \00"
@.str.1 = [18 x i8] c"Odd SLL: len: %d\0A\00"
@.str.2 = [14 x i8] c"Delete Head: \00"
@.str.3 = [19 x i8] c"Even SLL: sll: %d\0A\00"
define void @main() {
%1 = alloca %struct.sll_node*
%2 = alloca %struct.sll_node*
store %struct.sll_node* null, %struct.sll_node** %1
store %struct.sll_node* null, %struct.sll_node** %2
%3 = load %struct.sll_node*, %struct.sll_node** %1
%4 = call %struct.sll_node* @sll_add_at_head(%struct.sll_node* %3, i32 1)
store %struct.sll_node* %4, %struct.sll_node** %1
%5 = load %struct.sll_node*, %struct.sll_node** %1
%6 = call %struct.sll_node* @sll_add_at_head(%struct.sll_node* %5, i32 2)
store %struct.sll_node* %6, %struct.sll_node** %1
%7 = load %struct.sll_node*, %struct.sll_node** %1
%8 = call %struct.sll_node* @sll_add_at_head(%struct.sll_node* %7, i32 3)
store %struct.sll_node* %8, %struct.sll_node** %1
%9 = load %struct.sll_node*, %struct.sll_node** %1
%10 = call %struct.sll_node* @sll_add_at_head(%struct.sll_node* %9, i32 4)
store %struct.sll_node* %10, %struct.sll_node** %1
%11 = load %struct.sll_node*, %struct.sll_node** %1
%12 = call %struct.sll_node* @sll_add_at_head(%struct.sll_node* %11, i32 5)
store %struct.sll_node* %12, %struct.sll_node** %1
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%14 = load %struct.sll_node*, %struct.sll_node** %1
%15 = call i32 @sll_print(%struct.sll_node* %14)
%16 = load %struct.sll_node*, %struct.sll_node** %1
%17 = call i32 @sll_get_len(%struct.sll_node* %16)
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %17)
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%20 = load %struct.sll_node*, %struct.sll_node** %1
%21 = call %struct.sll_node* @sll_delete_at_index(%struct.sll_node* %20, i32 0)
store %struct.sll_node* %21, %struct.sll_node** %1
%22 = load %struct.sll_node*, %struct.sll_node** %1
%23 = call i32 @sll_print(%struct.sll_node* %22)
%24 = load %struct.sll_node*, %struct.sll_node** %1
%25 = call i32 @sll_get_len(%struct.sll_node* %24)
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i32 %25)
%27 = load %struct.sll_node*, %struct.sll_node** %1
%28 = call i32 @sll_destroy(%struct.sll_node* %27)
ret void
}

LLVM IR (-O2):
%struct.sll_node = type { i32 }
@.str = [7 x i8] c"SLL : \00"
@.str.1 = [18 x i8] c"Odd SLL: len: %d\0A\00"
@.str.2 = [14 x i8] c"Delete Head: \00"
@.str.3 = [19 x i8] c"Even SLL: sll: %d\0A\00"
define void @main() {
%1 = tail call %struct.sll_node* @sll_add_at_head(%struct.sll_node* null, i32 1)
%2 = tail call %struct.sll_node* @sll_add_at_head(%struct.sll_node* %1, i32 2)
%3 = tail call %struct.sll_node* @sll_add_at_head(%struct.sll_node* %2, i32 3)
%4 = tail call %struct.sll_node* @sll_add_at_head(%struct.sll_node* %3, i32 4)
%5 = tail call %struct.sll_node* @sll_add_at_head(%struct.sll_node* %4, i32 5)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 @sll_print(%struct.sll_node* %5)
%8 = tail call i32 @sll_get_len(%struct.sll_node* %5)
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %8)
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%11 = tail call %struct.sll_node* @sll_delete_at_index(%struct.sll_node* %5, i32 0)
%12 = tail call i32 @sll_print(%struct.sll_node* %11)
%13 = tail call i32 @sll_get_len(%struct.sll_node* %11)
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i32 %13)
%15 = tail call i32 @sll_destroy(%struct.sll_node* %11)
ret void
}