#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 *insertnode(int, int, struct node *);
int /*<<< orphan*/ print_tail(struct node *);
int /*<<< orphan*/ printnode(struct node *);
int /*<<< orphan*/ printnode_reverse(struct node *);
int /*<<< orphan*/ puts(char *);
int rand();
int /*<<< orphan*/ scanf(char *, int *);
struct node *set_tail(struct node *);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main() {
  int val, len;
  struct node *head = NULL, *tail = NULL;
  puts("How Many Elements You Want in your Linked List");
  scanf(" %d", &len);
  srand(time(NULL));
  for (int i = 1; i <= len; i++) {
    val = rand() % 10;
    head = insertnode(val, i, head);
    tail = set_tail(head);
  }
  printnode(head);
  printnode_reverse(tail);
  print_tail(tail);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
lea    0xe3a(%rip),%rdi
call   1030 <puts@plt>
lea    0xe5d(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   10a0 <scanf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1080 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
movl   $0x1,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     123e <main+0x9e>
mov    $0x0,%al
call   10c0 <rand@plt>
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x8(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x24(%rbp),%esi
mov    -0x18(%rbp),%rdx
call   1040 <insertnode@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1090 <set_tail@plt>
mov    %rax,-0x20(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11f2 <main+0x52>
mov    -0x18(%rbp),%rdi
call   10b0 <printnode@plt>
mov    -0x20(%rbp),%rdi
call   1050 <printnode_reverse@plt>
mov    -0x20(%rbp),%rdi
call   1070 <print_tail@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xe51(%rip),%rdi
call   1030 <puts@plt>
lea    0xe74(%rip),%rdi
lea    0xc(%rsp),%rsi
call   10a0 <scanf@plt>
xor    %r14d,%r14d
xor    %edi,%edi
call   1080 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
cmpl   $0x0,0xc(%rsp)
mov    $0x0,%ebx
jle    1236 <main+0x96>
xor    %ebp,%ebp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%ebp
xor    %eax,%eax
call   10c0 <rand@plt>
movslq %eax,%rdi
imul   $0x66666667,%rdi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%edi
mov    %ebp,%esi
mov    %rbx,%rdx
call   1040 <insertnode@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1090 <set_tail@plt>
cmp    0xc(%rsp),%ebp
jl     11f0 <main+0x50>
mov    %rax,%r14
mov    %rbx,%rdi
call   10b0 <printnode@plt>
mov    %r14,%rdi
call   1050 <printnode_reverse@plt>
mov    %r14,%rdi
call   1070 <print_tail@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.node = type { i32 }
@.str = [47 x i8] c"How Many Elements You Want in your Linked List\00"
@.str.1 = [4 x i8] c" %d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca %struct.node*
%5 = alloca %struct.node*
%6 = alloca i32
store i32 0, i32* %1
store %struct.node* null, %struct.node** %4
store %struct.node* null, %struct.node** %5
%7 = call i32 @puts(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%9 = call i32 @time(i32* null)
%10 = call i32 @srand(i32 %9)
store i32 1, i32* %6
br label %11
11: ; preds = %24, %0
%12 = load i32, i32* %6
%13 = load i32, i32* %3
%14 = icmp sle i32 %12, %13
br i1 %14, label %15, label %27
15: ; preds = %11
%16 = call i32 (...) @rand()
%17 = srem i32 %16, 10
store i32 %17, i32* %2
%18 = load i32, i32* %2
%19 = load i32, i32* %6
%20 = load %struct.node*, %struct.node** %4
%21 = call %struct.node* @insertnode(i32 %18, i32 %19, %struct.node* %20)
store %struct.node* %21, %struct.node** %4
%22 = load %struct.node*, %struct.node** %4
%23 = call %struct.node* @set_tail(%struct.node* %22)
store %struct.node* %23, %struct.node** %5
br label %24
24: ; preds = %15
%25 = load i32, i32* %6
%26 = add nsw i32 %25, 1
store i32 %26, i32* %6
br label %11
27: ; preds = %11
%28 = load %struct.node*, %struct.node** %4
%29 = call i32 @printnode(%struct.node* %28)
%30 = load %struct.node*, %struct.node** %5
%31 = call i32 @printnode_reverse(%struct.node* %30)
%32 = load %struct.node*, %struct.node** %5
%33 = call i32 @print_tail(%struct.node* %32)
%34 = load i32, i32* %1
ret i32 %34
}

LLVM IR (-O2):
%struct.node = type { i32 }
@.str = [47 x i8] c"How Many Elements You Want in your Linked List\00"
@.str.1 = [4 x i8] c" %d\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = call i32 @time(i32* null)
%6 = call i32 @srand(i32 %5)
%7 = load i32, i32* %1
%8 = icmp slt i32 %7, 1
br i1 %8, label %9, label %15
9: ; preds = %15, %0
%10 = phi %struct.node* [ null, %0 ], [ %20, %15 ]
%11 = phi %struct.node* [ null, %0 ], [ %21, %15 ]
%12 = call i32 @printnode(%struct.node* %10)
%13 = call i32 @printnode_reverse(%struct.node* %11)
%14 = call i32 @print_tail(%struct.node* %11)
ret i32 0
15: ; preds = %0, %15
%16 = phi i32 [ %22, %15 ], [ 1, %0 ]
%17 = phi %struct.node* [ %20, %15 ], [ null, %0 ]
%18 = call i32 (...) @rand()
%19 = srem i32 %18, 10
%20 = call %struct.node* @insertnode(i32 %19, i32 %16, %struct.node* %17)
%21 = call %struct.node* @set_tail(%struct.node* %20)
%22 = add nuw nsw i32 %16, 1
%23 = load i32, i32* %1
%24 = icmp slt i32 %16, %23
br i1 %24, label %15, label %9
}