#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*/ O_RDONLY;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ create_map(unsigned int, unsigned int);
int /*<<< orphan*/ exit(int);
int open(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int read(int, unsigned int *, int);
int previous_map() {
  unsigned int r, c;
  int fd = open("./seats_map/seats.map", O_RDONLY, 0660);
  if (fd < 0) {
    perror("Previous map may not exist, please restart the server adding 2 "
           "parameters indicating the cinema siz (rows,columns)");
    exit(1);
  }
  if (read(fd, &r, sizeof(unsigned int)) == -1) {
    perror("read error in new_map");
    exit(1);
  }
  if (read(fd, &c, sizeof(unsigned int)) == -1) {
    perror("read error in new_map");
    exit(1);
  }
  close(fd);
  create_map(r, c);
}


x86 assembly (clang, -O0):
<previous_map>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2e79(%rip),%rax
mov    (%rax),%esi
lea    0xe88(%rip),%rdi
mov    $0x1b0,%edx
call   1050 <open@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jge    11a5 <previous_map+0x45>
lea    0xe80(%rip),%rdi
call   1060 <perror@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%edi
lea    -0x8(%rbp),%rsi
mov    $0x4,%edx
call   1040 <read@plt>
cmp    $0xffffffff,%eax
jne    11d5 <previous_map+0x75>
lea    0xec3(%rip),%rdi
call   1060 <perror@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%edi
lea    -0xc(%rbp),%rsi
mov    $0x4,%edx
call   1040 <read@plt>
cmp    $0xffffffff,%eax
jne    1205 <previous_map+0xa5>
lea    0xe93(%rip),%rdi
call   1060 <perror@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%edi
call   1030 <close@plt>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1080 <create_map@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<previous_map>:
push   %rbx
sub    $0x10,%rsp
mov    0x2e7c(%rip),%rax
mov    (%rax),%esi
lea    0xe8b(%rip),%rdi
mov    $0x1b0,%edx
call   1050 <open@plt>
test   %eax,%eax
js     11d3 <previous_map+0x73>
mov    %eax,%ebx
lea    0xc(%rsp),%rsi
mov    %eax,%edi
mov    $0x4,%edx
call   1040 <read@plt>
cmp    $0xffffffff,%eax
je     11ca <previous_map+0x6a>
lea    0x8(%rsp),%rsi
mov    %ebx,%edi
mov    $0x4,%edx
call   1040 <read@plt>
cmp    $0xffffffff,%eax
je     11ca <previous_map+0x6a>
mov    %ebx,%edi
call   1030 <close@plt>
mov    0xc(%rsp),%edi
mov    0x8(%rsp),%esi
add    $0x10,%rsp
pop    %rbx
jmp    1080 <create_map@plt>
lea    0xeb8(%rip),%rdi
jmp    11da <previous_map+0x7a>
lea    0xe3c(%rip),%rdi
call   1060 <perror@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [22 x i8] c"./seats_map/seats.map\00"
@O_RDONLY = global i32 0
@.str.1 = [115 x i8] c"Previous map may not exist, please restart the server adding 2 parameters indicating the cinema siz (rows,columns)\00"
@.str.2 = [22 x i8] c"read error in new_map\00"
define i32 @previous_map() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = load i32, i32* @O_RDONLY
%6 = call i32 @open(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %5, i32 432)
store i32 %6, i32* %4
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %0
%10 = call i32 @perror(i8* getelementptr inbounds ([115 x i8], [115 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 @exit(i32 1)
unreachable
12: ; preds = %0
%13 = load i32, i32* %4
%14 = call i32 @read(i32 %13, i32* %2, i32 4)
%15 = icmp eq i32 %14, -1
br i1 %15, label %16, label %19
16: ; preds = %12
%17 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%18 = call i32 @exit(i32 1)
unreachable
19: ; preds = %12
%20 = load i32, i32* %4
%21 = call i32 @read(i32 %20, i32* %3, i32 4)
%22 = icmp eq i32 %21, -1
br i1 %22, label %23, label %26
23: ; preds = %19
%24 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%25 = call i32 @exit(i32 1)
unreachable
26: ; preds = %19
%27 = load i32, i32* %4
%28 = call i32 @close(i32 %27)
%29 = load i32, i32* %2
%30 = load i32, i32* %3
%31 = call i32 @create_map(i32 %29, i32 %30)
%32 = load i32, i32* %1
ret i32 %32
}

LLVM IR (-O2):
@.str = [22 x i8] c"./seats_map/seats.map\00"
@O_RDONLY = global i32 0
@.str.1 = [115 x i8] c"Previous map may not exist, please restart the server adding 2 parameters indicating the cinema siz (rows,columns)\00"
@.str.2 = [22 x i8] c"read error in new_map\00"
define i32 @previous_map() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = load i32, i32* @O_RDONLY
%6 = tail call i32 @open(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %5, i32 432)
%7 = icmp slt i32 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %0
%9 = tail call i32 @perror(i8* getelementptr inbounds ([115 x i8], [115 x i8]* @.str.1, i64 0, i64 0))
%10 = tail call i32 @exit(i32 1)
unreachable
11: ; preds = %0
%12 = call i32 @read(i32 %6, i32* %1, i32 4)
%13 = icmp eq i32 %12, -1
br i1 %13, label %14, label %17
14: ; preds = %11
%15 = tail call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%16 = tail call i32 @exit(i32 1)
unreachable
17: ; preds = %11
%18 = call i32 @read(i32 %6, i32* %2, i32 4)
%19 = icmp eq i32 %18, -1
br i1 %19, label %20, label %23
20: ; preds = %17
%21 = tail call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%22 = tail call i32 @exit(i32 1)
unreachable
23: ; preds = %17
%24 = tail call i32 @close(i32 %6)
%25 = load i32, i32* %1
%26 = load i32, i32* %2
%27 = tail call i32 @create_map(i32 %25, i32 %26)
ret i32 undef
}