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

/* Variables and functions */
struct LinkedNode *deleteNode(struct LinkedNode *, int);
struct LinkedNode *insertNode(struct LinkedNode *, int);
int /*<<< orphan*/ printLinkedList(struct LinkedNode *);
int /*<<< orphan*/ printf(char *);
int scanf(char *, int *);
int main() {
  struct LinkedNode *root = NULL;
  printf(" Insert an integer and press enter to insert it in\n");
  printf(" the Linked List. Insert zero to show the full list.\n");
  printf(" Insert number as negative to delete the positive\n");
  printf(" equivalent from the list.\n");
  int input;
  while (1) {
    printf(" > ");
    if (scanf("%i", &input) != 1)
      continue;
    if (input > 0) {
      root = insertNode(root, input);
    } else if (input < 0) {
      root = deleteNode(root, -input);
    } else {
      printLinkedList(root);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
lea    0xe92(%rip),%rdi
call   1040 <printf@plt>
lea    0xeba(%rip),%rdi
call   1040 <printf@plt>
lea    0xee4(%rip),%rdi
call   1040 <printf@plt>
lea    0xf0b(%rip),%rdi
call   1040 <printf@plt>
lea    0xf1b(%rip),%rdi
call   1040 <printf@plt>
lea    0xf13(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1050 <scanf@plt>
cmp    $0x1,%eax
je     11c1 <main+0x71>
jmp    1197 <main+0x47>
cmpl   $0x0,-0x14(%rbp)
jle    11e0 <main+0x90>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1030 <insertNode@plt>
mov    %rax,-0x10(%rbp)
jmp    120f <main+0xbf>
cmpl   $0x0,-0x14(%rbp)
jge    1201 <main+0xb1>
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
sub    -0x14(%rbp),%esi
call   1070 <deleteNode@plt>
mov    %rax,-0x10(%rbp)
jmp    120a <main+0xba>
mov    -0x10(%rbp),%rdi
call   1060 <printLinkedList@plt>
jmp    120f <main+0xbf>
jmp    1197 <main+0x47>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xe98(%rip),%rdi
call   1030 <puts@plt>
lea    0xebf(%rip),%rdi
call   1030 <puts@plt>
lea    0xee8(%rip),%rdi
call   1030 <puts@plt>
lea    0xf0e(%rip),%rdi
call   1030 <puts@plt>
xor    %r12d,%r12d
lea    0xe5e(%rip),%r14
lea    0xe5b(%rip),%r15
lea    0x4(%rsp),%rbx
jmp    11c0 <main+0x60>
mov    %r12,%rdi
call   1040 <insertNode@plt>
mov    %rax,%r12
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
cmp    $0x1,%eax
jne    11c0 <main+0x60>
mov    0x4(%rsp),%esi
test   %esi,%esi
jg     11b0 <main+0x50>
js     11ec <main+0x8c>
mov    %r12,%rdi
call   1070 <printLinkedList@plt>
jmp    11c0 <main+0x60>
neg    %esi
mov    %r12,%rdi
call   1080 <deleteNode@plt>
mov    %rax,%r12
jmp    11c0 <main+0x60>

LLVM IR (-O0):
%struct.LinkedNode = type { i32 }
@.str = [52 x i8] c" Insert an integer and press enter to insert it in\0A\00"
@.str.1 = [54 x i8] c" the Linked List. Insert zero to show the full list.\0A\00"
@.str.2 = [51 x i8] c" Insert number as negative to delete the positive\0A\00"
@.str.3 = [28 x i8] c" equivalent from the list.\0A\00"
@.str.4 = [4 x i8] c" > \00"
@.str.5 = [3 x i8] c"%i\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.LinkedNode*
%3 = alloca i32
store i32 0, i32* %1
store %struct.LinkedNode* null, %struct.LinkedNode** %2
%4 = call i32 @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.2, i64 0, i64 0))
%7 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
br label %8
8: ; preds = %0, %12, %32
%9 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %3)
%11 = icmp ne i32 %10, 1
br i1 %11, label %12, label %13
12: ; preds = %8
br label %8
13: ; preds = %8
%14 = load i32, i32* %3
%15 = icmp sgt i32 %14, 0
br i1 %15, label %16, label %20
16: ; preds = %13
%17 = load %struct.LinkedNode*, %struct.LinkedNode** %2
%18 = load i32, i32* %3
%19 = call %struct.LinkedNode* @insertNode(%struct.LinkedNode* %17, i32 %18)
store %struct.LinkedNode* %19, %struct.LinkedNode** %2
br label %32
20: ; preds = %13
%21 = load i32, i32* %3
%22 = icmp slt i32 %21, 0
br i1 %22, label %23, label %28
23: ; preds = %20
%24 = load %struct.LinkedNode*, %struct.LinkedNode** %2
%25 = load i32, i32* %3
%26 = sub nsw i32 0, %25
%27 = call %struct.LinkedNode* @deleteNode(%struct.LinkedNode* %24, i32 %26)
store %struct.LinkedNode* %27, %struct.LinkedNode** %2
br label %31
28: ; preds = %20
%29 = load %struct.LinkedNode*, %struct.LinkedNode** %2
%30 = call i32 @printLinkedList(%struct.LinkedNode* %29)
br label %31
31: ; preds = %28, %23
br label %32
32: ; preds = %31, %16
br label %8
}

LLVM IR (-O2):
%struct.LinkedNode = type { i32 }
@.str.4 = [4 x i8] c" > \00"
@.str.5 = [3 x i8] c"%i\00"
@str = [51 x i8] c" Insert an integer and press enter to insert it in\00"
@str.6 = [53 x i8] c" the Linked List. Insert zero to show the full list.\00"
@str.7 = [50 x i8] c" Insert number as negative to delete the positive\00"
@str.8 = [27 x i8] c" equivalent from the list.\00"
define i32 @main() {
%1 = alloca i32
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @str, i64 0, i64 0))
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str.6, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @str.7, i64 0, i64 0))
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.8, i64 0, i64 0))
%6 = bitcast i32* %1 to i8*
br label %7
7: ; preds = %19, %0
%8 = phi %struct.LinkedNode* [ null, %0 ], [ %20, %19 ]
br label %9
9: ; preds = %7, %26
br label %10
10: ; preds = %9, %10
%11 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %1)
%13 = icmp eq i32 %12, 1
br i1 %13, label %14, label %10
14: ; preds = %10
%15 = load i32, i32* %1
%16 = icmp sgt i32 %15, 0
br i1 %16, label %17, label %21
17: ; preds = %14
%18 = call %struct.LinkedNode* @insertNode(%struct.LinkedNode* %8, i32 %15)
br label %19
19: ; preds = %17, %23
%20 = phi %struct.LinkedNode* [ %25, %23 ], [ %18, %17 ]
br label %7
21: ; preds = %14
%22 = icmp slt i32 %15, 0
br i1 %22, label %23, label %26
23: ; preds = %21
%24 = sub nsw i32 0, %15
%25 = call %struct.LinkedNode* @deleteNode(%struct.LinkedNode* %8, i32 %24)
br label %19
26: ; preds = %21
%27 = call i32 @printLinkedList(%struct.LinkedNode* %8)
br label %9
}