#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 *addatbeg(struct node *, int);
struct node *addatend(struct node *, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
struct node *create_list(struct node *start) {
  int n, i, data;
  printf("enter no of nodes\n");
  scanf("%d", &n);
  if (n == 0) {
    return start;
  } else {
    printf("enter first element to be inserted\n");
    scanf("%d", &data);
    start = addatbeg(start, data);
    for (i = 2; i <= n; i++) {
      printf("enter next element\n");
      scanf("%d", &data);
      start = addatend(start, data);
    }
  }
  return start;
}


x86 assembly (clang, -O0):
<create_list>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
lea    0xead(%rip),%rdi
call   1040 <printf@plt>
lea    0xeb4(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1060 <scanf@plt>
cmpl   $0x0,-0x14(%rbp)
jne    117f <create_list+0x3f>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1205 <create_list+0xc5>
lea    0xe90(%rip),%rdi
call   1040 <printf@plt>
lea    0xe81(%rip),%rdi
lea    -0x1c(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1050 <addatbeg@plt>
mov    %rax,-0x10(%rbp)
movl   $0x2,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     11f8 <create_list+0xb8>
lea    0xe75(%rip),%rdi
call   1040 <printf@plt>
lea    0xe42(%rip),%rdi
lea    -0x1c(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1030 <addatend@plt>
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11b2 <create_list+0x72>
jmp    11fd <create_list+0xbd>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_list>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
lea    0xead(%rip),%rdi
call   1040 <puts@plt>
lea    0xe9e(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
cmpl   $0x0,0xc(%rsp)
je     11eb <create_list+0xab>
lea    0xe9b(%rip),%rdi
call   1040 <puts@plt>
lea    0xe7a(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1060 <scanf@plt>
mov    0x8(%rsp),%esi
mov    %rbx,%rdi
call   1050 <addatbeg@plt>
mov    %rax,%rbx
cmpl   $0x2,0xc(%rsp)
jl     11eb <create_list+0xab>
mov    $0x1,%ebp
lea    0xe86(%rip),%r14
lea    0xe47(%rip),%r15
lea    0x8(%rsp),%r12
xchg   %ax,%ax
mov    %r14,%rdi
call   1040 <puts@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1060 <scanf@plt>
mov    0x8(%rsp),%esi
mov    %rbx,%rdi
call   1030 <addatend@plt>
mov    %rax,%rbx
add    $0x1,%ebp
cmp    0xc(%rsp),%ebp
jl     11c0 <create_list+0x80>
mov    %rbx,%rax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.node = type { i32 }
@.str = [19 x i8] c"enter no of nodes\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [36 x i8] c"enter first element to be inserted\0A\00"
@.str.3 = [20 x i8] c"enter next element\0A\00"
define %struct.node* @create_list(%struct.node* %0) {
%2 = alloca %struct.node*
%3 = alloca %struct.node*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store %struct.node* %0, %struct.node** %3
%7 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%9 = load i32, i32* %4
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %1
%12 = load %struct.node*, %struct.node** %3
store %struct.node* %12, %struct.node** %2
br label %35
13: ; preds = %1
%14 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%16 = load %struct.node*, %struct.node** %3
%17 = load i32, i32* %6
%18 = call %struct.node* @addatbeg(%struct.node* %16, i32 %17)
store %struct.node* %18, %struct.node** %3
store i32 2, i32* %5
br label %19
19: ; preds = %29, %13
%20 = load i32, i32* %5
%21 = load i32, i32* %4
%22 = icmp sle i32 %20, %21
br i1 %22, label %23, label %32
23: ; preds = %19
%24 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
%25 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%26 = load %struct.node*, %struct.node** %3
%27 = load i32, i32* %6
%28 = call %struct.node* @addatend(%struct.node* %26, i32 %27)
store %struct.node* %28, %struct.node** %3
br label %29
29: ; preds = %23
%30 = load i32, i32* %5
%31 = add nsw i32 %30, 1
store i32 %31, i32* %5
br label %19
32: ; preds = %19
br label %33
33: ; preds = %32
%34 = load %struct.node*, %struct.node** %3
store %struct.node* %34, %struct.node** %2
br label %35
35: ; preds = %33, %11
%36 = load %struct.node*, %struct.node** %2
ret %struct.node* %36
}

LLVM IR (-O2):
%struct.node = type { i32 }
@.str.1 = [3 x i8] c"%d\00"
@str = [18 x i8] c"enter no of nodes\00"
@str.4 = [35 x i8] c"enter first element to be inserted\00"
@str.5 = [19 x i8] c"enter next element\00"
define %struct.node* @create_list(%struct.node* %0) {
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %2 to i8*
%5 = bitcast i32* %3 to i8*
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%8 = load i32, i32* %2
%9 = icmp eq i32 %8, 0
br i1 %9, label %27, label %10
10: ; preds = %1
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.4, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%13 = load i32, i32* %3
%14 = call %struct.node* @addatbeg(%struct.node* %0, i32 %13)
%15 = load i32, i32* %2
%16 = icmp slt i32 %15, 2
br i1 %16, label %27, label %17
17: ; preds = %10, %17
%18 = phi i32 [ %24, %17 ], [ 2, %10 ]
%19 = phi %struct.node* [ %23, %17 ], [ %14, %10 ]
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.5, i64 0, i64 0))
%21 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%22 = load i32, i32* %3
%23 = call %struct.node* @addatend(%struct.node* %19, i32 %22)
%24 = add nuw nsw i32 %18, 1
%25 = load i32, i32* %2
%26 = icmp slt i32 %18, %25
br i1 %26, label %17, label %27
27: ; preds = %17, %10, %1
%28 = phi %struct.node* [ %0, %1 ], [ %14, %10 ], [ %23, %17 ]
ret %struct.node* %28
}