#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 lNode {
  int dummy;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
struct lNode *addNode(struct lNode *, int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ free(struct lNode *);
int /*<<< orphan*/ printContents(struct lNode *);
int /*<<< orphan*/ printf(char *, char *);
struct lNode *removeNode(struct lNode *, int);
int sscanf(char *, char *, char *, int *);
int main(int argc, char **argv) {
  struct lNode *head;
  FILE *readfile;
  int value;
  char type;
  char buffer[100];
  head = NULL;
  if (argc < 2 || argc > 2) {
    printf("%s", "Incorrect Number of Arguments");
    return (0);
  }
  readfile = fopen(argv[1], "r");
  if (readfile == NULL) {
    printf("%s", "error\n");
    return (0);
  }
  while (fgets(buffer, 100, readfile) != NULL) {
    if (sscanf(buffer, "%c %d", &type, &value) != 2) {
      printf("%s", "error\n");
      return (0);
    }
    if (type == 'i') {
      head = addNode(head, value);
    }
    if (type == 'd') {
      head = removeNode(head, value);
    }
    if (type != 'i' && type != 'd') {
      printf("%s", "error\n");
      return (0);
    }
  }
  printContents(head);
  fclose(readfile);
  free(head);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
cmpl   $0x2,-0x8(%rbp)
jl     11c5 <main+0x35>
cmpl   $0x2,-0x8(%rbp)
jle    11e4 <main+0x54>
lea    0xe34(%rip),%rdi
lea    0xe30(%rip),%rsi
call   1060 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1327 <main+0x197>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe2e(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1226 <main+0x96>
lea    0xdf2(%rip),%rdi
lea    0xe0e(%rip),%rsi
call   1060 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1327 <main+0x197>
jmp    122b <main+0x9b>
lea    -0x90(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    $0x64,%esi
call   1070 <fgets@plt>
cmp    $0x0,%rax
je     1305 <main+0x175>
lea    -0x90(%rbp),%rdi
lea    0xdd2(%rip),%rsi
lea    -0x25(%rbp),%rdx
lea    -0x24(%rbp),%rcx
call   1080 <sscanf@plt>
cmp    $0x2,%eax
je     128d <main+0xfd>
lea    0xd8b(%rip),%rdi
lea    0xda7(%rip),%rsi
call   1060 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1327 <main+0x197>
movsbl -0x25(%rbp),%eax
cmp    $0x69,%eax
jne    12aa <main+0x11a>
mov    -0x18(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   1090 <addNode@plt>
mov    %rax,-0x18(%rbp)
movsbl -0x25(%rbp),%eax
cmp    $0x64,%eax
jne    12c7 <main+0x137>
mov    -0x18(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   1050 <removeNode@plt>
mov    %rax,-0x18(%rbp)
movsbl -0x25(%rbp),%eax
cmp    $0x69,%eax
je     1300 <main+0x170>
movsbl -0x25(%rbp),%eax
cmp    $0x64,%eax
je     1300 <main+0x170>
lea    0xd18(%rip),%rdi
lea    0xd34(%rip),%rsi
call   1060 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1327 <main+0x197>
jmp    122b <main+0x9b>
mov    -0x18(%rbp),%rdi
call   10b0 <printContents@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
cmp    $0x2,%edi
jne    129d <main+0x10d>
mov    0x8(%rsi),%rdi
lea    0xe6f(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     1288 <main+0xf8>
mov    %rax,%r14
lea    0x10(%rsp),%rdi
mov    $0x64,%esi
mov    %rax,%rdx
call   1070 <fgets@plt>
xor    %ebx,%ebx
test   %rax,%rax
je     12b2 <main+0x122>
lea    0xe43(%rip),%r15
lea    0x10(%rsp),%r12
lea    0xb(%rsp),%r13
lea    0xc(%rsp),%rbp
jmp    1219 <main+0x89>
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    $0x64,%esi
mov    %r14,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
je     12b2 <main+0x122>
mov    %r12,%rdi
mov    %r15,%rsi
mov    %r13,%rdx
mov    %rbp,%rcx
call   1080 <sscanf@plt>
cmp    $0x2,%eax
jne    1288 <main+0xf8>
movzbl 0xb(%rsp),%eax
cmp    $0x69,%al
je     1250 <main+0xc0>
cmp    $0x64,%al
je     1268 <main+0xd8>
cmp    $0x69,%al
jne    1280 <main+0xf0>
jmp    1200 <main+0x70>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
call   1090 <addNode@plt>
mov    %rax,%rbx
movzbl 0xb(%rsp),%eax
cmp    $0x64,%al
jne    123c <main+0xac>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
call   1050 <removeNode@plt>
mov    %rax,%rbx
movzbl 0xb(%rsp),%eax
cmp    $0x69,%al
je     1200 <main+0x70>
cmp    $0x64,%al
je     1200 <main+0x70>
lea    0xd71(%rip),%rdi
lea    0xd8d(%rip),%rsi
call   1060 <printf@plt>
jmp    12ca <main+0x13a>
lea    0xd5c(%rip),%rdi
lea    0xd58(%rip),%rsi
call   1060 <printf@plt>
jmp    12ca <main+0x13a>
mov    %rbx,%rdi
call   10b0 <printContents@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.lNode = type { i32 }
@.str = [3 x i8] c"%s\00"
@.str.1 = [30 x i8] c"Incorrect Number of Arguments\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [7 x i8] c"error\0A\00"
@.str.4 = [6 x i8] c"%c %d\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.lNode*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i8
%10 = alloca [100 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store %struct.lNode* null, %struct.lNode** %6
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 2
br i1 %12, label %16, label %13
13: ; preds = %2
%14 = load i32, i32* %4
%15 = icmp sgt i32 %14, 2
br i1 %15, label %16, label %18
16: ; preds = %13, %2
%17 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %3
br label %73
18: ; preds = %13
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i32* @fopen(i8* %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %22, i32** %7
%23 = load i32*, i32** %7
%24 = icmp eq i32* %23, null
br i1 %24, label %25, label %27
25: ; preds = %18
%26 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %3
br label %73
27: ; preds = %18
br label %28
28: ; preds = %65, %27
%29 = getelementptr inbounds [100 x i8], [100 x i8]* %10, i64 0, i64 0
%30 = load i32*, i32** %7
%31 = call i32* @fgets(i8* %29, i32 100, i32* %30)
%32 = icmp ne i32* %31, null
br i1 %32, label %33, label %66
33: ; preds = %28
%34 = getelementptr inbounds [100 x i8], [100 x i8]* %10, i64 0, i64 0
%35 = call i32 @sscanf(i8* %34, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* %9, i32* %8)
%36 = icmp ne i32 %35, 2
br i1 %36, label %37, label %39
37: ; preds = %33
%38 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %3
br label %73
39: ; preds = %33
%40 = load i8, i8* %9
%41 = sext i8 %40 to i32
%42 = icmp eq i32 %41, 105
br i1 %42, label %43, label %47
43: ; preds = %39
%44 = load %struct.lNode*, %struct.lNode** %6
%45 = load i32, i32* %8
%46 = call %struct.lNode* @addNode(%struct.lNode* %44, i32 %45)
store %struct.lNode* %46, %struct.lNode** %6
br label %47
47: ; preds = %43, %39
%48 = load i8, i8* %9
%49 = sext i8 %48 to i32
%50 = icmp eq i32 %49, 100
br i1 %50, label %51, label %55
51: ; preds = %47
%52 = load %struct.lNode*, %struct.lNode** %6
%53 = load i32, i32* %8
%54 = call %struct.lNode* @removeNode(%struct.lNode* %52, i32 %53)
store %struct.lNode* %54, %struct.lNode** %6
br label %55
55: ; preds = %51, %47
%56 = load i8, i8* %9
%57 = sext i8 %56 to i32
%58 = icmp ne i32 %57, 105
br i1 %58, label %59, label %65
59: ; preds = %55
%60 = load i8, i8* %9
%61 = sext i8 %60 to i32
%62 = icmp ne i32 %61, 100
br i1 %62, label %63, label %65
63: ; preds = %59
%64 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %3
br label %73
65: ; preds = %59, %55
br label %28
66: ; preds = %28
%67 = load %struct.lNode*, %struct.lNode** %6
%68 = call i32 @printContents(%struct.lNode* %67)
%69 = load i32*, i32** %7
%70 = call i32 @fclose(i32* %69)
%71 = load %struct.lNode*, %struct.lNode** %6
%72 = call i32 @free(%struct.lNode* %71)
store i32 0, i32* %3
br label %73
73: ; preds = %66, %63, %37, %25, %16
%74 = load i32, i32* %3
ret i32 %74
}

LLVM IR (-O2):
%struct.lNode = type { i32 }
@.str = [3 x i8] c"%s\00"
@.str.1 = [30 x i8] c"Incorrect Number of Arguments\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [7 x i8] c"error\0A\00"
@.str.4 = [6 x i8] c"%c %d\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i8
%5 = alloca [100 x i8]
%6 = bitcast i32* %3 to i8*
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%8 = icmp eq i32 %0, 2
br i1 %8, label %11, label %9
9: ; preds = %2
%10 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
br label %55
11: ; preds = %2
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = tail call i32* @fopen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%15 = icmp eq i32* %14, null
br i1 %15, label %19, label %16
16: ; preds = %11
%17 = call i32* @fgets(i8* %7, i32 100, i32* %14)
%18 = icmp eq i32* %17, null
br i1 %18, label %50, label %21
19: ; preds = %11
%20 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
br label %55
21: ; preds = %16, %45
%22 = phi %struct.lNode* [ %44, %45 ], [ null, %16 ]
%23 = call i32 @sscanf(i8* %7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* %4, i32* %3)
%24 = icmp eq i32 %23, 2
br i1 %24, label %27, label %25
25: ; preds = %21
%26 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
br label %55
27: ; preds = %21
%28 = load i8, i8* %4
%29 = icmp eq i8 %28, 105
br i1 %29, label %30, label %34
30: ; preds = %27
%31 = load i32, i32* %3
%32 = call %struct.lNode* @addNode(%struct.lNode* %22, i32 %31)
%33 = load i8, i8* %4
br label %34
34: ; preds = %30, %27
%35 = phi i8 [ %33, %30 ], [ %28, %27 ]
%36 = phi %struct.lNode* [ %32, %30 ], [ %22, %27 ]
%37 = icmp eq i8 %35, 100
br i1 %37, label %38, label %42
38: ; preds = %34
%39 = load i32, i32* %3
%40 = call %struct.lNode* @removeNode(%struct.lNode* %36, i32 %39)
%41 = load i8, i8* %4
br label %42
42: ; preds = %38, %34
%43 = phi i8 [ %41, %38 ], [ %35, %34 ]
%44 = phi %struct.lNode* [ %40, %38 ], [ %36, %34 ]
switch i8 %43, label %48 [
i8 105, label %45
i8 100, label %45
]
45: ; preds = %42, %42
%46 = call i32* @fgets(i8* %7, i32 100, i32* %14)
%47 = icmp eq i32* %46, null
br i1 %47, label %50, label %21
48: ; preds = %42
%49 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
br label %55
50: ; preds = %45, %16
%51 = phi %struct.lNode* [ null, %16 ], [ %44, %45 ]
%52 = call i32 @printContents(%struct.lNode* %51)
%53 = call i32 @fclose(i32* %14)
%54 = call i32 @free(%struct.lNode* %51)
br label %55
55: ; preds = %50, %48, %25, %19, %9
ret i32 0
}