#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 */
char Get_command();
int Get_value();
struct list_node_s *Insert(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();
      printf("Member not implemented\n");
      break;
    case 'd':
    case 'D':
      value = Get_value();
      printf("Delete not implemented\n");
      break;
    case 'f':
    case 'F':
      printf("Free list not implemented\n");
      break;
    default:
      printf("There is no %c command\n", command);
      printf("Please try again\n");
    }
    command = Get_command();
  }
  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   1040 <Get_command@plt>
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%ecx
xor    %eax,%eax
cmp    $0x71,%ecx
mov    %al,-0x19(%rbp)
je     1190 <main+0x40>
movsbl -0x5(%rbp),%eax
cmp    $0x51,%eax
setne  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    11a0 <main+0x50>
jmp    1273 <main+0x123>
movsbl -0x5(%rbp),%eax
add    $0xffffffbc,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x2c,%eax
ja     1244 <main+0xf4>
mov    -0x28(%rbp),%rax
lea    0xe3f(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x0,%al
call   1060 <Get_value@plt>
mov    %eax,-0xc(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1050 <Insert@plt>
mov    %rax,-0x18(%rbp)
jmp    1264 <main+0x114>
mov    -0x18(%rbp),%rdi
call   1070 <Print@plt>
jmp    1264 <main+0x114>
mov    $0x0,%al
call   1060 <Get_value@plt>
mov    %eax,-0xc(%rbp)
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1264 <main+0x114>
mov    $0x0,%al
call   1060 <Get_value@plt>
mov    %eax,-0xc(%rbp)
lea    0xea7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1264 <main+0x114>
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1264 <main+0x114>
movsbl -0x5(%rbp),%esi
lea    0xeb0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <Get_command@plt>
mov    %al,-0x5(%rbp)
jmp    1171 <main+0x21>
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    %eax,%eax
call   1050 <Get_command@plt>
mov    %eax,%ecx
and    $0xdf,%cl
cmp    $0x51,%cl
jne    118d <main+0x2d>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xf80(%rip),%r15
lea    0xe65(%rip),%r14
lea    0xf44(%rip),%r12
lea    0xf23(%rip),%r13
lea    0xf4d(%rip),%rbx
xor    %ebp,%ebp
jmp    11cd <main+0x6d>
mov    %r13,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1050 <Get_command@plt>
mov    %eax,%ecx
and    $0xdf,%cl
cmp    $0x51,%cl
je     117c <main+0x1c>
movsbl %al,%esi
lea    -0x44(%rsi),%eax
cmp    $0x2c,%eax
ja     1219 <main+0xb9>
movslq (%r14,%rax,4),%rax
add    %r14,%rax
jmp    *%rax
xor    %eax,%eax
call   1070 <Get_value@plt>
mov    %r12,%rdi
jmp    11b7 <main+0x57>
xor    %eax,%eax
call   1070 <Get_value@plt>
mov    %rbp,%rdi
mov    %eax,%esi
call   1060 <Insert@plt>
mov    %rax,%rbp
jmp    11bc <main+0x5c>
xor    %eax,%eax
call   1070 <Get_value@plt>
mov    %rbx,%rdi
jmp    11b7 <main+0x57>
mov    %rbp,%rdi
call   1080 <Print@plt>
jmp    11bc <main+0x5c>
lea    0xe94(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
jmp    11b7 <main+0x57>

LLVM IR (-O0):
%struct.list_node_s = type { i32 }
@.str = [24 x i8] c"Member not implemented\0A\00"
@.str.1 = [24 x i8] c"Delete not implemented\0A\00"
@.str.2 = [27 x i8] c"Free list not implemented\0A\00"
@.str.3 = [24 x i8] c"There is no %c command\0A\00"
@.str.4 = [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 = %40, %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 %42
16: ; preds = %14
%17 = load i8, i8* %2
%18 = sext i8 %17 to i32
switch i32 %18, label %35 [
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 %30
i32 68, label %30
i32 102, label %33
i32 70, label %33
]
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 %40
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 %40
27: ; preds = %16, %16
%28 = call i32 (...) @Get_value()
store i32 %28, i32* %3
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
br label %40
30: ; preds = %16, %16
%31 = call i32 (...) @Get_value()
store i32 %31, i32* %3
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
br label %40
33: ; preds = %16, %16
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
br label %40
35: ; preds = %16
%36 = load i8, i8* %2
%37 = sext i8 %36 to i32
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i32 %37)
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
br label %40
40: ; preds = %35, %33, %30, %27, %24, %19
%41 = call signext i8 (...) @Get_command()
store i8 %41, i8* %2
br label %6
42: ; preds = %14
ret i32 0
}

LLVM IR (-O2):
%struct.list_node_s = type { i32 }
@.str.3 = [24 x i8] c"There is no %c command\0A\00"
@str = [26 x i8] c"Free list not implemented\00"
@str.5 = [23 x i8] c"Delete not implemented\00"
@str.6 = [23 x i8] c"Member not implemented\00"
@str.7 = [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 %29, label %4
4: ; preds = %0, %24
%5 = phi i8 [ %26, %24 ], [ %1, %0 ]
%6 = phi %struct.list_node_s* [ %25, %24 ], [ null, %0 ]
%7 = sext i8 %5 to i32
switch i32 %7, label %21 [
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 %16
i32 68, label %16
i32 102, label %19
i32 70, label %19
]
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 %24
11: ; preds = %4, %4
%12 = tail call i32 @Print(%struct.list_node_s* %6)
br label %24
13: ; preds = %4, %4
%14 = tail call i32 (...) @Get_value()
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.6, i64 0, i64 0))
br label %24
16: ; preds = %4, %4
%17 = tail call i32 (...) @Get_value()
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.5, i64 0, i64 0))
br label %24
19: ; preds = %4, %4
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
br label %24
21: ; preds = %4
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i32 %7)
%23 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.7, i64 0, i64 0))
br label %24
24: ; preds = %21, %19, %16, %13, %11, %8
%25 = phi %struct.list_node_s* [ %6, %21 ], [ %6, %19 ], [ %6, %16 ], [ %6, %13 ], [ %6, %11 ], [ %10, %8 ]
%26 = tail call signext i8 (...) @Get_command()
%27 = and i8 %26, -33
%28 = icmp eq i8 %27, 81
br i1 %28, label %29, label %4
29: ; preds = %24, %0
ret i32 0
}