#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 *, ...);
void showBookedSeats(int seats[], int arrayLength) {
  int i = 0;
  int bookedSeats = 0;
  while (i < arrayLength) {
    if (seats[i] == 1) {
      printf("Seat number %d is booked\n", i + 1);
      bookedSeats++;
    }
    i++;
  }
  if (bookedSeats == 0) {
    printf("There are no booked seats\n");
  }
}


x86 assembly (clang, -O0):
<showBookedSeats>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1176 <showBookedSeats+0x66>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
cmpl   $0x1,(%rax,%rcx,4)
jne    1168 <showBookedSeats+0x58>
mov    -0x10(%rbp),%esi
add    $0x1,%esi
lea    0xea8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    112d <showBookedSeats+0x1d>
cmpl   $0x0,-0x14(%rbp)
jne    118e <showBookedSeats+0x7e>
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<showBookedSeats>:
test   %esi,%esi
jle    1172 <showBookedSeats+0x52>
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%r15
mov    %esi,%r12d
lea    0xec7(%rip),%r14
xor    %esi,%esi
xor    %ebp,%ebp
jmp    1148 <showBookedSeats+0x28>
nop
mov    %rbx,%rsi
cmp    %rbx,%r12
je     1165 <showBookedSeats+0x45>
lea    0x1(%rsi),%rbx
cmpl   $0x1,(%r15,%rsi,4)
jne    1140 <showBookedSeats+0x20>
add    $0x1,%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebp
jmp    1140 <showBookedSeats+0x20>
test   %ebp,%ebp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
je     1172 <showBookedSeats+0x52>
ret
lea    0xea1(%rip),%rdi
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [26 x i8] c"Seat number %d is booked\0A\00"
@.str.1 = [27 x i8] c"There are no booked seats\0A\00"
define void @showBookedSeats(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
br label %7
7: ; preds = %24, %2
%8 = load i32, i32* %5
%9 = load i32, i32* %4
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %27
11: ; preds = %7
%12 = load i32*, i32** %3
%13 = load i32, i32* %5
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i32, i32* %12, i64 %14
%16 = load i32, i32* %15
%17 = icmp eq i32 %16, 1
br i1 %17, label %18, label %24
18: ; preds = %11
%19 = load i32, i32* %5
%20 = add nsw i32 %19, 1
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %20)
%22 = load i32, i32* %6
%23 = add nsw i32 %22, 1
store i32 %23, i32* %6
br label %24
24: ; preds = %18, %11
%25 = load i32, i32* %5
%26 = add nsw i32 %25, 1
store i32 %26, i32* %5
br label %7
27: ; preds = %7
%28 = load i32, i32* %6
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %27
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
br label %32
32: ; preds = %30, %27
ret void
}

LLVM IR (-O2):
@.str = [26 x i8] c"Seat number %d is booked\0A\00"
@str = [26 x i8] c"There are no booked seats\00"
define void @showBookedSeats(i32* nocapture %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %4, label %22
4: ; preds = %2
%5 = zext i32 %1 to i64
br label %6
6: ; preds = %4, %17
%7 = phi i64 [ 0, %4 ], [ %12, %17 ]
%8 = phi i32 [ 0, %4 ], [ %18, %17 ]
%9 = getelementptr inbounds i32, i32* %0, i64 %7
%10 = load i32, i32* %9
%11 = icmp eq i32 %10, 1
%12 = add nuw nsw i64 %7, 1
br i1 %11, label %13, label %17
13: ; preds = %6
%14 = trunc i64 %12 to i32
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = add nsw i32 %8, 1
br label %17
17: ; preds = %6, %13
%18 = phi i32 [ %16, %13 ], [ %8, %6 ]
%19 = icmp eq i64 %12, %5
br i1 %19, label %20, label %6
20: ; preds = %17
%21 = icmp eq i32 %18, 0
br i1 %21, label %22, label %24
22: ; preds = %2, %20
%23 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
br label %24
24: ; preds = %22, %20
ret void
}