#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*/ addfirst(int);
int /*<<< orphan*/ addlast(int);
int /*<<< orphan*/ bubblesort(int);
int countt();
int /*<<< orphan*/ init();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ removee(int);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ searchh(int);
int /*<<< orphan*/ traversal();
int main() {
  int nr;
  init();
  printf("The list is\n");
  traversal();
  printf("Write the number you want to add at the beginning ");
  scanf("%d", &nr);
  addfirst(nr);
  traversal();
  printf("Write the number you want to add at the end ");
  scanf("%d", &nr);
  addlast(nr);
  traversal();
  printf("Write the number you want to remove from the list ");
  scanf("%d", &nr);
  removee(nr);
  int n = countt();
  printf("The list has %d elements\n\n", n);
  printf("Write the number you want to find in the list ");
  scanf("%d", &nr);
  searchh(nr);
  int mode;
  printf("Press 1 if you want to sort the list ascending,or 0 for descending ");
  scanf("%d", &mode);
  bubblesort(mode);
  traversal();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1070 <init@plt>
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1080 <traversal@plt>
lea    0xe3b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe60(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   10b0 <scanf@plt>
mov    -0x8(%rbp),%edi
call   1030 <addfirst@plt>
mov    $0x0,%al
call   1080 <traversal@plt>
lea    0xe44(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe33(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   10b0 <scanf@plt>
mov    -0x8(%rbp),%edi
call   1040 <addlast@plt>
mov    $0x0,%al
call   1080 <traversal@plt>
lea    0xe44(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe06(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   10b0 <scanf@plt>
mov    -0x8(%rbp),%edi
call   10a0 <removee@plt>
mov    $0x0,%al
call   1060 <countt@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe44(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xdc5(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   10b0 <scanf@plt>
mov    -0x8(%rbp),%edi
call   1090 <searchh@plt>
lea    0xe5a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xd9f(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   10b0 <scanf@plt>
mov    -0x10(%rbp),%edi
call   10c0 <bubblesort@plt>
mov    $0x0,%al
call   1080 <traversal@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1080 <init@plt>
lea    0xf62(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1090 <traversal@plt>
lea    0xe2b(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe50(%rip),%rbx
mov    %rsp,%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   10c0 <scanf@plt>
mov    (%rsp),%edi
call   1030 <addfirst@plt>
xor    %eax,%eax
call   1090 <traversal@plt>
lea    0xe2f(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   10c0 <scanf@plt>
mov    (%rsp),%edi
call   1050 <addlast@plt>
xor    %eax,%eax
call   1090 <traversal@plt>
lea    0xe34(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   10c0 <scanf@plt>
mov    (%rsp),%edi
call   10b0 <removee@plt>
xor    %eax,%eax
call   1070 <countt@plt>
lea    0xe3f(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe4a(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   10c0 <scanf@plt>
mov    (%rsp),%edi
call   10a0 <searchh@plt>
lea    0xe58(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
call   10c0 <scanf@plt>
mov    0x4(%rsp),%edi
call   10d0 <bubblesort@plt>
xor    %eax,%eax
call   1090 <traversal@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [13 x i8] c"The list is\0A\00"
@.str.1 = [51 x i8] c"Write the number you want to add at the beginning \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [45 x i8] c"Write the number you want to add at the end \00"
@.str.4 = [51 x i8] c"Write the number you want to remove from the list \00"
@.str.5 = [27 x i8] c"The list has %d elements\0A\0A\00"
@.str.6 = [47 x i8] c"Write the number you want to find in the list \00"
@.str.7 = [68 x i8] c"Press 1 if you want to sort the list ascending,or 0 for descending \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 (...) @init()
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%7 = call i32 (...) @traversal()
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%10 = load i32, i32* %2
%11 = call i32 @addfirst(i32 %10)
%12 = call i32 (...) @traversal()
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.3, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%15 = load i32, i32* %2
%16 = call i32 @addlast(i32 %15)
%17 = call i32 (...) @traversal()
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.4, i64 0, i64 0))
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%20 = load i32, i32* %2
%21 = call i32 @removee(i32 %20)
%22 = call i32 (...) @countt()
store i32 %22, i32* %3
%23 = load i32, i32* %3
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0), i32 %23)
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.6, i64 0, i64 0))
%26 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%27 = load i32, i32* %2
%28 = call i32 @searchh(i32 %27)
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.7, i64 0, i64 0))
%30 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %4)
%31 = load i32, i32* %4
%32 = call i32 @bubblesort(i32 %31)
%33 = call i32 (...) @traversal()
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [51 x i8] c"Write the number you want to add at the beginning \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [45 x i8] c"Write the number you want to add at the end \00"
@.str.4 = [51 x i8] c"Write the number you want to remove from the list \00"
@.str.5 = [27 x i8] c"The list has %d elements\0A\0A\00"
@.str.6 = [47 x i8] c"Write the number you want to find in the list \00"
@.str.7 = [68 x i8] c"Press 1 if you want to sort the list ascending,or 0 for descending \00"
@str = [12 x i8] c"The list is\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = tail call i32 (...) @init()
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 (...) @traversal()
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%9 = load i32, i32* %1
%10 = call i32 @addfirst(i32 %9)
%11 = call i32 (...) @traversal()
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.3, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%14 = load i32, i32* %1
%15 = call i32 @addlast(i32 %14)
%16 = call i32 (...) @traversal()
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str.4, i64 0, i64 0))
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%19 = load i32, i32* %1
%20 = call i32 @removee(i32 %19)
%21 = call i32 (...) @countt()
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0), i32 %21)
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str.6, i64 0, i64 0))
%24 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%25 = load i32, i32* %1
%26 = call i32 @searchh(i32 %25)
%27 = bitcast i32* %2 to i8*
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([68 x i8], [68 x i8]* @.str.7, i64 0, i64 0))
%29 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%30 = load i32, i32* %2
%31 = call i32 @bubblesort(i32 %30)
%32 = call i32 (...) @traversal()
ret i32 0
}