#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*/ printnode(struct node *);
int /*<<< orphan*/ puts(char *);
int rand();
struct node *reverse_list(struct node *);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(void) {
  struct node *head = NULL;
  int len, val;
  puts("How much elements you want in your list.");
  scanf(" %d", &len);
  srand(time(NULL));
  for (int i = 1; i <= len; i++) {
    val = rand() % 10;
    head = insertnode(val, i, head);
  }
  printnode(head);
  int userEnt;
  puts("Do you want to reverse it? [1 for yes/ 0 for no]");
  scanf(" %d", &userEnt);
  if (userEnt == 1) {
    head = reverse_list(head);
    printnode(head);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
lea    0xe62(%rip),%rdi
call   1030 <puts@plt>
lea    0xe7f(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1080 <scanf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     1209 <main+0x89>
mov    $0x0,%al
call   10a0 <rand@plt>
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x18(%rbp)
mov    -0x18(%rbp),%edi
mov    -0x1c(%rbp),%esi
mov    -0x10(%rbp),%rdx
call   1040 <insertnode@plt>
mov    %rax,-0x10(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11ca <main+0x4a>
mov    -0x10(%rbp),%rdi
call   1090 <printnode@plt>
lea    0xe14(%rip),%rdi
call   1030 <puts@plt>
lea    0xe04(%rip),%rdi
lea    -0x20(%rbp),%rsi
call   1080 <scanf@plt>
cmpl   $0x1,-0x20(%rbp)
jne    124e <main+0xce>
mov    -0x10(%rbp),%rdi
call   1070 <reverse_list@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1090 <printnode@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0xe76(%rip),%rdi
call   1030 <puts@plt>
lea    0xe93(%rip),%rdi
mov    %rsp,%rsi
call   1080 <scanf@plt>
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
cmpl   $0x0,(%rsp)
mov    $0x0,%ebx
jle    11fa <main+0x7a>
xor    %ebp,%ebp
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
add    $0x1,%ebp
xor    %eax,%eax
call   10a0 <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
cmp    (%rsp),%ebp
jl     11c0 <main+0x40>
mov    %rbx,%rdi
call   1090 <printnode@plt>
lea    0xe24(%rip),%rdi
call   1030 <puts@plt>
lea    0xe14(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1080 <scanf@plt>
cmpl   $0x1,0x4(%rsp)
jne    1236 <main+0xb6>
mov    %rbx,%rdi
call   1070 <reverse_list@plt>
mov    %rax,%rdi
call   1090 <printnode@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.node = type { i32 }
@.str = [41 x i8] c"How much elements you want in your list.\00"
@.str.1 = [4 x i8] c" %d\00"
@.str.2 = [49 x i8] c"Do you want to reverse it? [1 for yes/ 0 for no]\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.node*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store %struct.node* null, %struct.node** %2
%7 = call i32 @puts(i8* getelementptr inbounds ([41 x i8], [41 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* %5
br label %11
11: ; preds = %22, %0
%12 = load i32, i32* %5
%13 = load i32, i32* %3
%14 = icmp sle i32 %12, %13
br i1 %14, label %15, label %25
15: ; preds = %11
%16 = call i32 (...) @rand()
%17 = srem i32 %16, 10
store i32 %17, i32* %4
%18 = load i32, i32* %4
%19 = load i32, i32* %5
%20 = load %struct.node*, %struct.node** %2
%21 = call %struct.node* @insertnode(i32 %18, i32 %19, %struct.node* %20)
store %struct.node* %21, %struct.node** %2
br label %22
22: ; preds = %15
%23 = load i32, i32* %5
%24 = add nsw i32 %23, 1
store i32 %24, i32* %5
br label %11
25: ; preds = %11
%26 = load %struct.node*, %struct.node** %2
%27 = call i32 @printnode(%struct.node* %26)
%28 = call i32 @puts(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.2, i64 0, i64 0))
%29 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%30 = load i32, i32* %6
%31 = icmp eq i32 %30, 1
br i1 %31, label %32, label %37
32: ; preds = %25
%33 = load %struct.node*, %struct.node** %2
%34 = call %struct.node* @reverse_list(%struct.node* %33)
store %struct.node* %34, %struct.node** %2
%35 = load %struct.node*, %struct.node** %2
%36 = call i32 @printnode(%struct.node* %35)
br label %37
37: ; preds = %32, %25
ret i32 0
}

LLVM IR (-O2):
%struct.node = type { i32 }
@.str = [41 x i8] c"How much elements you want in your list.\00"
@.str.1 = [4 x i8] c" %d\00"
@.str.2 = [49 x i8] c"Do you want to reverse it? [1 for yes/ 0 for no]\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%6 = call i32 @time(i32* null)
%7 = call i32 @srand(i32 %6)
%8 = load i32, i32* %1
%9 = icmp slt i32 %8, 1
br i1 %9, label %10, label %18
10: ; preds = %18, %0
%11 = phi %struct.node* [ null, %0 ], [ %23, %18 ]
%12 = call i32 @printnode(%struct.node* %11)
%13 = bitcast i32* %2 to i8*
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.2, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%16 = load i32, i32* %2
%17 = icmp eq i32 %16, 1
br i1 %17, label %27, label %30
18: ; preds = %0, %18
%19 = phi i32 [ %24, %18 ], [ 1, %0 ]
%20 = phi %struct.node* [ %23, %18 ], [ null, %0 ]
%21 = call i32 (...) @rand()
%22 = srem i32 %21, 10
%23 = call %struct.node* @insertnode(i32 %22, i32 %19, %struct.node* %20)
%24 = add nuw nsw i32 %19, 1
%25 = load i32, i32* %1
%26 = icmp slt i32 %19, %25
br i1 %26, label %18, label %10
27: ; preds = %10
%28 = call %struct.node* @reverse_list(%struct.node* %11)
%29 = call i32 @printnode(%struct.node* %28)
br label %30
30: ; preds = %27, %10
ret i32 0
}