#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*/ close(int);
int /*<<< orphan*/ delete_reservation(int);
int /*<<< orphan*/ perror(char *);
int read(int, char *, int);
int /*<<< orphan*/ reservation(int);
int /*<<< orphan*/ show_seatsmap(int);
scalar_t__ strcmp(char *, char *);
int perform_action(int sock_descriptor) {
  char option[10];
  if (read(sock_descriptor, option, 10) == -1) {
    perror("Reading error init_connection");
  }
  if (strcmp(option, "-S\n") == 0) {
    show_seatsmap(sock_descriptor);
  }
  if (strcmp(option, "-R\n") == 0) {
    reservation(sock_descriptor);
  }
  if (strcmp(option, "-D\n") == 0) {
    delete_reservation(sock_descriptor);
  }
  close(sock_descriptor);
}


x86 assembly (clang, -O0):
<perform_action>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x12(%rbp),%rsi
mov    $0xa,%edx
call   1060 <read@plt>
cmp    $0xffffffff,%eax
jne    11a1 <perform_action+0x31>
lea    0xe64(%rip),%rdi
call   1080 <perror@plt>
lea    -0x12(%rbp),%rdi
lea    0xe72(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    11c3 <perform_action+0x53>
mov    -0x8(%rbp),%edi
call   1030 <show_seatsmap@plt>
lea    -0x12(%rbp),%rdi
lea    0xe54(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    11e5 <perform_action+0x75>
mov    -0x8(%rbp),%edi
call   1090 <reservation@plt>
lea    -0x12(%rbp),%rdi
lea    0xe36(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    1207 <perform_action+0x97>
mov    -0x8(%rbp),%edi
call   1050 <delete_reservation@plt>
mov    -0x8(%rbp),%edi
call   1040 <close@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<perform_action>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
lea    0x6(%rsp),%rsi
mov    $0xa,%edx
call   1060 <read@plt>
cmp    $0xffffffff,%eax
je     11ef <perform_action+0x7f>
lea    0xe8c(%rip),%rsi
lea    0x6(%rsp),%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
jne    11a8 <perform_action+0x38>
mov    %ebx,%edi
call   1030 <show_seatsmap@plt>
lea    0xe73(%rip),%rsi
lea    0x6(%rsp),%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
jne    11c5 <perform_action+0x55>
mov    %ebx,%edi
call   1090 <reservation@plt>
lea    0xe5a(%rip),%rsi
lea    0x6(%rsp),%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
jne    11e2 <perform_action+0x72>
mov    %ebx,%edi
call   1050 <delete_reservation@plt>
mov    %ebx,%edi
call   1040 <close@plt>
add    $0x10,%rsp
pop    %rbx
ret
lea    0xe0a(%rip),%rdi
call   1080 <perror@plt>
jmp    118b <perform_action+0x1b>

LLVM IR (-O0):
@.str = [30 x i8] c"Reading error init_connection\00"
@.str.1 = [4 x i8] c"-S\0A\00"
@.str.2 = [4 x i8] c"-R\0A\00"
@.str.3 = [4 x i8] c"-D\0A\00"
define i32 @perform_action(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca [10 x i8]
store i32 %0, i32* %3
%5 = load i32, i32* %3
%6 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 0
%7 = call i32 @read(i32 %5, i8* %6, i32 10)
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %11
9: ; preds = %1
%10 = call i32 @perror(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %9, %1
%12 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 0
%13 = call i64 @strcmp(i8* %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %11
%16 = load i32, i32* %3
%17 = call i32 @show_seatsmap(i32 %16)
br label %18
18: ; preds = %15, %11
%19 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 0
%20 = call i64 @strcmp(i8* %19, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %18
%23 = load i32, i32* %3
%24 = call i32 @reservation(i32 %23)
br label %25
25: ; preds = %22, %18
%26 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 0
%27 = call i64 @strcmp(i8* %26, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %25
%30 = load i32, i32* %3
%31 = call i32 @delete_reservation(i32 %30)
br label %32
32: ; preds = %29, %25
%33 = load i32, i32* %3
%34 = call i32 @close(i32 %33)
%35 = load i32, i32* %2
ret i32 %35
}

LLVM IR (-O2):
@.str = [30 x i8] c"Reading error init_connection\00"
@.str.1 = [4 x i8] c"-S\0A\00"
@.str.2 = [4 x i8] c"-R\0A\00"
@.str.3 = [4 x i8] c"-D\0A\00"
define i32 @perform_action(i32 %0) {
%2 = alloca [10 x i8]
%3 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%4 = call i32 @read(i32 %0, i8* %3, i32 10)
%5 = icmp eq i32 %4, -1
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = tail call i32 @perror(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %6, %1
%9 = call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = call i32 @show_seatsmap(i32 %0)
br label %13
13: ; preds = %11, %8
%14 = call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = call i32 @reservation(i32 %0)
br label %18
18: ; preds = %16, %13
%19 = call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %18
%22 = call i32 @delete_reservation(i32 %0)
br label %23
23: ; preds = %21, %18
%24 = call i32 @close(i32 %0)
ret i32 undef
}