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

/* Variables and functions */
struct list_node_s *Delete(struct list_node_s *, int);
struct list_node_s *Free_list(struct list_node_s *);
char Get_command();
int Get_value();
struct list_node_s *Insert(struct list_node_s *, int);
int /*<<< orphan*/ Member(struct list_node_s *, int);
int /*<<< orphan*/ Print(struct list_node_s *);
int /*<<< orphan*/ printf(char *, ...);
int main(void) {
  char command;
  int value;
  struct list_node_s *head_p = NULL;
  command = Get_command();
  while (command != 'q' && command != 'Q') {
    switch (command) {
    case 'i':
    case 'I':
      value = Get_value();
      head_p = Insert(head_p, value);
      break;
    case 'p':
    case 'P':
      Print(head_p);
      break;
    case 'm':
    case 'M':
      value = Get_value();
      if (Member(head_p, value))
        printf("%d is in the list\n", value);
      else
        printf("%d is not in the list\n", value);
      break;
    case 'd':
    case 'D':
      value = Get_value();
      head_p = Delete(head_p, value);
      break;
    case 'f':
    case 'F':
      head_p = Free_list(head_p);
      break;
    default:
      printf("There is no %c command\n", command);
      printf("Please try again\n");
    }
    command = Get_command();
  }
  head_p = Free_list(head_p);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x18(%rbp)
mov    $0x0,%al
call   1050 <Get_command@plt>
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%ecx
xor    %eax,%eax
cmp    $0x71,%ecx
mov    %al,-0x19(%rbp)
je     11c0 <main+0x40>
movsbl -0x5(%rbp),%eax
cmp    $0x51,%eax
setne  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    11d0 <main+0x50>
jmp    12d2 <main+0x152>
movsbl -0x5(%rbp),%eax
add    $0xffffffbc,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x2c,%eax
ja     12a3 <main+0x123>
mov    -0x28(%rbp),%rax
lea    0xe0f(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x0,%al
call   1090 <Get_value@plt>
mov    %eax,-0xc(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1070 <Insert@plt>
mov    %rax,-0x18(%rbp)
jmp    12c3 <main+0x143>
mov    -0x18(%rbp),%rdi
call   10a0 <Print@plt>
jmp    12c3 <main+0x143>
mov    $0x0,%al
call   1090 <Get_value@plt>
mov    %eax,-0xc(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1080 <Member@plt>
cmp    $0x0,%eax
je     125c <main+0xdc>
mov    -0xc(%rbp),%esi
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    126d <main+0xed>
mov    -0xc(%rbp),%esi
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12c3 <main+0x143>
mov    $0x0,%al
call   1090 <Get_value@plt>
mov    %eax,-0xc(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1030 <Delete@plt>
mov    %rax,-0x18(%rbp)
jmp    12c3 <main+0x143>
mov    -0x18(%rbp),%rdi
call   1060 <Free_list@plt>
mov    %rax,-0x18(%rbp)
jmp    12c3 <main+0x143>
movsbl -0x5(%rbp),%esi
lea    0xe30(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe3a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <Get_command@plt>
mov    %al,-0x5(%rbp)
jmp    11a1 <main+0x21>
mov    -0x18(%rbp),%rdi
call   1060 <Free_list@plt>
mov    %rax,-0x18(%rbp)
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <Get_command@plt>
mov    %eax,%ecx
and    $0xdf,%cl
cmp    $0x51,%cl
jne    11c7 <main+0x37>
mov    %rbx,%rdi
call   1070 <Free_list@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xf10(%rip),%r14
lea    0xf21(%rip),%r15
lea    0xe24(%rip),%r12
lea    0xed1(%rip),%r13
xor    %ebx,%ebx
jmp    1203 <main+0x73>
mov    %rbx,%rdi
call   1070 <Free_list@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1060 <Get_command@plt>
mov    %eax,%ecx
and    $0xdf,%cl
cmp    $0x51,%cl
je     11ae <main+0x1e>
movsbl %al,%esi
lea    -0x44(%rsi),%eax
cmp    $0x2c,%eax
ja     1263 <main+0xd3>
movslq (%r12,%rax,4),%rax
add    %r12,%rax
jmp    *%rax
xor    %eax,%eax
call   10a0 <Get_value@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1040 <Delete@plt>
jmp    11ef <main+0x5f>
xor    %eax,%eax
call   10a0 <Get_value@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1080 <Insert@plt>
jmp    11ef <main+0x5f>
xor    %eax,%eax
call   10a0 <Get_value@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
mov    %eax,%esi
call   1090 <Member@plt>
test   %eax,%eax
je     127a <main+0xea>
mov    %r13,%rdi
jmp    1281 <main+0xf1>
mov    %rbx,%rdi
call   10b0 <Print@plt>
jmp    11f2 <main+0x62>
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
call   1030 <puts@plt>
jmp    11f2 <main+0x62>
lea    0xe46(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11f2 <main+0x62>

LLVM IR (-O0):
%struct.list_node_s = type { i32 }
@.str = [19 x i8] c"%d is in the list\0A\00"
@.str.1 = [23 x i8] c"%d is not in the list\0A\00"
@.str.2 = [24 x i8] c"There is no %c command\0A\00"
@.str.3 = [18 x i8] c"Please try again\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i32
%4 = alloca %struct.list_node_s*
store i32 0, i32* %1
store %struct.list_node_s* null, %struct.list_node_s** %4
%5 = call signext i8 (...) @Get_command()
store i8 %5, i8* %2
br label %6
6: ; preds = %53, %0
%7 = load i8, i8* %2
%8 = sext i8 %7 to i32
%9 = icmp ne i32 %8, 113
br i1 %9, label %10, label %14
10: ; preds = %6
%11 = load i8, i8* %2
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %12, 81
br label %14
14: ; preds = %10, %6
%15 = phi i1 [ false, %6 ], [ %13, %10 ]
br i1 %15, label %16, label %55
16: ; preds = %14
%17 = load i8, i8* %2
%18 = sext i8 %17 to i32
switch i32 %18, label %48 [
i32 105, label %19
i32 73, label %19
i32 112, label %24
i32 80, label %24
i32 109, label %27
i32 77, label %27
i32 100, label %40
i32 68, label %40
i32 102, label %45
i32 70, label %45
]
19: ; preds = %16, %16
%20 = call i32 (...) @Get_value()
store i32 %20, i32* %3
%21 = load %struct.list_node_s*, %struct.list_node_s** %4
%22 = load i32, i32* %3
%23 = call %struct.list_node_s* @Insert(%struct.list_node_s* %21, i32 %22)
store %struct.list_node_s* %23, %struct.list_node_s** %4
br label %53
24: ; preds = %16, %16
%25 = load %struct.list_node_s*, %struct.list_node_s** %4
%26 = call i32 @Print(%struct.list_node_s* %25)
br label %53
27: ; preds = %16, %16
%28 = call i32 (...) @Get_value()
store i32 %28, i32* %3
%29 = load %struct.list_node_s*, %struct.list_node_s** %4
%30 = load i32, i32* %3
%31 = call i32 @Member(%struct.list_node_s* %29, i32 %30)
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %36
33: ; preds = %27
%34 = load i32, i32* %3
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %34)
br label %39
36: ; preds = %27
%37 = load i32, i32* %3
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %37)
br label %39
39: ; preds = %36, %33
br label %53
40: ; preds = %16, %16
%41 = call i32 (...) @Get_value()
store i32 %41, i32* %3
%42 = load %struct.list_node_s*, %struct.list_node_s** %4
%43 = load i32, i32* %3
%44 = call %struct.list_node_s* @Delete(%struct.list_node_s* %42, i32 %43)
store %struct.list_node_s* %44, %struct.list_node_s** %4
br label %53
45: ; preds = %16, %16
%46 = load %struct.list_node_s*, %struct.list_node_s** %4
%47 = call %struct.list_node_s* @Free_list(%struct.list_node_s* %46)
store %struct.list_node_s* %47, %struct.list_node_s** %4
br label %53
48: ; preds = %16
%49 = load i8, i8* %2
%50 = sext i8 %49 to i32
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32 %50)
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
br label %53
53: ; preds = %48, %45, %40, %39, %24, %19
%54 = call signext i8 (...) @Get_command()
store i8 %54, i8* %2
br label %6
55: ; preds = %14
%56 = load %struct.list_node_s*, %struct.list_node_s** %4
%57 = call %struct.list_node_s* @Free_list(%struct.list_node_s* %56)
store %struct.list_node_s* %57, %struct.list_node_s** %4
ret i32 0
}

LLVM IR (-O2):
%struct.list_node_s = type { i32 }
@.str = [19 x i8] c"%d is in the list\0A\00"
@.str.1 = [23 x i8] c"%d is not in the list\0A\00"
@.str.2 = [24 x i8] c"There is no %c command\0A\00"
@str = [17 x i8] c"Please try again\00"
define i32 @main() {
%1 = tail call signext i8 (...) @Get_command()
%2 = and i8 %1, -33
%3 = icmp eq i8 %2, 81
br i1 %3, label %34, label %4
4: ; preds = %0, %29
%5 = phi i8 [ %31, %29 ], [ %1, %0 ]
%6 = phi %struct.list_node_s* [ %30, %29 ], [ null, %0 ]
%7 = sext i8 %5 to i32
switch i32 %7, label %26 [
i32 105, label %8
i32 73, label %8
i32 112, label %11
i32 80, label %11
i32 109, label %13
i32 77, label %13
i32 100, label %21
i32 68, label %21
i32 102, label %24
i32 70, label %24
]
8: ; preds = %4, %4
%9 = tail call i32 (...) @Get_value()
%10 = tail call %struct.list_node_s* @Insert(%struct.list_node_s* %6, i32 %9)
br label %29
11: ; preds = %4, %4
%12 = tail call i32 @Print(%struct.list_node_s* %6)
br label %29
13: ; preds = %4, %4
%14 = tail call i32 (...) @Get_value()
%15 = tail call i32 @Member(%struct.list_node_s* %6, i32 %14)
%16 = icmp eq i32 %15, 0
br i1 %16, label %19, label %17
17: ; preds = %13
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %14)
br label %29
19: ; preds = %13
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %14)
br label %29
21: ; preds = %4, %4
%22 = tail call i32 (...) @Get_value()
%23 = tail call %struct.list_node_s* @Delete(%struct.list_node_s* %6, i32 %22)
br label %29
24: ; preds = %4, %4
%25 = tail call %struct.list_node_s* @Free_list(%struct.list_node_s* %6)
br label %29
26: ; preds = %4
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32 %7)
%28 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
br label %29
29: ; preds = %17, %19, %26, %24, %21, %11, %8
%30 = phi %struct.list_node_s* [ %6, %26 ], [ %25, %24 ], [ %23, %21 ], [ %6, %17 ], [ %6, %19 ], [ %6, %11 ], [ %10, %8 ]
%31 = tail call signext i8 (...) @Get_command()
%32 = and i8 %31, -33
%33 = icmp eq i8 %32, 81
br i1 %33, label %34, label %4
34: ; preds = %29, %0
%35 = phi %struct.list_node_s* [ null, %0 ], [ %30, %29 ]
%36 = tail call %struct.list_node_s* @Free_list(%struct.list_node_s* %35)
ret i32 0
}