#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
void reserveSpecific(int layout[], int maxSeats, int seat) {
  if (!seat) {
    printf("\nDoste arithmo thesis: ");
    scanf("%d", &seat);
  }
  if (seat <= maxSeats) {
    if (!layout[seat - 1]) {
      layout[seat - 1] = 1;
      printf("H thesi kratithike\n");
    } else {
      printf("H thesi einai HDH kratimeni, epilexte allh!\n");
    }
  } else {
    printf("Prepei na dosete enan egkyro arithmo thesis (Max = %d)\n",
           maxSeats);
  }
}


x86 assembly (clang, -O0):
<reserveSpecific>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jne    115a <reserveSpecific+0x3a>
lea    0xebd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec7(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     11b7 <reserveSpecific+0x97>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
cmpl   $0x0,(%rax,%rcx,4)
jne    11a4 <reserveSpecific+0x84>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movl   $0x1,(%rax,%rcx,4)
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11b2 <reserveSpecific+0x92>
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c8 <reserveSpecific+0xa8>
mov    -0xc(%rbp),%esi
lea    0xe9b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<reserveSpecific>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
mov    %edx,0x4(%rsp)
test   %edx,%edx
je     1156 <reserveSpecific+0x26>
cmp    %ebp,%edx
jle    117d <reserveSpecific+0x4d>
lea    0xed0(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11a7 <reserveSpecific+0x77>
lea    0xea3(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xead(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%edx
cmp    %ebp,%edx
jg     1144 <reserveSpecific+0x14>
movslq %edx,%rax
cmpl   $0x0,-0x4(%rbx,%rax,4)
je     1190 <reserveSpecific+0x60>
lea    0xed8(%rip),%rdi
jmp    11a2 <reserveSpecific+0x72>
add    $0xffffffffffffffff,%rax
movl   $0x1,(%rbx,%rax,4)
lea    0xeb1(%rip),%rdi
call   1030 <puts@plt>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [24 x i8] c"\0ADoste arithmo thesis: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [20 x i8] c"H thesi kratithike\0A\00"
@.str.3 = [45 x i8] c"H thesi einai HDH kratimeni, epilexte allh!\0A\00"
@.str.4 = [56 x i8] c"Prepei na dosete enan egkyro arithmo thesis (Max = %d)\0A\00"
define void @reserveSpecific(i32* %0, i32 %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%7 = load i32, i32* %6
%8 = icmp ne i32 %7, 0
br i1 %8, label %12, label %9
9: ; preds = %3
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
br label %12
12: ; preds = %9, %3
%13 = load i32, i32* %6
%14 = load i32, i32* %5
%15 = icmp sle i32 %13, %14
br i1 %15, label %16, label %34
16: ; preds = %12
%17 = load i32*, i32** %4
%18 = load i32, i32* %6
%19 = sub nsw i32 %18, 1
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i32, i32* %17, i64 %20
%22 = load i32, i32* %21
%23 = icmp ne i32 %22, 0
br i1 %23, label %31, label %24
24: ; preds = %16
%25 = load i32*, i32** %4
%26 = load i32, i32* %6
%27 = sub nsw i32 %26, 1
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i32, i32* %25, i64 %28
store i32 1, i32* %29
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
br label %33
31: ; preds = %16
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.3, i64 0, i64 0))
br label %33
33: ; preds = %31, %24
br label %37
34: ; preds = %12
%35 = load i32, i32* %5
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.4, i64 0, i64 0), i32 %35)
br label %37
37: ; preds = %34, %33
ret void
}

LLVM IR (-O2):
@.str = [24 x i8] c"\0ADoste arithmo thesis: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.4 = [56 x i8] c"Prepei na dosete enan egkyro arithmo thesis (Max = %d)\0A\00"
@str = [19 x i8] c"H thesi kratithike\00"
@str.5 = [44 x i8] c"H thesi einai HDH kratimeni, epilexte allh!\00"
define void @reserveSpecific(i32* nocapture %0, i32 %1, i32 %2) {
%4 = alloca i32
store i32 %2, i32* %4
%5 = icmp eq i32 %2, 0
br i1 %5, label %6, label %10
6: ; preds = %3
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%9 = load i32, i32* %4
br label %10
10: ; preds = %6, %3
%11 = phi i32 [ %9, %6 ], [ %2, %3 ]
%12 = icmp sgt i32 %11, %1
br i1 %12, label %23, label %13
13: ; preds = %10
%14 = add nsw i32 %11, -1
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i32, i32* %0, i64 %15
%17 = load i32, i32* %16
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %13
store i32 1, i32* %16
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
br label %25
21: ; preds = %13
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str.5, i64 0, i64 0))
br label %25
23: ; preds = %10
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @.str.4, i64 0, i64 0), i32 %1)
br label %25
25: ; preds = %19, %21, %23
ret void
}