#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 /*<<< orphan*/ sll_print(struct sll_node *);
struct sll_node *sll_reversal(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);
  h = sll_reversal(h);
  printf("Reversed SLL : ");
  sll_print(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   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)
lea    0xe40(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1040 <sll_print@plt>
mov    -0x8(%rbp),%rdi
call   1070 <sll_reversal@plt>
mov    %rax,-0x8(%rbp)
lea    0xe15(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1040 <sll_print@plt>
mov    -0x8(%rbp),%rdi
call   1050 <sll_destroy@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
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,%rbx
lea    0xe6e(%rip),%rdi
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1040 <sll_print@plt>
mov    %rbx,%rdi
call   1070 <sll_reversal@plt>
mov    %rax,%rbx
lea    0xe46(%rip),%rdi
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1040 <sll_print@plt>
mov    %rbx,%rdi
pop    %rbx
jmp    1050 <sll_destroy@plt>

LLVM IR (-O0):
%struct.sll_node = type { i32 }
@.str = [7 x i8] c"SLL : \00"
@.str.1 = [16 x i8] c"Reversed SLL : \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 @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 %struct.sll_node* @sll_reversal(%struct.sll_node* %16)
store %struct.sll_node* %17, %struct.sll_node** %1
%18 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%19 = load %struct.sll_node*, %struct.sll_node** %1
%20 = call i32 @sll_print(%struct.sll_node* %19)
%21 = load %struct.sll_node*, %struct.sll_node** %1
%22 = call i32 @sll_destroy(%struct.sll_node* %21)
ret void
}

LLVM IR (-O2):
%struct.sll_node = type { i32 }
@.str = [7 x i8] c"SLL : \00"
@.str.1 = [16 x i8] c"Reversed SLL : \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 @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 %struct.sll_node* @sll_reversal(%struct.sll_node* %5)
%9 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%10 = tail call i32 @sll_print(%struct.sll_node* %8)
%11 = tail call i32 @sll_destroy(%struct.sll_node* %8)
ret void
}