#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 */
int EXIT_SUCCESS;
int /*<<< orphan*/ add_as_head(struct node **, int);
int /*<<< orphan*/ add_as_tail(struct node **, int);
int /*<<< orphan*/ delete_head(struct node **);
int /*<<< orphan*/ delete_node(struct node **, int);
int /*<<< orphan*/ delete_tail(struct node **);
int /*<<< orphan*/ disp_list(struct node *);
int /*<<< orphan*/ free_list(struct node **);
int main(int argc, char *argv[]) {
  struct node *list;
  int i;
  for (i = 0; i < 5; i++)
    add_as_head(&list, i);
  add_as_tail(&list, 99);
  delete_node(&list, 99);
  delete_head(&list);
  delete_node(&list, 2);
  delete_tail(&list);
  disp_list(list);
  free_list(&list);
  return EXIT_SUCCESS;
}


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)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x5,-0x1c(%rbp)
jge    11b1 <main+0x41>
mov    -0x1c(%rbp),%esi
lea    -0x18(%rbp),%rdi
call   1040 <add_as_head@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    118d <main+0x1d>
lea    -0x18(%rbp),%rdi
mov    $0x63,%esi
call   1070 <add_as_tail@plt>
lea    -0x18(%rbp),%rdi
mov    $0x63,%esi
call   1060 <delete_node@plt>
lea    -0x18(%rbp),%rdi
call   1030 <delete_head@plt>
lea    -0x18(%rbp),%rdi
mov    $0x2,%esi
call   1060 <delete_node@plt>
lea    -0x18(%rbp),%rdi
call   1080 <delete_tail@plt>
mov    -0x18(%rbp),%rdi
call   1090 <disp_list@plt>
lea    -0x18(%rbp),%rdi
call   1050 <free_list@plt>
mov    0x2dda(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
call   1040 <add_as_head@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
call   1040 <add_as_head@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
call   1040 <add_as_head@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
call   1040 <add_as_head@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
call   1040 <add_as_head@plt>
mov    %rbx,%rdi
mov    $0x63,%esi
call   1070 <add_as_tail@plt>
mov    %rbx,%rdi
mov    $0x63,%esi
call   1060 <delete_node@plt>
mov    %rbx,%rdi
call   1030 <delete_head@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
call   1060 <delete_node@plt>
mov    %rbx,%rdi
call   1080 <delete_tail@plt>
mov    0x8(%rsp),%rdi
call   1090 <disp_list@plt>
mov    %rbx,%rdi
call   1050 <free_list@plt>
mov    0x2dd8(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.node = type { i32 }
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.node*
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
br label %8
8: ; preds = %14, %2
%9 = load i32, i32* %7
%10 = icmp slt i32 %9, 5
br i1 %10, label %11, label %17
11: ; preds = %8
%12 = load i32, i32* %7
%13 = call i32 @add_as_head(%struct.node** %6, i32 %12)
br label %14
14: ; preds = %11
%15 = load i32, i32* %7
%16 = add nsw i32 %15, 1
store i32 %16, i32* %7
br label %8
17: ; preds = %8
%18 = call i32 @add_as_tail(%struct.node** %6, i32 99)
%19 = call i32 @delete_node(%struct.node** %6, i32 99)
%20 = call i32 @delete_head(%struct.node** %6)
%21 = call i32 @delete_node(%struct.node** %6, i32 2)
%22 = call i32 @delete_tail(%struct.node** %6)
%23 = load %struct.node*, %struct.node** %6
%24 = call i32 @disp_list(%struct.node* %23)
%25 = call i32 @free_list(%struct.node** %6)
%26 = load i32, i32* @EXIT_SUCCESS
ret i32 %26
}

LLVM IR (-O2):
%struct.node = type { i32 }
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.node*
%4 = bitcast %struct.node** %3 to i8*
%5 = call i32 @add_as_head(%struct.node** %3, i32 0)
%6 = call i32 @add_as_head(%struct.node** %3, i32 1)
%7 = call i32 @add_as_head(%struct.node** %3, i32 2)
%8 = call i32 @add_as_head(%struct.node** %3, i32 3)
%9 = call i32 @add_as_head(%struct.node** %3, i32 4)
%10 = call i32 @add_as_tail(%struct.node** %3, i32 99)
%11 = call i32 @delete_node(%struct.node** %3, i32 99)
%12 = call i32 @delete_head(%struct.node** %3)
%13 = call i32 @delete_node(%struct.node** %3, i32 2)
%14 = call i32 @delete_tail(%struct.node** %3)
%15 = load %struct.node*, %struct.node** %3
%16 = call i32 @disp_list(%struct.node* %15)
%17 = call i32 @free_list(%struct.node** %3)
%18 = load i32, i32* @EXIT_SUCCESS
ret i32 %18
}