#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();
int /*<<< orphan*/ 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();
      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    126f <main+0x11f>
movsbl -0x5(%rbp),%eax
add    $0xffffffbc,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x2c,%eax
ja     1240 <main+0xf0>
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>
jmp    1260 <main+0x110>
mov    -0x18(%rbp),%rdi
call   1070 <Print@plt>
jmp    1260 <main+0x110>
mov    $0x0,%al
call   1060 <Get_value@plt>
mov    %eax,-0xc(%rbp)
lea    0xeb0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1260 <main+0x110>
mov    $0x0,%al
call   1060 <Get_value@plt>
mov    %eax,-0xc(%rbp)
lea    0xeab(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1260 <main+0x110>
lea    0xeb0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1260 <main+0x110>
movsbl -0x5(%rbp),%esi
lea    0xeb4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xebe(%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    0xf20(%rip),%r14
lea    0xf79(%rip),%r15
lea    0xe5e(%rip),%rbp
lea    0xf3d(%rip),%r12
lea    0xf1c(%rip),%r13
lea    0xf46(%rip),%rbx
jmp    11d2 <main+0x72>
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     121a <main+0xba>
movslq 0x0(%rbp,%rax,4),%rax
add    %rbp,%rax
jmp    *%rax
xor    %eax,%eax
call   1070 <Get_value@plt>
mov    %r12,%rdi
jmp    11bc <main+0x5c>
xor    %eax,%eax
call   1070 <Get_value@plt>
xor    %edi,%edi
mov    %eax,%esi
call   1060 <Insert@plt>
jmp    11c1 <main+0x61>
xor    %eax,%eax
call   1070 <Get_value@plt>
mov    %rbx,%rdi
jmp    11bc <main+0x5c>
xor    %edi,%edi
call   1080 <Print@plt>
jmp    11c1 <main+0x61>
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
jmp    11bc <main+0x5c>

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 i32 @Insert(%struct.list_node_s* %21, i32 %22)
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 %27, label %4
4: ; preds = %0, %23
%5 = phi i8 [ %24, %23 ], [ %1, %0 ]
%6 = sext i8 %5 to i32
switch i32 %6, label %20 [
i32 105, label %7
i32 73, label %7
i32 112, label %10
i32 80, label %10
i32 109, label %12
i32 77, label %12
i32 100, label %15
i32 68, label %15
i32 102, label %18
i32 70, label %18
]
7: ; preds = %4, %4
%8 = tail call i32 (...) @Get_value()
%9 = tail call i32 @Insert(%struct.list_node_s* null, i32 %8)
br label %23
10: ; preds = %4, %4
%11 = tail call i32 @Print(%struct.list_node_s* null)
br label %23
12: ; preds = %4, %4
%13 = tail call i32 (...) @Get_value()
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.6, i64 0, i64 0))
br label %23
15: ; preds = %4, %4
%16 = tail call i32 (...) @Get_value()
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.5, i64 0, i64 0))
br label %23
18: ; preds = %4, %4
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
br label %23
20: ; preds = %4
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i32 %6)
%22 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.7, i64 0, i64 0))
br label %23
23: ; preds = %20, %18, %15, %12, %10, %7
%24 = tail call signext i8 (...) @Get_command()
%25 = and i8 %24, -33
%26 = icmp eq i8 %25, 81
br i1 %26, label %27, label %4
27: ; preds = %23, %0
ret i32 0
}