#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 showDiagram(char busNumber[], int seats[], int arrayLength) {
  int i = 0;
  int character = 1;
  printf("%s\n", busNumber);
  while (i < arrayLength) {
    if (character == 3 && (i + 5 <= arrayLength)) {
      printf(" ");
    }
    if (character == 5 && (i + 5 <= arrayLength)) {
      printf("\n");
      character = 1;
    }
    if (seats[i] == 0) {
      printf("_");
    } else {
      printf("*");
    }
    i++;
    character++;
  }
}


x86 assembly (clang, -O0):
<showDiagram>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xec4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11ee <showDiagram+0xde>
cmpl   $0x3,-0x1c(%rbp)
jne    1176 <showDiagram+0x66>
mov    -0x18(%rbp),%eax
add    $0x5,%eax
cmp    -0x14(%rbp),%eax
jg     1176 <showDiagram+0x66>
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x5,-0x1c(%rbp)
jne    11a4 <showDiagram+0x94>
mov    -0x18(%rbp),%eax
add    $0x5,%eax
cmp    -0x14(%rbp),%eax
jg     11a4 <showDiagram+0x94>
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
jne    11c9 <showDiagram+0xb9>
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d7 <showDiagram+0xc7>
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1143 <showDiagram+0x33>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<showDiagram>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%r12d
mov    %rsi,%r14
call   1040 <puts@plt>
test   %r12d,%r12d
jle    11ac <showDiagram+0x8c>
mov    %r12d,%r15d
mov    $0x1,%ebp
xor    %ebx,%ebx
jmp    1161 <showDiagram+0x41>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
call   1030 <putchar@plt>
add    $0x1,%rbx
add    $0x1,%ebp
cmp    %rbx,%r15
je     11ac <showDiagram+0x8c>
lea    0x5(%rbx),%eax
cmp    $0x3,%ebp
jne    1180 <showDiagram+0x60>
cmp    %r12d,%eax
jg     1180 <showDiagram+0x60>
mov    $0x3,%ebp
mov    $0x20,%edi
jmp    1194 <showDiagram+0x74>
nopw   0x0(%rax,%rax,1)
cmp    $0x5,%ebp
jne    1199 <showDiagram+0x79>
cmp    %r12d,%eax
jg     1199 <showDiagram+0x79>
mov    $0x1,%ebp
mov    $0xa,%edi
call   1030 <putchar@plt>
cmpl   $0x0,(%r14,%rbx,4)
mov    $0x5f,%edi
je     1150 <showDiagram+0x30>
mov    $0x2a,%edi
jmp    1150 <showDiagram+0x30>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [2 x i8] c" \00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [2 x i8] c"_\00"
@.str.4 = [2 x i8] c"*\00"
define void @showDiagram(i8* %0, i32* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %4
store i32* %1, i32** %5
store i32 %2, i32* %6
store i32 0, i32* %7
store i32 1, i32* %8
%9 = load i8*, i8** %4
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %9)
br label %11
11: ; preds = %46, %3
%12 = load i32, i32* %7
%13 = load i32, i32* %6
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %51
15: ; preds = %11
%16 = load i32, i32* %8
%17 = icmp eq i32 %16, 3
br i1 %17, label %18, label %25
18: ; preds = %15
%19 = load i32, i32* %7
%20 = add nsw i32 %19, 5
%21 = load i32, i32* %6
%22 = icmp sle i32 %20, %21
br i1 %22, label %23, label %25
23: ; preds = %18
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %25
25: ; preds = %23, %18, %15
%26 = load i32, i32* %8
%27 = icmp eq i32 %26, 5
br i1 %27, label %28, label %35
28: ; preds = %25
%29 = load i32, i32* %7
%30 = add nsw i32 %29, 5
%31 = load i32, i32* %6
%32 = icmp sle i32 %30, %31
br i1 %32, label %33, label %35
33: ; preds = %28
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %8
br label %35
35: ; preds = %33, %28, %25
%36 = load i32*, i32** %5
%37 = load i32, i32* %7
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i32, i32* %36, i64 %38
%40 = load i32, i32* %39
%41 = icmp eq i32 %40, 0
br i1 %41, label %42, label %44
42: ; preds = %35
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %46
44: ; preds = %35
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %46
46: ; preds = %44, %42
%47 = load i32, i32* %7
%48 = add nsw i32 %47, 1
store i32 %48, i32* %7
%49 = load i32, i32* %8
%50 = add nsw i32 %49, 1
store i32 %50, i32* %8
br label %11
51: ; preds = %11
ret void
}

LLVM IR (-O2):
define void @showDiagram(i8* nocapture %0, i32* nocapture %1, i32 %2) {
%4 = tail call i32 @puts(i8* dereferenceable(1) %0)
%5 = icmp sgt i32 %2, 0
br i1 %5, label %6, label %33
6: ; preds = %3
%7 = zext i32 %2 to i64
br label %8
8: ; preds = %6, %23
%9 = phi i64 [ 0, %6 ], [ %30, %23 ]
%10 = phi i32 [ 1, %6 ], [ %31, %23 ]
%11 = icmp ne i32 %10, 3
%12 = trunc i64 %9 to i32
%13 = add i32 %12, 5
%14 = icmp sgt i32 %13, %2
%15 = select i1 %11, i1 true, i1 %14
br i1 %15, label %16, label %19
16: ; preds = %8
%17 = icmp ne i32 %10, 5
%18 = select i1 %17, i1 true, i1 %14
br i1 %18, label %23, label %19
19: ; preds = %16, %8
%20 = phi i32 [ 32, %8 ], [ 10, %16 ]
%21 = phi i32 [ 3, %8 ], [ 1, %16 ]
%22 = tail call i32 @putchar(i32 %20)
br label %23
23: ; preds = %19, %16
%24 = phi i32 [ %10, %16 ], [ %21, %19 ]
%25 = getelementptr inbounds i32, i32* %1, i64 %9
%26 = load i32, i32* %25
%27 = icmp eq i32 %26, 0
%28 = select i1 %27, i32 95, i32 42
%29 = tail call i32 @putchar(i32 %28)
%30 = add nuw nsw i64 %9, 1
%31 = add nsw i32 %24, 1
%32 = icmp eq i64 %30, %7
br i1 %32, label %33, label %8
33: ; preds = %23, %3
ret void
}