#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 */

/* Variables and functions */
int /*<<< orphan*/ delete_reservation(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ seats_reservation(char *);
int /*<<< orphan*/ show_seatsmap(char *);
int /*<<< orphan*/ stdin;
scalar_t__ strcmp(char *, char *);
void action_chooser() {
  char option[10];
  printf("=========================================\n");
  printf("What to do?\n\n");
  printf("-S show the seats map.\n");
  printf("-R reserve one or more seats.\n");
  printf("-D cancel reservation.\n");
  printf("-E terminate the session.\n");
  printf("=========================================\n");
  fgets(option, 10, stdin);
  do {
    if (strcmp(option, "-S\n") == 0) {
      show_seatsmap(option);
    } else if (strcmp(option, "-R\n") == 0) {
      seats_reservation(option);
    } else if (strcmp(option, "-D\n") == 0) {
      delete_reservation(option);
    } else if (strcmp(option, "-E\n") == 0) {
      exit(1);
    } else {
      printf("Error: use -R -S -D -E\n");
    }
    fgets(option, 10, stdin);
  } while (1);
}


x86 assembly (clang, -O0):
<action_chooser>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xe81(%rip),%rdi
call   1050 <printf@plt>
lea    0xea0(%rip),%rdi
call   1050 <printf@plt>
lea    0xea2(%rip),%rdi
call   1050 <printf@plt>
lea    0xeae(%rip),%rdi
call   1050 <printf@plt>
lea    0xec1(%rip),%rdi
call   1050 <printf@plt>
lea    0xecd(%rip),%rdi
call   1050 <printf@plt>
lea    0xe39(%rip),%rdi
call   1050 <printf@plt>
lea    -0xa(%rbp),%rdi
mov    0x2e11(%rip),%rax
mov    (%rax),%edx
mov    $0xa,%esi
call   1070 <fgets@plt>
lea    -0xa(%rbp),%rdi
lea    0xeb5(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    120b <action_chooser+0x9b>
lea    -0xa(%rbp),%rdi
call   1030 <show_seatsmap@plt>
jmp    129a <action_chooser+0x12a>
lea    -0xa(%rbp),%rdi
lea    0xe91(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    1233 <action_chooser+0xc3>
lea    -0xa(%rbp),%rdi
call   1040 <seats_reservation@plt>
jmp    1295 <action_chooser+0x125>
lea    -0xa(%rbp),%rdi
lea    0xe6d(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    125b <action_chooser+0xeb>
lea    -0xa(%rbp),%rdi
call   1060 <delete_reservation@plt>
jmp    1290 <action_chooser+0x120>
lea    -0xa(%rbp),%rdi
lea    0xe5d(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    127f <action_chooser+0x10f>
mov    $0x1,%edi
call   1090 <exit@plt>
lea    0xe29(%rip),%rdi
call   1050 <printf@plt>
jmp    1290 <action_chooser+0x120>
jmp    1295 <action_chooser+0x125>
jmp    129a <action_chooser+0x12a>
lea    -0xa(%rbp),%rdi
mov    0x2d43(%rip),%rax
mov    (%rax),%edx
mov    $0xa,%esi
call   1070 <fgets@plt>
mov    $0x1,%al
test   $0x1,%al
jne    11e3 <action_chooser+0x73>
jmp    12c0 <action_chooser+0x150>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<action_chooser>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xefe(%rip),%rbx
mov    %rbx,%rdi
call   1050 <puts@plt>
lea    0xe7c(%rip),%rdi
call   1050 <puts@plt>
lea    0xe7d(%rip),%rdi
call   1050 <puts@plt>
lea    0xe88(%rip),%rdi
call   1050 <puts@plt>
lea    0xe9a(%rip),%rdi
call   1050 <puts@plt>
lea    0xea5(%rip),%rdi
call   1050 <puts@plt>
mov    %rbx,%rdi
call   1050 <puts@plt>
mov    0x2e10(%rip),%r13
lea    0xe(%rsp),%rbx
lea    0xe1c(%rip),%r14
lea    0xe19(%rip),%r15
lea    0xe16(%rip),%r12
lea    0xeb4(%rip),%rbp
jmp    1205 <action_chooser+0x95>
nopl   0x0(%rax,%rax,1)
call   1030 <show_seatsmap@plt>
mov    0x0(%r13),%edx
mov    %rbx,%rdi
mov    $0xa,%esi
call   1070 <fgets@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1080 <strcmp@plt>
mov    %rbx,%rdi
test   %rax,%rax
je     1200 <action_chooser+0x90>
mov    %r15,%rsi
call   1080 <strcmp@plt>
mov    %rbx,%rdi
test   %rax,%rax
je     1270 <action_chooser+0x100>
mov    %r12,%rsi
call   1080 <strcmp@plt>
mov    %rbx,%rdi
test   %rax,%rax
je     1277 <action_chooser+0x107>
lea    0xdbc(%rip),%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     127e <action_chooser+0x10e>
mov    %rbp,%rdi
call   1050 <puts@plt>
jmp    1205 <action_chooser+0x95>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
call   1040 <seats_reservation@plt>
jmp    1205 <action_chooser+0x95>
call   1060 <delete_reservation@plt>
jmp    1205 <action_chooser+0x95>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [43 x i8] c"=========================================\0A\00"
@.str.1 = [14 x i8] c"What to do?\0A\0A\00"
@.str.2 = [24 x i8] c"-S show the seats map.\0A\00"
@.str.3 = [31 x i8] c"-R reserve one or more seats.\0A\00"
@.str.4 = [24 x i8] c"-D cancel reservation.\0A\00"
@.str.5 = [27 x i8] c"-E terminate the session.\0A\00"
@stdin = global i32 0
@.str.6 = [4 x i8] c"-S\0A\00"
@.str.7 = [4 x i8] c"-R\0A\00"
@.str.8 = [4 x i8] c"-D\0A\00"
@.str.9 = [4 x i8] c"-E\0A\00"
@.str.10 = [24 x i8] c"Error: use -R -S -D -E\0A\00"
define void @action_chooser() {
%1 = alloca [10 x i8]
%2 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0))
%3 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%4 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%5 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
%6 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
%7 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0))
%9 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%10 = load i32, i32* @stdin
%11 = call i32 @fgets(i8* %9, i32 10, i32 %10)
br label %12
12: ; preds = %48, %0
%13 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%14 = call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %12
%17 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%18 = call i32 @show_seatsmap(i8* %17)
br label %44
19: ; preds = %12
%20 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%21 = call i64 @strcmp(i8* %20, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %19
%24 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%25 = call i32 @seats_reservation(i8* %24)
br label %43
26: ; preds = %19
%27 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%28 = call i64 @strcmp(i8* %27, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %33
30: ; preds = %26
%31 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%32 = call i32 @delete_reservation(i8* %31)
br label %42
33: ; preds = %26
%34 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%35 = call i64 @strcmp(i8* %34, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %39
37: ; preds = %33
%38 = call i32 @exit(i32 1)
unreachable
39: ; preds = %33
%40 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.10, i64 0, i64 0))
br label %41
41: ; preds = %39
br label %42
42: ; preds = %41, %30
br label %43
43: ; preds = %42, %23
br label %44
44: ; preds = %43, %16
%45 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%46 = load i32, i32* @stdin
%47 = call i32 @fgets(i8* %45, i32 10, i32 %46)
br label %48
48: ; preds = %44
br i1 true, label %12, label %49
49: ; preds = %48
ret void
}

LLVM IR (-O2):
@stdin = global i32 0
@.str.6 = [4 x i8] c"-S\0A\00"
@.str.7 = [4 x i8] c"-R\0A\00"
@.str.8 = [4 x i8] c"-D\0A\00"
@.str.9 = [4 x i8] c"-E\0A\00"
@str.11 = [13 x i8] c"What to do?\0A\00"
@str.12 = [23 x i8] c"-S show the seats map.\00"
@str.13 = [30 x i8] c"-R reserve one or more seats.\00"
@str.14 = [23 x i8] c"-D cancel reservation.\00"
@str.15 = [26 x i8] c"-E terminate the session.\00"
@str.16 = [42 x i8] c"=========================================\00"
@str.17 = [23 x i8] c"Error: use -R -S -D -E\00"
define void @action_chooser() {
%1 = alloca [10 x i8]
%2 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str.16, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.11, i64 0, i64 0))
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.12, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.13, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.14, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.15, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str.16, i64 0, i64 0))
br label %10
10: ; preds = %22, %0
%11 = load i32, i32* @stdin
%12 = call i32 @fgets(i8* %2, i32 10, i32 %11)
%13 = call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %10
%16 = call i32 @show_seatsmap(i8* %2)
br label %22
17: ; preds = %10
%18 = call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %17
%21 = call i32 @seats_reservation(i8* %2)
br label %22
22: ; preds = %20, %33, %26, %15
br label %10
23: ; preds = %17
%24 = call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %23
%27 = call i32 @delete_reservation(i8* %2)
br label %22
28: ; preds = %23
%29 = call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %28
%32 = call i32 @exit(i32 1)
unreachable
33: ; preds = %28
%34 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.17, i64 0, i64 0))
br label %22
}