#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 */

/* Variables and functions */
int /*<<< orphan*/ deletenode(int);
int /*<<< orphan*/ insertnode(int, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ printnode();
int /*<<< orphan*/ puts(char *);
int rand();
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(void) {
  int val, len, pos;
  printf("How Many elements you want in your Linked list? \n");
  scanf(" %d", &len);
  srand(time(NULL));
  for (int i = 1; i <= len; i++) {
    val = rand() % 10;
    insertnode(val, i);
    printf("your list is : ");
    printnode();
  }
  puts("Enter Your Desired Position to delete");
  scanf(" %d", &pos);
  deletenode(pos);
  printf("\nyour list is  now : ");
  printnode();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe5a(%rip),%rdi
call   1050 <printf@plt>
lea    0xe80(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1090 <scanf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     121c <main+0x8c>
mov    $0x0,%al
call   10b0 <rand@plt>
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x8(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x14(%rbp),%esi
call   1040 <insertnode@plt>
lea    0xe34(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   10a0 <printnode@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11d2 <main+0x42>
lea    0xe23(%rip),%rdi
call   1030 <puts@plt>
lea    0xe03(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1090 <scanf@plt>
mov    -0x10(%rbp),%edi
call   1080 <deletenode@plt>
lea    0xe25(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   10a0 <printnode@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0xeb6(%rip),%rdi
call   1030 <puts@plt>
lea    0xe5a(%rip),%rdi
mov    %rsp,%rsi
call   1090 <scanf@plt>
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
cmpl   $0x0,(%rsp)
jle    1213 <main+0x83>
lea    0xe3b(%rip),%rbx
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
add    $0x1,%ebp
xor    %eax,%eax
call   10b0 <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
call   1040 <insertnode@plt>
mov    %rbx,%rdi
call   1050 <printf@plt>
xor    %eax,%eax
call   10a0 <printnode@plt>
cmp    (%rsp),%ebp
jl     11d0 <main+0x40>
lea    0xdfa(%rip),%rdi
call   1030 <puts@plt>
lea    0xdda(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1090 <scanf@plt>
mov    0x4(%rsp),%edi
call   1080 <deletenode@plt>
lea    0xdfa(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
call   10a0 <printnode@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [50 x i8] c"How Many elements you want in your Linked list? \0A\00"
@.str.1 = [4 x i8] c" %d\00"
@.str.2 = [16 x i8] c"your list is : \00"
@.str.3 = [38 x i8] c"Enter Your Desired Position to delete\00"
@.str.4 = [22 x i8] c"\0Ayour list is now : \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%8 = call i32 @time(i32* null)
%9 = call i32 @srand(i32 %8)
store i32 1, i32* %5
br label %10
10: ; preds = %22, %0
%11 = load i32, i32* %5
%12 = load i32, i32* %3
%13 = icmp sle i32 %11, %12
br i1 %13, label %14, label %25
14: ; preds = %10
%15 = call i32 (...) @rand()
%16 = srem i32 %15, 10
store i32 %16, i32* %2
%17 = load i32, i32* %2
%18 = load i32, i32* %5
%19 = call i32 @insertnode(i32 %17, i32 %18)
%20 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%21 = call i32 (...) @printnode()
br label %22
22: ; preds = %14
%23 = load i32, i32* %5
%24 = add nsw i32 %23, 1
store i32 %24, i32* %5
br label %10
25: ; preds = %10
%26 = call i32 @puts(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0))
%27 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%28 = load i32, i32* %4
%29 = call i32 @deletenode(i32 %28)
%30 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0))
%31 = call i32 (...) @printnode()
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [4 x i8] c" %d\00"
@.str.2 = [16 x i8] c"your list is : \00"
@.str.3 = [38 x i8] c"Enter Your Desired Position to delete\00"
@.str.4 = [22 x i8] c"\0Ayour list is now : \00"
@str = [49 x i8] c"How Many elements you want in your Linked list? \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%7 = call i32 @time(i32* null)
%8 = call i32 @srand(i32 %7)
%9 = load i32, i32* %1
%10 = icmp slt i32 %9, 1
br i1 %10, label %11, label %18
11: ; preds = %18, %0
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%14 = load i32, i32* %2
%15 = call i32 @deletenode(i32 %14)
%16 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0))
%17 = call i32 (...) @printnode()
ret i32 0
18: ; preds = %0, %18
%19 = phi i32 [ %25, %18 ], [ 1, %0 ]
%20 = call i32 (...) @rand()
%21 = srem i32 %20, 10
%22 = call i32 @insertnode(i32 %21, i32 %19)
%23 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%24 = call i32 (...) @printnode()
%25 = add nuw nsw i32 %19, 1
%26 = load i32, i32* %1
%27 = icmp slt i32 %19, %26
br i1 %27, label %18, label %11
}