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

/* Variables and functions */
struct list *list_constructor_tail(int);
int /*<<< orphan*/ list_print(struct list *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sorted_add(struct list **, int);
int main(int argc, const char *argv[]) {
  struct list *head;
  printf("Original list:\n");
  head = list_constructor_tail(10);
  list_print(head);
  printf("Adding -1:\n");
  sorted_add(&head, -1);
  list_print(head);
  printf("Adding 4:\n");
  sorted_add(&head, 4);
  list_print(head);
  printf("Adding 12:\n");
  sorted_add(&head, 12);
  list_print(head);
  printf("Adding 10:\n");
  sorted_add(&head, 10);
  list_print(head);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xea3(%rip),%rdi
call   1030 <printf@plt>
mov    $0xa,%edi
call   1060 <list_constructor_tail@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <list_print@plt>
lea    0xe90(%rip),%rdi
call   1030 <printf@plt>
lea    -0x18(%rbp),%rdi
mov    $0xffffffff,%esi
call   1050 <sorted_add@plt>
mov    -0x18(%rbp),%rdi
call   1040 <list_print@plt>
lea    0xe79(%rip),%rdi
call   1030 <printf@plt>
lea    -0x18(%rbp),%rdi
mov    $0x4,%esi
call   1050 <sorted_add@plt>
mov    -0x18(%rbp),%rdi
call   1040 <list_print@plt>
lea    0xe61(%rip),%rdi
call   1030 <printf@plt>
lea    -0x18(%rbp),%rdi
mov    $0xc,%esi
call   1050 <sorted_add@plt>
mov    -0x18(%rbp),%rdi
call   1040 <list_print@plt>
lea    0xe4a(%rip),%rdi
call   1030 <printf@plt>
lea    -0x18(%rbp),%rdi
mov    $0xa,%esi
call   1050 <sorted_add@plt>
mov    -0x18(%rbp),%rdi
call   1040 <list_print@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xeb4(%rip),%rdi
call   1030 <puts@plt>
mov    $0xa,%edi
call   1060 <list_constructor_tail@plt>
mov    %rax,0x8(%rsp)
mov    %rax,%rdi
call   1040 <list_print@plt>
lea    0xea0(%rip),%rdi
call   1030 <puts@plt>
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
mov    $0xffffffff,%esi
call   1050 <sorted_add@plt>
mov    0x8(%rsp),%rdi
call   1040 <list_print@plt>
lea    0xe83(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
call   1050 <sorted_add@plt>
mov    0x8(%rsp),%rdi
call   1040 <list_print@plt>
lea    0xe6a(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    $0xc,%esi
call   1050 <sorted_add@plt>
mov    0x8(%rsp),%rdi
call   1040 <list_print@plt>
lea    0xe52(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1050 <sorted_add@plt>
mov    0x8(%rsp),%rdi
call   1040 <list_print@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.list = type { i32 }
@.str = [16 x i8] c"Original list:\0A\00"
@.str.1 = [12 x i8] c"Adding -1:\0A\00"
@.str.2 = [11 x i8] c"Adding 4:\0A\00"
@.str.3 = [12 x i8] c"Adding 12:\0A\00"
@.str.4 = [12 x i8] c"Adding 10:\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.list*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%8 = call %struct.list* @list_constructor_tail(i32 10)
store %struct.list* %8, %struct.list** %6
%9 = load %struct.list*, %struct.list** %6
%10 = call i32 @list_print(%struct.list* %9)
%11 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 @sorted_add(%struct.list** %6, i32 -1)
%13 = load %struct.list*, %struct.list** %6
%14 = call i32 @list_print(%struct.list* %13)
%15 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%16 = call i32 @sorted_add(%struct.list** %6, i32 4)
%17 = load %struct.list*, %struct.list** %6
%18 = call i32 @list_print(%struct.list* %17)
%19 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%20 = call i32 @sorted_add(%struct.list** %6, i32 12)
%21 = load %struct.list*, %struct.list** %6
%22 = call i32 @list_print(%struct.list* %21)
%23 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
%24 = call i32 @sorted_add(%struct.list** %6, i32 10)
%25 = load %struct.list*, %struct.list** %6
%26 = call i32 @list_print(%struct.list* %25)
ret i32 0
}

LLVM IR (-O2):
%struct.list = type { i32 }
@str = [15 x i8] c"Original list:\00"
@str.5 = [11 x i8] c"Adding -1:\00"
@str.6 = [10 x i8] c"Adding 4:\00"
@str.7 = [11 x i8] c"Adding 12:\00"
@str.8 = [11 x i8] c"Adding 10:\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.list*
%4 = bitcast %struct.list** %3 to i8*
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
%6 = tail call %struct.list* @list_constructor_tail(i32 10)
store %struct.list* %6, %struct.list** %3
%7 = tail call i32 @list_print(%struct.list* %6)
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.5, i64 0, i64 0))
%9 = call i32 @sorted_add(%struct.list** %3, i32 -1)
%10 = load %struct.list*, %struct.list** %3
%11 = call i32 @list_print(%struct.list* %10)
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.6, i64 0, i64 0))
%13 = call i32 @sorted_add(%struct.list** %3, i32 4)
%14 = load %struct.list*, %struct.list** %3
%15 = call i32 @list_print(%struct.list* %14)
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.7, i64 0, i64 0))
%17 = call i32 @sorted_add(%struct.list** %3, i32 12)
%18 = load %struct.list*, %struct.list** %3
%19 = call i32 @list_print(%struct.list* %18)
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.8, i64 0, i64 0))
%21 = call i32 @sorted_add(%struct.list** %3, i32 10)
%22 = load %struct.list*, %struct.list** %3
%23 = call i32 @list_print(%struct.list* %22)
ret i32 0
}