#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 seatIsBooked(int seats[], int arrayLength) {
  int seatNumber;
  printf("Give the number of the seat you want to search\n");
  scanf("%d", &seatNumber);
  if (seatNumber > arrayLength || seatNumber <= 0) {
    printf("The number of the seat you have given does not exist\n");
  } else {
    if (seats[seatNumber - 1] == 0) {
      printf("The seat with number %d is not booked\n", seatNumber);
    } else {
      printf("The seat with number %d is booked\n", seatNumber);
    }
  }
}


x86 assembly (clang, -O0):
<seatIsBooked>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeec(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     1163 <seatIsBooked+0x43>
cmpl   $0x0,-0x10(%rbp)
jg     1176 <seatIsBooked+0x56>
lea    0xec9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11b9 <seatIsBooked+0x99>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
cmpl   $0x0,(%rax,%rcx,4)
jne    11a3 <seatIsBooked+0x83>
mov    -0x10(%rbp),%esi
lea    0xed2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11b4 <seatIsBooked+0x94>
mov    -0x10(%rbp),%esi
lea    0xee3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11b9 <seatIsBooked+0x99>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<seatIsBooked>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
lea    0xf0e(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb5(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%esi
cmp    %ebp,%esi
jg     1173 <seatIsBooked+0x43>
test   %esi,%esi
jle    1173 <seatIsBooked+0x43>
lea    -0x1(%rsi),%eax
cmpl   $0x0,(%rbx,%rax,4)
je     1181 <seatIsBooked+0x51>
lea    0xeb9(%rip),%rdi
jmp    1188 <seatIsBooked+0x58>
lea    0xf02(%rip),%rdi
call   1030 <puts@plt>
jmp    118f <seatIsBooked+0x5f>
lea    0xe7b(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [48 x i8] c"Give the number of the seat you want to search\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [54 x i8] c"The number of the seat you have given does not exist\0A\00"
@.str.3 = [39 x i8] c"The seat with number %d is not booked\0A\00"
@.str.4 = [35 x i8] c"The seat with number %d is booked\0A\00"
define void @seatIsBooked(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%8 = load i32, i32* %5
%9 = load i32, i32* %4
%10 = icmp sgt i32 %8, %9
br i1 %10, label %14, label %11
11: ; preds = %2
%12 = load i32, i32* %5
%13 = icmp sle i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %11, %2
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.2, i64 0, i64 0))
br label %31
16: ; preds = %11
%17 = load i32*, i32** %3
%18 = load i32, i32* %5
%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 eq i32 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %16
%25 = load i32, i32* %5
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0), i32 %25)
br label %30
27: ; preds = %16
%28 = load i32, i32* %5
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0), i32 %28)
br label %30
30: ; preds = %27, %24
br label %31
31: ; preds = %30, %14
ret void
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [39 x i8] c"The seat with number %d is not booked\0A\00"
@.str.4 = [35 x i8] c"The seat with number %d is booked\0A\00"
@str = [47 x i8] c"Give the number of the seat you want to search\00"
@str.5 = [53 x i8] c"The number of the seat you have given does not exist\00"
define void @seatIsBooked(i32* nocapture %0, i32 %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%7 = load i32, i32* %3
%8 = icmp sgt i32 %7, %1
%9 = icmp slt i32 %7, 1
%10 = or i1 %8, %9
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str.5, i64 0, i64 0))
br label %23
13: ; preds = %2
%14 = add nsw i32 %7, -1
%15 = zext 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
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0), i32 %7)
br label %23
21: ; preds = %13
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0), i32 %7)
br label %23
23: ; preds = %19, %21, %11
ret void
}