#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();
int /*<<< orphan*/ 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();
      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    12ce <main+0x14e>
movsbl -0x5(%rbp),%eax
add    $0xffffffbc,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x2c,%eax
ja     129f <main+0x11f>
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    -0xc(%rbp),%esi
lea    -0x18(%rbp),%rdi
call   1070 <Insert@plt>
jmp    12bf <main+0x13f>
mov    -0x18(%rbp),%rdi
call   10a0 <Print@plt>
jmp    12bf <main+0x13f>
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     1258 <main+0xd8>
mov    -0xc(%rbp),%esi
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1269 <main+0xe9>
mov    -0xc(%rbp),%esi
lea    0xe65(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12bf <main+0x13f>
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    12bf <main+0x13f>
mov    -0x18(%rbp),%rdi
call   1060 <Free_list@plt>
mov    %rax,-0x18(%rbp)
jmp    12bf <main+0x13f>
movsbl -0x5(%rbp),%esi
lea    0xe34(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe3e(%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
movq   $0x0,(%rsp)
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <Get_command@plt>
mov    %eax,%ecx
and    $0xdf,%cl
cmp    $0x51,%cl
je     1290 <main+0x100>
lea    0xf1d(%rip),%r14
lea    0xf2e(%rip),%r15
lea    0xe31(%rip),%r12
mov    %rsp,%rbx
lea    0xedb(%rip),%r13
jmp    11fd <main+0x6d>
mov    (%rsp),%rdi
call   1070 <Free_list@plt>
mov    %rax,(%rsp)
xor    %eax,%eax
call   1060 <Get_command@plt>
mov    %eax,%ecx
and    $0xdf,%cl
cmp    $0x51,%cl
je     128c <main+0xfc>
movsbl %al,%esi
lea    -0x44(%rsi),%eax
cmp    $0x2c,%eax
ja     1260 <main+0xd0>
movslq (%r12,%rax,4),%rax
add    %r12,%rax
jmp    *%rax
xor    %eax,%eax
call   10a0 <Get_value@plt>
mov    (%rsp),%rdi
mov    %eax,%esi
call   1040 <Delete@plt>
jmp    11e4 <main+0x54>
xor    %eax,%eax
call   10a0 <Get_value@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1080 <Insert@plt>
jmp    11e8 <main+0x58>
xor    %eax,%eax
call   10a0 <Get_value@plt>
mov    %eax,%ebp
mov    (%rsp),%rdi
mov    %eax,%esi
call   1090 <Member@plt>
test   %eax,%eax
je     1277 <main+0xe7>
mov    %r13,%rdi
jmp    127e <main+0xee>
mov    (%rsp),%rdi
call   10b0 <Print@plt>
jmp    11e8 <main+0x58>
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
call   1030 <puts@plt>
jmp    11e8 <main+0x58>
lea    0xe49(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11e8 <main+0x58>
mov    (%rsp),%rbx
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

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 = %52, %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 %54
16: ; preds = %14
%17 = load i8, i8* %2
%18 = sext i8 %17 to i32
switch i32 %18, label %47 [
i32 105, label %19
i32 73, label %19
i32 112, label %23
i32 80, label %23
i32 109, label %26
i32 77, label %26
i32 100, label %39
i32 68, label %39
i32 102, label %44
i32 70, label %44
]
19: ; preds = %16, %16
%20 = call i32 (...) @Get_value()
store i32 %20, i32* %3
%21 = load i32, i32* %3
%22 = call i32 @Insert(%struct.list_node_s** %4, i32 %21)
br label %52
23: ; preds = %16, %16
%24 = load %struct.list_node_s*, %struct.list_node_s** %4
%25 = call i32 @Print(%struct.list_node_s* %24)
br label %52
26: ; preds = %16, %16
%27 = call i32 (...) @Get_value()
store i32 %27, i32* %3
%28 = load %struct.list_node_s*, %struct.list_node_s** %4
%29 = load i32, i32* %3
%30 = call i32 @Member(%struct.list_node_s* %28, i32 %29)
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %35
32: ; preds = %26
%33 = load i32, i32* %3
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %33)
br label %38
35: ; preds = %26
%36 = load i32, i32* %3
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %36)
br label %38
38: ; preds = %35, %32
br label %52
39: ; preds = %16, %16
%40 = call i32 (...) @Get_value()
store i32 %40, i32* %3
%41 = load %struct.list_node_s*, %struct.list_node_s** %4
%42 = load i32, i32* %3
%43 = call %struct.list_node_s* @Delete(%struct.list_node_s* %41, i32 %42)
store %struct.list_node_s* %43, %struct.list_node_s** %4
br label %52
44: ; preds = %16, %16
%45 = load %struct.list_node_s*, %struct.list_node_s** %4
%46 = call %struct.list_node_s* @Free_list(%struct.list_node_s* %45)
store %struct.list_node_s* %46, %struct.list_node_s** %4
br label %52
47: ; preds = %16
%48 = load i8, i8* %2
%49 = sext i8 %48 to i32
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32 %49)
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
br label %52
52: ; preds = %47, %44, %39, %38, %23, %19
%53 = call signext i8 (...) @Get_command()
store i8 %53, i8* %2
br label %6
54: ; preds = %14
%55 = load %struct.list_node_s*, %struct.list_node_s** %4
%56 = call %struct.list_node_s* @Free_list(%struct.list_node_s* %55)
store %struct.list_node_s* %56, %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 = alloca %struct.list_node_s*
%2 = bitcast %struct.list_node_s** %1 to i8*
store %struct.list_node_s* null, %struct.list_node_s** %1
%3 = tail call signext i8 (...) @Get_command()
%4 = and i8 %3, -33
%5 = icmp eq i8 %4, 81
br i1 %5, label %40, label %6
6: ; preds = %0, %34
%7 = phi i8 [ %35, %34 ], [ %3, %0 ]
%8 = sext i8 %7 to i32
switch i32 %8, label %31 [
i32 105, label %9
i32 73, label %9
i32 112, label %12
i32 80, label %12
i32 109, label %15
i32 77, label %15
i32 100, label %24
i32 68, label %24
i32 102, label %28
i32 70, label %28
]
9: ; preds = %6, %6
%10 = call i32 (...) @Get_value()
%11 = call i32 @Insert(%struct.list_node_s** %1, i32 %10)
br label %34
12: ; preds = %6, %6
%13 = load %struct.list_node_s*, %struct.list_node_s** %1
%14 = call i32 @Print(%struct.list_node_s* %13)
br label %34
15: ; preds = %6, %6
%16 = call i32 (...) @Get_value()
%17 = load %struct.list_node_s*, %struct.list_node_s** %1
%18 = call i32 @Member(%struct.list_node_s* %17, i32 %16)
%19 = icmp eq i32 %18, 0
br i1 %19, label %22, label %20
20: ; preds = %15
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %16)
br label %34
22: ; preds = %15
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %16)
br label %34
24: ; preds = %6, %6
%25 = call i32 (...) @Get_value()
%26 = load %struct.list_node_s*, %struct.list_node_s** %1
%27 = call %struct.list_node_s* @Delete(%struct.list_node_s* %26, i32 %25)
store %struct.list_node_s* %27, %struct.list_node_s** %1
br label %34
28: ; preds = %6, %6
%29 = load %struct.list_node_s*, %struct.list_node_s** %1
%30 = call %struct.list_node_s* @Free_list(%struct.list_node_s* %29)
store %struct.list_node_s* %30, %struct.list_node_s** %1
br label %34
31: ; preds = %6
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32 %8)
%33 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
br label %34
34: ; preds = %20, %22, %31, %28, %24, %12, %9
%35 = call signext i8 (...) @Get_command()
%36 = and i8 %35, -33
%37 = icmp eq i8 %36, 81
br i1 %37, label %38, label %6
38: ; preds = %34
%39 = load %struct.list_node_s*, %struct.list_node_s** %1
br label %40
40: ; preds = %38, %0
%41 = phi %struct.list_node_s* [ %39, %38 ], [ null, %0 ]
%42 = call %struct.list_node_s* @Free_list(%struct.list_node_s* %41)
ret i32 0
}