#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);
int /*<<< orphan*/ sll_destroy(struct sll_node *);
int sll_get_occurance(struct sll_node *, int);
int /*<<< orphan*/ sll_print(struct sll_node *);
void main() {
  struct sll_node *h = NULL;
  struct sll_node *mid = NULL;
  int key;
  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);
  h = sll_add_at_head(h, 3);
  h = sll_add_at_head(h, 3);
  h = sll_add_at_head(h, 4);
  h = sll_add_at_head(h, 5);
  h = sll_add_at_head(h, 3);
  h = sll_add_at_head(h, 4);
  printf("SLL : ");
  sll_print(h);
  key = 1;
  printf("%d  occured %d times in sll.\n", key, sll_get_occurance(h, key));
  key = 2;
  printf("%d  occured %d times in sll.\n", key, sll_get_occurance(h, key));
  key = 3;
  printf("%d  occured %d times in sll.\n", key, sll_get_occurance(h, key));
  key = 4;
  printf("%d  occured %d times in sll.\n", key, sll_get_occurance(h, key));
  key = 5;
  printf("%d  occured %d times in sll.\n", key, sll_get_occurance(h, key));
  key = 6;
  printf("%d  occured %d times in sll.\n", key, sll_get_occurance(h, key));
  sll_destroy(h);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movq   $0x0,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x1,%esi
call   1060 <sll_add_at_head@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x2,%esi
call   1060 <sll_add_at_head@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x3,%esi
call   1060 <sll_add_at_head@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x4,%esi
call   1060 <sll_add_at_head@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x5,%esi
call   1060 <sll_add_at_head@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x3,%esi
call   1060 <sll_add_at_head@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x3,%esi
call   1060 <sll_add_at_head@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x4,%esi
call   1060 <sll_add_at_head@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x5,%esi
call   1060 <sll_add_at_head@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x3,%esi
call   1060 <sll_add_at_head@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x4,%esi
call   1060 <sll_add_at_head@plt>
mov    %rax,-0x8(%rbp)
lea    0xdcb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1040 <sll_print@plt>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1070 <sll_get_occurance@plt>
mov    -0x2c(%rbp),%esi
mov    %eax,%edx
lea    0xd9d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x2,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1070 <sll_get_occurance@plt>
mov    -0x28(%rbp),%esi
mov    %eax,%edx
lea    0xd71(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x3,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1070 <sll_get_occurance@plt>
mov    -0x24(%rbp),%esi
mov    %eax,%edx
lea    0xd45(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x4,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1070 <sll_get_occurance@plt>
mov    -0x20(%rbp),%esi
mov    %eax,%edx
lea    0xd19(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x5,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1070 <sll_get_occurance@plt>
mov    -0x1c(%rbp),%esi
mov    %eax,%edx
lea    0xced(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x6,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1070 <sll_get_occurance@plt>
mov    -0x18(%rbp),%esi
mov    %eax,%edx
lea    0xcc1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1050 <sll_destroy@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
xor    %edi,%edi
mov    $0x1,%esi
call   1060 <sll_add_at_head@plt>
mov    %rax,%rdi
mov    $0x2,%esi
call   1060 <sll_add_at_head@plt>
mov    %rax,%rdi
mov    $0x3,%esi
call   1060 <sll_add_at_head@plt>
mov    %rax,%rdi
mov    $0x4,%esi
call   1060 <sll_add_at_head@plt>
mov    %rax,%rdi
mov    $0x5,%esi
call   1060 <sll_add_at_head@plt>
mov    %rax,%rdi
mov    $0x3,%esi
call   1060 <sll_add_at_head@plt>
mov    %rax,%rdi
mov    $0x3,%esi
call   1060 <sll_add_at_head@plt>
mov    %rax,%rdi
mov    $0x4,%esi
call   1060 <sll_add_at_head@plt>
mov    %rax,%rdi
mov    $0x5,%esi
call   1060 <sll_add_at_head@plt>
mov    %rax,%rdi
mov    $0x3,%esi
call   1060 <sll_add_at_head@plt>
mov    %rax,%rdi
mov    $0x4,%esi
call   1060 <sll_add_at_head@plt>
mov    %rax,%rbx
lea    0xe14(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1040 <sll_print@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
call   1070 <sll_get_occurance@plt>
lea    0xdf8(%rip),%r14
mov    %r14,%rdi
mov    $0x1,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
call   1070 <sll_get_occurance@plt>
mov    %r14,%rdi
mov    $0x2,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
call   1070 <sll_get_occurance@plt>
mov    %r14,%rdi
mov    $0x3,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
call   1070 <sll_get_occurance@plt>
mov    %r14,%rdi
mov    $0x4,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x5,%esi
call   1070 <sll_get_occurance@plt>
mov    %r14,%rdi
mov    $0x5,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x6,%esi
call   1070 <sll_get_occurance@plt>
mov    %r14,%rdi
mov    $0x6,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <sll_destroy@plt>

LLVM IR (-O0):
%struct.sll_node = type { i32 }
@.str = [7 x i8] c"SLL : \00"
@.str.1 = [30 x i8] c"%d occured %d times in sll.\0A\00"
define void @main() {
%1 = alloca %struct.sll_node*
%2 = alloca %struct.sll_node*
%3 = alloca i32
store %struct.sll_node* null, %struct.sll_node** %1
store %struct.sll_node* null, %struct.sll_node** %2
%4 = load %struct.sll_node*, %struct.sll_node** %1
%5 = call %struct.sll_node* @sll_add_at_head(%struct.sll_node* %4, i32 1)
store %struct.sll_node* %5, %struct.sll_node** %1
%6 = load %struct.sll_node*, %struct.sll_node** %1
%7 = call %struct.sll_node* @sll_add_at_head(%struct.sll_node* %6, i32 2)
store %struct.sll_node* %7, %struct.sll_node** %1
%8 = load %struct.sll_node*, %struct.sll_node** %1
%9 = call %struct.sll_node* @sll_add_at_head(%struct.sll_node* %8, i32 3)
store %struct.sll_node* %9, %struct.sll_node** %1
%10 = load %struct.sll_node*, %struct.sll_node** %1
%11 = call %struct.sll_node* @sll_add_at_head(%struct.sll_node* %10, i32 4)
store %struct.sll_node* %11, %struct.sll_node** %1
%12 = load %struct.sll_node*, %struct.sll_node** %1
%13 = call %struct.sll_node* @sll_add_at_head(%struct.sll_node* %12, i32 5)
store %struct.sll_node* %13, %struct.sll_node** %1
%14 = load %struct.sll_node*, %struct.sll_node** %1
%15 = call %struct.sll_node* @sll_add_at_head(%struct.sll_node* %14, i32 3)
store %struct.sll_node* %15, %struct.sll_node** %1
%16 = load %struct.sll_node*, %struct.sll_node** %1
%17 = call %struct.sll_node* @sll_add_at_head(%struct.sll_node* %16, i32 3)
store %struct.sll_node* %17, %struct.sll_node** %1
%18 = load %struct.sll_node*, %struct.sll_node** %1
%19 = call %struct.sll_node* @sll_add_at_head(%struct.sll_node* %18, i32 4)
store %struct.sll_node* %19, %struct.sll_node** %1
%20 = load %struct.sll_node*, %struct.sll_node** %1
%21 = call %struct.sll_node* @sll_add_at_head(%struct.sll_node* %20, i32 5)
store %struct.sll_node* %21, %struct.sll_node** %1
%22 = load %struct.sll_node*, %struct.sll_node** %1
%23 = call %struct.sll_node* @sll_add_at_head(%struct.sll_node* %22, i32 3)
store %struct.sll_node* %23, %struct.sll_node** %1
%24 = load %struct.sll_node*, %struct.sll_node** %1
%25 = call %struct.sll_node* @sll_add_at_head(%struct.sll_node* %24, i32 4)
store %struct.sll_node* %25, %struct.sll_node** %1
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%27 = load %struct.sll_node*, %struct.sll_node** %1
%28 = call i32 @sll_print(%struct.sll_node* %27)
store i32 1, i32* %3
%29 = load i32, i32* %3
%30 = load %struct.sll_node*, %struct.sll_node** %1
%31 = load i32, i32* %3
%32 = call i32 @sll_get_occurance(%struct.sll_node* %30, i32 %31)
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 %29, i32 %32)
store i32 2, i32* %3
%34 = load i32, i32* %3
%35 = load %struct.sll_node*, %struct.sll_node** %1
%36 = load i32, i32* %3
%37 = call i32 @sll_get_occurance(%struct.sll_node* %35, i32 %36)
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 %34, i32 %37)
store i32 3, i32* %3
%39 = load i32, i32* %3
%40 = load %struct.sll_node*, %struct.sll_node** %1
%41 = load i32, i32* %3
%42 = call i32 @sll_get_occurance(%struct.sll_node* %40, i32 %41)
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 %39, i32 %42)
store i32 4, i32* %3
%44 = load i32, i32* %3
%45 = load %struct.sll_node*, %struct.sll_node** %1
%46 = load i32, i32* %3
%47 = call i32 @sll_get_occurance(%struct.sll_node* %45, i32 %46)
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 %44, i32 %47)
store i32 5, i32* %3
%49 = load i32, i32* %3
%50 = load %struct.sll_node*, %struct.sll_node** %1
%51 = load i32, i32* %3
%52 = call i32 @sll_get_occurance(%struct.sll_node* %50, i32 %51)
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 %49, i32 %52)
store i32 6, i32* %3
%54 = load i32, i32* %3
%55 = load %struct.sll_node*, %struct.sll_node** %1
%56 = load i32, i32* %3
%57 = call i32 @sll_get_occurance(%struct.sll_node* %55, i32 %56)
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 %54, i32 %57)
%59 = load %struct.sll_node*, %struct.sll_node** %1
%60 = call i32 @sll_destroy(%struct.sll_node* %59)
ret void
}

LLVM IR (-O2):
%struct.sll_node = type { i32 }
@.str = [7 x i8] c"SLL : \00"
@.str.1 = [30 x i8] c"%d occured %d times in sll.\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 %struct.sll_node* @sll_add_at_head(%struct.sll_node* %5, i32 3)
%7 = tail call %struct.sll_node* @sll_add_at_head(%struct.sll_node* %6, i32 3)
%8 = tail call %struct.sll_node* @sll_add_at_head(%struct.sll_node* %7, i32 4)
%9 = tail call %struct.sll_node* @sll_add_at_head(%struct.sll_node* %8, i32 5)
%10 = tail call %struct.sll_node* @sll_add_at_head(%struct.sll_node* %9, i32 3)
%11 = tail call %struct.sll_node* @sll_add_at_head(%struct.sll_node* %10, i32 4)
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%13 = tail call i32 @sll_print(%struct.sll_node* %11)
%14 = tail call i32 @sll_get_occurance(%struct.sll_node* %11, i32 1)
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 1, i32 %14)
%16 = tail call i32 @sll_get_occurance(%struct.sll_node* %11, i32 2)
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 2, i32 %16)
%18 = tail call i32 @sll_get_occurance(%struct.sll_node* %11, i32 3)
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 3, i32 %18)
%20 = tail call i32 @sll_get_occurance(%struct.sll_node* %11, i32 4)
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 4, i32 %20)
%22 = tail call i32 @sll_get_occurance(%struct.sll_node* %11, i32 5)
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 5, i32 %22)
%24 = tail call i32 @sll_get_occurance(%struct.sll_node* %11, i32 6)
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 6, i32 %24)
%26 = tail call i32 @sll_destroy(%struct.sll_node* %11)
ret void
}