#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;
    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    1226 <main+0xd6>
movsbl -0x5(%rbp),%eax
add    $0xffffffb7,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x27,%eax
ja     11f7 <main+0xa7>
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    1217 <main+0xc7>
mov    -0x18(%rbp),%rdi
call   1070 <Print@plt>
jmp    1217 <main+0xc7>
movsbl -0x5(%rbp),%esi
lea    0xe9e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea8(%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   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
call   1050 <Get_command@plt>
mov    %eax,%ecx
and    $0xdf,%cl
cmp    $0x51,%cl
jne    1187 <main+0x27>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
lea    0xf12(%rip),%r14
lea    0xf23(%rip),%r15
lea    0xe64(%rip),%r12
xor    %ebx,%ebx
jmp    11b9 <main+0x59>
mov    %rbx,%rdi
call   1080 <Print@plt>
xor    %eax,%eax
call   1050 <Get_command@plt>
mov    %eax,%ecx
and    $0xdf,%cl
cmp    $0x51,%cl
je     1179 <main+0x19>
movsbl %al,%esi
lea    -0x49(%rsi),%eax
cmp    $0x27,%eax
ja     11f0 <main+0x90>
movslq (%r12,%rax,4),%rax
add    %r12,%rax
jmp    *%rax
xor    %eax,%eax
call   1070 <Get_value@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1060 <Insert@plt>
mov    %rax,%rbx
jmp    11a8 <main+0x48>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
call   1030 <puts@plt>
jmp    11a8 <main+0x48>

LLVM IR (-O0):
%struct.list_node_s = type { i32 }
@.str = [24 x i8] c"There is no %c command\0A\00"
@.str.1 = [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 = %32, %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 %34
16: ; preds = %14
%17 = load i8, i8* %2
%18 = sext i8 %17 to i32
switch i32 %18, label %27 [
i32 105, label %19
i32 73, label %19
i32 112, label %24
i32 80, label %24
]
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 %32
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 %32
27: ; preds = %16
%28 = load i8, i8* %2
%29 = sext i8 %28 to i32
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %29)
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
br label %32
32: ; preds = %27, %24, %19
%33 = call signext i8 (...) @Get_command()
store i8 %33, i8* %2
br label %6
34: ; preds = %14
ret i32 0
}

LLVM IR (-O2):
%struct.list_node_s = type { i32 }
@.str = [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 %21, label %4
4: ; preds = %0, %16
%5 = phi i8 [ %18, %16 ], [ %1, %0 ]
%6 = phi %struct.list_node_s* [ %17, %16 ], [ null, %0 ]
%7 = sext i8 %5 to i32
switch i32 %7, label %13 [
i32 105, label %8
i32 73, label %8
i32 112, label %11
i32 80, label %11
]
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 %16
11: ; preds = %4, %4
%12 = tail call i32 @Print(%struct.list_node_s* %6)
br label %16
13: ; preds = %4
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %7)
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
br label %16
16: ; preds = %13, %11, %8
%17 = phi %struct.list_node_s* [ %6, %13 ], [ %6, %11 ], [ %10, %8 ]
%18 = tail call signext i8 (...) @Get_command()
%19 = and i8 %18, -33
%20 = icmp eq i8 %19, 81
br i1 %20, label %21, label %4
21: ; preds = %16, %0
ret i32 0
}