#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*/ printPass(int);
int assignFirstClassSeat(int seats[]) {
  int seatAssigned = 0;
  int i;
  for (i = 0; i < 5; i++) {
    if (seats[i] == 0) {
      seats[i] = 1;
      seatAssigned = 1;
      printPass(i);
      break;
    }
  }
  return seatAssigned;
}


x86 assembly (clang, -O0):
<assignFirstClassSeat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x5,-0x10(%rbp)
jge    117c <assignFirstClassSeat+0x6c>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
jne    1169 <assignFirstClassSeat+0x59>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movl   $0x1,(%rax,%rcx,4)
movl   $0x1,-0xc(%rbp)
mov    -0x10(%rbp),%edi
call   1030 <printPass@plt>
jmp    117c <assignFirstClassSeat+0x6c>
jmp    116e <assignFirstClassSeat+0x5e>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    112a <assignFirstClassSeat+0x1a>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<assignFirstClassSeat>:
push   %rax
cmpl   $0x0,(%rdi)
je     1132 <assignFirstClassSeat+0x22>
cmpl   $0x0,0x4(%rdi)
je     1136 <assignFirstClassSeat+0x26>
cmpl   $0x0,0x8(%rdi)
je     113d <assignFirstClassSeat+0x2d>
cmpl   $0x0,0xc(%rdi)
je     1144 <assignFirstClassSeat+0x34>
xor    %eax,%eax
cmpl   $0x0,0x10(%rdi)
je     114b <assignFirstClassSeat+0x3b>
pop    %rcx
ret
xor    %eax,%eax
jmp    1150 <assignFirstClassSeat+0x40>
mov    $0x1,%eax
jmp    1150 <assignFirstClassSeat+0x40>
mov    $0x2,%eax
jmp    1150 <assignFirstClassSeat+0x40>
mov    $0x3,%eax
jmp    1150 <assignFirstClassSeat+0x40>
mov    $0x4,%eax
mov    %eax,%ecx
movl   $0x1,(%rdi,%rcx,4)
mov    %eax,%edi
call   1030 <printPass@plt>
mov    $0x1,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @assignFirstClassSeat(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
store i32* %0, i32** %2
store i32 0, i32* %3
store i32 0, i32* %4
br label %5
5: ; preds = %23, %1
%6 = load i32, i32* %4
%7 = icmp slt i32 %6, 5
br i1 %7, label %8, label %26
8: ; preds = %5
%9 = load i32*, i32** %2
%10 = load i32, i32* %4
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i32, i32* %9, i64 %11
%13 = load i32, i32* %12
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %22
15: ; preds = %8
%16 = load i32*, i32** %2
%17 = load i32, i32* %4
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i32, i32* %16, i64 %18
store i32 1, i32* %19
store i32 1, i32* %3
%20 = load i32, i32* %4
%21 = call i32 @printPass(i32 %20)
br label %26
22: ; preds = %8
br label %23
23: ; preds = %22
%24 = load i32, i32* %4
%25 = add nsw i32 %24, 1
store i32 %25, i32* %4
br label %5
26: ; preds = %15, %5
%27 = load i32, i32* %3
ret i32 %27
}

LLVM IR (-O2):
define i32 @assignFirstClassSeat(i32* nocapture %0) {
%2 = load i32, i32* %0
%3 = icmp eq i32 %2, 0
br i1 %3, label %4, label %9
4: ; preds = %21, %17, %13, %9, %1
%5 = phi i32 [ 0, %1 ], [ 1, %9 ], [ 2, %13 ], [ 3, %17 ], [ 4, %21 ]
%6 = zext i32 %5 to i64
%7 = getelementptr inbounds i32, i32* %0, i64 %6
store i32 1, i32* %7
%8 = tail call i32 @printPass(i32 %5)
br label %25
9: ; preds = %1
%10 = getelementptr inbounds i32, i32* %0, i64 1
%11 = load i32, i32* %10
%12 = icmp eq i32 %11, 0
br i1 %12, label %4, label %13
13: ; preds = %9
%14 = getelementptr inbounds i32, i32* %0, i64 2
%15 = load i32, i32* %14
%16 = icmp eq i32 %15, 0
br i1 %16, label %4, label %17
17: ; preds = %13
%18 = getelementptr inbounds i32, i32* %0, i64 3
%19 = load i32, i32* %18
%20 = icmp eq i32 %19, 0
br i1 %20, label %4, label %21
21: ; preds = %17
%22 = getelementptr inbounds i32, i32* %0, i64 4
%23 = load i32, i32* %22
%24 = icmp eq i32 %23, 0
br i1 %24, label %4, label %25
25: ; preds = %21, %4
%26 = phi i32 [ 1, %4 ], [ 0, %21 ]
ret i32 %26
}