#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 ListNode {
  int dummy;
};

/* Variables and functions */
struct ListNode *addNodeInPos(struct ListNode *, struct ListNode *, int);
int /*<<< orphan*/ clearScreen();
struct ListNode *createNode(int /*<<< orphan*/);
int /*<<< orphan*/ createStudent(int /*<<< orphan*/);
int getLenght(struct ListNode *);
int /*<<< orphan*/ printStudentsList(struct ListNode *);
int /*<<< orphan*/ printf(char *, ...);
struct ListNode *push(struct ListNode *, struct ListNode *);
int main(void) {
  struct ListNode *studList;
  studList = createNode(createStudent(0));
  studList = push(studList, createNode(createStudent(0)));
  printf("Prima lista:\n");
  printStudentsList(studList);
  printf("\nN° studenti presenti: %d;\n", getLenght(studList));
  clearScreen();
  studList = addNodeInPos(studList, createNode(createStudent(0)),
                          getLenght(studList) - 1);
  printf("Lista aggiornata:\n");
  printStudentsList(studList);
  printf("\nN° studenti presenti: %d;\n", getLenght(studList));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
xor    %edi,%edi
call   1030 <createStudent@plt>
mov    %eax,%edi
call   1060 <createNode@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
xor    %edi,%edi
call   1030 <createStudent@plt>
mov    %eax,%edi
call   1060 <createNode@plt>
mov    -0x28(%rbp),%rdi
mov    %rax,%rsi
call   10a0 <push@plt>
mov    %rax,-0x10(%rbp)
lea    0xe32(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <printStudentsList@plt>
mov    -0x10(%rbp),%rdi
call   1070 <getLenght@plt>
mov    %eax,%esi
lea    0xe1e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1080 <clearScreen@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
xor    %edi,%edi
call   1030 <createStudent@plt>
mov    %eax,%edi
call   1060 <createNode@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <getLenght@plt>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    %eax,%edx
sub    $0x1,%edx
call   1090 <addNodeInPos@plt>
mov    %rax,-0x10(%rbp)
lea    0xded(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <printStudentsList@plt>
mov    -0x10(%rbp),%rdi
call   1070 <getLenght@plt>
mov    %eax,%esi
lea    0xdae(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
xor    %edi,%edi
call   1030 <createStudent@plt>
mov    %eax,%edi
call   1070 <createNode@plt>
mov    %rax,%rbx
xor    %edi,%edi
call   1030 <createStudent@plt>
mov    %eax,%edi
call   1070 <createNode@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   10b0 <push@plt>
mov    %rax,%rbx
lea    0xe54(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1050 <printStudentsList@plt>
mov    %rbx,%rdi
call   1080 <getLenght@plt>
lea    0xe1b(%rip),%r14
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
call   1090 <clearScreen@plt>
xor    %edi,%edi
call   1030 <createStudent@plt>
mov    %eax,%edi
call   1070 <createNode@plt>
mov    %rax,%r15
mov    %rbx,%rdi
call   1080 <getLenght@plt>
lea    -0x1(%rax),%edx
mov    %rbx,%rdi
mov    %r15,%rsi
call   10a0 <addNodeInPos@plt>
mov    %rax,%rbx
lea    0xe01(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1050 <printStudentsList@plt>
mov    %rbx,%rdi
call   1080 <getLenght@plt>
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.ListNode = type { i32 }
@.str = [14 x i8] c"Prima lista:\0A\00"
@.str.1 = [29 x i8] c"\0AN\C2\B0 studenti presenti: %d;\0A\00"
@.str.2 = [19 x i8] c"Lista aggiornata:\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.ListNode*
store i32 0, i32* %1
%3 = call i32 @createStudent(i32 0)
%4 = call %struct.ListNode* @createNode(i32 %3)
store %struct.ListNode* %4, %struct.ListNode** %2
%5 = load %struct.ListNode*, %struct.ListNode** %2
%6 = call i32 @createStudent(i32 0)
%7 = call %struct.ListNode* @createNode(i32 %6)
%8 = call %struct.ListNode* @push(%struct.ListNode* %5, %struct.ListNode* %7)
store %struct.ListNode* %8, %struct.ListNode** %2
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%10 = load %struct.ListNode*, %struct.ListNode** %2
%11 = call i32 @printStudentsList(%struct.ListNode* %10)
%12 = load %struct.ListNode*, %struct.ListNode** %2
%13 = call i32 @getLenght(%struct.ListNode* %12)
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 %13)
%15 = call i32 (...) @clearScreen()
%16 = load %struct.ListNode*, %struct.ListNode** %2
%17 = call i32 @createStudent(i32 0)
%18 = call %struct.ListNode* @createNode(i32 %17)
%19 = load %struct.ListNode*, %struct.ListNode** %2
%20 = call i32 @getLenght(%struct.ListNode* %19)
%21 = sub nsw i32 %20, 1
%22 = call %struct.ListNode* @addNodeInPos(%struct.ListNode* %16, %struct.ListNode* %18, i32 %21)
store %struct.ListNode* %22, %struct.ListNode** %2
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%24 = load %struct.ListNode*, %struct.ListNode** %2
%25 = call i32 @printStudentsList(%struct.ListNode* %24)
%26 = load %struct.ListNode*, %struct.ListNode** %2
%27 = call i32 @getLenght(%struct.ListNode* %26)
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 %27)
ret i32 0
}

LLVM IR (-O2):
%struct.ListNode = type { i32 }
@.str.1 = [29 x i8] c"\0AN\C2\B0 studenti presenti: %d;\0A\00"
@str = [13 x i8] c"Prima lista:\00"
@str.3 = [18 x i8] c"Lista aggiornata:\00"
define i32 @main() {
%1 = tail call i32 @createStudent(i32 0)
%2 = tail call %struct.ListNode* @createNode(i32 %1)
%3 = tail call i32 @createStudent(i32 0)
%4 = tail call %struct.ListNode* @createNode(i32 %3)
%5 = tail call %struct.ListNode* @push(%struct.ListNode* %2, %struct.ListNode* %4)
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
%7 = tail call i32 @printStudentsList(%struct.ListNode* %5)
%8 = tail call i32 @getLenght(%struct.ListNode* %5)
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 %8)
%10 = tail call i32 (...) @clearScreen()
%11 = tail call i32 @createStudent(i32 0)
%12 = tail call %struct.ListNode* @createNode(i32 %11)
%13 = tail call i32 @getLenght(%struct.ListNode* %5)
%14 = add nsw i32 %13, -1
%15 = tail call %struct.ListNode* @addNodeInPos(%struct.ListNode* %5, %struct.ListNode* %12, i32 %14)
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.3, i64 0, i64 0))
%17 = tail call i32 @printStudentsList(%struct.ListNode* %15)
%18 = tail call i32 @getLenght(%struct.ListNode* %15)
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 %18)
ret i32 0
}