#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 i, n, data;
  printf("enter no. of nodes\n");
  scanf("%d", &n);
  if (n == 0)
    return start;
  else {
    printf("enter first element\n");
    scanf("%d", &data);
    start = addatbeg(start, data);
    for (i = 2; i <= n; i++) {
      printf("enter element no %d - \n", i);
      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
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeb3(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1060 <scanf@plt>
cmpl   $0x0,-0x18(%rbp)
jne    1181 <create_list+0x41>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    120e <create_list+0xce>
lea    0xe8f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe7e(%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,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jg     1201 <create_list+0xc1>
mov    -0x14(%rbp),%esi
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe3a(%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    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11b6 <create_list+0x76>
jmp    1206 <create_list+0xc6>
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    0xeb5(%rip),%rdi
call   1040 <puts@plt>
lea    0xe8e(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1070 <scanf@plt>
cmpl   $0x0,0xc(%rsp)
je     11ff <create_list+0xaf>
lea    0xea4(%rip),%rdi
call   1040 <puts@plt>
lea    0xe6a(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1070 <scanf@plt>
mov    0x8(%rsp),%esi
mov    %rbx,%rdi
call   1060 <addatbeg@plt>
mov    %rax,%rbx
cmpl   $0x2,0xc(%rsp)
jl     11ff <create_list+0xaf>
mov    $0x1,%ebp
lea    0xe41(%rip),%r14
lea    0xe37(%rip),%r15
lea    0x8(%rsp),%r12
xchg   %ax,%ax
add    $0x1,%ebp
mov    %r14,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1070 <scanf@plt>
mov    0x8(%rsp),%esi
mov    %rbx,%rdi
call   1030 <addatend@plt>
mov    %rax,%rbx
cmp    0xc(%rsp),%ebp
jl     11d0 <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 = [20 x i8] c"enter no. of nodes\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [21 x i8] c"enter first element\0A\00"
@.str.3 = [24 x i8] c"enter element no %d - \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 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 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* %5)
%9 = load i32, i32* %5
%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 %36
13: ; preds = %1
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 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* %4
br label %19
19: ; preds = %30, %13
%20 = load i32, i32* %4
%21 = load i32, i32* %5
%22 = icmp sle i32 %20, %21
br i1 %22, label %23, label %33
23: ; preds = %19
%24 = load i32, i32* %4
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i32 %24)
%26 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%27 = load %struct.node*, %struct.node** %3
%28 = load i32, i32* %6
%29 = call %struct.node* @addatend(%struct.node* %27, i32 %28)
store %struct.node* %29, %struct.node** %3
br label %30
30: ; preds = %23
%31 = load i32, i32* %4
%32 = add nsw i32 %31, 1
store i32 %32, i32* %4
br label %19
33: ; preds = %19
br label %34
34: ; preds = %33
%35 = load %struct.node*, %struct.node** %3
store %struct.node* %35, %struct.node** %2
br label %36
36: ; preds = %34, %11
%37 = load %struct.node*, %struct.node** %2
ret %struct.node* %37
}

LLVM IR (-O2):
%struct.node = type { i32 }
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [24 x i8] c"enter element no %d - \0A\00"
@str = [19 x i8] c"enter no. of nodes\00"
@str.4 = [20 x i8] c"enter first 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 ([19 x i8], [19 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 ([20 x i8], [20 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 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i32 %18)
%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
}