#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 O_CREAT;
int O_TRUNC;
int O_WRONLY;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ create_map(unsigned int, unsigned int);
int /*<<< orphan*/ exit(int);
int open(char *, int, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
unsigned int strtol(char *, int /*<<< orphan*/ *, int);
int write(int, unsigned int *, int);
int new_map(char *row, char *clmn) {
  unsigned int r = strtol(row, NULL, 10);
  unsigned int c = strtol(clmn, NULL, 10);
  if (r == 0 || c == 0) {
    printf("dimension 0 is not accepted\n");
    exit(1);
  }
  printf("The new cinema has %u rows and %u columns\n", r, c);
  create_map(r, c);
  int fd = open("./seats_map/seats.map", O_WRONLY | O_CREAT | O_TRUNC, 0660);
  if (fd < 0) {
    perror("Open issue at matrix_init");
    exit(1);
  }
  if (write(fd, &r, sizeof(unsigned int)) == -1) {
    perror("write error in new_map");
    exit(1);
  }
  if (write(fd, &c, sizeof(unsigned int)) == -1) {
    perror("write error in new_map");
    exit(1);
  }
  close(fd);
  fd = open("./seats_res/reservations", O_WRONLY | O_CREAT | O_TRUNC, 0660);
  if (fd < 0) {
    perror("Error in reservations file\n");
    exit(1);
  }
  close(fd);
}


x86 assembly (clang, -O0):
<new_map>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1060 <strtol@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1060 <strtol@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     11ce <new_map+0x4e>
cmpl   $0x0,-0x20(%rbp)
jne    11e6 <new_map+0x66>
lea    0xe2b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
lea    0xe2a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
call   10a0 <create_map@plt>
mov    0x2dbc(%rip),%rax
mov    (%rax),%esi
mov    0x2de3(%rip),%rax
or     (%rax),%esi
mov    0x2dd2(%rip),%rax
or     (%rax),%esi
lea    0xe21(%rip),%rdi
mov    $0x1b0,%edx
call   1070 <open@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jge    1254 <new_map+0xd4>
lea    0xe19(%rip),%rdi
call   1080 <perror@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x24(%rbp),%edi
lea    -0x1c(%rbp),%rsi
mov    $0x4,%edx
call   1030 <write@plt>
cmp    $0xffffffff,%eax
jne    1284 <new_map+0x104>
lea    0xe03(%rip),%rdi
call   1080 <perror@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x24(%rbp),%edi
lea    -0x20(%rbp),%rsi
mov    $0x4,%edx
call   1030 <write@plt>
cmp    $0xffffffff,%eax
jne    12b4 <new_map+0x134>
lea    0xdd3(%rip),%rdi
call   1080 <perror@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x24(%rbp),%edi
call   1050 <close@plt>
mov    0x2d05(%rip),%rax
mov    (%rax),%esi
mov    0x2d2c(%rip),%rax
or     (%rax),%esi
mov    0x2d1b(%rip),%rax
or     (%rax),%esi
lea    0xdb1(%rip),%rdi
mov    $0x1b0,%edx
call   1070 <open@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jge    130b <new_map+0x18b>
lea    0xdac(%rip),%rdi
call   1080 <perror@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x24(%rbp),%edi
call   1050 <close@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<new_map>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbp
xor    %esi,%esi
mov    $0xa,%edx
call   1070 <strtol@plt>
mov    %eax,%ebx
mov    %eax,0x4(%rsp)
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1070 <strtol@plt>
mov    %eax,(%rsp)
test   %ebx,%ebx
je     128d <new_map+0xfd>
mov    %eax,%ebp
test   %eax,%eax
je     128d <new_map+0xfd>
lea    0xe29(%rip),%rdi
mov    %ebx,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %ebx,%edi
mov    %ebp,%esi
call   10b0 <create_map@plt>
mov    0x2dd6(%rip),%r14
mov    0x2dff(%rip),%rbp
mov    0x0(%rbp),%esi
or     (%r14),%esi
mov    0x2dea(%rip),%r15
or     (%r15),%esi
lea    0xe1b(%rip),%rdi
mov    $0x1b0,%edx
call   1080 <open@plt>
test   %eax,%eax
js     12a3 <new_map+0x113>
mov    %eax,%ebx
lea    0x4(%rsp),%rsi
mov    %eax,%edi
mov    $0x4,%edx
call   1040 <write@plt>
cmp    $0xffffffff,%eax
je     1284 <new_map+0xf4>
mov    %rsp,%rsi
mov    %ebx,%edi
mov    $0x4,%edx
call   1040 <write@plt>
cmp    $0xffffffff,%eax
je     1284 <new_map+0xf4>
mov    %ebx,%edi
call   1060 <close@plt>
mov    0x0(%rbp),%esi
or     (%r14),%esi
or     (%r15),%esi
lea    0xe0d(%rip),%rdi
mov    $0x1b0,%edx
call   1080 <open@plt>
test   %eax,%eax
js     12ac <new_map+0x11c>
mov    %eax,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <close@plt>
lea    0xdd0(%rip),%rdi
jmp    12b3 <new_map+0x123>
lea    0xe13(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
lea    0xd97(%rip),%rdi
jmp    12b3 <new_map+0x123>
lea    0xdd8(%rip),%rdi
call   1090 <perror@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [29 x i8] c"dimension 0 is not accepted\0A\00"
@.str.1 = [43 x i8] c"The new cinema has %u rows and %u columns\0A\00"
@.str.2 = [22 x i8] c"./seats_map/seats.map\00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@.str.3 = [26 x i8] c"Open issue at matrix_init\00"
@.str.4 = [23 x i8] c"write error in new_map\00"
@.str.5 = [25 x i8] c"./seats_res/reservations\00"
@.str.6 = [28 x i8] c"Error in reservations file\0A\00"
define i32 @new_map(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
%9 = load i8*, i8** %4
%10 = call i32 @strtol(i8* %9, i32* null, i32 10)
store i32 %10, i32* %6
%11 = load i8*, i8** %5
%12 = call i32 @strtol(i8* %11, i32* null, i32 10)
store i32 %12, i32* %7
%13 = load i32, i32* %6
%14 = icmp eq i32 %13, 0
br i1 %14, label %18, label %15
15: ; preds = %2
%16 = load i32, i32* %7
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %15, %2
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%20 = call i32 @exit(i32 1)
unreachable
21: ; preds = %15
%22 = load i32, i32* %6
%23 = load i32, i32* %7
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), i32 %22, i32 %23)
%25 = load i32, i32* %6
%26 = load i32, i32* %7
%27 = call i32 @create_map(i32 %25, i32 %26)
%28 = load i32, i32* @O_WRONLY
%29 = load i32, i32* @O_CREAT
%30 = or i32 %28, %29
%31 = load i32, i32* @O_TRUNC
%32 = or i32 %30, %31
%33 = call i32 @open(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i32 %32, i32 432)
store i32 %33, i32* %8
%34 = load i32, i32* %8
%35 = icmp slt i32 %34, 0
br i1 %35, label %36, label %39
36: ; preds = %21
%37 = call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
%38 = call i32 @exit(i32 1)
unreachable
39: ; preds = %21
%40 = load i32, i32* %8
%41 = call i32 @write(i32 %40, i32* %6, i32 4)
%42 = icmp eq i32 %41, -1
br i1 %42, label %43, label %46
43: ; preds = %39
%44 = call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0))
%45 = call i32 @exit(i32 1)
unreachable
46: ; preds = %39
%47 = load i32, i32* %8
%48 = call i32 @write(i32 %47, i32* %7, i32 4)
%49 = icmp eq i32 %48, -1
br i1 %49, label %50, label %53
50: ; preds = %46
%51 = call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0))
%52 = call i32 @exit(i32 1)
unreachable
53: ; preds = %46
%54 = load i32, i32* %8
%55 = call i32 @close(i32 %54)
%56 = load i32, i32* @O_WRONLY
%57 = load i32, i32* @O_CREAT
%58 = or i32 %56, %57
%59 = load i32, i32* @O_TRUNC
%60 = or i32 %58, %59
%61 = call i32 @open(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i32 %60, i32 432)
store i32 %61, i32* %8
%62 = load i32, i32* %8
%63 = icmp slt i32 %62, 0
br i1 %63, label %64, label %67
64: ; preds = %53
%65 = call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0))
%66 = call i32 @exit(i32 1)
unreachable
67: ; preds = %53
%68 = load i32, i32* %8
%69 = call i32 @close(i32 %68)
%70 = load i32, i32* %3
ret i32 %70
}

LLVM IR (-O2):
@.str.1 = [43 x i8] c"The new cinema has %u rows and %u columns\0A\00"
@.str.2 = [22 x i8] c"./seats_map/seats.map\00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@.str.3 = [26 x i8] c"Open issue at matrix_init\00"
@.str.4 = [23 x i8] c"write error in new_map\00"
@.str.5 = [25 x i8] c"./seats_res/reservations\00"
@.str.6 = [28 x i8] c"Error in reservations file\0A\00"
@str = [28 x i8] c"dimension 0 is not accepted\00"
define i32 @new_map(i8* nocapture %0, i8* nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %3 to i8*
%6 = tail call i32 @strtol(i8* nocapture %0, i32* null, i32 10)
store i32 %6, i32* %3
%7 = bitcast i32* %4 to i8*
%8 = tail call i32 @strtol(i8* nocapture %1, i32* null, i32 10)
store i32 %8, i32* %4
%9 = icmp eq i32 %6, 0
%10 = icmp eq i32 %8, 0
%11 = select i1 %9, i1 true, i1 %10
br i1 %11, label %12, label %15
12: ; preds = %2
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
%14 = tail call i32 @exit(i32 1)
unreachable
15: ; preds = %2
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), i32 %6, i32 %8)
%17 = tail call i32 @create_map(i32 %6, i32 %8)
%18 = load i32, i32* @O_WRONLY
%19 = load i32, i32* @O_CREAT
%20 = or i32 %19, %18
%21 = load i32, i32* @O_TRUNC
%22 = or i32 %20, %21
%23 = tail call i32 @open(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i32 %22, i32 432)
%24 = icmp slt i32 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %15
%26 = tail call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
%27 = tail call i32 @exit(i32 1)
unreachable
28: ; preds = %15
%29 = call i32 @write(i32 %23, i32* %3, i32 4)
%30 = icmp eq i32 %29, -1
br i1 %30, label %31, label %34
31: ; preds = %28
%32 = tail call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0))
%33 = tail call i32 @exit(i32 1)
unreachable
34: ; preds = %28
%35 = call i32 @write(i32 %23, i32* %4, i32 4)
%36 = icmp eq i32 %35, -1
br i1 %36, label %37, label %40
37: ; preds = %34
%38 = tail call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0))
%39 = tail call i32 @exit(i32 1)
unreachable
40: ; preds = %34
%41 = tail call i32 @close(i32 %23)
%42 = load i32, i32* @O_WRONLY
%43 = load i32, i32* @O_CREAT
%44 = or i32 %43, %42
%45 = load i32, i32* @O_TRUNC
%46 = or i32 %44, %45
%47 = tail call i32 @open(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i32 %46, i32 432)
%48 = icmp slt i32 %47, 0
br i1 %48, label %49, label %52
49: ; preds = %40
%50 = tail call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0))
%51 = tail call i32 @exit(i32 1)
unreachable
52: ; preds = %40
%53 = tail call i32 @close(i32 %47)
ret i32 undef
}